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