1 //===---X86InstrPredicates.td - X86 Predicate Definitions --*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 def TruePredicate : Predicate<"true">;
11 // Intel x86 instructions have three separate encoding spaces: legacy, VEX, and
12 // EVEX. Not all X86 instructions are extended for EGPR. The following is an
13 // overview of which instructions are extended and how we implement them.
16 // All instructions in legacy maps 0 and 1 that have explicit GPR or memory
17 // operands can use the REX2 prefix to access the EGPR, except XSAVE*/XRSTOR.
20 // All instructions in the EVEX space can access the EGPR in their
21 // register/memory operands.
23 // For the above intructions, the only difference in encoding is reflected in
24 // the REX2/EVEX prefix when EGPR is used, i.e. the opcode and opcode name are
25 // unchanged. We don’t add new entries in TD, and instead we extend GPR with
26 // R16-R31 and make them allocatable only when the feature EGPR is available.
28 // Besides, some instructions in legacy space with map 2/3 and VEX space are
29 // promoted into EVEX space. Encoding space changes after the promotion, opcode
30 // and opcode map may change too sometimes. For these instructions, we add new
31 // entries in TD to avoid overcomplicating the assembler and disassembler.
33 // HasEGPR is for the new entries and NoEGPR is for the entries before
34 // promotion, so that the promoted variant can be selected first to benefit RA.
35 def HasEGPR : Predicate<"Subtarget->hasEGPR()">;
36 def NoEGPR : Predicate<"!Subtarget->hasEGPR()">;
38 // APX extends some instructions with a new form that has an extra register
39 // operand called a new data destination (NDD). In such forms, NDD is the new
40 // destination register receiving the result of the computation and all other
41 // operands (including the original destination operand) become read-only source
44 // HasNDD is for the new NDD entries and NoNDD is for the legacy 2-address
45 // entries, so that the NDD variant can be selected first to benefit RA.
46 def HasNDD : Predicate<"Subtarget->hasNDD()">;
47 def NoNDD : Predicate<"!Subtarget->hasNDD()">;
48 def HasZU : Predicate<"Subtarget->hasZU()">;
49 def HasCF : Predicate<"Subtarget->hasCF()">;
50 def HasCMOV : Predicate<"Subtarget->canUseCMOV()">;
51 def NoCMOV : Predicate<"!Subtarget->canUseCMOV()">;
52 def HasNOPL : Predicate<"Subtarget->hasNOPL()">;
53 def HasMMX : Predicate<"Subtarget->hasMMX()">;
54 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
55 def UseSSE1 : Predicate<"Subtarget->hasSSE1() && !Subtarget->hasAVX()">;
56 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
57 def UseSSE2 : Predicate<"Subtarget->hasSSE2() && !Subtarget->hasAVX()">;
58 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
59 def UseSSE3 : Predicate<"Subtarget->hasSSE3() && !Subtarget->hasAVX()">;
60 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
61 def UseSSSE3 : Predicate<"Subtarget->hasSSSE3() && !Subtarget->hasAVX()">;
62 def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
63 def NoSSE41 : Predicate<"!Subtarget->hasSSE41()">;
64 def UseSSE41 : Predicate<"Subtarget->hasSSE41() && !Subtarget->hasAVX()">;
65 def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
66 def UseSSE42 : Predicate<"Subtarget->hasSSE42() && !Subtarget->hasAVX()">;
67 def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
68 def NoAVX : Predicate<"!Subtarget->hasAVX()">;
69 def HasAVX : Predicate<"Subtarget->hasAVX()">;
70 def HasAVX2 : Predicate<"Subtarget->hasAVX2()">;
71 def HasAVX1Only : Predicate<"Subtarget->hasAVX() && !Subtarget->hasAVX2()">;
72 def HasEVEX512 : Predicate<"Subtarget->hasEVEX512()">;
73 def HasAVX10_1 : Predicate<"Subtarget->hasAVX10_1()">;
74 def HasAVX10_1_512 : Predicate<"Subtarget->hasAVX10_1_512()">;
75 def HasAVX10_2 : Predicate<"Subtarget->hasAVX10_2()">;
76 def HasAVX10_2_512 : Predicate<"Subtarget->hasAVX10_2_512()">;
77 def NoAVX10_2 : Predicate<"!Subtarget->hasAVX10_2()">;
78 def HasAVX512 : Predicate<"Subtarget->hasAVX512()">;
79 def UseAVX : Predicate<"Subtarget->hasAVX() && !Subtarget->hasAVX512()">;
80 def UseAVX2 : Predicate<"Subtarget->hasAVX2() && !Subtarget->hasAVX512()">;
81 def NoAVX512 : Predicate<"!Subtarget->hasAVX512()">;
82 def HasCDI : Predicate<"Subtarget->hasCDI()">;
83 def HasVPOPCNTDQ : Predicate<"Subtarget->hasVPOPCNTDQ()">;
84 def HasDQI : Predicate<"Subtarget->hasDQI()">;
85 def NoDQI : Predicate<"!Subtarget->hasDQI()">;
86 def HasBWI : Predicate<"Subtarget->hasBWI()">;
87 def NoBWI : Predicate<"!Subtarget->hasBWI()">;
88 def HasVLX : Predicate<"Subtarget->hasVLX()">;
89 def NoVLX : Predicate<"!Subtarget->hasVLX()">;
90 def NoVLX_Or_NoBWI : Predicate<"!Subtarget->hasVLX() || !Subtarget->hasBWI()">;
91 def NoVLX_Or_NoDQI : Predicate<"!Subtarget->hasVLX() || !Subtarget->hasDQI()">;
92 def HasPKU : Predicate<"Subtarget->hasPKU()">;
93 def HasVNNI : Predicate<"Subtarget->hasVNNI()">;
94 def HasVP2INTERSECT : Predicate<"Subtarget->hasVP2INTERSECT()">;
95 def HasBF16 : Predicate<"Subtarget->hasBF16()">;
96 def HasFP16 : Predicate<"Subtarget->hasFP16()">;
97 def HasAVXVNNIINT16 : Predicate<"Subtarget->hasAVXVNNIINT16()">;
98 def HasAVXVNNIINT8 : Predicate<"Subtarget->hasAVXVNNIINT8()">;
99 def HasAVXVNNI : Predicate <"Subtarget->hasAVXVNNI()">;
100 def NoVLX_Or_NoVNNI : Predicate<"!Subtarget->hasVLX() || !Subtarget->hasVNNI()">;
102 def HasBITALG : Predicate<"Subtarget->hasBITALG()">;
103 def HasPOPCNT : Predicate<"Subtarget->hasPOPCNT()">;
104 def HasAES : Predicate<"Subtarget->hasAES()">;
105 def HasVAES : Predicate<"Subtarget->hasVAES()">;
106 def NoVLX_Or_NoVAES : Predicate<"!Subtarget->hasVLX() || !Subtarget->hasVAES()">;
107 def HasFXSR : Predicate<"Subtarget->hasFXSR()">;
108 def HasX87 : Predicate<"Subtarget->hasX87()">;
109 def HasXSAVE : Predicate<"Subtarget->hasXSAVE()">;
110 def HasXSAVEOPT : Predicate<"Subtarget->hasXSAVEOPT()">;
111 def HasXSAVEC : Predicate<"Subtarget->hasXSAVEC()">;
112 def HasXSAVES : Predicate<"Subtarget->hasXSAVES()">;
113 def HasPCLMUL : Predicate<"Subtarget->hasPCLMUL()">;
114 def NoVLX_Or_NoVPCLMULQDQ :
115 Predicate<"!Subtarget->hasVLX() || !Subtarget->hasVPCLMULQDQ()">;
116 def HasVPCLMULQDQ : Predicate<"Subtarget->hasVPCLMULQDQ()">;
117 def HasGFNI : Predicate<"Subtarget->hasGFNI()">;
118 def HasFMA : Predicate<"Subtarget->hasFMA()">;
119 def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
120 def NoFMA4 : Predicate<"!Subtarget->hasFMA4()">;
121 def HasXOP : Predicate<"Subtarget->hasXOP()">;
122 def HasTBM : Predicate<"Subtarget->hasTBM()">;
123 def NoTBM : Predicate<"!Subtarget->hasTBM()">;
124 def HasLWP : Predicate<"Subtarget->hasLWP()">;
125 def HasMOVBE : Predicate<"Subtarget->hasMOVBE()">;
126 def NoNDD_Or_NoMOVBE : Predicate<"!Subtarget->hasNDD() || !Subtarget->hasMOVBE()">;
127 def HasRDRAND : Predicate<"Subtarget->hasRDRAND()">;
128 def HasF16C : Predicate<"Subtarget->hasF16C()">;
129 def HasFSGSBase : Predicate<"Subtarget->hasFSGSBase()">;
130 def HasLZCNT : Predicate<"Subtarget->hasLZCNT()">;
131 def HasBMI : Predicate<"Subtarget->hasBMI()">;
132 def HasBMI2 : Predicate<"Subtarget->hasBMI2()">;
133 def NoBMI2 : Predicate<"!Subtarget->hasBMI2()">;
134 def HasVBMI : Predicate<"Subtarget->hasVBMI()">;
135 def HasVBMI2 : Predicate<"Subtarget->hasVBMI2()">;
136 def HasIFMA : Predicate<"Subtarget->hasIFMA()">;
137 def HasAVXIFMA : Predicate<"Subtarget->hasAVXIFMA()">;
138 def NoVLX_Or_NoIFMA : Predicate<"!Subtarget->hasVLX() || !Subtarget->hasIFMA()">;
139 def HasRTM : Predicate<"Subtarget->hasRTM()">;
140 def HasSHA : Predicate<"Subtarget->hasSHA()">;
141 def HasSHA512 : Predicate<"Subtarget->hasSHA512()">;
142 def HasSGX : Predicate<"Subtarget->hasSGX()">;
143 def HasSM3 : Predicate<"Subtarget->hasSM3()">;
144 def HasRDSEED : Predicate<"Subtarget->hasRDSEED()">;
145 def HasSSEPrefetch : Predicate<"Subtarget->hasSSEPrefetch()">;
146 def HasPRFCHW : Predicate<"Subtarget->hasPRFCHW()">;
147 def HasPREFETCHI : Predicate<"Subtarget->hasPREFETCHI()">;
148 def HasPrefetchW : Predicate<"Subtarget->hasPrefetchW()">;
149 def HasLAHFSAHF : Predicate<"Subtarget->hasLAHFSAHF()">;
150 def HasLAHFSAHF64 : Predicate<"Subtarget->hasLAHFSAHF64()">;
151 def HasMWAITX : Predicate<"Subtarget->hasMWAITX()">;
152 def HasCLZERO : Predicate<"Subtarget->hasCLZERO()">;
153 def HasCLDEMOTE : Predicate<"Subtarget->hasCLDEMOTE()">;
154 def HasMOVDIRI : Predicate<"Subtarget->hasMOVDIRI()">;
155 def HasMOVDIR64B : Predicate<"Subtarget->hasMOVDIR64B()">;
156 def HasMOVRS : Predicate<"Subtarget->hasMOVRS()">;
157 def HasPTWRITE : Predicate<"Subtarget->hasPTWRITE()">;
158 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
159 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
160 def HasSHSTK : Predicate<"Subtarget->hasSHSTK()">;
161 def HasSM4 : Predicate<"Subtarget->hasSM4()">;
162 def HasCLFLUSH : Predicate<"Subtarget->hasCLFLUSH()">;
163 def HasCLFLUSHOPT : Predicate<"Subtarget->hasCLFLUSHOPT()">;
164 def HasCLWB : Predicate<"Subtarget->hasCLWB()">;
165 def HasWBNOINVD : Predicate<"Subtarget->hasWBNOINVD()">;
166 def HasRDPID : Predicate<"Subtarget->hasRDPID()">;
167 def HasRDPRU : Predicate<"Subtarget->hasRDPRU()">;
168 def HasWAITPKG : Predicate<"Subtarget->hasWAITPKG()">;
169 def HasINVPCID : Predicate<"Subtarget->hasINVPCID()">;
170 def HasCX8 : Predicate<"Subtarget->hasCX8()">;
171 def HasCX16 : Predicate<"Subtarget->hasCX16()">;
172 def HasPCONFIG : Predicate<"Subtarget->hasPCONFIG()">;
173 def HasENQCMD : Predicate<"Subtarget->hasENQCMD()">;
174 def HasAMXFP16 : Predicate<"Subtarget->hasAMXFP16()">;
175 def HasCMPCCXADD : Predicate<"Subtarget->hasCMPCCXADD()">;
176 def HasAVXNECONVERT : Predicate<"Subtarget->hasAVXNECONVERT()">;
177 def HasKL : Predicate<"Subtarget->hasKL()">;
178 def HasRAOINT : Predicate<"Subtarget->hasRAOINT()">;
179 def HasWIDEKL : Predicate<"Subtarget->hasWIDEKL()">;
180 def HasHRESET : Predicate<"Subtarget->hasHRESET()">;
181 def HasSERIALIZE : Predicate<"Subtarget->hasSERIALIZE()">;
182 def HasTSXLDTRK : Predicate<"Subtarget->hasTSXLDTRK()">;
183 def HasAMXTILE : Predicate<"Subtarget->hasAMXTILE()">;
184 def HasAMXBF16 : Predicate<"Subtarget->hasAMXBF16()">;
185 def HasAMXINT8 : Predicate<"Subtarget->hasAMXINT8()">;
186 def HasAMXCOMPLEX : Predicate<"Subtarget->hasAMXCOMPLEX()">;
187 def HasAMXFP8 : Predicate<"Subtarget->hasAMXFP8()">;
188 def HasAMXMOVRS : Predicate<"Subtarget->hasAMXMOVRS()">;
189 def HasAMXTRANSPOSE : Predicate<"Subtarget->hasAMXTRANSPOSE()">;
190 def HasAMXAVX512 : Predicate<"Subtarget->hasAMXAVX512()">;
191 def HasAMXTF32 : Predicate<"Subtarget->hasAMXTF32()">;
192 def HasUINTR : Predicate<"Subtarget->hasUINTR()">;
193 def HasUSERMSR : Predicate<"Subtarget->hasUSERMSR()">;
194 def HasCRC32 : Predicate<"Subtarget->hasCRC32()">;
196 def HasX86_64 : Predicate<"Subtarget->hasX86_64()">;
197 def Not64BitMode : Predicate<"!Subtarget->is64Bit()">,
198 AssemblerPredicate<(all_of (not Is64Bit)), "Not 64-bit mode">;
199 def In64BitMode : Predicate<"Subtarget->is64Bit()">,
200 AssemblerPredicate<(all_of Is64Bit), "64-bit mode">;
201 def IsLP64 : Predicate<"Subtarget->isTarget64BitLP64()">;
202 def NotLP64 : Predicate<"!Subtarget->isTarget64BitLP64()">;
203 def In16BitMode : Predicate<"Subtarget->is16Bit()">,
204 AssemblerPredicate<(all_of Is16Bit), "16-bit mode">;
205 def Not16BitMode : Predicate<"!Subtarget->is16Bit()">,
206 AssemblerPredicate<(all_of (not Is16Bit)), "Not 16-bit mode">;
207 def In32BitMode : Predicate<"Subtarget->is32Bit()">,
208 AssemblerPredicate<(all_of Is32Bit), "32-bit mode">;
209 def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
210 def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
211 def NotWin64WithoutFP : Predicate<"!Subtarget->isTargetWin64() ||"
212 "Subtarget->getFrameLowering()->hasFP(*MF)"> {
213 let RecomputePerFunction = 1;
215 def IsPS : Predicate<"Subtarget->isTargetPS()">;
216 def NotPS : Predicate<"!Subtarget->isTargetPS()">;
217 def IsNaCl : Predicate<"Subtarget->isTargetNaCl()">;
218 def NotNaCl : Predicate<"!Subtarget->isTargetNaCl()">;
219 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
220 def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
221 def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
222 "TM.getCodeModel() == CodeModel::Kernel">;
223 def IsNotPIC : Predicate<"!TM.isPositionIndependent()">;
225 // We could compute these on a per-module basis but doing so requires accessing
226 // the Function object through the <Target>Subtarget and objections were raised
227 // to that (see post-commit review comments for r301750).
228 let RecomputePerFunction = 1 in {
229 def OptForSize : Predicate<"shouldOptForSize(MF)">;
230 def OptForMinSize : Predicate<"MF->getFunction().hasMinSize()">;
231 def OptForSpeed : Predicate<"!shouldOptForSize(MF)">;
232 def UseIncDec : Predicate<"!Subtarget->slowIncDec() || "
233 "shouldOptForSize(MF)">;
234 def NoSSE41_Or_OptForSize : Predicate<"shouldOptForSize(MF) || "
235 "!Subtarget->hasSSE41()">;
238 def CallImmAddr : Predicate<"Subtarget->isLegalToCallImmediateAddr()">;
239 def FavorMemIndirectCall : Predicate<"!Subtarget->slowTwoMemOps()">;
240 def HasFastMem32 : Predicate<"!Subtarget->isUnalignedMem32Slow()">;
241 def HasFastLZCNT : Predicate<"Subtarget->hasFastLZCNT()">;
242 def HasFastSHLDRotate : Predicate<"Subtarget->hasFastSHLDRotate()">;
243 def HasERMSB : Predicate<"Subtarget->hasERMSB()">;
244 def HasFSRM : Predicate<"Subtarget->hasFSRM()">;
245 def HasMFence : Predicate<"Subtarget->hasMFence()">;
246 def HasFastDPWSSD: Predicate<"Subtarget->hasFastDPWSSD()">;
247 def UseIndirectThunkCalls : Predicate<"Subtarget->useIndirectThunkCalls()">;
248 def NotUseIndirectThunkCalls : Predicate<"!Subtarget->useIndirectThunkCalls()">;