TargetSelectionDAG.td revision 543790673c747ab2793fc657e239ce5f78419dc0
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 SDTSelectCC : SDTypeProfile<1, 5, [     // select_cc
153  SDTCisSameAs<1, 2>, SDTCisSameAs<3, 4>, SDTCisSameAs<0, 3>,
154  SDTCisVT<5, OtherVT>
155]>;
156
157def SDTBr : SDTypeProfile<0, 1, [           // br
158  SDTCisVT<0, OtherVT>
159]>;
160
161def SDTBrcond : SDTypeProfile<0, 2, [       // brcond
162  SDTCisInt<0>, SDTCisVT<1, OtherVT>
163]>;
164
165def SDTBrind : SDTypeProfile<0, 1, [        // brind
166  SDTCisPtrTy<0>
167]>;
168
169def SDTNone : SDTypeProfile<0, 0, []>;      // ret, trap
170
171def SDTLoad : SDTypeProfile<1, 1, [         // load
172  SDTCisPtrTy<1>
173]>;
174
175def SDTStore : SDTypeProfile<0, 2, [        // store
176  SDTCisPtrTy<1>
177]>;
178
179def SDTIStore : SDTypeProfile<1, 3, [       // indexed store
180  SDTCisSameAs<0, 2>, SDTCisPtrTy<0>, SDTCisPtrTy<3>
181]>;
182
183def SDTVecShuffle : SDTypeProfile<1, 2, [
184  SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>
185]>;
186def SDTVecExtract : SDTypeProfile<1, 2, [   // vector extract
187  SDTCisEltOfVec<0, 1>, SDTCisPtrTy<2>
188]>;
189def SDTVecInsert : SDTypeProfile<1, 3, [    // vector insert
190  SDTCisEltOfVec<2, 1>, SDTCisSameAs<0, 1>, SDTCisPtrTy<3>
191]>;
192
193def SDTSubVecExtract : SDTypeProfile<1, 2, [// subvector extract
194  SDTCisSubVecOfVec<0,1>, SDTCisInt<2>
195]>;
196def SDTSubVecInsert : SDTypeProfile<1, 3, [ // subvector insert
197  SDTCisSubVecOfVec<2, 1>, SDTCisSameAs<0,1>, SDTCisInt<3>
198]>;
199
200def SDTPrefetch : SDTypeProfile<0, 3, [     // prefetch
201  SDTCisPtrTy<0>, SDTCisSameAs<1, 2>, SDTCisInt<1>
202]>;
203
204def SDTMemBarrier : SDTypeProfile<0, 5, [   // memory barier
205  SDTCisSameAs<0,1>,  SDTCisSameAs<0,2>,  SDTCisSameAs<0,3>, SDTCisSameAs<0,4>,
206  SDTCisInt<0>
207]>;
208def SDTAtomic3 : SDTypeProfile<1, 3, [
209  SDTCisSameAs<0,2>,  SDTCisSameAs<0,3>, SDTCisInt<0>, SDTCisPtrTy<1>
210]>;
211def SDTAtomic2 : SDTypeProfile<1, 2, [
212  SDTCisSameAs<0,2>, SDTCisInt<0>, SDTCisPtrTy<1>
213]>;
214
215def SDTConvertOp : SDTypeProfile<1, 5, [ //cvtss, su, us, uu, ff, fs, fu, sf, su
216  SDTCisVT<2, OtherVT>, SDTCisVT<3, OtherVT>, SDTCisPtrTy<4>, SDTCisPtrTy<5>
217]>;
218
219class SDCallSeqStart<list<SDTypeConstraint> constraints> :
220        SDTypeProfile<0, 1, constraints>;
221class SDCallSeqEnd<list<SDTypeConstraint> constraints> :
222        SDTypeProfile<0, 2, constraints>;
223
224//===----------------------------------------------------------------------===//
225// Selection DAG Node Properties.
226//
227// Note: These are hard coded into tblgen.
228//
229class SDNodeProperty;
230def SDNPCommutative : SDNodeProperty;   // X op Y == Y op X
231def SDNPAssociative : SDNodeProperty;   // (X op Y) op Z == X op (Y op Z)
232def SDNPHasChain    : SDNodeProperty;   // R/W chain operand and result
233def SDNPOutGlue     : SDNodeProperty;   // Write a flag result
234def SDNPInGlue      : SDNodeProperty;   // Read a flag operand
235def SDNPOptInGlue   : SDNodeProperty;   // Optionally read a flag operand
236def SDNPMayStore    : SDNodeProperty;   // May write to memory, sets 'mayStore'.
237def SDNPMayLoad     : SDNodeProperty;   // May read memory, sets 'mayLoad'.
238def SDNPSideEffect  : SDNodeProperty;   // Sets 'HasUnmodelledSideEffects'.
239def SDNPMemOperand  : SDNodeProperty;   // Touches memory, has assoc MemOperand
240def SDNPVariadic    : SDNodeProperty;   // Node has variable arguments.
241def SDNPWantRoot    : SDNodeProperty;   // ComplexPattern gets the root of match
242def SDNPWantParent  : SDNodeProperty;   // ComplexPattern gets the parent
243
244//===----------------------------------------------------------------------===//
245// Selection DAG Pattern Operations
246class SDPatternOperator;
247
248//===----------------------------------------------------------------------===//
249// Selection DAG Node definitions.
250//
251class SDNode<string opcode, SDTypeProfile typeprof,
252             list<SDNodeProperty> props = [], string sdclass = "SDNode">
253             : SDPatternOperator {
254  string Opcode  = opcode;
255  string SDClass = sdclass;
256  list<SDNodeProperty> Properties = props;
257  SDTypeProfile TypeProfile = typeprof;
258}
259
260// Special TableGen-recognized dag nodes
261def set;
262def implicit;
263def node;
264def srcvalue;
265
266def imm        : SDNode<"ISD::Constant"  , SDTIntLeaf , [], "ConstantSDNode">;
267def timm       : SDNode<"ISD::TargetConstant",SDTIntLeaf, [], "ConstantSDNode">;
268def fpimm      : SDNode<"ISD::ConstantFP", SDTFPLeaf  , [], "ConstantFPSDNode">;
269def vt         : SDNode<"ISD::VALUETYPE" , SDTOther   , [], "VTSDNode">;
270def bb         : SDNode<"ISD::BasicBlock", SDTOther   , [], "BasicBlockSDNode">;
271def cond       : SDNode<"ISD::CONDCODE"  , SDTOther   , [], "CondCodeSDNode">;
272def undef      : SDNode<"ISD::UNDEF"     , SDTUNDEF   , []>;
273def globaladdr : SDNode<"ISD::GlobalAddress",         SDTPtrLeaf, [],
274                        "GlobalAddressSDNode">;
275def tglobaladdr : SDNode<"ISD::TargetGlobalAddress",  SDTPtrLeaf, [],
276                         "GlobalAddressSDNode">;
277def globaltlsaddr : SDNode<"ISD::GlobalTLSAddress",         SDTPtrLeaf, [],
278                          "GlobalAddressSDNode">;
279def tglobaltlsaddr : SDNode<"ISD::TargetGlobalTLSAddress",  SDTPtrLeaf, [],
280                           "GlobalAddressSDNode">;
281def constpool   : SDNode<"ISD::ConstantPool",         SDTPtrLeaf, [],
282                         "ConstantPoolSDNode">;
283def tconstpool  : SDNode<"ISD::TargetConstantPool",   SDTPtrLeaf, [],
284                         "ConstantPoolSDNode">;
285def jumptable   : SDNode<"ISD::JumpTable",            SDTPtrLeaf, [],
286                         "JumpTableSDNode">;
287def tjumptable  : SDNode<"ISD::TargetJumpTable",      SDTPtrLeaf, [],
288                         "JumpTableSDNode">;
289def frameindex  : SDNode<"ISD::FrameIndex",           SDTPtrLeaf, [],
290                         "FrameIndexSDNode">;
291def tframeindex : SDNode<"ISD::TargetFrameIndex",     SDTPtrLeaf, [],
292                         "FrameIndexSDNode">;
293def externalsym : SDNode<"ISD::ExternalSymbol",       SDTPtrLeaf, [],
294                         "ExternalSymbolSDNode">;
295def texternalsym: SDNode<"ISD::TargetExternalSymbol", SDTPtrLeaf, [],
296                         "ExternalSymbolSDNode">;
297def blockaddress : SDNode<"ISD::BlockAddress",        SDTPtrLeaf, [],
298                         "BlockAddressSDNode">;
299def tblockaddress: SDNode<"ISD::TargetBlockAddress",  SDTPtrLeaf, [],
300                         "BlockAddressSDNode">;
301
302def add        : SDNode<"ISD::ADD"       , SDTIntBinOp   ,
303                        [SDNPCommutative, SDNPAssociative]>;
304def sub        : SDNode<"ISD::SUB"       , SDTIntBinOp>;
305def mul        : SDNode<"ISD::MUL"       , SDTIntBinOp,
306                        [SDNPCommutative, SDNPAssociative]>;
307def mulhs      : SDNode<"ISD::MULHS"     , SDTIntBinOp, [SDNPCommutative]>;
308def mulhu      : SDNode<"ISD::MULHU"     , SDTIntBinOp, [SDNPCommutative]>;
309def smullohi   : SDNode<"ISD::SMUL_LOHI" , SDTIntBinHiLoOp, [SDNPCommutative]>;
310def umullohi   : SDNode<"ISD::UMUL_LOHI" , SDTIntBinHiLoOp, [SDNPCommutative]>;
311def sdiv       : SDNode<"ISD::SDIV"      , SDTIntBinOp>;
312def udiv       : SDNode<"ISD::UDIV"      , SDTIntBinOp>;
313def srem       : SDNode<"ISD::SREM"      , SDTIntBinOp>;
314def urem       : SDNode<"ISD::UREM"      , SDTIntBinOp>;
315def sdivrem    : SDNode<"ISD::SDIVREM"   , SDTIntBinHiLoOp>;
316def udivrem    : SDNode<"ISD::UDIVREM"   , SDTIntBinHiLoOp>;
317def srl        : SDNode<"ISD::SRL"       , SDTIntShiftOp>;
318def sra        : SDNode<"ISD::SRA"       , SDTIntShiftOp>;
319def shl        : SDNode<"ISD::SHL"       , SDTIntShiftOp>;
320def rotl       : SDNode<"ISD::ROTL"      , SDTIntShiftOp>;
321def rotr       : SDNode<"ISD::ROTR"      , SDTIntShiftOp>;
322def and        : SDNode<"ISD::AND"       , SDTIntBinOp,
323                        [SDNPCommutative, SDNPAssociative]>;
324def or         : SDNode<"ISD::OR"        , SDTIntBinOp,
325                        [SDNPCommutative, SDNPAssociative]>;
326def xor        : SDNode<"ISD::XOR"       , SDTIntBinOp,
327                        [SDNPCommutative, SDNPAssociative]>;
328def addc       : SDNode<"ISD::ADDC"      , SDTIntBinOp,
329                        [SDNPCommutative, SDNPOutGlue]>;
330def adde       : SDNode<"ISD::ADDE"      , SDTIntBinOp,
331                        [SDNPCommutative, SDNPOutGlue, SDNPInGlue]>;
332def subc       : SDNode<"ISD::SUBC"      , SDTIntBinOp,
333                        [SDNPOutGlue]>;
334def sube       : SDNode<"ISD::SUBE"      , SDTIntBinOp,
335                        [SDNPOutGlue, SDNPInGlue]>;
336
337def sext_inreg : SDNode<"ISD::SIGN_EXTEND_INREG", SDTExtInreg>;
338def bswap      : SDNode<"ISD::BSWAP"      , SDTIntUnaryOp>;
339def ctlz       : SDNode<"ISD::CTLZ"       , SDTIntUnaryOp>;
340def cttz       : SDNode<"ISD::CTTZ"       , SDTIntUnaryOp>;
341def ctpop      : SDNode<"ISD::CTPOP"      , SDTIntUnaryOp>;
342def sext       : SDNode<"ISD::SIGN_EXTEND", SDTIntExtendOp>;
343def zext       : SDNode<"ISD::ZERO_EXTEND", SDTIntExtendOp>;
344def anyext     : SDNode<"ISD::ANY_EXTEND" , SDTIntExtendOp>;
345def trunc      : SDNode<"ISD::TRUNCATE"   , SDTIntTruncOp>;
346def bitconvert : SDNode<"ISD::BITCAST"    , SDTUnaryOp>;
347def extractelt : SDNode<"ISD::EXTRACT_VECTOR_ELT", SDTVecExtract>;
348def insertelt  : SDNode<"ISD::INSERT_VECTOR_ELT", SDTVecInsert>;
349
350
351def fadd       : SDNode<"ISD::FADD"       , SDTFPBinOp, [SDNPCommutative]>;
352def fsub       : SDNode<"ISD::FSUB"       , SDTFPBinOp>;
353def fmul       : SDNode<"ISD::FMUL"       , SDTFPBinOp, [SDNPCommutative]>;
354def fdiv       : SDNode<"ISD::FDIV"       , SDTFPBinOp>;
355def frem       : SDNode<"ISD::FREM"       , SDTFPBinOp>;
356def fabs       : SDNode<"ISD::FABS"       , SDTFPUnaryOp>;
357def fneg       : SDNode<"ISD::FNEG"       , SDTFPUnaryOp>;
358def fsqrt      : SDNode<"ISD::FSQRT"      , SDTFPUnaryOp>;
359def fsin       : SDNode<"ISD::FSIN"       , SDTFPUnaryOp>;
360def fcos       : SDNode<"ISD::FCOS"       , SDTFPUnaryOp>;
361def fexp2      : SDNode<"ISD::FEXP2"      , SDTFPUnaryOp>;
362def flog2      : SDNode<"ISD::FLOG2"      , SDTFPUnaryOp>;
363def frint      : SDNode<"ISD::FRINT"      , SDTFPUnaryOp>;
364def ftrunc     : SDNode<"ISD::FTRUNC"     , SDTFPUnaryOp>;
365def fceil      : SDNode<"ISD::FCEIL"      , SDTFPUnaryOp>;
366def ffloor     : SDNode<"ISD::FFLOOR"     , SDTFPUnaryOp>;
367def fnearbyint : SDNode<"ISD::FNEARBYINT" , SDTFPUnaryOp>;
368
369def fround     : SDNode<"ISD::FP_ROUND"   , SDTFPRoundOp>;
370def fextend    : SDNode<"ISD::FP_EXTEND"  , SDTFPExtendOp>;
371def fcopysign  : SDNode<"ISD::FCOPYSIGN"  , SDTFPSignOp>;
372
373def sint_to_fp : SDNode<"ISD::SINT_TO_FP" , SDTIntToFPOp>;
374def uint_to_fp : SDNode<"ISD::UINT_TO_FP" , SDTIntToFPOp>;
375def fp_to_sint : SDNode<"ISD::FP_TO_SINT" , SDTFPToIntOp>;
376def fp_to_uint : SDNode<"ISD::FP_TO_UINT" , SDTFPToIntOp>;
377def f16_to_f32 : SDNode<"ISD::FP16_TO_FP32", SDTIntToFPOp>;
378def f32_to_f16 : SDNode<"ISD::FP32_TO_FP16", SDTFPToIntOp>;
379
380def setcc      : SDNode<"ISD::SETCC"      , SDTSetCC>;
381def select     : SDNode<"ISD::SELECT"     , SDTSelect>;
382def selectcc   : SDNode<"ISD::SELECT_CC"  , SDTSelectCC>;
383def vsetcc     : SDNode<"ISD::VSETCC"     , SDTSetCC>;
384
385def brcond     : SDNode<"ISD::BRCOND"     , SDTBrcond, [SDNPHasChain]>;
386def brind      : SDNode<"ISD::BRIND"      , SDTBrind,  [SDNPHasChain]>;
387def br         : SDNode<"ISD::BR"         , SDTBr,     [SDNPHasChain]>;
388def trap       : SDNode<"ISD::TRAP"       , SDTNone,
389                        [SDNPHasChain, SDNPSideEffect]>;
390
391def prefetch   : SDNode<"ISD::PREFETCH"   , SDTPrefetch,
392                        [SDNPHasChain, SDNPMayLoad, SDNPMayStore,
393                         SDNPMemOperand]>;
394
395def membarrier : SDNode<"ISD::MEMBARRIER" , SDTMemBarrier,
396                        [SDNPHasChain, SDNPSideEffect]>;
397
398def atomic_cmp_swap : SDNode<"ISD::ATOMIC_CMP_SWAP" , SDTAtomic3,
399                    [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
400def atomic_load_add : SDNode<"ISD::ATOMIC_LOAD_ADD" , SDTAtomic2,
401                    [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
402def atomic_swap     : SDNode<"ISD::ATOMIC_SWAP", SDTAtomic2,
403                    [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
404def atomic_load_sub : SDNode<"ISD::ATOMIC_LOAD_SUB" , SDTAtomic2,
405                    [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
406def atomic_load_and : SDNode<"ISD::ATOMIC_LOAD_AND" , SDTAtomic2,
407                    [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
408def atomic_load_or  : SDNode<"ISD::ATOMIC_LOAD_OR" , SDTAtomic2,
409                    [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
410def atomic_load_xor : SDNode<"ISD::ATOMIC_LOAD_XOR" , SDTAtomic2,
411                    [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
412def atomic_load_nand: SDNode<"ISD::ATOMIC_LOAD_NAND", SDTAtomic2,
413                    [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
414def atomic_load_min : SDNode<"ISD::ATOMIC_LOAD_MIN", SDTAtomic2,
415                    [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
416def atomic_load_max : SDNode<"ISD::ATOMIC_LOAD_MAX", SDTAtomic2,
417                    [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
418def atomic_load_umin : SDNode<"ISD::ATOMIC_LOAD_UMIN", SDTAtomic2,
419                    [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
420def atomic_load_umax : SDNode<"ISD::ATOMIC_LOAD_UMAX", SDTAtomic2,
421                    [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
422
423// Do not use ld, st directly. Use load, extload, sextload, zextload, store,
424// and truncst (see below).
425def ld         : SDNode<"ISD::LOAD"       , SDTLoad,
426                        [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
427def st         : SDNode<"ISD::STORE"      , SDTStore,
428                        [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
429def ist        : SDNode<"ISD::STORE"      , SDTIStore,
430                        [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
431
432def vector_shuffle : SDNode<"ISD::VECTOR_SHUFFLE", SDTVecShuffle, []>;
433def build_vector : SDNode<"ISD::BUILD_VECTOR", SDTypeProfile<1, -1, []>, []>;
434def scalar_to_vector : SDNode<"ISD::SCALAR_TO_VECTOR", SDTypeProfile<1, 1, []>,
435                              []>;
436def vector_extract : SDNode<"ISD::EXTRACT_VECTOR_ELT",
437    SDTypeProfile<1, 2, [SDTCisPtrTy<2>]>, []>;
438def vector_insert : SDNode<"ISD::INSERT_VECTOR_ELT",
439    SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisPtrTy<3>]>, []>;
440
441// This operator does not do subvector type checking.  The ARM
442// backend, at least, needs it.
443def vector_extract_subvec : SDNode<"ISD::EXTRACT_SUBVECTOR",
444    SDTypeProfile<1, 2, [SDTCisInt<2>, SDTCisVec<1>, SDTCisVec<0>]>, 
445    []>;
446
447// This operator does subvector type checking.
448def extract_subvector : SDNode<"ISD::EXTRACT_SUBVECTOR", SDTSubVecExtract, []>;
449def insert_subvector : SDNode<"ISD::INSERT_SUBVECTOR", SDTSubVecInsert, []>;
450
451// Nodes for intrinsics, you should use the intrinsic itself and let tblgen use
452// these internally.  Don't reference these directly.
453def intrinsic_void : SDNode<"ISD::INTRINSIC_VOID",
454                            SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>,
455                            [SDNPHasChain]>;
456def intrinsic_w_chain : SDNode<"ISD::INTRINSIC_W_CHAIN",
457                               SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>,
458                               [SDNPHasChain]>;
459def intrinsic_wo_chain : SDNode<"ISD::INTRINSIC_WO_CHAIN",
460                                SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>, []>;
461
462// Do not use cvt directly. Use cvt forms below
463def cvt : SDNode<"ISD::CONVERT_RNDSAT", SDTConvertOp>;
464
465//===----------------------------------------------------------------------===//
466// Selection DAG Condition Codes
467
468class CondCode; // ISD::CondCode enums
469def SETOEQ : CondCode; def SETOGT : CondCode;
470def SETOGE : CondCode; def SETOLT : CondCode; def SETOLE : CondCode;
471def SETONE : CondCode; def SETO   : CondCode; def SETUO  : CondCode;
472def SETUEQ : CondCode; def SETUGT : CondCode; def SETUGE : CondCode;
473def SETULT : CondCode; def SETULE : CondCode; def SETUNE : CondCode;
474
475def SETEQ : CondCode; def SETGT : CondCode; def SETGE : CondCode;
476def SETLT : CondCode; def SETLE : CondCode; def SETNE : CondCode;
477
478
479//===----------------------------------------------------------------------===//
480// Selection DAG Node Transformation Functions.
481//
482// This mechanism allows targets to manipulate nodes in the output DAG once a
483// match has been formed.  This is typically used to manipulate immediate
484// values.
485//
486class SDNodeXForm<SDNode opc, code xformFunction> {
487  SDNode Opcode = opc;
488  code XFormFunction = xformFunction;
489}
490
491def NOOP_SDNodeXForm : SDNodeXForm<imm, [{}]>;
492
493//===----------------------------------------------------------------------===//
494// PatPred Subclasses.
495//
496// These allow specifying different sorts of predicates that control whether a
497// node is matched.
498//
499class PatPred;
500
501class CodePatPred<code predicate> : PatPred {
502  code PredicateCode = predicate;
503}
504
505
506//===----------------------------------------------------------------------===//
507// Selection DAG Pattern Fragments.
508//
509// Pattern fragments are reusable chunks of dags that match specific things.
510// They can take arguments and have C++ predicates that control whether they
511// match.  They are intended to make the patterns for common instructions more
512// compact and readable.
513//
514
515/// PatFrag - Represents a pattern fragment.  This can match something on the
516/// DAG, from a single node to multiple nested other fragments.
517///
518class PatFrag<dag ops, dag frag, code pred = [{}],
519              SDNodeXForm xform = NOOP_SDNodeXForm> : SDPatternOperator {
520  dag Operands = ops;
521  dag Fragment = frag;
522  code PredicateCode = pred;
523  SDNodeXForm OperandTransform = xform;
524}
525
526// PatLeaf's are pattern fragments that have no operands.  This is just a helper
527// to define immediates and other common things concisely.
528class PatLeaf<dag frag, code pred = [{}], SDNodeXForm xform = NOOP_SDNodeXForm>
529 : PatFrag<(ops), frag, pred, xform>;
530
531// Leaf fragments.
532
533def vtInt      : PatLeaf<(vt),  [{ return N->getVT().isInteger(); }]>;
534def vtFP       : PatLeaf<(vt),  [{ return N->getVT().isFloatingPoint(); }]>;
535
536def immAllOnesV: PatLeaf<(build_vector), [{
537  return ISD::isBuildVectorAllOnes(N);
538}]>;
539def immAllZerosV: PatLeaf<(build_vector), [{
540  return ISD::isBuildVectorAllZeros(N);
541}]>;
542
543
544
545// Other helper fragments.
546def not  : PatFrag<(ops node:$in), (xor node:$in, -1)>;
547def vnot : PatFrag<(ops node:$in), (xor node:$in, immAllOnesV)>;
548def ineg : PatFrag<(ops node:$in), (sub 0, node:$in)>;
549
550// load fragments.
551def unindexedload : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
552  return cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
553}]>;
554def load : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{
555  return cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
556}]>;
557
558// extending load fragments.
559def extload   : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{
560  return cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
561}]>;
562def sextload  : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{
563  return cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
564}]>;
565def zextload  : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{
566  return cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
567}]>;
568
569def extloadi1  : PatFrag<(ops node:$ptr), (extload node:$ptr), [{
570  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i1;
571}]>;
572def extloadi8  : PatFrag<(ops node:$ptr), (extload node:$ptr), [{
573  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8;
574}]>;
575def extloadi16 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{
576  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16;
577}]>;
578def extloadi32 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{
579  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i32;
580}]>;
581def extloadf32 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{
582  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::f32;
583}]>;
584def extloadf64 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{
585  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::f64;
586}]>;
587
588def sextloadi1  : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{
589  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i1;
590}]>;
591def sextloadi8  : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{
592  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8;
593}]>;
594def sextloadi16 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{
595  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16;
596}]>;
597def sextloadi32 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{
598  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i32;
599}]>;
600
601def zextloadi1  : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{
602  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i1;
603}]>;
604def zextloadi8  : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{
605  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8;
606}]>;
607def zextloadi16 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{
608  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16;
609}]>;
610def zextloadi32 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{
611  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i32;
612}]>;
613
614// store fragments.
615def unindexedstore : PatFrag<(ops node:$val, node:$ptr),
616                             (st node:$val, node:$ptr), [{
617  return cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
618}]>;
619def store : PatFrag<(ops node:$val, node:$ptr),
620                    (unindexedstore node:$val, node:$ptr), [{
621  return !cast<StoreSDNode>(N)->isTruncatingStore();
622}]>;
623
624// truncstore fragments.
625def truncstore : PatFrag<(ops node:$val, node:$ptr),
626                         (unindexedstore node:$val, node:$ptr), [{
627  return cast<StoreSDNode>(N)->isTruncatingStore();
628}]>;
629def truncstorei8 : PatFrag<(ops node:$val, node:$ptr),
630                           (truncstore node:$val, node:$ptr), [{
631  return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i8;
632}]>;
633def truncstorei16 : PatFrag<(ops node:$val, node:$ptr),
634                            (truncstore node:$val, node:$ptr), [{
635  return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i16;
636}]>;
637def truncstorei32 : PatFrag<(ops node:$val, node:$ptr),
638                            (truncstore node:$val, node:$ptr), [{
639  return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i32;
640}]>;
641def truncstoref32 : PatFrag<(ops node:$val, node:$ptr),
642                            (truncstore node:$val, node:$ptr), [{
643  return cast<StoreSDNode>(N)->getMemoryVT() == MVT::f32;
644}]>;
645def truncstoref64 : PatFrag<(ops node:$val, node:$ptr),
646                            (truncstore node:$val, node:$ptr), [{
647  return cast<StoreSDNode>(N)->getMemoryVT() == MVT::f64;
648}]>;
649
650// indexed store fragments.
651def istore : PatFrag<(ops node:$val, node:$base, node:$offset),
652                     (ist node:$val, node:$base, node:$offset), [{
653  return !cast<StoreSDNode>(N)->isTruncatingStore();
654}]>;
655
656def pre_store : PatFrag<(ops node:$val, node:$base, node:$offset),
657                        (istore node:$val, node:$base, node:$offset), [{
658  ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
659  return AM == ISD::PRE_INC || AM == ISD::PRE_DEC;
660}]>;
661
662def itruncstore : PatFrag<(ops node:$val, node:$base, node:$offset),
663                          (ist node:$val, node:$base, node:$offset), [{
664  return cast<StoreSDNode>(N)->isTruncatingStore();
665}]>;
666def pre_truncst : PatFrag<(ops node:$val, node:$base, node:$offset),
667                          (itruncstore node:$val, node:$base, node:$offset), [{
668  ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
669  return AM == ISD::PRE_INC || AM == ISD::PRE_DEC;
670}]>;
671def pre_truncsti1 : PatFrag<(ops node:$val, node:$base, node:$offset),
672                            (pre_truncst node:$val, node:$base, node:$offset), [{
673  return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i1;
674}]>;
675def pre_truncsti8 : PatFrag<(ops node:$val, node:$base, node:$offset),
676                            (pre_truncst node:$val, node:$base, node:$offset), [{
677  return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i8;
678}]>;
679def pre_truncsti16 : PatFrag<(ops node:$val, node:$base, node:$offset),
680                             (pre_truncst node:$val, node:$base, node:$offset), [{
681  return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i16;
682}]>;
683def pre_truncsti32 : PatFrag<(ops node:$val, node:$base, node:$offset),
684                             (pre_truncst node:$val, node:$base, node:$offset), [{
685  return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i32;
686}]>;
687def pre_truncstf32 : PatFrag<(ops node:$val, node:$base, node:$offset),
688                             (pre_truncst node:$val, node:$base, node:$offset), [{
689  return cast<StoreSDNode>(N)->getMemoryVT() == MVT::f32;
690}]>;
691
692def post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
693                         (istore node:$val, node:$ptr, node:$offset), [{
694  ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
695  return AM == ISD::POST_INC || AM == ISD::POST_DEC;
696}]>;
697
698def post_truncst : PatFrag<(ops node:$val, node:$base, node:$offset),
699                           (itruncstore node:$val, node:$base, node:$offset), [{
700  ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
701  return AM == ISD::POST_INC || AM == ISD::POST_DEC;
702}]>;
703def post_truncsti1 : PatFrag<(ops node:$val, node:$base, node:$offset),
704                             (post_truncst node:$val, node:$base, node:$offset), [{
705  return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i1;
706}]>;
707def post_truncsti8 : PatFrag<(ops node:$val, node:$base, node:$offset),
708                             (post_truncst node:$val, node:$base, node:$offset), [{
709  return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i8;
710}]>;
711def post_truncsti16 : PatFrag<(ops node:$val, node:$base, node:$offset),
712                              (post_truncst node:$val, node:$base, node:$offset), [{
713  return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i16;
714}]>;
715def post_truncsti32 : PatFrag<(ops node:$val, node:$base, node:$offset),
716                              (post_truncst node:$val, node:$base, node:$offset), [{
717  return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i32;
718}]>;
719def post_truncstf32 : PatFrag<(ops node:$val, node:$base, node:$offset),
720                              (post_truncst node:$val, node:$base, node:$offset), [{
721  return cast<StoreSDNode>(N)->getMemoryVT() == MVT::f32;
722}]>;
723
724// setcc convenience fragments.
725def setoeq : PatFrag<(ops node:$lhs, node:$rhs),
726                     (setcc node:$lhs, node:$rhs, SETOEQ)>;
727def setogt : PatFrag<(ops node:$lhs, node:$rhs),
728                     (setcc node:$lhs, node:$rhs, SETOGT)>;
729def setoge : PatFrag<(ops node:$lhs, node:$rhs),
730                     (setcc node:$lhs, node:$rhs, SETOGE)>;
731def setolt : PatFrag<(ops node:$lhs, node:$rhs),
732                     (setcc node:$lhs, node:$rhs, SETOLT)>;
733def setole : PatFrag<(ops node:$lhs, node:$rhs),
734                     (setcc node:$lhs, node:$rhs, SETOLE)>;
735def setone : PatFrag<(ops node:$lhs, node:$rhs),
736                     (setcc node:$lhs, node:$rhs, SETONE)>;
737def seto   : PatFrag<(ops node:$lhs, node:$rhs),
738                     (setcc node:$lhs, node:$rhs, SETO)>;
739def setuo  : PatFrag<(ops node:$lhs, node:$rhs),
740                     (setcc node:$lhs, node:$rhs, SETUO)>;
741def setueq : PatFrag<(ops node:$lhs, node:$rhs),
742                     (setcc node:$lhs, node:$rhs, SETUEQ)>;
743def setugt : PatFrag<(ops node:$lhs, node:$rhs),
744                     (setcc node:$lhs, node:$rhs, SETUGT)>;
745def setuge : PatFrag<(ops node:$lhs, node:$rhs),
746                     (setcc node:$lhs, node:$rhs, SETUGE)>;
747def setult : PatFrag<(ops node:$lhs, node:$rhs),
748                     (setcc node:$lhs, node:$rhs, SETULT)>;
749def setule : PatFrag<(ops node:$lhs, node:$rhs),
750                     (setcc node:$lhs, node:$rhs, SETULE)>;
751def setune : PatFrag<(ops node:$lhs, node:$rhs),
752                     (setcc node:$lhs, node:$rhs, SETUNE)>;
753def seteq  : PatFrag<(ops node:$lhs, node:$rhs),
754                     (setcc node:$lhs, node:$rhs, SETEQ)>;
755def setgt  : PatFrag<(ops node:$lhs, node:$rhs),
756                     (setcc node:$lhs, node:$rhs, SETGT)>;
757def setge  : PatFrag<(ops node:$lhs, node:$rhs),
758                     (setcc node:$lhs, node:$rhs, SETGE)>;
759def setlt  : PatFrag<(ops node:$lhs, node:$rhs),
760                     (setcc node:$lhs, node:$rhs, SETLT)>;
761def setle  : PatFrag<(ops node:$lhs, node:$rhs),
762                     (setcc node:$lhs, node:$rhs, SETLE)>;
763def setne  : PatFrag<(ops node:$lhs, node:$rhs),
764                     (setcc node:$lhs, node:$rhs, SETNE)>;
765
766def atomic_cmp_swap_8 :
767  PatFrag<(ops node:$ptr, node:$cmp, node:$swap),
768          (atomic_cmp_swap node:$ptr, node:$cmp, node:$swap), [{
769  return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i8;
770}]>;
771def atomic_cmp_swap_16 :
772  PatFrag<(ops node:$ptr, node:$cmp, node:$swap),
773          (atomic_cmp_swap node:$ptr, node:$cmp, node:$swap), [{
774  return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i16;
775}]>;
776def atomic_cmp_swap_32 :
777  PatFrag<(ops node:$ptr, node:$cmp, node:$swap),
778          (atomic_cmp_swap node:$ptr, node:$cmp, node:$swap), [{
779  return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i32;
780}]>;
781def atomic_cmp_swap_64 :
782  PatFrag<(ops node:$ptr, node:$cmp, node:$swap),
783          (atomic_cmp_swap node:$ptr, node:$cmp, node:$swap), [{
784  return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i64;
785}]>;
786
787multiclass binary_atomic_op<SDNode atomic_op> {
788  def _8 : PatFrag<(ops node:$ptr, node:$val),
789                   (atomic_op node:$ptr, node:$val), [{
790    return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i8;
791  }]>;
792  def _16 : PatFrag<(ops node:$ptr, node:$val),
793                   (atomic_op node:$ptr, node:$val), [{
794    return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i16;
795  }]>;
796  def _32 : PatFrag<(ops node:$ptr, node:$val),
797                   (atomic_op node:$ptr, node:$val), [{
798    return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i32;
799  }]>;
800  def _64 : PatFrag<(ops node:$ptr, node:$val),
801                   (atomic_op node:$ptr, node:$val), [{
802    return cast<AtomicSDNode>(N)->getMemoryVT() == MVT::i64;
803  }]>;
804}
805
806defm atomic_load_add  : binary_atomic_op<atomic_load_add>;
807defm atomic_swap      : binary_atomic_op<atomic_swap>;
808defm atomic_load_sub  : binary_atomic_op<atomic_load_sub>;
809defm atomic_load_and  : binary_atomic_op<atomic_load_and>;
810defm atomic_load_or   : binary_atomic_op<atomic_load_or>;
811defm atomic_load_xor  : binary_atomic_op<atomic_load_xor>;
812defm atomic_load_nand : binary_atomic_op<atomic_load_nand>;
813defm atomic_load_min  : binary_atomic_op<atomic_load_min>;
814defm atomic_load_max  : binary_atomic_op<atomic_load_max>;
815defm atomic_load_umin : binary_atomic_op<atomic_load_umin>;
816defm atomic_load_umax : binary_atomic_op<atomic_load_umax>;
817
818//===----------------------------------------------------------------------===//
819// Selection DAG CONVERT_RNDSAT patterns
820
821def cvtff : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
822    (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
823       return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_FF;
824    }]>;
825
826def cvtss : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
827    (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
828       return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_SS;
829    }]>;
830
831def cvtsu : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
832    (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
833       return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_SU;
834    }]>;
835
836def cvtus : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
837    (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
838       return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_US;
839    }]>;
840
841def cvtuu : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
842    (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
843       return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_UU;
844    }]>;
845
846def cvtsf : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
847    (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
848       return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_SF;
849    }]>;
850
851def cvtuf : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
852    (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
853       return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_UF;
854    }]>;
855
856def cvtfs : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
857    (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
858       return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_FS;
859    }]>;
860
861def cvtfu : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
862    (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
863       return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_FU;
864    }]>;
865
866//===----------------------------------------------------------------------===//
867// Selection DAG Pattern Support.
868//
869// Patterns are what are actually matched against by the target-flavored
870// instruction selection DAG.  Instructions defined by the target implicitly
871// define patterns in most cases, but patterns can also be explicitly added when
872// an operation is defined by a sequence of instructions (e.g. loading a large
873// immediate value on RISC targets that do not support immediates as large as
874// their GPRs).
875//
876
877class Pattern<dag patternToMatch, list<dag> resultInstrs> {
878  dag             PatternToMatch  = patternToMatch;
879  list<dag>       ResultInstrs    = resultInstrs;
880  list<Predicate> Predicates      = [];  // See class Instruction in Target.td.
881  int             AddedComplexity = 0;   // See class Instruction in Target.td.
882}
883
884// Pat - A simple (but common) form of a pattern, which produces a simple result
885// not needing a full list.
886class Pat<dag pattern, dag result> : Pattern<pattern, [result]>;
887
888//===----------------------------------------------------------------------===//
889// Complex pattern definitions.
890//
891
892// Complex patterns, e.g. X86 addressing mode, requires pattern matching code
893// in C++. NumOperands is the number of operands returned by the select function;
894// SelectFunc is the name of the function used to pattern match the max. pattern;
895// RootNodes are the list of possible root nodes of the sub-dags to match.
896// e.g. X86 addressing mode - def addr : ComplexPattern<4, "SelectAddr", [add]>;
897//
898class ComplexPattern<ValueType ty, int numops, string fn,
899                     list<SDNode> roots = [], list<SDNodeProperty> props = []> {
900  ValueType Ty = ty;
901  int NumOperands = numops;
902  string SelectFunc = fn;
903  list<SDNode> RootNodes = roots;
904  list<SDNodeProperty> Properties = props;
905}
906