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