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