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