xref: /freebsd/contrib/llvm-project/llvm/lib/Target/X86/X86InstrPredicates.td (revision b64c5a0ace59af62eff52bfe110a521dc73c937b)
1//===---X86InstrPredicates.td - X86 Predicate Definitions --*- tablegen -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9def TruePredicate : Predicate<"true">;
10
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.
14//
15// * Legacy space
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.
18//
19// * EVEX space
20//   All instructions in the EVEX space can access the EGPR in their
21//   register/memory operands.
22//
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.
27//
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.
32//
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.
35def HasEGPR      : Predicate<"Subtarget->hasEGPR()">;
36def NoEGPR       : Predicate<"!Subtarget->hasEGPR()">;
37
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
42// operands.
43//
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.
46def HasNDD       : Predicate<"Subtarget->hasNDD()">;
47def NoNDD        : Predicate<"!Subtarget->hasNDD()">;
48def HasCF        : Predicate<"Subtarget->hasCF()">;
49def HasCMOV      : Predicate<"Subtarget->canUseCMOV()">;
50def NoCMOV       : Predicate<"!Subtarget->canUseCMOV()">;
51def HasNOPL      : Predicate<"Subtarget->hasNOPL()">;
52def HasMMX       : Predicate<"Subtarget->hasMMX()">;
53def HasSSE1      : Predicate<"Subtarget->hasSSE1()">;
54def UseSSE1      : Predicate<"Subtarget->hasSSE1() && !Subtarget->hasAVX()">;
55def HasSSE2      : Predicate<"Subtarget->hasSSE2()">;
56def UseSSE2      : Predicate<"Subtarget->hasSSE2() && !Subtarget->hasAVX()">;
57def HasSSE3      : Predicate<"Subtarget->hasSSE3()">;
58def UseSSE3      : Predicate<"Subtarget->hasSSE3() && !Subtarget->hasAVX()">;
59def HasSSSE3     : Predicate<"Subtarget->hasSSSE3()">;
60def UseSSSE3     : Predicate<"Subtarget->hasSSSE3() && !Subtarget->hasAVX()">;
61def HasSSE41     : Predicate<"Subtarget->hasSSE41()">;
62def NoSSE41      : Predicate<"!Subtarget->hasSSE41()">;
63def UseSSE41     : Predicate<"Subtarget->hasSSE41() && !Subtarget->hasAVX()">;
64def HasSSE42     : Predicate<"Subtarget->hasSSE42()">;
65def UseSSE42     : Predicate<"Subtarget->hasSSE42() && !Subtarget->hasAVX()">;
66def HasSSE4A     : Predicate<"Subtarget->hasSSE4A()">;
67def NoAVX        : Predicate<"!Subtarget->hasAVX()">;
68def HasAVX       : Predicate<"Subtarget->hasAVX()">;
69def HasAVX2      : Predicate<"Subtarget->hasAVX2()">;
70def HasAVX1Only  : Predicate<"Subtarget->hasAVX() && !Subtarget->hasAVX2()">;
71def HasEVEX512   : Predicate<"Subtarget->hasEVEX512()">;
72def HasAVX10_1   : Predicate<"Subtarget->hasAVX10_1()">;
73def HasAVX10_1_512 : Predicate<"Subtarget->hasAVX10_1_512()">;
74def HasAVX512    : Predicate<"Subtarget->hasAVX512()">;
75def UseAVX       : Predicate<"Subtarget->hasAVX() && !Subtarget->hasAVX512()">;
76def UseAVX2      : Predicate<"Subtarget->hasAVX2() && !Subtarget->hasAVX512()">;
77def NoAVX512     : Predicate<"!Subtarget->hasAVX512()">;
78def HasCDI       : Predicate<"Subtarget->hasCDI()">;
79def HasVPOPCNTDQ : Predicate<"Subtarget->hasVPOPCNTDQ()">;
80def HasDQI       : Predicate<"Subtarget->hasDQI()">;
81def NoDQI        : Predicate<"!Subtarget->hasDQI()">;
82def HasBWI       : Predicate<"Subtarget->hasBWI()">;
83def NoBWI        : Predicate<"!Subtarget->hasBWI()">;
84def HasVLX       : Predicate<"Subtarget->hasVLX()">;
85def NoVLX        : Predicate<"!Subtarget->hasVLX()">;
86def NoVLX_Or_NoBWI : Predicate<"!Subtarget->hasVLX() || !Subtarget->hasBWI()">;
87def NoVLX_Or_NoDQI : Predicate<"!Subtarget->hasVLX() || !Subtarget->hasDQI()">;
88def HasPKU       : Predicate<"Subtarget->hasPKU()">;
89def HasVNNI      : Predicate<"Subtarget->hasVNNI()">;
90def HasVP2INTERSECT : Predicate<"Subtarget->hasVP2INTERSECT()">;
91def HasBF16      : Predicate<"Subtarget->hasBF16()">;
92def HasFP16      : Predicate<"Subtarget->hasFP16()">;
93def HasAVXVNNIINT16 : Predicate<"Subtarget->hasAVXVNNIINT16()">;
94def HasAVXVNNIINT8 : Predicate<"Subtarget->hasAVXVNNIINT8()">;
95def HasAVXVNNI : Predicate <"Subtarget->hasAVXVNNI()">;
96def NoVLX_Or_NoVNNI : Predicate<"!Subtarget->hasVLX() || !Subtarget->hasVNNI()">;
97
98def HasBITALG    : Predicate<"Subtarget->hasBITALG()">;
99def HasPOPCNT    : Predicate<"Subtarget->hasPOPCNT()">;
100def HasAES       : Predicate<"Subtarget->hasAES()">;
101def HasVAES      : Predicate<"Subtarget->hasVAES()">;
102def NoVLX_Or_NoVAES : Predicate<"!Subtarget->hasVLX() || !Subtarget->hasVAES()">;
103def HasFXSR      : Predicate<"Subtarget->hasFXSR()">;
104def HasX87       : Predicate<"Subtarget->hasX87()">;
105def HasXSAVE     : Predicate<"Subtarget->hasXSAVE()">;
106def HasXSAVEOPT  : Predicate<"Subtarget->hasXSAVEOPT()">;
107def HasXSAVEC    : Predicate<"Subtarget->hasXSAVEC()">;
108def HasXSAVES    : Predicate<"Subtarget->hasXSAVES()">;
109def HasPCLMUL    : Predicate<"Subtarget->hasPCLMUL()">;
110def NoVLX_Or_NoVPCLMULQDQ :
111                    Predicate<"!Subtarget->hasVLX() || !Subtarget->hasVPCLMULQDQ()">;
112def HasVPCLMULQDQ : Predicate<"Subtarget->hasVPCLMULQDQ()">;
113def HasGFNI      : Predicate<"Subtarget->hasGFNI()">;
114def HasFMA       : Predicate<"Subtarget->hasFMA()">;
115def HasFMA4      : Predicate<"Subtarget->hasFMA4()">;
116def NoFMA4       : Predicate<"!Subtarget->hasFMA4()">;
117def HasXOP       : Predicate<"Subtarget->hasXOP()">;
118def HasTBM       : Predicate<"Subtarget->hasTBM()">;
119def NoTBM        : Predicate<"!Subtarget->hasTBM()">;
120def HasLWP       : Predicate<"Subtarget->hasLWP()">;
121def HasMOVBE     : Predicate<"Subtarget->hasMOVBE()">;
122def NoNDD_Or_NoMOVBE     : Predicate<"!Subtarget->hasNDD() || !Subtarget->hasMOVBE()">;
123def HasRDRAND    : Predicate<"Subtarget->hasRDRAND()">;
124def HasF16C      : Predicate<"Subtarget->hasF16C()">;
125def HasFSGSBase  : Predicate<"Subtarget->hasFSGSBase()">;
126def HasLZCNT     : Predicate<"Subtarget->hasLZCNT()">;
127def HasBMI       : Predicate<"Subtarget->hasBMI()">;
128def HasBMI2      : Predicate<"Subtarget->hasBMI2()">;
129def NoBMI2       : Predicate<"!Subtarget->hasBMI2()">;
130def HasVBMI      : Predicate<"Subtarget->hasVBMI()">;
131def HasVBMI2     : Predicate<"Subtarget->hasVBMI2()">;
132def HasIFMA      : Predicate<"Subtarget->hasIFMA()">;
133def HasAVXIFMA   : Predicate<"Subtarget->hasAVXIFMA()">;
134def NoVLX_Or_NoIFMA : Predicate<"!Subtarget->hasVLX() || !Subtarget->hasIFMA()">;
135def HasRTM       : Predicate<"Subtarget->hasRTM()">;
136def HasSHA       : Predicate<"Subtarget->hasSHA()">;
137def HasSHA512    : Predicate<"Subtarget->hasSHA512()">;
138def HasSGX       : Predicate<"Subtarget->hasSGX()">;
139def HasSM3       : Predicate<"Subtarget->hasSM3()">;
140def HasRDSEED    : Predicate<"Subtarget->hasRDSEED()">;
141def HasSSEPrefetch : Predicate<"Subtarget->hasSSEPrefetch()">;
142def HasPRFCHW    : Predicate<"Subtarget->hasPRFCHW()">;
143def HasPREFETCHI : Predicate<"Subtarget->hasPREFETCHI()">;
144def HasPrefetchW : Predicate<"Subtarget->hasPrefetchW()">;
145def HasLAHFSAHF  : Predicate<"Subtarget->hasLAHFSAHF()">;
146def HasLAHFSAHF64 : Predicate<"Subtarget->hasLAHFSAHF64()">;
147def HasMWAITX    : Predicate<"Subtarget->hasMWAITX()">;
148def HasCLZERO    : Predicate<"Subtarget->hasCLZERO()">;
149def HasCLDEMOTE  : Predicate<"Subtarget->hasCLDEMOTE()">;
150def HasMOVDIRI   : Predicate<"Subtarget->hasMOVDIRI()">;
151def HasMOVDIR64B : Predicate<"Subtarget->hasMOVDIR64B()">;
152def HasPTWRITE   : Predicate<"Subtarget->hasPTWRITE()">;
153def FPStackf32   : Predicate<"!Subtarget->hasSSE1()">;
154def FPStackf64   : Predicate<"!Subtarget->hasSSE2()">;
155def HasSHSTK     : Predicate<"Subtarget->hasSHSTK()">;
156def HasSM4       : Predicate<"Subtarget->hasSM4()">;
157def HasCLFLUSH   : Predicate<"Subtarget->hasCLFLUSH()">;
158def HasCLFLUSHOPT : Predicate<"Subtarget->hasCLFLUSHOPT()">;
159def HasCLWB      : Predicate<"Subtarget->hasCLWB()">;
160def HasWBNOINVD  : Predicate<"Subtarget->hasWBNOINVD()">;
161def HasRDPID     : Predicate<"Subtarget->hasRDPID()">;
162def HasRDPRU     : Predicate<"Subtarget->hasRDPRU()">;
163def HasWAITPKG   : Predicate<"Subtarget->hasWAITPKG()">;
164def HasINVPCID   : Predicate<"Subtarget->hasINVPCID()">;
165def HasCX8       : Predicate<"Subtarget->hasCX8()">;
166def HasCX16      : Predicate<"Subtarget->hasCX16()">;
167def HasPCONFIG   : Predicate<"Subtarget->hasPCONFIG()">;
168def HasENQCMD    : Predicate<"Subtarget->hasENQCMD()">;
169def HasAMXFP16   : Predicate<"Subtarget->hasAMXFP16()">;
170def HasCMPCCXADD : Predicate<"Subtarget->hasCMPCCXADD()">;
171def HasAVXNECONVERT : Predicate<"Subtarget->hasAVXNECONVERT()">;
172def HasKL        : Predicate<"Subtarget->hasKL()">;
173def HasRAOINT    : Predicate<"Subtarget->hasRAOINT()">;
174def HasWIDEKL    : Predicate<"Subtarget->hasWIDEKL()">;
175def HasHRESET    : Predicate<"Subtarget->hasHRESET()">;
176def HasSERIALIZE : Predicate<"Subtarget->hasSERIALIZE()">;
177def HasTSXLDTRK  : Predicate<"Subtarget->hasTSXLDTRK()">;
178def HasAMXTILE   : Predicate<"Subtarget->hasAMXTILE()">;
179def HasAMXBF16   : Predicate<"Subtarget->hasAMXBF16()">;
180def HasAMXINT8   : Predicate<"Subtarget->hasAMXINT8()">;
181def HasAMXCOMPLEX : Predicate<"Subtarget->hasAMXCOMPLEX()">;
182def HasUINTR     : Predicate<"Subtarget->hasUINTR()">;
183def HasUSERMSR   : Predicate<"Subtarget->hasUSERMSR()">;
184def HasCRC32     : Predicate<"Subtarget->hasCRC32()">;
185
186def HasX86_64    : Predicate<"Subtarget->hasX86_64()">;
187def Not64BitMode : Predicate<"!Subtarget->is64Bit()">,
188                             AssemblerPredicate<(all_of (not Is64Bit)), "Not 64-bit mode">;
189def In64BitMode  : Predicate<"Subtarget->is64Bit()">,
190                             AssemblerPredicate<(all_of Is64Bit), "64-bit mode">;
191def IsLP64  : Predicate<"Subtarget->isTarget64BitLP64()">;
192def NotLP64 : Predicate<"!Subtarget->isTarget64BitLP64()">;
193def In16BitMode  : Predicate<"Subtarget->is16Bit()">,
194                             AssemblerPredicate<(all_of Is16Bit), "16-bit mode">;
195def Not16BitMode : Predicate<"!Subtarget->is16Bit()">,
196                             AssemblerPredicate<(all_of (not Is16Bit)), "Not 16-bit mode">;
197def In32BitMode  : Predicate<"Subtarget->is32Bit()">,
198                             AssemblerPredicate<(all_of Is32Bit), "32-bit mode">;
199def IsWin64      : Predicate<"Subtarget->isTargetWin64()">;
200def NotWin64     : Predicate<"!Subtarget->isTargetWin64()">;
201def NotWin64WithoutFP : Predicate<"!Subtarget->isTargetWin64() ||"
202                                  "Subtarget->getFrameLowering()->hasFP(*MF)"> {
203  let RecomputePerFunction = 1;
204}
205def IsPS         : Predicate<"Subtarget->isTargetPS()">;
206def NotPS        : Predicate<"!Subtarget->isTargetPS()">;
207def IsNaCl       : Predicate<"Subtarget->isTargetNaCl()">;
208def NotNaCl      : Predicate<"!Subtarget->isTargetNaCl()">;
209def SmallCode    : Predicate<"TM.getCodeModel() == CodeModel::Small">;
210def KernelCode   : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
211def NearData     : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
212                             "TM.getCodeModel() == CodeModel::Kernel">;
213def IsNotPIC     : Predicate<"!TM.isPositionIndependent()">;
214
215// We could compute these on a per-module basis but doing so requires accessing
216// the Function object through the <Target>Subtarget and objections were raised
217// to that (see post-commit review comments for r301750).
218let RecomputePerFunction = 1 in {
219  def OptForSize   : Predicate<"shouldOptForSize(MF)">;
220  def OptForMinSize : Predicate<"MF->getFunction().hasMinSize()">;
221  def OptForSpeed  : Predicate<"!shouldOptForSize(MF)">;
222  def UseIncDec : Predicate<"!Subtarget->slowIncDec() || "
223                            "shouldOptForSize(MF)">;
224  def NoSSE41_Or_OptForSize : Predicate<"shouldOptForSize(MF) || "
225                                        "!Subtarget->hasSSE41()">;
226}
227
228def CallImmAddr  : Predicate<"Subtarget->isLegalToCallImmediateAddr()">;
229def FavorMemIndirectCall  : Predicate<"!Subtarget->slowTwoMemOps()">;
230def HasFastMem32 : Predicate<"!Subtarget->isUnalignedMem32Slow()">;
231def HasFastLZCNT : Predicate<"Subtarget->hasFastLZCNT()">;
232def HasFastSHLDRotate : Predicate<"Subtarget->hasFastSHLDRotate()">;
233def HasERMSB : Predicate<"Subtarget->hasERMSB()">;
234def HasFSRM : Predicate<"Subtarget->hasFSRM()">;
235def HasMFence    : Predicate<"Subtarget->hasMFence()">;
236def HasFastDPWSSD: Predicate<"Subtarget->hasFastDPWSSD()">;
237def UseIndirectThunkCalls : Predicate<"Subtarget->useIndirectThunkCalls()">;
238def NotUseIndirectThunkCalls : Predicate<"!Subtarget->useIndirectThunkCalls()">;
239