Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 2bcbecf

Browse files
committed
[X86] Encode the EVEX2VEX exception list information in .td files instead of the emitter source.
Rather than having an exclusion list in tablegen sources, add a flag to the X86 instruction records that can be used to suppress checking for convertibility. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334971 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 6f176b7 commit 2bcbecf

File tree

3 files changed

+40
-41
lines changed

3 files changed

+40
-41
lines changed

lib/Target/X86/X86InstrAVX512.td

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4733,7 +4733,8 @@ defm VPMULLD : avx512_binop_rm_vl_d<0x40, "vpmulld", mul,
47334733
defm VPMULLW : avx512_binop_rm_vl_w<0xD5, "vpmullw", mul,
47344734
SchedWriteVecIMul, HasBWI, 1>;
47354735
defm VPMULLQ : avx512_binop_rm_vl_q<0x40, "vpmullq", mul,
4736-
SchedWriteVecIMul, HasDQI, 1>, T8PD;
4736+
SchedWriteVecIMul, HasDQI, 1>, T8PD,
4737+
NotEVEX2VEXConvertible;
47374738
defm VPMULHW : avx512_binop_rm_vl_w<0xE5, "vpmulhw", mulhs, SchedWriteVecIMul,
47384739
HasBWI, 1>;
47394740
defm VPMULHUW : avx512_binop_rm_vl_w<0xE4, "vpmulhuw", mulhu, SchedWriteVecIMul,
@@ -4875,29 +4876,41 @@ defm VPMAXSB : avx512_binop_rm_vl_b<0x3C, "vpmaxsb", smax,
48754876
SchedWriteVecALU, HasBWI, 1>, T8PD;
48764877
defm VPMAXSW : avx512_binop_rm_vl_w<0xEE, "vpmaxsw", smax,
48774878
SchedWriteVecALU, HasBWI, 1>;
4878-
defm VPMAXS : avx512_binop_rm_vl_dq<0x3D, 0x3D, "vpmaxs", smax,
4879+
defm VPMAXSD : avx512_binop_rm_vl_d<0x3D, "vpmaxsd", smax,
48794880
SchedWriteVecALU, HasAVX512, 1>, T8PD;
4881+
defm VPMAXSQ : avx512_binop_rm_vl_q<0x3D, "vpmaxsq", smax,
4882+
SchedWriteVecALU, HasAVX512, 1>, T8PD,
4883+
NotEVEX2VEXConvertible;
48804884

48814885
defm VPMAXUB : avx512_binop_rm_vl_b<0xDE, "vpmaxub", umax,
48824886
SchedWriteVecALU, HasBWI, 1>;
48834887
defm VPMAXUW : avx512_binop_rm_vl_w<0x3E, "vpmaxuw", umax,
48844888
SchedWriteVecALU, HasBWI, 1>, T8PD;
4885-
defm VPMAXU : avx512_binop_rm_vl_dq<0x3F, 0x3F, "vpmaxu", umax,
4889+
defm VPMAXUD : avx512_binop_rm_vl_d<0x3F, "vpmaxud", umax,
48864890
SchedWriteVecALU, HasAVX512, 1>, T8PD;
4891+
defm VPMAXUQ : avx512_binop_rm_vl_q<0x3F, "vpmaxuq", umax,
4892+
SchedWriteVecALU, HasAVX512, 1>, T8PD,
4893+
NotEVEX2VEXConvertible;
48874894

48884895
defm VPMINSB : avx512_binop_rm_vl_b<0x38, "vpminsb", smin,
48894896
SchedWriteVecALU, HasBWI, 1>, T8PD;
48904897
defm VPMINSW : avx512_binop_rm_vl_w<0xEA, "vpminsw", smin,
48914898
SchedWriteVecALU, HasBWI, 1>;
4892-
defm VPMINS : avx512_binop_rm_vl_dq<0x39, 0x39, "vpmins", smin,
4899+
defm VPMINSD : avx512_binop_rm_vl_d<0x39, "vpminsd", smin,
48934900
SchedWriteVecALU, HasAVX512, 1>, T8PD;
4901+
defm VPMINSQ : avx512_binop_rm_vl_q<0x39, "vpminsq", smin,
4902+
SchedWriteVecALU, HasAVX512, 1>, T8PD,
4903+
NotEVEX2VEXConvertible;
48944904

48954905
defm VPMINUB : avx512_binop_rm_vl_b<0xDA, "vpminub", umin,
48964906
SchedWriteVecALU, HasBWI, 1>;
48974907
defm VPMINUW : avx512_binop_rm_vl_w<0x3A, "vpminuw", umin,
48984908
SchedWriteVecALU, HasBWI, 1>, T8PD;
4899-
defm VPMINU : avx512_binop_rm_vl_dq<0x3B, 0x3B, "vpminu", umin,
4909+
defm VPMINUD : avx512_binop_rm_vl_d<0x3B, "vpminud", umin,
49004910
SchedWriteVecALU, HasAVX512, 1>, T8PD;
4911+
defm VPMINUQ : avx512_binop_rm_vl_q<0x3B, "vpminuq", umin,
4912+
SchedWriteVecALU, HasAVX512, 1>, T8PD,
4913+
NotEVEX2VEXConvertible;
49014914

49024915
// PMULLQ: Use 512bit version to implement 128/256 bit in case NoVLX.
49034916
let Predicates = [HasDQI, NoVLX] in {
@@ -5523,7 +5536,7 @@ multiclass avx512_fp_scalef_all<bits<8> opc, bits<8> opcScaler, string OpcodeStr
55235536
}
55245537
}
55255538
defm VSCALEF : avx512_fp_scalef_all<0x2C, 0x2D, "vscalef", X86scalef, X86scalefs,
5526-
SchedWriteFAdd>, T8PD;
5539+
SchedWriteFAdd>, T8PD, NotEVEX2VEXConvertible;
55275540

55285541
//===----------------------------------------------------------------------===//
55295542
// AVX-512 VPTESTM instructions
@@ -5765,9 +5778,11 @@ multiclass avx512_shift_sizes<bits<8> opc, string OpcodeStr, SDNode OpNode,
57655778

57665779
multiclass avx512_shift_types<bits<8> opcd, bits<8> opcq, bits<8> opcw,
57675780
string OpcodeStr, SDNode OpNode,
5768-
X86SchedWriteWidths sched> {
5781+
X86SchedWriteWidths sched,
5782+
bit NotEVEX2VEXConvertibleQ = 0> {
57695783
defm D : avx512_shift_sizes<opcd, OpcodeStr#"d", OpNode, sched, v4i32,
57705784
bc_v4i32, avx512vl_i32_info, HasAVX512>;
5785+
let notEVEX2VEXConvertible = NotEVEX2VEXConvertibleQ in
57715786
defm Q : avx512_shift_sizes<opcq, OpcodeStr#"q", OpNode, sched, v2i64,
57725787
bc_v2i64, avx512vl_i64_info, HasAVX512>, VEX_W;
57735788
defm W : avx512_shift_sizes<opcw, OpcodeStr#"w", OpNode, sched, v8i16,
@@ -5812,9 +5827,11 @@ multiclass avx512_shift_rmi_w<bits<8> opcw, Format ImmFormR, Format ImmFormM,
58125827
multiclass avx512_shift_rmi_dq<bits<8> opcd, bits<8> opcq,
58135828
Format ImmFormR, Format ImmFormM,
58145829
string OpcodeStr, SDNode OpNode,
5815-
X86SchedWriteWidths sched> {
5830+
X86SchedWriteWidths sched,
5831+
bit NotEVEX2VEXConvertibleQ = 0> {
58165832
defm D: avx512_shift_rmi_sizes<opcd, ImmFormR, ImmFormM, OpcodeStr#"d", OpNode,
58175833
sched, avx512vl_i32_info>, EVEX_CD8<32, CD8VF>;
5834+
let notEVEX2VEXConvertible = NotEVEX2VEXConvertibleQ in
58185835
defm Q: avx512_shift_rmi_sizes<opcq, ImmFormR, ImmFormM, OpcodeStr#"q", OpNode,
58195836
sched, avx512vl_i64_info>, EVEX_CD8<64, CD8VF>, VEX_W;
58205837
}
@@ -5830,7 +5847,7 @@ defm VPSLL : avx512_shift_rmi_dq<0x72, 0x73, MRM6r, MRM6m, "vpsll", X86vshli,
58305847
SchedWriteVecShiftImm>, AVX512BIi8Base, EVEX_4V;
58315848

58325849
defm VPSRA : avx512_shift_rmi_dq<0x72, 0x72, MRM4r, MRM4m, "vpsra", X86vsrai,
5833-
SchedWriteVecShiftImm>,
5850+
SchedWriteVecShiftImm, 1>,
58345851
avx512_shift_rmi_w<0x71, MRM4r, MRM4m, "vpsraw", X86vsrai,
58355852
SchedWriteVecShiftImm>, AVX512BIi8Base, EVEX_4V;
58365853

@@ -5842,7 +5859,7 @@ defm VPROL : avx512_shift_rmi_dq<0x72, 0x72, MRM1r, MRM1m, "vprol", X86vrotli,
58425859
defm VPSLL : avx512_shift_types<0xF2, 0xF3, 0xF1, "vpsll", X86vshl,
58435860
SchedWriteVecShift>;
58445861
defm VPSRA : avx512_shift_types<0xE2, 0xE2, 0xE1, "vpsra", X86vsra,
5845-
SchedWriteVecShift>;
5862+
SchedWriteVecShift, 1>;
58465863
defm VPSRL : avx512_shift_types<0xD2, 0xD3, 0xD1, "vpsrl", X86vsrl,
58475864
SchedWriteVecShift>;
58485865

@@ -7701,9 +7718,9 @@ multiclass avx512_cvtqq2pd<bits<8> opc, string OpcodeStr, SDNode OpNode,
77017718
}
77027719
let Predicates = [HasDQI, HasVLX] in {
77037720
defm Z128 : avx512_vcvt_fp<opc, OpcodeStr, v2f64x_info, v2i64x_info, OpNode,
7704-
sched.XMM>, EVEX_V128;
7721+
sched.XMM>, EVEX_V128, NotEVEX2VEXConvertible;
77057722
defm Z256 : avx512_vcvt_fp<opc, OpcodeStr, v4f64x_info, v4i64x_info, OpNode,
7706-
sched.YMM>, EVEX_V256;
7723+
sched.YMM>, EVEX_V256, NotEVEX2VEXConvertible;
77077724
}
77087725
}
77097726

@@ -7760,9 +7777,11 @@ multiclass avx512_cvtqq2ps<bits<8> opc, string OpcodeStr, SDNode OpNode,
77607777
// dest type - 'v4i32x_info'. We also specify the broadcast string explicitly
77617778
// due to the same reason.
77627779
defm Z128 : avx512_vcvt_fp<opc, OpcodeStr, v4f32x_info, v2i64x_info, OpNode128,
7763-
sched.XMM, "{1to2}", "{x}">, EVEX_V128;
7780+
sched.XMM, "{1to2}", "{x}">, EVEX_V128,
7781+
NotEVEX2VEXConvertible;
77647782
defm Z256 : avx512_vcvt_fp<opc, OpcodeStr, v4f32x_info, v4i64x_info, OpNode,
7765-
sched.YMM, "{1to4}", "{y}">, EVEX_V256;
7783+
sched.YMM, "{1to4}", "{y}">, EVEX_V256,
7784+
NotEVEX2VEXConvertible;
77667785

77677786
def : InstAlias<OpcodeStr##"x\t{$src, $dst|$dst, $src}",
77687787
(!cast<Instruction>(NAME # "Z128rr") VR128X:$dst, VR128X:$src), 0>;
@@ -10263,7 +10282,7 @@ let Predicates = [HasVLX, HasBWI] in {
1026310282

1026410283
defm VDBPSADBW: avx512_common_3Op_rm_imm8<0x42, X86dbpsadbw, "vdbpsadbw",
1026510284
SchedWritePSADBW, avx512vl_i16_info, avx512vl_i8_info>,
10266-
EVEX_CD8<8, CD8VF>;
10285+
EVEX_CD8<8, CD8VF>, NotEVEX2VEXConvertible;
1026710286

1026810287
multiclass avx512_unary_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1026910288
X86FoldableSchedWrite sched, X86VectorVTInfo _> {

lib/Target/X86/X86InstrFormats.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ class FoldGenData<string _RegisterForm> {
241241
// Mark the instruction as "illegal to memory fold/unfold"
242242
class NotMemoryFoldable { bit isMemoryFoldable = 0; }
243243

244+
// Prevent EVEX->VEX conversion from considering this instruction.
245+
class NotEVEX2VEXConvertible { bit notEVEX2VEXConvertible = 1; }
246+
244247
class X86Inst<bits<8> opcod, Format f, ImmType i, dag outs, dag ins,
245248
string AsmStr, Domain d = GenericDomain>
246249
: Instruction {
@@ -321,6 +324,7 @@ class X86Inst<bits<8> opcod, Format f, ImmType i, dag outs, dag ins,
321324
string FoldGenRegForm = ?;
322325

323326
bit isMemoryFoldable = 1; // Is it allowed to memory fold/unfold this instruction?
327+
bit notEVEX2VEXConvertible = 0; // Prevent EVEX->VEX conversion.
324328

325329
// TSFlags layout should be kept in sync with X86BaseInfo.h.
326330
let TSFlags{6-0} = FormBits;

utils/TableGen/X86EVEX2VEXTablesEmitter.cpp

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,35 +52,11 @@ class X86EVEX2VEXTablesEmitter {
5252
// Prints the given table as a C++ array of type
5353
// X86EvexToVexCompressTableEntry
5454
void printTable(const std::vector<Entry> &Table, raw_ostream &OS);
55-
56-
bool inExceptionList(const CodeGenInstruction *Inst) {
57-
// List of EVEX instructions that match VEX instructions by the encoding
58-
// but do not perform the same operation.
59-
static constexpr const char *ExceptionList[] = {
60-
"VCVTQQ2PD",
61-
"VCVTQQ2PS",
62-
"VPMAXSQ",
63-
"VPMAXUQ",
64-
"VPMINSQ",
65-
"VPMINUQ",
66-
"VPMULLQ",
67-
"VPSRAQ",
68-
"VDBPSADBW",
69-
"VSCALEFPS"
70-
};
71-
// Instruction's name starts with one of the entries in the exception list
72-
for (StringRef InstStr : ExceptionList) {
73-
if (Inst->TheDef->getName().startswith(InstStr))
74-
return true;
75-
}
76-
return false;
77-
}
78-
7955
};
8056

8157
void X86EVEX2VEXTablesEmitter::printTable(const std::vector<Entry> &Table,
8258
raw_ostream &OS) {
83-
std::string Size = (Table == EVEX2VEX128) ? "128" : "256";
59+
StringRef Size = (Table == EVEX2VEX128) ? "128" : "256";
8460

8561
OS << "// X86 EVEX encoded instructions that have a VEX " << Size
8662
<< " encoding\n"
@@ -332,7 +308,7 @@ void X86EVEX2VEXTablesEmitter::run(raw_ostream &OS) {
332308
!Inst->TheDef->getValueAsBit("hasEVEX_B") &&
333309
getValueFromBitsInit(Inst->TheDef->
334310
getValueAsBitsInit("EVEX_LL")) != 2 &&
335-
!inExceptionList(Inst))
311+
!Inst->TheDef->getValueAsBit("notEVEX2VEXConvertible"))
336312
EVEXInsts.push_back(Inst);
337313
}
338314

0 commit comments

Comments
 (0)