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