Skip to content

Commit 54b2ddb

Browse files
committed
[X86] Support encoding/decoding and lowering for APX variant SHL/SHR/SAR/SHLD/SHRD
1 parent 914cfa4 commit 54b2ddb

37 files changed

+10196
-62
lines changed

llvm/lib/Target/X86/X86InstrShiftRotate.td

Lines changed: 362 additions & 47 deletions
Large diffs are not rendered by default.

llvm/lib/Target/X86/X86InstrUtils.td

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,20 @@ defvar unaryop_ndd_args = "{$src1, $dst|$dst, $src1}";
100100
defvar binop_args = "{$src2, $src1|$src1, $src2}";
101101
defvar binop_ndd_args = "{$src2, $src1, $dst|$dst, $src1, $src2}";
102102
defvar binop_cl_args = "{%cl, $src1|$src1, cl}";
103+
defvar binop_cl_ndd_args = "{%cl, $src1, $dst|$dst, $src1, cl}";
103104
defvar triop_args = "{$src3, $src2, $src1|$src1, $src2, $src3}";
105+
defvar triop_ndd_args = "{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}";
104106
defvar triop_cl_args = "{%cl, $src2, $src1|$src1, $src2, cl}";
107+
defvar triop_cl_ndd_args = "{%cl, $src2, $src1, $dst|$dst, $src1, $src2, cl}";
105108
defvar tie_dst_src1 = "$src1 = $dst";
106109

107110
// NDD - Helper for new data destination instructions
108-
class NDD<bit ndd, Map map = OB> {
111+
class NDD<bit ndd> {
109112
string Constraints = !if(!eq(ndd, 0), tie_dst_src1, "");
110113
Encoding OpEnc = !if(!eq(ndd, 0), EncNormal, EncEVEX);
111114
bit hasEVEX_B = ndd;
112115
bit hasVEX_4V = ndd;
113-
Map OpMap = !if(!eq(ndd, 0), map, T_MAP4);
116+
Map OpMap = !if(!eq(ndd, 0), OB, T_MAP4);
114117
}
115118
// NF - Helper for NF (no flags update) instructions
116119
class NF: T_MAP4, EVEX, EVEX_NF;
@@ -1067,9 +1070,10 @@ class BinOpRI_R<bits<8> o, string m, X86TypeInfo t, Format f, bit ndd = 0>
10671070
: BinOpRI<o, m, !if(!eq(ndd, 0), binop_args, binop_ndd_args), t, f, (outs t.RegClass:$dst),
10681071
[]>, NDD<ndd>;
10691072
// BinOpRI8U_R - Instructions that read "reg, u8imm" and write "reg".
1070-
class BinOpRI8U_R<string m, Format f, X86TypeInfo t, SDPatternOperator node>
1073+
class BinOpRI8U_R<string m, Format f, X86TypeInfo t, SDPatternOperator node, bit ndd = 0>
10711074
: ITy<0xC1, f, t, (outs t.RegClass:$dst), (ins t.RegClass:$src1, u8imm:$src2), m,
1072-
binop_args, [(set t.RegClass:$dst, (node t.RegClass:$src1, (i8 imm:$src2)))]>, NDD<0> {
1075+
!if(!eq(ndd, 0), binop_args, binop_ndd_args),
1076+
[(set t.RegClass:$dst, (node t.RegClass:$src1, (i8 imm:$src2)))]>, NDD<ndd> {
10731077
let ImmT = Imm8;
10741078
}
10751079
// BinOpRI_RF - Instructions that read "reg, imm" and write "reg", EFLAGS.
@@ -1232,20 +1236,22 @@ class BinOpMI8<string m, string args, X86TypeInfo t, Format f, dag out>
12321236
let ImmT = Imm8;
12331237
let mayLoad = 1;
12341238
}
1239+
// BinOpMI8U - Instructions that read "[mem], u8imm".
1240+
class BinOpMI8U<string m, string args, X86TypeInfo t, Format f, dag out, list<dag> p>
1241+
: ITy<0xC1, f, t, out, (ins t.MemOperand:$src1, u8imm:$src2), m, args, p> {
1242+
let ImmT = Imm8;
1243+
let mayLoad = 1;
1244+
}
12351245
// BinOpMI8_F - Instructions that read "[mem], imm8" and write EFLAGS only.
12361246
class BinOpMI8_F<string m, X86TypeInfo t, Format f>
12371247
: BinOpMI8<m, binop_args, t, f, (outs)>, Sched<[WriteALU.Folded]>, DefEFLAGS;
12381248
// BinOpMI8_R - Instructions that read "[mem], imm8" and write "reg".
12391249
class BinOpMI8_R<string m, X86TypeInfo t, Format f>
12401250
: BinOpMI8<m, binop_ndd_args, t, f, (outs t.RegClass:$dst)>, Sched<[WriteALU.Folded, WriteALU.ReadAfterFold]>, NDD<1>;
1241-
// BinOpMI8U_M - Instructions that read "[mem], u8imm" and write "[mem]".
1242-
class BinOpMI8U_M<string m, Format f, X86TypeInfo t, SDPatternOperator node>
1243-
: ITy<0xC1, f, t, (outs), (ins t.MemOperand:$src1, u8imm:$src2), m,
1244-
binop_args, [(store (node (t.LoadNode addr:$src1), (i8 imm:$src2)), addr:$src1)]> {
1245-
let ImmT = Imm8;
1246-
let mayLoad = 1;
1247-
let mayStore = 1;
1248-
}
1251+
// BinOpMI8U_R - Instructions that read "[mem], u8imm" and write "reg".
1252+
class BinOpMI8U_R<string m, Format f, X86TypeInfo t, SDPatternOperator node>
1253+
: BinOpMI8U<m, binop_ndd_args, t, f, (outs t.RegClass:$dst),
1254+
[(set t.RegClass:$dst, (node (t.LoadNode addr:$src1), (i8 imm:$src2)))]>, NDD<1>;
12491255
// BinOpMI8_RF - Instructions that read "[mem], imm8" and write "reg"/EFLAGS.
12501256
class BinOpMI8_RF<string m, X86TypeInfo t, Format f>
12511257
: BinOpMI8<m, binop_ndd_args, t, f, (outs t.RegClass:$dst)>, Sched<[WriteALU.Folded, WriteALU.ReadAfterFold]>, DefEFLAGS, NDD<1>;
@@ -1254,6 +1260,12 @@ class BinOpMI8_M<string m, X86TypeInfo t, Format f>
12541260
: BinOpMI8<m, binop_args, t, f, (outs)>, Sched<[WriteALURMW]> {
12551261
let mayStore = 1;
12561262
}
1263+
// BinOpMI8U_M - Instructions that read "[mem], u8imm" and write "[mem]".
1264+
class BinOpMI8U_M<string m, Format f, X86TypeInfo t, SDPatternOperator node>
1265+
: BinOpMI8U<m, binop_args, t, f, (outs),
1266+
[(store (node (t.LoadNode addr:$src1), (i8 imm:$src2)), addr:$src1)]> {
1267+
let mayStore = 1;
1268+
}
12571269
// BinOpMI8_MF - Instructions that read "[mem], imm8" and write "[mem]", EFLAGS.
12581270
class BinOpMI8_MF<string m, X86TypeInfo t, Format f>
12591271
: BinOpMI8<m, binop_args, t, f, (outs)>, Sched<[WriteALURMW]>, DefEFLAGS {
@@ -1296,9 +1308,10 @@ class BinOpAIF_AF<bits<8> o, string m, X86TypeInfo t, Register areg,
12961308
let SchedRW = [WriteADC];
12971309
}
12981310
// BinOpRC_R - Instructions that read "reg, cl" and write reg.
1299-
class BinOpRC_R<string m, Format f, X86TypeInfo t, SDPatternOperator node>
1300-
: ITy<0xD3, f, t, (outs t.RegClass:$dst), (ins t.RegClass:$src1), m, binop_cl_args,
1301-
[(set t.RegClass:$dst, (node t.RegClass:$src1, CL))]>, NDD<0> {
1311+
class BinOpRC_R<string m, Format f, X86TypeInfo t, SDPatternOperator node, bit ndd = 0>
1312+
: ITy<0xD3, f, t, (outs t.RegClass:$dst), (ins t.RegClass:$src1), m,
1313+
!if(!eq(ndd, 0), binop_cl_args, binop_cl_ndd_args),
1314+
[(set t.RegClass:$dst, (node t.RegClass:$src1, CL))]>, NDD<ndd> {
13021315
let Uses = [CL];
13031316
}
13041317
// BinOpMC_M - Instructions that read "[mem], cl" and write [mem].
@@ -1309,6 +1322,13 @@ class BinOpMC_M<string m, Format f, X86TypeInfo t, SDPatternOperator node>
13091322
let mayLoad = 1;
13101323
let mayStore = 1;
13111324
}
1325+
// BinOpMC_R - Instructions that read "[mem], cl" and write reg.
1326+
class BinOpMC_R<string m, Format f, X86TypeInfo t, SDPatternOperator node>
1327+
: ITy<0xD3, f, t, (outs t.RegClass:$dst), (ins t.MemOperand:$src1), m, binop_cl_ndd_args,
1328+
[(set t.RegClass:$dst, (node (t.LoadNode addr:$src1), CL))]>, NDD<1> {
1329+
let Uses = [CL];
1330+
let mayLoad = 1;
1331+
}
13121332

13131333
// UnaryOpR - Instructions that read "reg".
13141334
class UnaryOpR<bits<8> o, Format f, string m, string args, X86TypeInfo t,

0 commit comments

Comments
 (0)