1 //===- TargetSelectionDAG.td - Common code for DAG isels ---*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the target-independent interfaces used by SelectionDAG
11 // instruction selection generators.
13 //===----------------------------------------------------------------------===//
15 //===----------------------------------------------------------------------===//
16 // Selection DAG Type Constraint definitions.
18 // Note that the semantics of these constraints are hard coded into tblgen. To
19 // modify or add constraints, you have to hack tblgen.
22 class SDTypeConstraint<int opnum> {
23 int OperandNum = opnum;
26 // SDTCisVT - The specified operand has exactly this VT.
27 class SDTCisVT<int OpNum, ValueType vt> : SDTypeConstraint<OpNum> {
31 class SDTCisPtrTy<int OpNum> : SDTypeConstraint<OpNum>;
33 // SDTCisInt - The specified operand has integer type.
34 class SDTCisInt<int OpNum> : SDTypeConstraint<OpNum>;
36 // SDTCisFP - The specified operand has floating-point type.
37 class SDTCisFP<int OpNum> : SDTypeConstraint<OpNum>;
39 // SDTCisVec - The specified operand has a vector type.
40 class SDTCisVec<int OpNum> : SDTypeConstraint<OpNum>;
42 // SDTCisSameAs - The two specified operands have identical types.
43 class SDTCisSameAs<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> {
44 int OtherOperandNum = OtherOp;
47 // SDTCisVTSmallerThanOp - The specified operand is a VT SDNode, and its type is
48 // smaller than the 'Other' operand.
49 class SDTCisVTSmallerThanOp<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> {
50 int OtherOperandNum = OtherOp;
53 class SDTCisOpSmallerThanOp<int SmallOp, int BigOp> : SDTypeConstraint<SmallOp>{
54 int BigOperandNum = BigOp;
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.
59 class SDTCisEltOfVec<int ThisOp, int OtherOp>
60 : SDTypeConstraint<ThisOp> {
61 int OtherOpNum = OtherOp;
64 /// SDTCisSubVecOfVec - This indicates that ThisOp is a vector type
65 /// with length less that of OtherOp, which is a vector type.
66 class SDTCisSubVecOfVec<int ThisOp, int OtherOp>
67 : SDTypeConstraint<ThisOp> {
68 int OtherOpNum = OtherOp;
71 //===----------------------------------------------------------------------===//
72 // Selection DAG Type Profile definitions.
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.
79 // SDTypeProfile - This profile describes the type requirements of a Selection
81 class SDTypeProfile<int numresults, int numoperands,
82 list<SDTypeConstraint> constraints> {
83 int NumResults = numresults;
84 int NumOperands = numoperands;
85 list<SDTypeConstraint> Constraints = constraints;
89 def SDTIntLeaf: SDTypeProfile<1, 0, [SDTCisInt<0>]>; // for 'imm'.
90 def SDTFPLeaf : SDTypeProfile<1, 0, [SDTCisFP<0>]>; // for 'fpimm'.
91 def SDTPtrLeaf: SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>; // for '&g'.
92 def SDTOther : SDTypeProfile<1, 0, [SDTCisVT<0, OtherVT>]>; // for 'vt'.
93 def SDTUNDEF : SDTypeProfile<1, 0, []>; // for 'undef'.
94 def SDTUnaryOp : SDTypeProfile<1, 1, []>; // for bitconvert.
96 def SDTIntBinOp : SDTypeProfile<1, 2, [ // add, and, or, xor, udiv, etc.
97 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<0>
99 def SDTIntShiftOp : SDTypeProfile<1, 2, [ // shl, sra, srl
100 SDTCisSameAs<0, 1>, SDTCisInt<0>, SDTCisInt<2>
102 def SDTIntBinHiLoOp : SDTypeProfile<2, 2, [ // mulhi, mullo, sdivrem, udivrem
103 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>,SDTCisInt<0>
106 def SDTFPBinOp : SDTypeProfile<1, 2, [ // fadd, fmul, etc.
107 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisFP<0>
109 def SDTFPSignOp : SDTypeProfile<1, 2, [ // fcopysign.
110 SDTCisSameAs<0, 1>, SDTCisFP<0>, SDTCisFP<2>
112 def SDTFPTernaryOp : SDTypeProfile<1, 3, [ // fmadd, fnmsub, etc.
113 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>, SDTCisFP<0>
115 def SDTIntUnaryOp : SDTypeProfile<1, 1, [ // ctlz
116 SDTCisSameAs<0, 1>, SDTCisInt<0>
118 def SDTIntExtendOp : SDTypeProfile<1, 1, [ // sext, zext, anyext
119 SDTCisInt<0>, SDTCisInt<1>, SDTCisOpSmallerThanOp<1, 0>
121 def SDTIntTruncOp : SDTypeProfile<1, 1, [ // trunc
122 SDTCisInt<0>, SDTCisInt<1>, SDTCisOpSmallerThanOp<0, 1>
124 def SDTFPUnaryOp : SDTypeProfile<1, 1, [ // fneg, fsqrt, etc
125 SDTCisSameAs<0, 1>, SDTCisFP<0>
127 def SDTFPRoundOp : SDTypeProfile<1, 1, [ // fround
128 SDTCisFP<0>, SDTCisFP<1>, SDTCisOpSmallerThanOp<0, 1>
130 def SDTFPExtendOp : SDTypeProfile<1, 1, [ // fextend
131 SDTCisFP<0>, SDTCisFP<1>, SDTCisOpSmallerThanOp<1, 0>
133 def SDTIntToFPOp : SDTypeProfile<1, 1, [ // [su]int_to_fp
134 SDTCisFP<0>, SDTCisInt<1>
136 def SDTFPToIntOp : SDTypeProfile<1, 1, [ // fp_to_[su]int
137 SDTCisInt<0>, SDTCisFP<1>
139 def SDTExtInreg : SDTypeProfile<1, 2, [ // sext_inreg
140 SDTCisSameAs<0, 1>, SDTCisInt<0>, SDTCisVT<2, OtherVT>,
141 SDTCisVTSmallerThanOp<2, 1>
144 def SDTSetCC : SDTypeProfile<1, 3, [ // setcc
145 SDTCisInt<0>, SDTCisSameAs<1, 2>, SDTCisVT<3, OtherVT>
148 def SDTSelect : SDTypeProfile<1, 3, [ // select
149 SDTCisInt<1>, SDTCisSameAs<0, 2>, SDTCisSameAs<2, 3>
152 def SDTSelectCC : SDTypeProfile<1, 5, [ // select_cc
153 SDTCisSameAs<1, 2>, SDTCisSameAs<3, 4>, SDTCisSameAs<0, 3>,
157 def SDTBr : SDTypeProfile<0, 1, [ // br
161 def SDTBrcond : SDTypeProfile<0, 2, [ // brcond
162 SDTCisInt<0>, SDTCisVT<1, OtherVT>
165 def SDTBrind : SDTypeProfile<0, 1, [ // brind
169 def SDTNone : SDTypeProfile<0, 0, []>; // ret, trap
171 def SDTLoad : SDTypeProfile<1, 1, [ // load
175 def SDTStore : SDTypeProfile<0, 2, [ // store
179 def SDTIStore : SDTypeProfile<1, 3, [ // indexed store
180 SDTCisSameAs<0, 2>, SDTCisPtrTy<0>, SDTCisPtrTy<3>
183 def SDTVecShuffle : SDTypeProfile<1, 2, [
184 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>
186 def SDTVecExtract : SDTypeProfile<1, 2, [ // vector extract
187 SDTCisEltOfVec<0, 1>, SDTCisPtrTy<2>
189 def SDTVecInsert : SDTypeProfile<1, 3, [ // vector insert
190 SDTCisEltOfVec<2, 1>, SDTCisSameAs<0, 1>, SDTCisPtrTy<3>
193 def SDTSubVecExtract : SDTypeProfile<1, 2, [// subvector extract
194 SDTCisSubVecOfVec<0,1>, SDTCisInt<2>
196 def SDTSubVecInsert : SDTypeProfile<1, 3, [ // subvector insert
197 SDTCisSubVecOfVec<2, 1>, SDTCisSameAs<0,1>, SDTCisInt<3>
200 def SDTPrefetch : SDTypeProfile<0, 4, [ // prefetch
201 SDTCisPtrTy<0>, SDTCisSameAs<1, 2>, SDTCisSameAs<1, 3>, SDTCisInt<1>
204 def SDTMemBarrier : SDTypeProfile<0, 5, [ // memory barier
205 SDTCisSameAs<0,1>, SDTCisSameAs<0,2>, SDTCisSameAs<0,3>, SDTCisSameAs<0,4>,
208 def SDTAtomicFence : SDTypeProfile<0, 2, [
209 SDTCisSameAs<0,1>, SDTCisPtrTy<0>
211 def SDTAtomic3 : SDTypeProfile<1, 3, [
212 SDTCisSameAs<0,2>, SDTCisSameAs<0,3>, SDTCisInt<0>, SDTCisPtrTy<1>
214 def SDTAtomic2 : SDTypeProfile<1, 2, [
215 SDTCisSameAs<0,2>, SDTCisInt<0>, SDTCisPtrTy<1>
217 def SDTAtomicStore : SDTypeProfile<0, 2, [
218 SDTCisPtrTy<0>, SDTCisInt<1>
220 def SDTAtomicLoad : SDTypeProfile<1, 1, [
221 SDTCisInt<0>, SDTCisPtrTy<1>
224 def SDTConvertOp : SDTypeProfile<1, 5, [ //cvtss, su, us, uu, ff, fs, fu, sf, su
225 SDTCisVT<2, OtherVT>, SDTCisVT<3, OtherVT>, SDTCisPtrTy<4>, SDTCisPtrTy<5>
228 class SDCallSeqStart<list<SDTypeConstraint> constraints> :
229 SDTypeProfile<0, 1, constraints>;
230 class SDCallSeqEnd<list<SDTypeConstraint> constraints> :
231 SDTypeProfile<0, 2, constraints>;
233 //===----------------------------------------------------------------------===//
234 // Selection DAG Node Properties.
236 // Note: These are hard coded into tblgen.
238 class SDNodeProperty;
239 def SDNPCommutative : SDNodeProperty; // X op Y == Y op X
240 def SDNPAssociative : SDNodeProperty; // (X op Y) op Z == X op (Y op Z)
241 def SDNPHasChain : SDNodeProperty; // R/W chain operand and result
242 def SDNPOutGlue : SDNodeProperty; // Write a flag result
243 def SDNPInGlue : SDNodeProperty; // Read a flag operand
244 def SDNPOptInGlue : SDNodeProperty; // Optionally read a flag operand
245 def SDNPMayStore : SDNodeProperty; // May write to memory, sets 'mayStore'.
246 def SDNPMayLoad : SDNodeProperty; // May read memory, sets 'mayLoad'.
247 def SDNPSideEffect : SDNodeProperty; // Sets 'HasUnmodelledSideEffects'.
248 def SDNPMemOperand : SDNodeProperty; // Touches memory, has assoc MemOperand
249 def SDNPVariadic : SDNodeProperty; // Node has variable arguments.
250 def SDNPWantRoot : SDNodeProperty; // ComplexPattern gets the root of match
251 def SDNPWantParent : SDNodeProperty; // ComplexPattern gets the parent
253 //===----------------------------------------------------------------------===//
254 // Selection DAG Pattern Operations
255 class SDPatternOperator;
257 //===----------------------------------------------------------------------===//
258 // Selection DAG Node definitions.
260 class SDNode<string opcode, SDTypeProfile typeprof,
261 list<SDNodeProperty> props = [], string sdclass = "SDNode">
262 : SDPatternOperator {
263 string Opcode = opcode;
264 string SDClass = sdclass;
265 list<SDNodeProperty> Properties = props;
266 SDTypeProfile TypeProfile = typeprof;
269 // Special TableGen-recognized dag nodes
275 def imm : SDNode<"ISD::Constant" , SDTIntLeaf , [], "ConstantSDNode">;
276 def timm : SDNode<"ISD::TargetConstant",SDTIntLeaf, [], "ConstantSDNode">;
277 def fpimm : SDNode<"ISD::ConstantFP", SDTFPLeaf , [], "ConstantFPSDNode">;
278 def vt : SDNode<"ISD::VALUETYPE" , SDTOther , [], "VTSDNode">;
279 def bb : SDNode<"ISD::BasicBlock", SDTOther , [], "BasicBlockSDNode">;
280 def cond : SDNode<"ISD::CONDCODE" , SDTOther , [], "CondCodeSDNode">;
281 def undef : SDNode<"ISD::UNDEF" , SDTUNDEF , []>;
282 def globaladdr : SDNode<"ISD::GlobalAddress", SDTPtrLeaf, [],
283 "GlobalAddressSDNode">;
284 def tglobaladdr : SDNode<"ISD::TargetGlobalAddress", SDTPtrLeaf, [],
285 "GlobalAddressSDNode">;
286 def globaltlsaddr : SDNode<"ISD::GlobalTLSAddress", SDTPtrLeaf, [],
287 "GlobalAddressSDNode">;
288 def tglobaltlsaddr : SDNode<"ISD::TargetGlobalTLSAddress", SDTPtrLeaf, [],
289 "GlobalAddressSDNode">;
290 def constpool : SDNode<"ISD::ConstantPool", SDTPtrLeaf, [],
291 "ConstantPoolSDNode">;
292 def tconstpool : SDNode<"ISD::TargetConstantPool", SDTPtrLeaf, [],
293 "ConstantPoolSDNode">;
294 def jumptable : SDNode<"ISD::JumpTable", SDTPtrLeaf, [],
296 def tjumptable : SDNode<"ISD::TargetJumpTable", SDTPtrLeaf, [],
298 def frameindex : SDNode<"ISD::FrameIndex", SDTPtrLeaf, [],
300 def tframeindex : SDNode<"ISD::TargetFrameIndex", SDTPtrLeaf, [],
302 def externalsym : SDNode<"ISD::ExternalSymbol", SDTPtrLeaf, [],
303 "ExternalSymbolSDNode">;
304 def texternalsym: SDNode<"ISD::TargetExternalSymbol", SDTPtrLeaf, [],
305 "ExternalSymbolSDNode">;
306 def blockaddress : SDNode<"ISD::BlockAddress", SDTPtrLeaf, [],
307 "BlockAddressSDNode">;
308 def tblockaddress: SDNode<"ISD::TargetBlockAddress", SDTPtrLeaf, [],
309 "BlockAddressSDNode">;
311 def add : SDNode<"ISD::ADD" , SDTIntBinOp ,
312 [SDNPCommutative, SDNPAssociative]>;
313 def sub : SDNode<"ISD::SUB" , SDTIntBinOp>;
314 def mul : SDNode<"ISD::MUL" , SDTIntBinOp,
315 [SDNPCommutative, SDNPAssociative]>;
316 def mulhs : SDNode<"ISD::MULHS" , SDTIntBinOp, [SDNPCommutative]>;
317 def mulhu : SDNode<"ISD::MULHU" , SDTIntBinOp, [SDNPCommutative]>;
318 def smullohi : SDNode<"ISD::SMUL_LOHI" , SDTIntBinHiLoOp, [SDNPCommutative]>;
319 def umullohi : SDNode<"ISD::UMUL_LOHI" , SDTIntBinHiLoOp, [SDNPCommutative]>;
320 def sdiv : SDNode<"ISD::SDIV" , SDTIntBinOp>;
321 def udiv : SDNode<"ISD::UDIV" , SDTIntBinOp>;
322 def srem : SDNode<"ISD::SREM" , SDTIntBinOp>;
323 def urem : SDNode<"ISD::UREM" , SDTIntBinOp>;
324 def sdivrem : SDNode<"ISD::SDIVREM" , SDTIntBinHiLoOp>;
325 def udivrem : SDNode<"ISD::UDIVREM" , SDTIntBinHiLoOp>;
326 def srl : SDNode<"ISD::SRL" , SDTIntShiftOp>;
327 def sra : SDNode<"ISD::SRA" , SDTIntShiftOp>;
328 def shl : SDNode<"ISD::SHL" , SDTIntShiftOp>;
329 def rotl : SDNode<"ISD::ROTL" , SDTIntShiftOp>;
330 def rotr : SDNode<"ISD::ROTR" , SDTIntShiftOp>;
331 def and : SDNode<"ISD::AND" , SDTIntBinOp,
332 [SDNPCommutative, SDNPAssociative]>;
333 def or : SDNode<"ISD::OR" , SDTIntBinOp,
334 [SDNPCommutative, SDNPAssociative]>;
335 def xor : SDNode<"ISD::XOR" , SDTIntBinOp,
336 [SDNPCommutative, SDNPAssociative]>;
337 def addc : SDNode<"ISD::ADDC" , SDTIntBinOp,
338 [SDNPCommutative, SDNPOutGlue]>;
339 def adde : SDNode<"ISD::ADDE" , SDTIntBinOp,
340 [SDNPCommutative, SDNPOutGlue, SDNPInGlue]>;
341 def subc : SDNode<"ISD::SUBC" , SDTIntBinOp,
343 def sube : SDNode<"ISD::SUBE" , SDTIntBinOp,
344 [SDNPOutGlue, SDNPInGlue]>;
346 def sext_inreg : SDNode<"ISD::SIGN_EXTEND_INREG", SDTExtInreg>;
347 def bswap : SDNode<"ISD::BSWAP" , SDTIntUnaryOp>;
348 def ctlz : SDNode<"ISD::CTLZ" , SDTIntUnaryOp>;
349 def cttz : SDNode<"ISD::CTTZ" , SDTIntUnaryOp>;
350 def ctpop : SDNode<"ISD::CTPOP" , SDTIntUnaryOp>;
351 def sext : SDNode<"ISD::SIGN_EXTEND", SDTIntExtendOp>;
352 def zext : SDNode<"ISD::ZERO_EXTEND", SDTIntExtendOp>;
353 def anyext : SDNode<"ISD::ANY_EXTEND" , SDTIntExtendOp>;
354 def trunc : SDNode<"ISD::TRUNCATE" , SDTIntTruncOp>;
355 def bitconvert : SDNode<"ISD::BITCAST" , SDTUnaryOp>;
356 def extractelt : SDNode<"ISD::EXTRACT_VECTOR_ELT", SDTVecExtract>;
357 def insertelt : SDNode<"ISD::INSERT_VECTOR_ELT", SDTVecInsert>;
360 def fadd : SDNode<"ISD::FADD" , SDTFPBinOp, [SDNPCommutative]>;
361 def fsub : SDNode<"ISD::FSUB" , SDTFPBinOp>;
362 def fmul : SDNode<"ISD::FMUL" , SDTFPBinOp, [SDNPCommutative]>;
363 def fdiv : SDNode<"ISD::FDIV" , SDTFPBinOp>;
364 def frem : SDNode<"ISD::FREM" , SDTFPBinOp>;
365 def fma : SDNode<"ISD::FMA" , SDTFPTernaryOp>;
366 def fabs : SDNode<"ISD::FABS" , SDTFPUnaryOp>;
367 def fgetsign : SDNode<"ISD::FGETSIGN" , SDTFPToIntOp>;
368 def fneg : SDNode<"ISD::FNEG" , SDTFPUnaryOp>;
369 def fsqrt : SDNode<"ISD::FSQRT" , SDTFPUnaryOp>;
370 def fsin : SDNode<"ISD::FSIN" , SDTFPUnaryOp>;
371 def fcos : SDNode<"ISD::FCOS" , SDTFPUnaryOp>;
372 def fexp2 : SDNode<"ISD::FEXP2" , SDTFPUnaryOp>;
373 def flog2 : SDNode<"ISD::FLOG2" , SDTFPUnaryOp>;
374 def frint : SDNode<"ISD::FRINT" , SDTFPUnaryOp>;
375 def ftrunc : SDNode<"ISD::FTRUNC" , SDTFPUnaryOp>;
376 def fceil : SDNode<"ISD::FCEIL" , SDTFPUnaryOp>;
377 def ffloor : SDNode<"ISD::FFLOOR" , SDTFPUnaryOp>;
378 def fnearbyint : SDNode<"ISD::FNEARBYINT" , SDTFPUnaryOp>;
380 def fround : SDNode<"ISD::FP_ROUND" , SDTFPRoundOp>;
381 def fextend : SDNode<"ISD::FP_EXTEND" , SDTFPExtendOp>;
382 def fcopysign : SDNode<"ISD::FCOPYSIGN" , SDTFPSignOp>;
384 def sint_to_fp : SDNode<"ISD::SINT_TO_FP" , SDTIntToFPOp>;
385 def uint_to_fp : SDNode<"ISD::UINT_TO_FP" , SDTIntToFPOp>;
386 def fp_to_sint : SDNode<"ISD::FP_TO_SINT" , SDTFPToIntOp>;
387 def fp_to_uint : SDNode<"ISD::FP_TO_UINT" , SDTFPToIntOp>;
388 def f16_to_f32 : SDNode<"ISD::FP16_TO_FP32", SDTIntToFPOp>;
389 def f32_to_f16 : SDNode<"ISD::FP32_TO_FP16", SDTFPToIntOp>;
391 def setcc : SDNode<"ISD::SETCC" , SDTSetCC>;
392 def select : SDNode<"ISD::SELECT" , SDTSelect>;
393 def selectcc : SDNode<"ISD::SELECT_CC" , SDTSelectCC>;
394 def vsetcc : SDNode<"ISD::VSETCC" , SDTSetCC>;
396 def brcond : SDNode<"ISD::BRCOND" , SDTBrcond, [SDNPHasChain]>;
397 def brind : SDNode<"ISD::BRIND" , SDTBrind, [SDNPHasChain]>;
398 def br : SDNode<"ISD::BR" , SDTBr, [SDNPHasChain]>;
399 def trap : SDNode<"ISD::TRAP" , SDTNone,
400 [SDNPHasChain, SDNPSideEffect]>;
402 def prefetch : SDNode<"ISD::PREFETCH" , SDTPrefetch,
403 [SDNPHasChain, SDNPMayLoad, SDNPMayStore,
406 def membarrier : SDNode<"ISD::MEMBARRIER" , SDTMemBarrier,
407 [SDNPHasChain, SDNPSideEffect]>;
409 def atomic_fence : SDNode<"ISD::ATOMIC_FENCE" , SDTAtomicFence,
410 [SDNPHasChain, SDNPSideEffect]>;
412 def atomic_cmp_swap : SDNode<"ISD::ATOMIC_CMP_SWAP" , SDTAtomic3,
413 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
414 def atomic_load_add : SDNode<"ISD::ATOMIC_LOAD_ADD" , SDTAtomic2,
415 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
416 def atomic_swap : SDNode<"ISD::ATOMIC_SWAP", SDTAtomic2,
417 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
418 def atomic_load_sub : SDNode<"ISD::ATOMIC_LOAD_SUB" , SDTAtomic2,
419 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
420 def atomic_load_and : SDNode<"ISD::ATOMIC_LOAD_AND" , SDTAtomic2,
421 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
422 def atomic_load_or : SDNode<"ISD::ATOMIC_LOAD_OR" , SDTAtomic2,
423 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
424 def atomic_load_xor : SDNode<"ISD::ATOMIC_LOAD_XOR" , SDTAtomic2,
425 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
426 def atomic_load_nand: SDNode<"ISD::ATOMIC_LOAD_NAND", SDTAtomic2,
427 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
428 def atomic_load_min : SDNode<"ISD::ATOMIC_LOAD_MIN", SDTAtomic2,
429 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
430 def atomic_load_max : SDNode<"ISD::ATOMIC_LOAD_MAX", SDTAtomic2,
431 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
432 def atomic_load_umin : SDNode<"ISD::ATOMIC_LOAD_UMIN", SDTAtomic2,
433 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
434 def atomic_load_umax : SDNode<"ISD::ATOMIC_LOAD_UMAX", SDTAtomic2,
435 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
436 def atomic_load : SDNode<"ISD::ATOMIC_LOAD", SDTAtomicLoad,
437 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
438 def atomic_store : SDNode<"ISD::ATOMIC_STORE", SDTAtomicStore,
439 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
441 // Do not use ld, st directly. Use load, extload, sextload, zextload, store,
442 // and truncst (see below).
443 def ld : SDNode<"ISD::LOAD" , SDTLoad,
444 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
445 def st : SDNode<"ISD::STORE" , SDTStore,
446 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
447 def ist : SDNode<"ISD::STORE" , SDTIStore,
448 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
450 def vector_shuffle : SDNode<"ISD::VECTOR_SHUFFLE", SDTVecShuffle, []>;
451 def build_vector : SDNode<"ISD::BUILD_VECTOR", SDTypeProfile<1, -1, []>, []>;
452 def scalar_to_vector : SDNode<"ISD::SCALAR_TO_VECTOR", SDTypeProfile<1, 1, []>,
454 def vector_extract : SDNode<"ISD::EXTRACT_VECTOR_ELT",
455 SDTypeProfile<1, 2, [SDTCisPtrTy<2>]>, []>;
456 def vector_insert : SDNode<"ISD::INSERT_VECTOR_ELT",
457 SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisPtrTy<3>]>, []>;
459 // This operator does not do subvector type checking. The ARM
460 // backend, at least, needs it.
461 def vector_extract_subvec : SDNode<"ISD::EXTRACT_SUBVECTOR",
462 SDTypeProfile<1, 2, [SDTCisInt<2>, SDTCisVec<1>, SDTCisVec<0>]>,
465 // This operator does subvector type checking.
466 def extract_subvector : SDNode<"ISD::EXTRACT_SUBVECTOR", SDTSubVecExtract, []>;
467 def insert_subvector : SDNode<"ISD::INSERT_SUBVECTOR", SDTSubVecInsert, []>;
469 // Nodes for intrinsics, you should use the intrinsic itself and let tblgen use
470 // these internally. Don't reference these directly.
471 def intrinsic_void : SDNode<"ISD::INTRINSIC_VOID",
472 SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>,
474 def intrinsic_w_chain : SDNode<"ISD::INTRINSIC_W_CHAIN",
475 SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>,
477 def intrinsic_wo_chain : SDNode<"ISD::INTRINSIC_WO_CHAIN",
478 SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>, []>;
480 // Do not use cvt directly. Use cvt forms below
481 def cvt : SDNode<"ISD::CONVERT_RNDSAT", SDTConvertOp>;
483 //===----------------------------------------------------------------------===//
484 // Selection DAG Condition Codes
486 class CondCode; // ISD::CondCode enums
487 def SETOEQ : CondCode; def SETOGT : CondCode;
488 def SETOGE : CondCode; def SETOLT : CondCode; def SETOLE : CondCode;
489 def SETONE : CondCode; def SETO : CondCode; def SETUO : CondCode;
490 def SETUEQ : CondCode; def SETUGT : CondCode; def SETUGE : CondCode;
491 def SETULT : CondCode; def SETULE : CondCode; def SETUNE : CondCode;
493 def SETEQ : CondCode; def SETGT : CondCode; def SETGE : CondCode;
494 def SETLT : CondCode; def SETLE : CondCode; def SETNE : CondCode;
497 //===----------------------------------------------------------------------===//
498 // Selection DAG Node Transformation Functions.
500 // This mechanism allows targets to manipulate nodes in the output DAG once a
501 // match has been formed. This is typically used to manipulate immediate
504 class SDNodeXForm<SDNode opc, code xformFunction> {
506 code XFormFunction = xformFunction;
509 def NOOP_SDNodeXForm : SDNodeXForm<imm, [{}]>;
511 //===----------------------------------------------------------------------===//
512 // PatPred Subclasses.
514 // These allow specifying different sorts of predicates that control whether a
519 class CodePatPred<code predicate> : PatPred {
520 code PredicateCode = predicate;
524 //===----------------------------------------------------------------------===//
525 // Selection DAG Pattern Fragments.
527 // Pattern fragments are reusable chunks of dags that match specific things.
528 // They can take arguments and have C++ predicates that control whether they
529 // match. They are intended to make the patterns for common instructions more
530 // compact and readable.
533 /// PatFrag - Represents a pattern fragment. This can match something on the
534 /// DAG, from a single node to multiple nested other fragments.
536 class PatFrag<dag ops, dag frag, code pred = [{}],
537 SDNodeXForm xform = NOOP_SDNodeXForm> : SDPatternOperator {
540 code PredicateCode = pred;
541 code ImmediateCode = [{}];
542 SDNodeXForm OperandTransform = xform;
545 // PatLeaf's are pattern fragments that have no operands. This is just a helper
546 // to define immediates and other common things concisely.
547 class PatLeaf<dag frag, code pred = [{}], SDNodeXForm xform = NOOP_SDNodeXForm>
548 : PatFrag<(ops), frag, pred, xform>;
551 // ImmLeaf is a pattern fragment with a constraint on the immediate. The
552 // constraint is a function that is run on the immediate (always with the value
553 // sign extended out to an int64_t) as Imm. For example:
555 // def immSExt8 : ImmLeaf<i16, [{ return (char)Imm == Imm; }]>;
557 // this is a more convenient form to match 'imm' nodes in than PatLeaf and also
558 // is preferred over using PatLeaf because it allows the code generator to
559 // reason more about the constraint.
561 // If FastIsel should ignore all instructions that have an operand of this type,
562 // the FastIselShouldIgnore flag can be set. This is an optimization to reduce
563 // the code size of the generated fast instruction selector.
564 class ImmLeaf<ValueType vt, code pred, SDNodeXForm xform = NOOP_SDNodeXForm>
565 : PatFrag<(ops), (vt imm), [{}], xform> {
566 let ImmediateCode = pred;
567 bit FastIselShouldIgnore = 0;
573 def vtInt : PatLeaf<(vt), [{ return N->getVT().isInteger(); }]>;
574 def vtFP : PatLeaf<(vt), [{ return N->getVT().isFloatingPoint(); }]>;
576 def immAllOnesV: PatLeaf<(build_vector), [{
577 return ISD::isBuildVectorAllOnes(N);
579 def immAllZerosV: PatLeaf<(build_vector), [{
580 return ISD::isBuildVectorAllZeros(N);
585 // Other helper fragments.
586 def not : PatFrag<(ops node:$in), (xor node:$in, -1)>;
587 def vnot : PatFrag<(ops node:$in), (xor node:$in, immAllOnesV)>;
588 def ineg : PatFrag<(ops node:$in), (sub 0, node:$in)>;
591 def unindexedload : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
592 return cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
594 def load : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{
595 return cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
598 // extending load fragments.
599 def extload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{
600 return cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
602 def sextload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{
603 return cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
605 def zextload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{
606 return cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
609 def extloadi1 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{
610 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i1;
612 def extloadi8 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{
613 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8;
615 def extloadi16 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{
616 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16;
618 def extloadi32 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{
619 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i32;
621 def extloadf32 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{
622 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::f32;
624 def extloadf64 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{
625 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::f64;
628 def sextloadi1 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{
629 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i1;
631 def sextloadi8 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{
632 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8;
634 def sextloadi16 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{
635 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16;
637 def sextloadi32 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{
638 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i32;
641 def zextloadi1 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{
642 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i1;
644 def zextloadi8 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{
645 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8;
647 def zextloadi16 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{
648 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16;
650 def zextloadi32 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{
651 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i32;
655 def unindexedstore : PatFrag<(ops node:$val, node:$ptr),
656 (st node:$val, node:$ptr), [{
657 return cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
659 def store : PatFrag<(ops node:$val, node:$ptr),
660 (unindexedstore node:$val, node:$ptr), [{
661 return !cast<StoreSDNode>(N)->isTruncatingStore();
664 // truncstore fragments.
665 def truncstore : PatFrag<(ops node:$val, node:$ptr),
666 (unindexedstore node:$val, node:$ptr), [{
667 return cast<StoreSDNode>(N)->isTruncatingStore();
669 def truncstorei8 : PatFrag<(ops node:$val, node:$ptr),
670 (truncstore node:$val, node:$ptr), [{
671 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i8;
673 def truncstorei16 : PatFrag<(ops node:$val, node:$ptr),
674 (truncstore node:$val, node:$ptr), [{
675 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i16;
677 def truncstorei32 : PatFrag<(ops node:$val, node:$ptr),
678 (truncstore node:$val, node:$ptr), [{
679 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i32;
681 def truncstoref32 : PatFrag<(ops node:$val, node:$ptr),
682 (truncstore node:$val, node:$ptr), [{
683 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::f32;
685 def truncstoref64 : PatFrag<(ops node:$val, node:$ptr),
686 (truncstore node:$val, node:$ptr), [{
687 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::f64;
690 // indexed store fragments.
691 def istore : PatFrag<(ops node:$val, node:$base, node:$offset),
692 (ist node:$val, node:$base, node:$offset), [{
693 return !cast<StoreSDNode>(N)->isTruncatingStore();
696 def pre_store : PatFrag<(ops node:$val, node:$base, node:$offset),
697 (istore node:$val, node:$base, node:$offset), [{
698 ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
699 return AM == ISD::PRE_INC || AM == ISD::PRE_DEC;
702 def itruncstore : PatFrag<(ops node:$val, node:$base, node:$offset),
703 (ist node:$val, node:$base, node:$offset), [{
704 return cast<StoreSDNode>(N)->isTruncatingStore();
706 def pre_truncst : PatFrag<(ops node:$val, node:$base, node:$offset),
707 (itruncstore node:$val, node:$base, node:$offset), [{
708 ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
709 return AM == ISD::PRE_INC || AM == ISD::PRE_DEC;
711 def pre_truncsti1 : PatFrag<(ops node:$val, node:$base, node:$offset),
712 (pre_truncst node:$val, node:$base, node:$offset), [{
713 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i1;
715 def pre_truncsti8 : PatFrag<(ops node:$val, node:$base, node:$offset),
716 (pre_truncst node:$val, node:$base, node:$offset), [{
717 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i8;
719 def pre_truncsti16 : PatFrag<(ops node:$val, node:$base, node:$offset),
720 (pre_truncst node:$val, node:$base, node:$offset), [{
721 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i16;
723 def pre_truncsti32 : PatFrag<(ops node:$val, node:$base, node:$offset),
724 (pre_truncst node:$val, node:$base, node:$offset), [{
725 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i32;
727 def pre_truncstf32 : PatFrag<(ops node:$val, node:$base, node:$offset),
728 (pre_truncst node:$val, node:$base, node:$offset), [{
729 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::f32;
732 def post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
733 (istore node:$val, node:$ptr, node:$offset), [{
734 ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
735 return AM == ISD::POST_INC || AM == ISD::POST_DEC;
738 def post_truncst : PatFrag<(ops node:$val, node:$base, node:$offset),
739 (itruncstore node:$val, node:$base, node:$offset), [{
740 ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
741 return AM == ISD::POST_INC || AM == ISD::POST_DEC;
743 def post_truncsti1 : PatFrag<(ops node:$val, node:$base, node:$offset),
744 (post_truncst node:$val, node:$base, node:$offset), [{
745 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i1;
747 def post_truncsti8 : PatFrag<(ops node:$val, node:$base, node:$offset),
748 (post_truncst node:$val, node:$base, node:$offset), [{
749 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i8;
751 def post_truncsti16 : PatFrag<(ops node:$val, node:$base, node:$offset),
752 (post_truncst node:$val, node:$base, node:$offset), [{
753 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i16;
755 def post_truncsti32 : PatFrag<(ops node:$val, node:$base, node:$offset),
756 (post_truncst node:$val, node:$base, node:$offset), [{
757 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i32;
759 def post_truncstf32 : PatFrag<(ops node:$val, node:$base, node:$offset),
760 (post_truncst node:$val, node:$base, node:$offset), [{
761 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::f32;
764 // setcc convenience fragments.
765 def setoeq : PatFrag<(ops node:$lhs, node:$rhs),
766 (setcc node:$lhs, node:$rhs, SETOEQ)>;
767 def setogt : PatFrag<(ops node:$lhs, node:$rhs),
768 (setcc node:$lhs, node:$rhs, SETOGT)>;
769 def setoge : PatFrag<(ops node:$lhs, node:$rhs),
770 (setcc node:$lhs, node:$rhs, SETOGE)>;
771 def setolt : PatFrag<(ops node:$lhs, node:$rhs),
772 (setcc node:$lhs, node:$rhs, SETOLT)>;
773 def setole : PatFrag<(ops node:$lhs, node:$rhs),
774 (setcc node:$lhs, node:$rhs, SETOLE)>;
775 def setone : PatFrag<(ops node:$lhs, node:$rhs),
776 (setcc node:$lhs, node:$rhs, SETONE)>;
777 def seto : PatFrag<(ops node:$lhs, node:$rhs),
778 (setcc node:$lhs, node:$rhs, SETO)>;
779 def setuo : PatFrag<(ops node:$lhs, node:$rhs),
780 (setcc node:$lhs, node:$rhs, SETUO)>;
781 def setueq : PatFrag<(ops node:$lhs, node:$rhs),
782 (setcc node:$lhs, node:$rhs, SETUEQ)>;
783 def setugt : PatFrag<(ops node:$lhs, node:$rhs),
784 (setcc node:$lhs, node:$rhs, SETUGT)>;
785 def setuge : PatFrag<(ops node:$lhs, node:$rhs),
786 (setcc node:$lhs, node:$rhs, SETUGE)>;
787 def setult : PatFrag<(ops node:$lhs, node:$rhs),
788 (setcc node:$lhs, node:$rhs, SETULT)>;
789 def setule : PatFrag<(ops node:$lhs, node:$rhs),
790 (setcc node:$lhs, node:$rhs, SETULE)>;
791 def setune : PatFrag<(ops node:$lhs, node:$rhs),
792 (setcc node:$lhs, node:$rhs, SETUNE)>;
793 def seteq : PatFrag<(ops node:$lhs, node:$rhs),
794 (setcc node:$lhs, node:$rhs, SETEQ)>;
795 def setgt : PatFrag<(ops node:$lhs, node:$rhs),
796 (setcc node:$lhs, node:$rhs, SETGT)>;
797 def setge : PatFrag<(ops node:$lhs, node:$rhs),
798 (setcc node:$lhs, node:$rhs, SETGE)>;
799 def setlt : PatFrag<(ops node:$lhs, node:$rhs),
800 (setcc node:$lhs, node:$rhs, SETLT)>;
801 def setle : PatFrag<(ops node:$lhs, node:$rhs),
802 (setcc node:$lhs, node:$rhs, SETLE)>;
803 def setne : PatFrag<(ops node:$lhs, node:$rhs),
804 (setcc node:$lhs, node:$rhs, SETNE)>;
806 def atomic_cmp_swap_8 :
807 PatFrag<(ops node:$ptr, node:$cmp, node:$swap),
808 (atomic_cmp_swap node:$ptr, node:$cmp, node:$swap), [{
809 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i8;
811 def atomic_cmp_swap_16 :
812 PatFrag<(ops node:$ptr, node:$cmp, node:$swap),
813 (atomic_cmp_swap node:$ptr, node:$cmp, node:$swap), [{
814 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i16;
816 def atomic_cmp_swap_32 :
817 PatFrag<(ops node:$ptr, node:$cmp, node:$swap),
818 (atomic_cmp_swap node:$ptr, node:$cmp, node:$swap), [{
819 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i32;
821 def atomic_cmp_swap_64 :
822 PatFrag<(ops node:$ptr, node:$cmp, node:$swap),
823 (atomic_cmp_swap node:$ptr, node:$cmp, node:$swap), [{
824 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i64;
827 multiclass binary_atomic_op<SDNode atomic_op> {
828 def _8 : PatFrag<(ops node:$ptr, node:$val),
829 (atomic_op node:$ptr, node:$val), [{
830 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i8;
832 def _16 : PatFrag<(ops node:$ptr, node:$val),
833 (atomic_op node:$ptr, node:$val), [{
834 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i16;
836 def _32 : PatFrag<(ops node:$ptr, node:$val),
837 (atomic_op node:$ptr, node:$val), [{
838 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i32;
840 def _64 : PatFrag<(ops node:$ptr, node:$val),
841 (atomic_op node:$ptr, node:$val), [{
842 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i64;
846 defm atomic_load_add : binary_atomic_op<atomic_load_add>;
847 defm atomic_swap : binary_atomic_op<atomic_swap>;
848 defm atomic_load_sub : binary_atomic_op<atomic_load_sub>;
849 defm atomic_load_and : binary_atomic_op<atomic_load_and>;
850 defm atomic_load_or : binary_atomic_op<atomic_load_or>;
851 defm atomic_load_xor : binary_atomic_op<atomic_load_xor>;
852 defm atomic_load_nand : binary_atomic_op<atomic_load_nand>;
853 defm atomic_load_min : binary_atomic_op<atomic_load_min>;
854 defm atomic_load_max : binary_atomic_op<atomic_load_max>;
855 defm atomic_load_umin : binary_atomic_op<atomic_load_umin>;
856 defm atomic_load_umax : binary_atomic_op<atomic_load_umax>;
857 defm atomic_store : binary_atomic_op<atomic_store>;
860 PatFrag<(ops node:$ptr),
861 (atomic_load node:$ptr), [{
862 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i8;
865 PatFrag<(ops node:$ptr),
866 (atomic_load node:$ptr), [{
867 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i16;
870 PatFrag<(ops node:$ptr),
871 (atomic_load node:$ptr), [{
872 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i32;
875 PatFrag<(ops node:$ptr),
876 (atomic_load node:$ptr), [{
877 return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i64;
880 //===----------------------------------------------------------------------===//
881 // Selection DAG CONVERT_RNDSAT patterns
883 def cvtff : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
884 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
885 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_FF;
888 def cvtss : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
889 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
890 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_SS;
893 def cvtsu : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
894 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
895 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_SU;
898 def cvtus : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
899 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
900 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_US;
903 def cvtuu : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
904 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
905 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_UU;
908 def cvtsf : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
909 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
910 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_SF;
913 def cvtuf : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
914 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
915 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_UF;
918 def cvtfs : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
919 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
920 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_FS;
923 def cvtfu : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
924 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
925 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_FU;
928 //===----------------------------------------------------------------------===//
929 // Selection DAG Pattern Support.
931 // Patterns are what are actually matched against by the target-flavored
932 // instruction selection DAG. Instructions defined by the target implicitly
933 // define patterns in most cases, but patterns can also be explicitly added when
934 // an operation is defined by a sequence of instructions (e.g. loading a large
935 // immediate value on RISC targets that do not support immediates as large as
939 class Pattern<dag patternToMatch, list<dag> resultInstrs> {
940 dag PatternToMatch = patternToMatch;
941 list<dag> ResultInstrs = resultInstrs;
942 list<Predicate> Predicates = []; // See class Instruction in Target.td.
943 int AddedComplexity = 0; // See class Instruction in Target.td.
946 // Pat - A simple (but common) form of a pattern, which produces a simple result
947 // not needing a full list.
948 class Pat<dag pattern, dag result> : Pattern<pattern, [result]>;
950 //===----------------------------------------------------------------------===//
951 // Complex pattern definitions.
954 // Complex patterns, e.g. X86 addressing mode, requires pattern matching code
955 // in C++. NumOperands is the number of operands returned by the select function;
956 // SelectFunc is the name of the function used to pattern match the max. pattern;
957 // RootNodes are the list of possible root nodes of the sub-dags to match.
958 // e.g. X86 addressing mode - def addr : ComplexPattern<4, "SelectAddr", [add]>;
960 class ComplexPattern<ValueType ty, int numops, string fn,
961 list<SDNode> roots = [], list<SDNodeProperty> props = []> {
963 int NumOperands = numops;
964 string SelectFunc = fn;
965 list<SDNode> RootNodes = roots;
966 list<SDNodeProperty> Properties = props;