xref: /freebsd/contrib/llvm-project/llvm/lib/Target/X86/X86InstrKL.td (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1e8d8bef9SDimitry Andric//===---------------------------*-tablegen-*-------------------------------===//
2e8d8bef9SDimitry Andric//===------------- X86InstrKL.td - KL Instruction Set Extension -----------===//
3e8d8bef9SDimitry Andric//
4349cc55cSDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5349cc55cSDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
6349cc55cSDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7e8d8bef9SDimitry Andric//
8e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===//
9e8d8bef9SDimitry Andric//
10e8d8bef9SDimitry Andric// This file describes the instructions that make up the Intel key locker
11e8d8bef9SDimitry Andric// instruction set.
12e8d8bef9SDimitry Andric//
13e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===//
14e8d8bef9SDimitry Andric
15e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===//
16e8d8bef9SDimitry Andric// Key Locker instructions
17*0fca6ea1SDimitry Andricclass Encodekey<bits<8> opcode, string m>
18*0fca6ea1SDimitry Andric  : I<opcode, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src), m#"\t{$src, $dst|$dst, $src}", []>,
19*0fca6ea1SDimitry Andric    NoCD8, XS;
20e8d8bef9SDimitry Andric
21*0fca6ea1SDimitry Andricmulticlass Aesencdec<string suffix> {
22*0fca6ea1SDimitry Andric def AESENC128KL#suffix : I<0xDC, MRMSrcMem, (outs VR128:$dst),
23*0fca6ea1SDimitry Andric                            (ins VR128:$src1, opaquemem:$src2),
24*0fca6ea1SDimitry Andric                            "aesenc128kl\t{$src2, $src1|$src1, $src2}",
25*0fca6ea1SDimitry Andric                            [(set VR128:$dst, EFLAGS, (X86aesenc128kl VR128:$src1, addr:$src2))]>,
26*0fca6ea1SDimitry Andric                          NoCD8, XS;
27*0fca6ea1SDimitry Andric def AESDEC128KL#suffix : I<0xDD, MRMSrcMem, (outs VR128:$dst),
28*0fca6ea1SDimitry Andric                            (ins VR128:$src1, opaquemem:$src2),
29*0fca6ea1SDimitry Andric                            "aesdec128kl\t{$src2, $src1|$src1, $src2}",
30*0fca6ea1SDimitry Andric                            [(set VR128:$dst, EFLAGS, (X86aesdec128kl VR128:$src1, addr:$src2))]>,
31*0fca6ea1SDimitry Andric                          NoCD8, XS;
32*0fca6ea1SDimitry Andric def AESENC256KL#suffix : I<0xDE, MRMSrcMem, (outs VR128:$dst),
33*0fca6ea1SDimitry Andric                            (ins VR128:$src1, opaquemem:$src2),
34*0fca6ea1SDimitry Andric                            "aesenc256kl\t{$src2, $src1|$src1, $src2}",
35*0fca6ea1SDimitry Andric                            [(set VR128:$dst, EFLAGS, (X86aesenc256kl VR128:$src1, addr:$src2))]>,
36*0fca6ea1SDimitry Andric                          NoCD8, XS;
37*0fca6ea1SDimitry Andric def AESDEC256KL#suffix : I<0xDF, MRMSrcMem, (outs VR128:$dst),
38*0fca6ea1SDimitry Andric                            (ins VR128:$src1, opaquemem:$src2),
39*0fca6ea1SDimitry Andric                            "aesdec256kl\t{$src2, $src1|$src1, $src2}",
40*0fca6ea1SDimitry Andric                            [(set VR128:$dst, EFLAGS, (X86aesdec256kl VR128:$src1, addr:$src2))]>,
41*0fca6ea1SDimitry Andric                          NoCD8, XS;
42*0fca6ea1SDimitry Andric}
43*0fca6ea1SDimitry Andric
44*0fca6ea1SDimitry Andriclet SchedRW = [WriteSystem] in {
45*0fca6ea1SDimitry Andric  let Uses = [XMM0, EAX], Defs = [EFLAGS], Predicates = [HasKL] in {
46e8d8bef9SDimitry Andric    def LOADIWKEY : I<0xDC, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
47e8d8bef9SDimitry Andric                      "loadiwkey\t{$src2, $src1|$src1, $src2}",
48cb14a3feSDimitry Andric                      [(int_x86_loadiwkey XMM0, VR128:$src1, VR128:$src2, EAX)]>, T8, XS;
49e8d8bef9SDimitry Andric  }
50e8d8bef9SDimitry Andric
51*0fca6ea1SDimitry Andric  let Predicates = [HasKL] in {
52*0fca6ea1SDimitry Andric    let Uses = [XMM0], Defs = [XMM0, XMM1, XMM2, XMM4, XMM5, XMM6, EFLAGS] in
53*0fca6ea1SDimitry Andric      def ENCODEKEY128 : Encodekey<0xFA, "encodekey128">, T8;
54*0fca6ea1SDimitry Andric
55*0fca6ea1SDimitry Andric    let Uses = [XMM0, XMM1], Defs = [XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, EFLAGS] in
56*0fca6ea1SDimitry Andric      def ENCODEKEY256 : Encodekey<0xFB, "encodekey256">, T8;
57*0fca6ea1SDimitry Andric
58*0fca6ea1SDimitry Andric    let Constraints = "$src1 = $dst", Defs = [EFLAGS] in
59*0fca6ea1SDimitry Andric      defm "" : Aesencdec<"">, T8;
60*0fca6ea1SDimitry Andric  }
61*0fca6ea1SDimitry Andric} // SchedRW
62*0fca6ea1SDimitry Andric
63*0fca6ea1SDimitry Andricmulticlass Aesencdecwide<string suffix> {
64*0fca6ea1SDimitry Andric  def AESENCWIDE128KL#suffix : I<0xD8, MRM0m, (outs), (ins opaquemem:$src), "aesencwide128kl\t$src", []>, NoCD8, XS;
65*0fca6ea1SDimitry Andric  def AESDECWIDE128KL#suffix : I<0xD8, MRM1m, (outs), (ins opaquemem:$src), "aesdecwide128kl\t$src", []>, NoCD8, XS;
66*0fca6ea1SDimitry Andric  def AESENCWIDE256KL#suffix : I<0xD8, MRM2m, (outs), (ins opaquemem:$src), "aesencwide256kl\t$src", []>, NoCD8, XS;
67*0fca6ea1SDimitry Andric  def AESDECWIDE256KL#suffix : I<0xD8, MRM3m, (outs), (ins opaquemem:$src), "aesdecwide256kl\t$src", []>, NoCD8, XS;
68e8d8bef9SDimitry Andric}
69e8d8bef9SDimitry Andric
70*0fca6ea1SDimitry Andriclet SchedRW = [WriteSystem], Uses = [XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7],
71*0fca6ea1SDimitry Andric    Defs = [EFLAGS, XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7], mayLoad = 1 in {
72*0fca6ea1SDimitry Andric  let Predicates = [HasWIDEKL] in
73*0fca6ea1SDimitry Andric    defm "" : Aesencdecwide<"">, T8;
74*0fca6ea1SDimitry Andric} // SchedRW
75