1//===- TargetSelectionDAG.td - Common code for DAG isels ---*- tablegen -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file defines the target-independent interfaces used by SelectionDAG 11// instruction selection generators. 12// 13//===----------------------------------------------------------------------===// 14 15//===----------------------------------------------------------------------===// 16// Selection DAG Type Constraint definitions. 17// 18// Note that the semantics of these constraints are hard coded into tblgen. To 19// modify or add constraints, you have to hack tblgen. 20// 21 22class SDTypeConstraint<int opnum> { 23 int OperandNum = opnum; 24} 25 26// SDTCisVT - The specified operand has exactly this VT. 27class SDTCisVT<int OpNum, ValueType vt> : SDTypeConstraint<OpNum> { 28 ValueType VT = vt; 29} 30 31class SDTCisPtrTy<int OpNum> : SDTypeConstraint<OpNum>; 32 33// SDTCisInt - The specified operand has integer type. 34class SDTCisInt<int OpNum> : SDTypeConstraint<OpNum>; 35 36// SDTCisFP - The specified operand has floating-point type. 37class SDTCisFP<int OpNum> : SDTypeConstraint<OpNum>; 38 39// SDTCisVec - The specified operand has a vector type. 40class SDTCisVec<int OpNum> : SDTypeConstraint<OpNum>; 41 42// SDTCisSameAs - The two specified operands have identical types. 43class SDTCisSameAs<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> { 44 int OtherOperandNum = OtherOp; 45} 46 47// SDTCisVTSmallerThanOp - The specified operand is a VT SDNode, and its type is 48// smaller than the 'Other' operand. 49class SDTCisVTSmallerThanOp<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> { 50 int OtherOperandNum = OtherOp; 51} 52 53class SDTCisOpSmallerThanOp<int SmallOp, int BigOp> : SDTypeConstraint<SmallOp>{ 54 int BigOperandNum = BigOp; 55} 56 57/// SDTCisEltOfVec - This indicates that ThisOp is a scalar type of the same 58/// type as the element type of OtherOp, which is a vector type. 59class SDTCisEltOfVec<int ThisOp, int OtherOp> 60 : SDTypeConstraint<ThisOp> { 61 int OtherOpNum = OtherOp; 62} 63 64/// SDTCisSubVecOfVec - This indicates that ThisOp is a vector type 65/// with length less that of OtherOp, which is a vector type. 66class SDTCisSubVecOfVec<int ThisOp, int OtherOp> 67 : SDTypeConstraint<ThisOp> { 68 int OtherOpNum = OtherOp; 69} 70 71//===----------------------------------------------------------------------===// 72// Selection DAG Type Profile definitions. 73// 74// These use the constraints defined above to describe the type requirements of 75// the various nodes. These are not hard coded into tblgen, allowing targets to 76// add their own if needed. 77// 78 79// SDTypeProfile - This profile describes the type requirements of a Selection 80// DAG node. 81class SDTypeProfile<int numresults, int numoperands, 82 list<SDTypeConstraint> constraints> { 83 int NumResults = numresults; 84 int NumOperands = numoperands; 85 list<SDTypeConstraint> Constraints = constraints; 86} 87 88// Builtin profiles. 89def SDTIntLeaf: SDTypeProfile<1, 0, [SDTCisInt<0>]>; // for 'imm'. 90def SDTFPLeaf : SDTypeProfile<1, 0, [SDTCisFP<0>]>; // for 'fpimm'. 91def SDTPtrLeaf: SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>; // for '&g'. 92def SDTOther : SDTypeProfile<1, 0, [SDTCisVT<0, OtherVT>]>; // for 'vt'. 93def SDTUNDEF : SDTypeProfile<1, 0, []>; // for 'undef'. 94def SDTUnaryOp : SDTypeProfile<1, 1, []>; // for bitconvert. 95 96def SDTIntBinOp : SDTypeProfile<1, 2, [ // add, and, or, xor, udiv, etc. 97 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<0> 98]>; 99def SDTIntShiftOp : SDTypeProfile<1, 2, [ // shl, sra, srl 100 SDTCisSameAs<0, 1>, SDTCisInt<0>, SDTCisInt<2> 101]>; 102def SDTIntBinHiLoOp : SDTypeProfile<2, 2, [ // mulhi, mullo, sdivrem, udivrem 103 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>,SDTCisInt<0> 104]>; 105 106def SDTFPBinOp : SDTypeProfile<1, 2, [ // fadd, fmul, etc. 107 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisFP<0> 108]>; 109def SDTFPSignOp : SDTypeProfile<1, 2, [ // fcopysign. 110 SDTCisSameAs<0, 1>, SDTCisFP<0>, SDTCisFP<2> 111]>; 112def SDTFPTernaryOp : SDTypeProfile<1, 3, [ // fmadd, fnmsub, etc. 113 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>, SDTCisFP<0> 114]>; 115def SDTIntUnaryOp : SDTypeProfile<1, 1, [ // ctlz 116 SDTCisSameAs<0, 1>, SDTCisInt<0> 117]>; 118def SDTIntExtendOp : SDTypeProfile<1, 1, [ // sext, zext, anyext 119 SDTCisInt<0>, SDTCisInt<1>, SDTCisOpSmallerThanOp<1, 0> 120]>; 121def SDTIntTruncOp : SDTypeProfile<1, 1, [ // trunc 122 SDTCisInt<0>, SDTCisInt<1>, SDTCisOpSmallerThanOp<0, 1> 123]>; 124def SDTFPUnaryOp : SDTypeProfile<1, 1, [ // fneg, fsqrt, etc 125 SDTCisSameAs<0, 1>, SDTCisFP<0> 126]>; 127def SDTFPRoundOp : SDTypeProfile<1, 1, [ // fround 128 SDTCisFP<0>, SDTCisFP<1>, SDTCisOpSmallerThanOp<0, 1> 129]>; 130def SDTFPExtendOp : SDTypeProfile<1, 1, [ // fextend 131 SDTCisFP<0>, SDTCisFP<1>, SDTCisOpSmallerThanOp<1, 0> 132]>; 133def SDTIntToFPOp : SDTypeProfile<1, 1, [ // [su]int_to_fp 134 SDTCisFP<0>, SDTCisInt<1> 135]>; 136def SDTFPToIntOp : SDTypeProfile<1, 1, [ // fp_to_[su]int 137 SDTCisInt<0>, SDTCisFP<1> 138]>; 139def SDTExtInreg : SDTypeProfile<1, 2, [ // sext_inreg 140 SDTCisSameAs<0, 1>, SDTCisInt<0>, SDTCisVT<2, OtherVT>, 141 SDTCisVTSmallerThanOp<2, 1> 142]>; 143 144def SDTSetCC : SDTypeProfile<1, 3, [ // setcc 145 SDTCisInt<0>, SDTCisSameAs<1, 2>, SDTCisVT<3, OtherVT> 146]>; 147 148def SDTSelect : SDTypeProfile<1, 3, [ // select 149 SDTCisInt<1>, SDTCisSameAs<0, 2>, SDTCisSameAs<2, 3> 150]>; 151 152def SDTVSelect : SDTypeProfile<1, 3, [ // vselect 153 SDTCisInt<1>, SDTCisSameAs<0, 2>, SDTCisSameAs<2, 3> 154]>; 155 156def SDTSelectCC : SDTypeProfile<1, 5, [ // select_cc 157 SDTCisSameAs<1, 2>, SDTCisSameAs<3, 4>, SDTCisSameAs<0, 3>, 158 SDTCisVT<5, OtherVT> 159]>; 160 161def SDTBr : SDTypeProfile<0, 1, [ // br 162 SDTCisVT<0, OtherVT> 163]>; 164 165def SDTBrcond : SDTypeProfile<0, 2, [ // brcond 166 SDTCisInt<0>, SDTCisVT<1, OtherVT> 167]>; 168 169def SDTBrind : SDTypeProfile<0, 1, [ // brind 170 SDTCisPtrTy<0> 171]>; 172 173def SDTNone : SDTypeProfile<0, 0, []>; // ret, trap 174 175def SDTLoad : SDTypeProfile<1, 1, [ // load 176 SDTCisPtrTy<1> 177]>; 178 179def SDTStore : SDTypeProfile<0, 2, [ // store 180 SDTCisPtrTy<1> 181]>; 182 183def SDTIStore : SDTypeProfile<1, 3, [ // indexed store 184 SDTCisSameAs<0, 2>, SDTCisPtrTy<0>, SDTCisPtrTy<3> 185]>; 186 187def SDTVecShuffle : SDTypeProfile<1, 2, [ 188 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2> 189]>; 190def SDTVecExtract : SDTypeProfile<1, 2, [ // vector extract 191 SDTCisEltOfVec<0, 1>, SDTCisPtrTy<2> 192]>; 193def SDTVecInsert : SDTypeProfile<1, 3, [ // vector insert 194 SDTCisEltOfVec<2, 1>, SDTCisSameAs<0, 1>, SDTCisPtrTy<3> 195]>; 196 197def SDTSubVecExtract : SDTypeProfile<1, 2, [// subvector extract 198 SDTCisSubVecOfVec<0,1>, SDTCisInt<2> 199]>; 200def SDTSubVecInsert : SDTypeProfile<1, 3, [ // subvector insert 201 SDTCisSubVecOfVec<2, 1>, SDTCisSameAs<0,1>, SDTCisInt<3> 202]>; 203 204def SDTPrefetch : SDTypeProfile<0, 4, [ // prefetch 205 SDTCisPtrTy<0>, SDTCisSameAs<1, 2>, SDTCisSameAs<1, 3>, SDTCisInt<1> 206]>; 207 208def SDTMemBarrier : SDTypeProfile<0, 5, [ // memory barier 209 SDTCisSameAs<0,1>, SDTCisSameAs<0,2>, SDTCisSameAs<0,3>, SDTCisSameAs<0,4>, 210 SDTCisInt<0> 211]>; 212def SDTAtomicFence : SDTypeProfile<0, 2, [ 213 SDTCisSameAs<0,1>, SDTCisPtrTy<0> 214]>; 215def SDTAtomic3 : SDTypeProfile<1, 3, [ 216 SDTCisSameAs<0,2>, SDTCisSameAs<0,3>, SDTCisInt<0>, SDTCisPtrTy<1> 217]>; 218def SDTAtomic2 : SDTypeProfile<1, 2, [ 219 SDTCisSameAs<0,2>, SDTCisInt<0>, SDTCisPtrTy<1> 220]>; 221def SDTAtomicStore : SDTypeProfile<0, 2, [ 222 SDTCisPtrTy<0>, SDTCisInt<1> 223]>; 224def SDTAtomicLoad : SDTypeProfile<1, 1, [ 225 SDTCisInt<0>, SDTCisPtrTy<1> 226]>; 227 228def SDTConvertOp : SDTypeProfile<1, 5, [ //cvtss, su, us, uu, ff, fs, fu, sf, su 229 SDTCisVT<2, OtherVT>, SDTCisVT<3, OtherVT>, SDTCisPtrTy<4>, SDTCisPtrTy<5> 230]>; 231 232class SDCallSeqStart<list<SDTypeConstraint> constraints> : 233 SDTypeProfile<0, 1, constraints>; 234class SDCallSeqEnd<list<SDTypeConstraint> constraints> : 235 SDTypeProfile<0, 2, constraints>; 236 237//===----------------------------------------------------------------------===// 238// Selection DAG Node Properties. 239// 240// Note: These are hard coded into tblgen. 241// 242class SDNodeProperty; 243def SDNPCommutative : SDNodeProperty; // X op Y == Y op X 244def SDNPAssociative : SDNodeProperty; // (X op Y) op Z == X op (Y op Z) 245def SDNPHasChain : SDNodeProperty; // R/W chain operand and result 246def SDNPOutGlue : SDNodeProperty; // Write a flag result 247def SDNPInGlue : SDNodeProperty; // Read a flag operand 248def SDNPOptInGlue : SDNodeProperty; // Optionally read a flag operand 249def SDNPMayStore : SDNodeProperty; // May write to memory, sets 'mayStore'. 250def SDNPMayLoad : SDNodeProperty; // May read memory, sets 'mayLoad'. 251def SDNPSideEffect : SDNodeProperty; // Sets 'HasUnmodelledSideEffects'. 252def SDNPMemOperand : SDNodeProperty; // Touches memory, has assoc MemOperand 253def SDNPVariadic : SDNodeProperty; // Node has variable arguments. 254def SDNPWantRoot : SDNodeProperty; // ComplexPattern gets the root of match 255def SDNPWantParent : SDNodeProperty; // ComplexPattern gets the parent 256 257//===----------------------------------------------------------------------===// 258// Selection DAG Pattern Operations 259class SDPatternOperator; 260 261//===----------------------------------------------------------------------===// 262// Selection DAG Node definitions. 263// 264class SDNode<string opcode, SDTypeProfile typeprof, 265 list<SDNodeProperty> props = [], string sdclass = "SDNode"> 266 : SDPatternOperator { 267 string Opcode = opcode; 268 string SDClass = sdclass; 269 list<SDNodeProperty> Properties = props; 270 SDTypeProfile TypeProfile = typeprof; 271} 272 273// Special TableGen-recognized dag nodes 274def set; 275def implicit; 276def node; 277def srcvalue; 278 279def imm : SDNode<"ISD::Constant" , SDTIntLeaf , [], "ConstantSDNode">; 280def timm : SDNode<"ISD::TargetConstant",SDTIntLeaf, [], "ConstantSDNode">; 281def fpimm : SDNode<"ISD::ConstantFP", SDTFPLeaf , [], "ConstantFPSDNode">; 282def vt : SDNode<"ISD::VALUETYPE" , SDTOther , [], "VTSDNode">; 283def bb : SDNode<"ISD::BasicBlock", SDTOther , [], "BasicBlockSDNode">; 284def cond : SDNode<"ISD::CONDCODE" , SDTOther , [], "CondCodeSDNode">; 285def undef : SDNode<"ISD::UNDEF" , SDTUNDEF , []>; 286def globaladdr : SDNode<"ISD::GlobalAddress", SDTPtrLeaf, [], 287 "GlobalAddressSDNode">; 288def tglobaladdr : SDNode<"ISD::TargetGlobalAddress", SDTPtrLeaf, [], 289 "GlobalAddressSDNode">; 290def globaltlsaddr : SDNode<"ISD::GlobalTLSAddress", SDTPtrLeaf, [], 291 "GlobalAddressSDNode">; 292def tglobaltlsaddr : SDNode<"ISD::TargetGlobalTLSAddress", SDTPtrLeaf, [], 293 "GlobalAddressSDNode">; 294def constpool : SDNode<"ISD::ConstantPool", SDTPtrLeaf, [], 295 "ConstantPoolSDNode">; 296def tconstpool : SDNode<"ISD::TargetConstantPool", SDTPtrLeaf, [], 297 "ConstantPoolSDNode">; 298def jumptable : SDNode<"ISD::JumpTable", SDTPtrLeaf, [], 299 "JumpTableSDNode">; 300def tjumptable : SDNode<"ISD::TargetJumpTable", SDTPtrLeaf, [], 301 "JumpTableSDNode">; 302def frameindex : SDNode<"ISD::FrameIndex", SDTPtrLeaf, [], 303 "FrameIndexSDNode">; 304def tframeindex : SDNode<"ISD::TargetFrameIndex", SDTPtrLeaf, [], 305 "FrameIndexSDNode">; 306def externalsym : SDNode<"ISD::ExternalSymbol", SDTPtrLeaf, [], 307 "ExternalSymbolSDNode">; 308def texternalsym: SDNode<"ISD::TargetExternalSymbol", SDTPtrLeaf, [], 309 "ExternalSymbolSDNode">; 310def blockaddress : SDNode<"ISD::BlockAddress", SDTPtrLeaf, [], 311 "BlockAddressSDNode">; 312def tblockaddress: SDNode<"ISD::TargetBlockAddress", SDTPtrLeaf, [], 313 "BlockAddressSDNode">; 314 315def add : SDNode<"ISD::ADD" , SDTIntBinOp , 316 [SDNPCommutative, SDNPAssociative]>; 317def sub : SDNode<"ISD::SUB" , SDTIntBinOp>; 318def mul : SDNode<"ISD::MUL" , SDTIntBinOp, 319 [SDNPCommutative, SDNPAssociative]>; 320def mulhs : SDNode<"ISD::MULHS" , SDTIntBinOp, [SDNPCommutative]>; 321def mulhu : SDNode<"ISD::MULHU" , SDTIntBinOp, [SDNPCommutative]>; 322def smullohi : SDNode<"ISD::SMUL_LOHI" , SDTIntBinHiLoOp, [SDNPCommutative]>; 323def umullohi : SDNode<"ISD::UMUL_LOHI" , SDTIntBinHiLoOp, [SDNPCommutative]>; 324def sdiv : SDNode<"ISD::SDIV" , SDTIntBinOp>; 325def udiv : SDNode<"ISD::UDIV" , SDTIntBinOp>; 326def srem : SDNode<"ISD::SREM" , SDTIntBinOp>; 327def urem : SDNode<"ISD::UREM" , SDTIntBinOp>; 328def sdivrem : SDNode<"ISD::SDIVREM" , SDTIntBinHiLoOp>; 329def udivrem : SDNode<"ISD::UDIVREM" , SDTIntBinHiLoOp>; 330def srl : SDNode<"ISD::SRL" , SDTIntShiftOp>; 331def sra : SDNode<"ISD::SRA" , SDTIntShiftOp>; 332def shl : SDNode<"ISD::SHL" , SDTIntShiftOp>; 333def rotl : SDNode<"ISD::ROTL" , SDTIntShiftOp>; 334def rotr : SDNode<"ISD::ROTR" , SDTIntShiftOp>; 335def and : SDNode<"ISD::AND" , SDTIntBinOp, 336 [SDNPCommutative, SDNPAssociative]>; 337def or : SDNode<"ISD::OR" , SDTIntBinOp, 338 [SDNPCommutative, SDNPAssociative]>; 339def xor : SDNode<"ISD::XOR" , SDTIntBinOp, 340 [SDNPCommutative, SDNPAssociative]>; 341def addc : SDNode<"ISD::ADDC" , SDTIntBinOp, 342 [SDNPCommutative, SDNPOutGlue]>; 343def adde : SDNode<"ISD::ADDE" , SDTIntBinOp, 344 [SDNPCommutative, SDNPOutGlue, SDNPInGlue]>; 345def subc : SDNode<"ISD::SUBC" , SDTIntBinOp, 346 [SDNPOutGlue]>; 347def sube : SDNode<"ISD::SUBE" , SDTIntBinOp, 348 [SDNPOutGlue, SDNPInGlue]>; 349 350def sext_inreg : SDNode<"ISD::SIGN_EXTEND_INREG", SDTExtInreg>; 351def bswap : SDNode<"ISD::BSWAP" , SDTIntUnaryOp>; 352def ctlz : SDNode<"ISD::CTLZ" , SDTIntUnaryOp>; 353def cttz : SDNode<"ISD::CTTZ" , SDTIntUnaryOp>; 354def ctpop : SDNode<"ISD::CTPOP" , SDTIntUnaryOp>; 355def ctlz_zero_undef : SDNode<"ISD::CTLZ_ZERO_UNDEF", SDTIntUnaryOp>; 356def cttz_zero_undef : SDNode<"ISD::CTTZ_ZERO_UNDEF", SDTIntUnaryOp>; 357def sext : SDNode<"ISD::SIGN_EXTEND", SDTIntExtendOp>; 358def zext : SDNode<"ISD::ZERO_EXTEND", SDTIntExtendOp>; 359def anyext : SDNode<"ISD::ANY_EXTEND" , SDTIntExtendOp>; 360def trunc : SDNode<"ISD::TRUNCATE" , SDTIntTruncOp>; 361def bitconvert : SDNode<"ISD::BITCAST" , SDTUnaryOp>; 362def extractelt : SDNode<"ISD::EXTRACT_VECTOR_ELT", SDTVecExtract>; 363def insertelt : SDNode<"ISD::INSERT_VECTOR_ELT", SDTVecInsert>; 364 365 366def fadd : SDNode<"ISD::FADD" , SDTFPBinOp, [SDNPCommutative]>; 367def fsub : SDNode<"ISD::FSUB" , SDTFPBinOp>; 368def fmul : SDNode<"ISD::FMUL" , SDTFPBinOp, [SDNPCommutative]>; 369def fdiv : SDNode<"ISD::FDIV" , SDTFPBinOp>; 370def frem : SDNode<"ISD::FREM" , SDTFPBinOp>; 371def fma : SDNode<"ISD::FMA" , SDTFPTernaryOp>; 372def fabs : SDNode<"ISD::FABS" , SDTFPUnaryOp>; 373def fgetsign : SDNode<"ISD::FGETSIGN" , SDTFPToIntOp>; 374def fneg : SDNode<"ISD::FNEG" , SDTFPUnaryOp>; 375def fsqrt : SDNode<"ISD::FSQRT" , SDTFPUnaryOp>; 376def fsin : SDNode<"ISD::FSIN" , SDTFPUnaryOp>; 377def fcos : SDNode<"ISD::FCOS" , SDTFPUnaryOp>; 378def fexp2 : SDNode<"ISD::FEXP2" , SDTFPUnaryOp>; 379def fpow : SDNode<"ISD::FPOW" , SDTFPBinOp>; 380def flog2 : SDNode<"ISD::FLOG2" , SDTFPUnaryOp>; 381def frint : SDNode<"ISD::FRINT" , SDTFPUnaryOp>; 382def ftrunc : SDNode<"ISD::FTRUNC" , SDTFPUnaryOp>; 383def fceil : SDNode<"ISD::FCEIL" , SDTFPUnaryOp>; 384def ffloor : SDNode<"ISD::FFLOOR" , SDTFPUnaryOp>; 385def fnearbyint : SDNode<"ISD::FNEARBYINT" , SDTFPUnaryOp>; 386 387def fround : SDNode<"ISD::FP_ROUND" , SDTFPRoundOp>; 388def fextend : SDNode<"ISD::FP_EXTEND" , SDTFPExtendOp>; 389def fcopysign : SDNode<"ISD::FCOPYSIGN" , SDTFPSignOp>; 390 391def sint_to_fp : SDNode<"ISD::SINT_TO_FP" , SDTIntToFPOp>; 392def uint_to_fp : SDNode<"ISD::UINT_TO_FP" , SDTIntToFPOp>; 393def fp_to_sint : SDNode<"ISD::FP_TO_SINT" , SDTFPToIntOp>; 394def fp_to_uint : SDNode<"ISD::FP_TO_UINT" , SDTFPToIntOp>; 395def f16_to_f32 : SDNode<"ISD::FP16_TO_FP32", SDTIntToFPOp>; 396def f32_to_f16 : SDNode<"ISD::FP32_TO_FP16", SDTFPToIntOp>; 397 398def setcc : SDNode<"ISD::SETCC" , SDTSetCC>; 399def select : SDNode<"ISD::SELECT" , SDTSelect>; 400def vselect : SDNode<"ISD::VSELECT" , SDTVSelect>; 401def selectcc : SDNode<"ISD::SELECT_CC" , SDTSelectCC>; 402 403def brcond : SDNode<"ISD::BRCOND" , SDTBrcond, [SDNPHasChain]>; 404def brind : SDNode<"ISD::BRIND" , SDTBrind, [SDNPHasChain]>; 405def br : SDNode<"ISD::BR" , SDTBr, [SDNPHasChain]>; 406def trap : SDNode<"ISD::TRAP" , SDTNone, 407 [SDNPHasChain, SDNPSideEffect]>; 408def debugtrap : SDNode<"ISD::DEBUGTRAP" , SDTNone, 409 [SDNPHasChain, SDNPSideEffect]>; 410 411def prefetch : SDNode<"ISD::PREFETCH" , SDTPrefetch, 412 [SDNPHasChain, SDNPMayLoad, SDNPMayStore, 413 SDNPMemOperand]>; 414 415def readcyclecounter : SDNode<"ISD::READCYCLECOUNTER", SDTIntLeaf, 416 [SDNPHasChain, SDNPSideEffect]>; 417 418def atomic_fence : SDNode<"ISD::ATOMIC_FENCE" , SDTAtomicFence, 419 [SDNPHasChain, SDNPSideEffect]>; 420 421def atomic_cmp_swap : SDNode<"ISD::ATOMIC_CMP_SWAP" , SDTAtomic3, 422 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>; 423def atomic_load_add : SDNode<"ISD::ATOMIC_LOAD_ADD" , SDTAtomic2, 424 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>; 425def atomic_swap : SDNode<"ISD::ATOMIC_SWAP", SDTAtomic2, 426 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>; 427def atomic_load_sub : SDNode<"ISD::ATOMIC_LOAD_SUB" , SDTAtomic2, 428 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>; 429def atomic_load_and : SDNode<"ISD::ATOMIC_LOAD_AND" , SDTAtomic2, 430 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>; 431def atomic_load_or : SDNode<"ISD::ATOMIC_LOAD_OR" , SDTAtomic2, 432 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>; 433def atomic_load_xor : SDNode<"ISD::ATOMIC_LOAD_XOR" , SDTAtomic2, 434 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>; 435def atomic_load_nand: SDNode<"ISD::ATOMIC_LOAD_NAND", SDTAtomic2, 436 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>; 437def atomic_load_min : SDNode<"ISD::ATOMIC_LOAD_MIN", SDTAtomic2, 438 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>; 439def atomic_load_max : SDNode<"ISD::ATOMIC_LOAD_MAX", SDTAtomic2, 440 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>; 441def atomic_load_umin : SDNode<"ISD::ATOMIC_LOAD_UMIN", SDTAtomic2, 442 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>; 443def atomic_load_umax : SDNode<"ISD::ATOMIC_LOAD_UMAX", SDTAtomic2, 444 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>; 445def atomic_load : SDNode<"ISD::ATOMIC_LOAD", SDTAtomicLoad, 446 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>; 447def atomic_store : SDNode<"ISD::ATOMIC_STORE", SDTAtomicStore, 448 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>; 449 450// Do not use ld, st directly. Use load, extload, sextload, zextload, store, 451// and truncst (see below). 452def ld : SDNode<"ISD::LOAD" , SDTLoad, 453 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>; 454def st : SDNode<"ISD::STORE" , SDTStore, 455 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>; 456def ist : SDNode<"ISD::STORE" , SDTIStore, 457 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>; 458 459def vector_shuffle : SDNode<"ISD::VECTOR_SHUFFLE", SDTVecShuffle, []>; 460def build_vector : SDNode<"ISD::BUILD_VECTOR", SDTypeProfile<1, -1, []>, []>; 461def scalar_to_vector : SDNode<"ISD::SCALAR_TO_VECTOR", SDTypeProfile<1, 1, []>, 462 []>; 463def vector_extract : SDNode<"ISD::EXTRACT_VECTOR_ELT", 464 SDTypeProfile<1, 2, [SDTCisPtrTy<2>]>, []>; 465def vector_insert : SDNode<"ISD::INSERT_VECTOR_ELT", 466 SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisPtrTy<3>]>, []>; 467 468// This operator does not do subvector type checking. The ARM 469// backend, at least, needs it. 470def vector_extract_subvec : SDNode<"ISD::EXTRACT_SUBVECTOR", 471 SDTypeProfile<1, 2, [SDTCisInt<2>, SDTCisVec<1>, SDTCisVec<0>]>, 472 []>; 473 474// This operator does subvector type checking. 475def extract_subvector : SDNode<"ISD::EXTRACT_SUBVECTOR", SDTSubVecExtract, []>; 476def insert_subvector : SDNode<"ISD::INSERT_SUBVECTOR", SDTSubVecInsert, []>; 477 478// Nodes for intrinsics, you should use the intrinsic itself and let tblgen use 479// these internally. Don't reference these directly. 480def intrinsic_void : SDNode<"ISD::INTRINSIC_VOID", 481 SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>, 482 [SDNPHasChain]>; 483def intrinsic_w_chain : SDNode<"ISD::INTRINSIC_W_CHAIN", 484 SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>, 485 [SDNPHasChain]>; 486def intrinsic_wo_chain : SDNode<"ISD::INTRINSIC_WO_CHAIN", 487 SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>, []>; 488 489// Do not use cvt directly. Use cvt forms below 490def cvt : SDNode<"ISD::CONVERT_RNDSAT", SDTConvertOp>; 491 492//===----------------------------------------------------------------------===// 493// Selection DAG Condition Codes 494 495class CondCode; // ISD::CondCode enums 496def SETOEQ : CondCode; def SETOGT : CondCode; 497def SETOGE : CondCode; def SETOLT : CondCode; def SETOLE : CondCode; 498def SETONE : CondCode; def SETO : CondCode; def SETUO : CondCode; 499def SETUEQ : CondCode; def SETUGT : CondCode; def SETUGE : CondCode; 500def SETULT : CondCode; def SETULE : CondCode; def SETUNE : CondCode; 501 502def SETEQ : CondCode; def SETGT : CondCode; def SETGE : CondCode; 503def SETLT : CondCode; def SETLE : CondCode; def SETNE : CondCode; 504 505 506//===----------------------------------------------------------------------===// 507// Selection DAG Node Transformation Functions. 508// 509// This mechanism allows targets to manipulate nodes in the output DAG once a 510// match has been formed. This is typically used to manipulate immediate 511// values. 512// 513class SDNodeXForm<SDNode opc, code xformFunction> { 514 SDNode Opcode = opc; 515 code XFormFunction = xformFunction; 516} 517 518def NOOP_SDNodeXForm : SDNodeXForm<imm, [{}]>; 519 520//===----------------------------------------------------------------------===// 521// PatPred Subclasses. 522// 523// These allow specifying different sorts of predicates that control whether a 524// node is matched. 525// 526class PatPred; 527 528class CodePatPred<code predicate> : PatPred { 529 code PredicateCode = predicate; 530} 531 532 533//===----------------------------------------------------------------------===// 534// Selection DAG Pattern Fragments. 535// 536// Pattern fragments are reusable chunks of dags that match specific things. 537// They can take arguments and have C++ predicates that control whether they 538// match. They are intended to make the patterns for common instructions more 539// compact and readable. 540// 541 542/// PatFrag - Represents a pattern fragment. This can match something on the 543/// DAG, from a single node to multiple nested other fragments. 544/// 545class PatFrag<dag ops, dag frag, code pred = [{}], 546 SDNodeXForm xform = NOOP_SDNodeXForm> : SDPatternOperator { 547 dag Operands = ops; 548 dag Fragment = frag; 549 code PredicateCode = pred; 550 code ImmediateCode = [{}]; 551 SDNodeXForm OperandTransform = xform; 552} 553 554// PatLeaf's are pattern fragments that have no operands. This is just a helper 555// to define immediates and other common things concisely. 556class PatLeaf<dag frag, code pred = [{}], SDNodeXForm xform = NOOP_SDNodeXForm> 557 : PatFrag<(ops), frag, pred, xform>; 558 559 560// ImmLeaf is a pattern fragment with a constraint on the immediate. The 561// constraint is a function that is run on the immediate (always with the value 562// sign extended out to an int64_t) as Imm. For example: 563// 564// def immSExt8 : ImmLeaf<i16, [{ return (char)Imm == Imm; }]>; 565// 566// this is a more convenient form to match 'imm' nodes in than PatLeaf and also 567// is preferred over using PatLeaf because it allows the code generator to 568// reason more about the constraint. 569// 570// If FastIsel should ignore all instructions that have an operand of this type, 571// the FastIselShouldIgnore flag can be set. This is an optimization to reduce 572// the code size of the generated fast instruction selector. 573class ImmLeaf<ValueType vt, code pred, SDNodeXForm xform = NOOP_SDNodeXForm> 574 : PatFrag<(ops), (vt imm), [{}], xform> { 575 let ImmediateCode = pred; 576 bit FastIselShouldIgnore = 0; 577} 578 579 580// Leaf fragments. 581 582def vtInt : PatLeaf<(vt), [{ return N->getVT().isInteger(); }]>; 583def vtFP : PatLeaf<(vt), [{ return N->getVT().isFloatingPoint(); }]>; 584 585def immAllOnesV: PatLeaf<(build_vector), [{ 586 return ISD::isBuildVectorAllOnes(N); 587}]>; 588def immAllZerosV: PatLeaf<(build_vector), [{ 589 return ISD::isBuildVectorAllZeros(N); 590}]>; 591 592 593 594// Other helper fragments. 595def not : PatFrag<(ops node:$in), (xor node:$in, -1)>; 596def vnot : PatFrag<(ops node:$in), (xor node:$in, immAllOnesV)>; 597def ineg : PatFrag<(ops node:$in), (sub 0, node:$in)>; 598 599// null_frag - The null pattern operator is used in multiclass instantiations 600// which accept an SDPatternOperator for use in matching patterns for internal 601// definitions. When expanding a pattern, if the null fragment is referenced 602// in the expansion, the pattern is discarded and it is as-if '[]' had been 603// specified. This allows multiclasses to have the isel patterns be optional. 604def null_frag : SDPatternOperator; 605 606// load fragments. 607def unindexedload : PatFrag<(ops node:$ptr), (ld node:$ptr), [{ 608 return cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED; 609}]>; 610def load : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{ 611 return cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD; 612}]>; 613 614// extending load fragments. 615def extload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{ 616 return cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD; 617}]>; 618def sextload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{ 619 return cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD; 620}]>; 621def zextload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{ 622 return cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD; 623}]>; 624 625def extloadi1 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{ 626 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i1; 627}]>; 628def extloadi8 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{ 629 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8; 630}]>; 631def extloadi16 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{ 632 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16; 633}]>; 634def extloadi32 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{ 635 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i32; 636}]>; 637def extloadf32 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{ 638 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::f32; 639}]>; 640def extloadf64 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{ 641 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::f64; 642}]>; 643 644def sextloadi1 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{ 645 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i1; 646}]>; 647def sextloadi8 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{ 648 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8; 649}]>; 650def sextloadi16 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{ 651 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16; 652}]>; 653def sextloadi32 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{ 654 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i32; 655}]>; 656 657def zextloadi1 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{ 658 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i1; 659}]>; 660def zextloadi8 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{ 661 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8; 662}]>; 663def zextloadi16 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{ 664 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16; 665}]>; 666def zextloadi32 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{ 667 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i32; 668}]>; 669 670def extloadvi1 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{ 671 return cast<LoadSDNode>(N)->getMemoryVT().getScalarType() == MVT::i1; 672}]>; 673def extloadvi8 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{ 674 return cast<LoadSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8; 675}]>; 676def extloadvi16 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{ 677 return cast<LoadSDNode>(N)->getMemoryVT().getScalarType() == MVT::i16; 678}]>; 679def extloadvi32 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{ 680 return cast<LoadSDNode>(N)->getMemoryVT().getScalarType() == MVT::i32; 681}]>; 682def extloadvf32 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{ 683 return cast<LoadSDNode>(N)->getMemoryVT().getScalarType() == MVT::f32; 684}]>; 685def extloadvf64 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{ 686 return cast<LoadSDNode>(N)->getMemoryVT().getScalarType() == MVT::f64; 687}]>; 688 689def sextloadvi1 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{ 690 return cast<LoadSDNode>(N)->getMemoryVT().getScalarType() == MVT::i1; 691}]>; 692def sextloadvi8 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{ 693 return cast<LoadSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8; 694}]>; 695def sextloadvi16 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{ 696 return cast<LoadSDNode>(N)->getMemoryVT().getScalarType() == MVT::i16; 697}]>; 698def sextloadvi32 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{ 699 return cast<LoadSDNode>(N)->getMemoryVT().getScalarType() == MVT::i32; 700}]>; 701 702def zextloadvi1 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{ 703 return cast<LoadSDNode>(N)->getMemoryVT().getScalarType() == MVT::i1; 704}]>; 705def zextloadvi8 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{ 706 return cast<LoadSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8; 707}]>; 708def zextloadvi16 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{ 709 return cast<LoadSDNode>(N)->getMemoryVT().getScalarType() == MVT::i16; 710}]>; 711def zextloadvi32 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{ 712 return cast<LoadSDNode>(N)->getMemoryVT().getScalarType() == MVT::i32; 713}]>; 714 715// store fragments. 716def unindexedstore : PatFrag<(ops node:$val, node:$ptr), 717 (st node:$val, node:$ptr), [{ 718 return cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED; 719}]>; 720def store : PatFrag<(ops node:$val, node:$ptr), 721 (unindexedstore node:$val, node:$ptr), [{ 722 return !cast<StoreSDNode>(N)->isTruncatingStore(); 723}]>; 724 725// truncstore fragments. 726def truncstore : PatFrag<(ops node:$val, node:$ptr), 727 (unindexedstore node:$val, node:$ptr), [{ 728 return cast<StoreSDNode>(N)->isTruncatingStore(); 729}]>; 730def truncstorei8 : PatFrag<(ops node:$val, node:$ptr), 731 (truncstore node:$val, node:$ptr), [{ 732 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i8; 733}]>; 734def truncstorei16 : PatFrag<(ops node:$val, node:$ptr), 735 (truncstore node:$val, node:$ptr), [{ 736 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i16; 737}]>; 738def truncstorei32 : PatFrag<(ops node:$val, node:$ptr), 739 (truncstore node:$val, node:$ptr), [{ 740 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i32; 741}]>; 742def truncstoref32 : PatFrag<(ops node:$val, node:$ptr), 743 (truncstore node:$val, node:$ptr), [{ 744 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::f32; 745}]>; 746def truncstoref64 : PatFrag<(ops node:$val, node:$ptr), 747 (truncstore node:$val, node:$ptr), [{ 748 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::f64; 749}]>; 750 751// indexed store fragments. 752def istore : PatFrag<(ops node:$val, node:$base, node:$offset), 753 (ist node:$val, node:$base, node:$offset), [{ 754 return !cast<StoreSDNode>(N)->isTruncatingStore(); 755}]>; 756 757def pre_store : PatFrag<(ops node:$val, node:$base, node:$offset), 758 (istore node:$val, node:$base, node:$offset), [{ 759 ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode(); 760 return AM == ISD::PRE_INC || AM == ISD::PRE_DEC; 761}]>; 762 763def itruncstore : PatFrag<(ops node:$val, node:$base, node:$offset), 764 (ist node:$val, node:$base, node:$offset), [{ 765 return cast<StoreSDNode>(N)->isTruncatingStore(); 766}]>; 767def pre_truncst : PatFrag<(ops node:$val, node:$base, node:$offset), 768 (itruncstore node:$val, node:$base, node:$offset), [{ 769 ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode(); 770 return AM == ISD::PRE_INC || AM == ISD::PRE_DEC; 771}]>; 772def pre_truncsti1 : PatFrag<(ops node:$val, node:$base, node:$offset), 773 (pre_truncst node:$val, node:$base, node:$offset), [{ 774 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i1; 775}]>; 776def pre_truncsti8 : PatFrag<(ops node:$val, node:$base, node:$offset), 777 (pre_truncst node:$val, node:$base, node:$offset), [{ 778 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i8; 779}]>; 780def pre_truncsti16 : PatFrag<(ops node:$val, node:$base, node:$offset), 781 (pre_truncst node:$val, node:$base, node:$offset), [{ 782 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i16; 783}]>; 784def pre_truncsti32 : PatFrag<(ops node:$val, node:$base, node:$offset), 785 (pre_truncst node:$val, node:$base, node:$offset), [{ 786 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i32; 787}]>; 788def pre_truncstf32 : PatFrag<(ops node:$val, node:$base, node:$offset), 789 (pre_truncst node:$val, node:$base, node:$offset), [{ 790 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::f32; 791}]>; 792 793def post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset), 794 (istore node:$val, node:$ptr, node:$offset), [{ 795 ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode(); 796 return AM == ISD::POST_INC || AM == ISD::POST_DEC; 797}]>; 798 799def post_truncst : PatFrag<(ops node:$val, node:$base, node:$offset), 800 (itruncstore node:$val, node:$base, node:$offset), [{ 801 ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode(); 802 return AM == ISD::POST_INC || AM == ISD::POST_DEC; 803}]>; 804def post_truncsti1 : PatFrag<(ops node:$val, node:$base, node:$offset), 805 (post_truncst node:$val, node:$base, node:$offset), [{ 806 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i1; 807}]>; 808def post_truncsti8 : PatFrag<(ops node:$val, node:$base, node:$offset), 809 (post_truncst node:$val, node:$base, node:$offset), [{ 810 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i8; 811}]>; 812def post_truncsti16 : PatFrag<(ops node:$val, node:$base, node:$offset), 813 (post_truncst node:$val, node:$base, node:$offset), [{ 814 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i16; 815}]>; 816def post_truncsti32 : PatFrag<(ops node:$val, node:$base, node:$offset), 817 (post_truncst node:$val, node:$base, node:$offset), [{ 818 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i32; 819}]>; 820def post_truncstf32 : PatFrag<(ops node:$val, node:$base, node:$offset), 821 (post_truncst node:$val, node:$base, node:$offset), [{ 822 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::f32; 823}]>; 824 825// setcc convenience fragments. 826def setoeq : PatFrag<(ops node:$lhs, node:$rhs), 827 (setcc node:$lhs, node:$rhs, SETOEQ)>; 828def setogt : PatFrag<(ops node:$lhs, node:$rhs), 829 (setcc node:$lhs, node:$rhs, SETOGT)>; 830def setoge : PatFrag<(ops node:$lhs, node:$rhs), 831 (setcc node:$lhs, node:$rhs, SETOGE)>; 832def setolt : PatFrag<(ops node:$lhs, node:$rhs), 833 (setcc node:$lhs, node:$rhs, SETOLT)>; 834def setole : PatFrag<(ops node:$lhs, node:$rhs), 835 (setcc node:$lhs, node:$rhs, SETOLE)>; 836def setone : PatFrag<(ops node:$lhs, node:$rhs), 837 (setcc node:$lhs, node:$rhs, SETONE)>; 838def seto : PatFrag<(ops node:$lhs, node:$rhs), 839 (setcc node:$lhs, node:$rhs, SETO)>; 840def setuo : PatFrag<(ops node:$lhs, node:$rhs), 841 (setcc node:$lhs, node:$rhs, SETUO)>; 842def setueq : PatFrag<(ops node:$lhs, node:$rhs), 843 (setcc node:$lhs, node:$rhs, SETUEQ)>; 844def setugt : PatFrag<(ops node:$lhs, node:$rhs), 845 (setcc node:$lhs, node:$rhs, SETUGT)>; 846def setuge : PatFrag<(ops node:$lhs, node:$rhs), 847 (setcc node:$lhs, node:$rhs, SETUGE)>; 848def setult : PatFrag<(ops node:$lhs, node:$rhs), 849 (setcc node:$lhs, node:$rhs, SETULT)>; 850def setule : PatFrag<(ops node:$lhs, node:$rhs), 851 (setcc node:$lhs, node:$rhs, SETULE)>; 852def setune : PatFrag<(ops node:$lhs, node:$rhs), 853 (setcc node:$lhs, node:$rhs, SETUNE)>; 854def seteq : PatFrag<(ops node:$lhs, node:$rhs), 855 (setcc node:$lhs, node:$rhs, SETEQ)>; 856def setgt : PatFrag<(ops node:$lhs, node:$rhs), 857 (setcc node:$lhs, node:$rhs, SETGT)>; 858def setge : PatFrag<(ops node:$lhs, node:$rhs), 859 (setcc node:$lhs, node:$rhs, SETGE)>; 860def setlt : PatFrag<(ops node:$lhs, node:$rhs), 861 (setcc node:$lhs, node:$rhs, SETLT)>; 862def setle : PatFrag<(ops node:$lhs, node:$rhs), 863 (setcc node:$lhs, node:$rhs, SETLE)>; 864def setne : PatFrag<(ops node:$lhs, node:$rhs), 865 (setcc node:$lhs, node:$rhs, SETNE)>; 866 867def atomic_cmp_swap_8 : 868 PatFrag<(ops node:$ptr, node:$cmp, node:$swap), 869 (atomic_cmp_swap node:$ptr, node:$cmp, node:$swap), [{ 870 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i8; 871}]>; 872def atomic_cmp_swap_16 : 873 PatFrag<(ops node:$ptr, node:$cmp, node:$swap), 874 (atomic_cmp_swap node:$ptr, node:$cmp, node:$swap), [{ 875 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i16; 876}]>; 877def atomic_cmp_swap_32 : 878 PatFrag<(ops node:$ptr, node:$cmp, node:$swap), 879 (atomic_cmp_swap node:$ptr, node:$cmp, node:$swap), [{ 880 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i32; 881}]>; 882def atomic_cmp_swap_64 : 883 PatFrag<(ops node:$ptr, node:$cmp, node:$swap), 884 (atomic_cmp_swap node:$ptr, node:$cmp, node:$swap), [{ 885 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i64; 886}]>; 887 888multiclass binary_atomic_op<SDNode atomic_op> { 889 def _8 : PatFrag<(ops node:$ptr, node:$val), 890 (atomic_op node:$ptr, node:$val), [{ 891 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i8; 892 }]>; 893 def _16 : PatFrag<(ops node:$ptr, node:$val), 894 (atomic_op node:$ptr, node:$val), [{ 895 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i16; 896 }]>; 897 def _32 : PatFrag<(ops node:$ptr, node:$val), 898 (atomic_op node:$ptr, node:$val), [{ 899 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i32; 900 }]>; 901 def _64 : PatFrag<(ops node:$ptr, node:$val), 902 (atomic_op node:$ptr, node:$val), [{ 903 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i64; 904 }]>; 905} 906 907defm atomic_load_add : binary_atomic_op<atomic_load_add>; 908defm atomic_swap : binary_atomic_op<atomic_swap>; 909defm atomic_load_sub : binary_atomic_op<atomic_load_sub>; 910defm atomic_load_and : binary_atomic_op<atomic_load_and>; 911defm atomic_load_or : binary_atomic_op<atomic_load_or>; 912defm atomic_load_xor : binary_atomic_op<atomic_load_xor>; 913defm atomic_load_nand : binary_atomic_op<atomic_load_nand>; 914defm atomic_load_min : binary_atomic_op<atomic_load_min>; 915defm atomic_load_max : binary_atomic_op<atomic_load_max>; 916defm atomic_load_umin : binary_atomic_op<atomic_load_umin>; 917defm atomic_load_umax : binary_atomic_op<atomic_load_umax>; 918defm atomic_store : binary_atomic_op<atomic_store>; 919 920def atomic_load_8 : 921 PatFrag<(ops node:$ptr), 922 (atomic_load node:$ptr), [{ 923 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i8; 924}]>; 925def atomic_load_16 : 926 PatFrag<(ops node:$ptr), 927 (atomic_load node:$ptr), [{ 928 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i16; 929}]>; 930def atomic_load_32 : 931 PatFrag<(ops node:$ptr), 932 (atomic_load node:$ptr), [{ 933 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i32; 934}]>; 935def atomic_load_64 : 936 PatFrag<(ops node:$ptr), 937 (atomic_load node:$ptr), [{ 938 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i64; 939}]>; 940 941//===----------------------------------------------------------------------===// 942// Selection DAG CONVERT_RNDSAT patterns 943 944def cvtff : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat), 945 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{ 946 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_FF; 947 }]>; 948 949def cvtss : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat), 950 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{ 951 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_SS; 952 }]>; 953 954def cvtsu : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat), 955 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{ 956 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_SU; 957 }]>; 958 959def cvtus : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat), 960 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{ 961 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_US; 962 }]>; 963 964def cvtuu : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat), 965 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{ 966 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_UU; 967 }]>; 968 969def cvtsf : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat), 970 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{ 971 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_SF; 972 }]>; 973 974def cvtuf : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat), 975 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{ 976 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_UF; 977 }]>; 978 979def cvtfs : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat), 980 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{ 981 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_FS; 982 }]>; 983 984def cvtfu : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat), 985 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{ 986 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_FU; 987 }]>; 988 989//===----------------------------------------------------------------------===// 990// Selection DAG Pattern Support. 991// 992// Patterns are what are actually matched against by the target-flavored 993// instruction selection DAG. Instructions defined by the target implicitly 994// define patterns in most cases, but patterns can also be explicitly added when 995// an operation is defined by a sequence of instructions (e.g. loading a large 996// immediate value on RISC targets that do not support immediates as large as 997// their GPRs). 998// 999 1000class Pattern<dag patternToMatch, list<dag> resultInstrs> { 1001 dag PatternToMatch = patternToMatch; 1002 list<dag> ResultInstrs = resultInstrs; 1003 list<Predicate> Predicates = []; // See class Instruction in Target.td. 1004 int AddedComplexity = 0; // See class Instruction in Target.td. 1005} 1006 1007// Pat - A simple (but common) form of a pattern, which produces a simple result 1008// not needing a full list. 1009class Pat<dag pattern, dag result> : Pattern<pattern, [result]>; 1010 1011//===----------------------------------------------------------------------===// 1012// Complex pattern definitions. 1013// 1014 1015// Complex patterns, e.g. X86 addressing mode, requires pattern matching code 1016// in C++. NumOperands is the number of operands returned by the select function; 1017// SelectFunc is the name of the function used to pattern match the max. pattern; 1018// RootNodes are the list of possible root nodes of the sub-dags to match. 1019// e.g. X86 addressing mode - def addr : ComplexPattern<4, "SelectAddr", [add]>; 1020// 1021class ComplexPattern<ValueType ty, int numops, string fn, 1022 list<SDNode> roots = [], list<SDNodeProperty> props = []> { 1023 ValueType Ty = ty; 1024 int NumOperands = numops; 1025 string SelectFunc = fn; 1026 list<SDNode> RootNodes = roots; 1027 list<SDNodeProperty> Properties = props; 1028} 1029