blob: c936f7af4c62e670a38f5ef7baf6b7e41b2a7b4f [file] [log] [blame]
Chris Lattner17f2cf02005-10-10 06:00:30 +00001//===- TargetSelectionDAG.td - Common code for DAG isels ---*- tablegen -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattner17f2cf02005-10-10 06:00:30 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file defines the target-independent interfaces used by SelectionDAG
11// instruction selection generators.
12//
13//===----------------------------------------------------------------------===//
14
15//===----------------------------------------------------------------------===//
16// Selection DAG Type Constraint definitions.
17//
18// Note that the semantics of these constraints are hard coded into tblgen. To
19// modify or add constraints, you have to hack tblgen.
20//
21
22class SDTypeConstraint<int opnum> {
23 int OperandNum = opnum;
24}
25
26// SDTCisVT - The specified operand has exactly this VT.
Chris Lattnerd8fe3b32005-12-09 22:58:42 +000027class SDTCisVT<int OpNum, ValueType vt> : SDTypeConstraint<OpNum> {
Chris Lattner17f2cf02005-10-10 06:00:30 +000028 ValueType VT = vt;
29}
30
Chris Lattnerd8fe3b32005-12-09 22:58:42 +000031class SDTCisPtrTy<int OpNum> : SDTypeConstraint<OpNum>;
32
Chris Lattner17f2cf02005-10-10 06:00:30 +000033// SDTCisInt - The specified operand is has integer type.
34class SDTCisInt<int OpNum> : SDTypeConstraint<OpNum>;
35
36// SDTCisFP - The specified operand is has floating point type.
Chris Lattnerd8fe3b32005-12-09 22:58:42 +000037class SDTCisFP<int OpNum> : SDTypeConstraint<OpNum>;
Chris Lattner17f2cf02005-10-10 06:00:30 +000038
39// SDTCisSameAs - The two specified operands have identical types.
40class 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.
46class SDTCisVTSmallerThanOp<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> {
47 int OtherOperandNum = OtherOp;
48}
49
Chris Lattner13664a62005-10-14 04:55:10 +000050class SDTCisOpSmallerThanOp<int SmallOp, int BigOp> : SDTypeConstraint<SmallOp>{
51 int BigOperandNum = BigOp;
52}
53
Chris Lattnerfa818d02006-03-20 05:40:45 +000054/// SDTCisIntVectorOfSameSize - This indicates that ThisOp and OtherOp are
Dan Gohman07a96762007-07-16 14:29:03 +000055/// vector types, and that ThisOp is the result of
Duncan Sands83ec4b62008-06-06 12:08:01 +000056/// MVT::getIntVectorWithNumElements with the number of elements
57/// that ThisOp has.
Chris Lattnerfa818d02006-03-20 05:40:45 +000058class SDTCisIntVectorOfSameSize<int ThisOp, int OtherOp>
59 : SDTypeConstraint<ThisOp> {
60 int OtherOpNum = OtherOp;
61}
62
Nate Begemanb5af3342008-02-09 01:37:05 +000063/// 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.
Dan Gohmane4c67cd2008-05-31 02:11:25 +000065class SDTCisEltOfVec<int ThisOp, int OtherOp>
Nate Begemanb5af3342008-02-09 01:37:05 +000066 : SDTypeConstraint<ThisOp> {
67 int OtherOpNum = OtherOp;
68}
69
Chris Lattner17f2cf02005-10-10 06:00:30 +000070//===----------------------------------------------------------------------===//
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.
80class 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.
Bill Wendling7ab1fc12008-10-31 21:26:08 +000088def SDTIntLeaf: SDTypeProfile<1, 0, [SDTCisInt<0>]>; // for 'imm'.
89def SDTFPLeaf : SDTypeProfile<1, 0, [SDTCisFP<0>]>; // for 'fpimm'.
90def SDTPtrLeaf: SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>; // for '&g'.
Evan Chengf8ac8142005-12-04 08:13:17 +000091def SDTOther : SDTypeProfile<1, 0, [SDTCisVT<0, OtherVT>]>; // for 'vt'.
Bill Wendling7ab1fc12008-10-31 21:26:08 +000092def SDTUNDEF : SDTypeProfile<1, 0, []>; // for 'undef'.
93def SDTUnaryOp : SDTypeProfile<1, 1, []>; // for bitconvert.
Chris Lattnerc29e1262006-03-16 01:29:53 +000094
Bill Wendling7ab1fc12008-10-31 21:26:08 +000095def SDTIntBinOp : SDTypeProfile<1, 2, [ // add, and, or, xor, udiv, etc.
Chris Lattner17f2cf02005-10-10 06:00:30 +000096 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<0>
97]>;
Chris Lattner68bfd9c2005-12-05 02:37:26 +000098def SDTIntShiftOp : SDTypeProfile<1, 2, [ // shl, sra, srl
99 SDTCisSameAs<0, 1>, SDTCisInt<0>, SDTCisInt<2>
100]>;
Chris Lattner17f2cf02005-10-10 06:00:30 +0000101def SDTFPBinOp : SDTypeProfile<1, 2, [ // fadd, fmul, etc.
102 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisFP<0>
103]>;
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000104def SDTFPSignOp : SDTypeProfile<1, 2, [ // fcopysign.
Andrew Lenharthd26b8f92006-03-09 17:47:22 +0000105 SDTCisSameAs<0, 1>, SDTCisFP<0>, SDTCisFP<2>
106]>;
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000107def SDTFPTernaryOp : SDTypeProfile<1, 3, [ // fmadd, fnmsub, etc.
Nate Begeman993aeb22005-12-13 22:55:22 +0000108 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>, SDTCisFP<0>
109]>;
Chris Lattner17f2cf02005-10-10 06:00:30 +0000110def SDTIntUnaryOp : SDTypeProfile<1, 1, [ // ctlz
111 SDTCisSameAs<0, 1>, SDTCisInt<0>
112]>;
Chris Lattner444215d2005-10-14 06:40:20 +0000113def SDTIntExtendOp : SDTypeProfile<1, 1, [ // sext, zext, anyext
114 SDTCisInt<0>, SDTCisInt<1>, SDTCisOpSmallerThanOp<1, 0>
115]>;
116def SDTIntTruncOp : SDTypeProfile<1, 1, [ // trunc
117 SDTCisInt<0>, SDTCisInt<1>, SDTCisOpSmallerThanOp<0, 1>
118]>;
Chris Lattner17f2cf02005-10-10 06:00:30 +0000119def SDTFPUnaryOp : SDTypeProfile<1, 1, [ // fneg, fsqrt, etc
120 SDTCisSameAs<0, 1>, SDTCisFP<0>
121]>;
Chris Lattner13664a62005-10-14 04:55:10 +0000122def SDTFPRoundOp : SDTypeProfile<1, 1, [ // fround
123 SDTCisFP<0>, SDTCisFP<1>, SDTCisOpSmallerThanOp<0, 1>
124]>;
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000125def SDTFPExtendOp : SDTypeProfile<1, 1, [ // fextend
Chris Lattner13664a62005-10-14 04:55:10 +0000126 SDTCisFP<0>, SDTCisFP<1>, SDTCisOpSmallerThanOp<1, 0>
127]>;
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000128def SDTIntToFPOp : SDTypeProfile<1, 1, [ // [su]int_to_fp
Duraid Madinae2fd9e22005-11-01 03:07:25 +0000129 SDTCisFP<0>, SDTCisInt<1>
130]>;
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000131def SDTFPToIntOp : SDTypeProfile<1, 1, [ // fp_to_[su]int
Duraid Madinae2fd9e22005-11-01 03:07:25 +0000132 SDTCisInt<0>, SDTCisFP<1>
133]>;
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000134def SDTExtInreg : SDTypeProfile<1, 2, [ // sext_inreg
Chris Lattner17f2cf02005-10-10 06:00:30 +0000135 SDTCisSameAs<0, 1>, SDTCisInt<0>, SDTCisVT<2, OtherVT>,
136 SDTCisVTSmallerThanOp<2, 1>
137]>;
138
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000139def SDTSetCC : SDTypeProfile<1, 3, [ // setcc
Chris Lattner1f426de2005-10-26 17:00:25 +0000140 SDTCisInt<0>, SDTCisSameAs<1, 2>, SDTCisVT<3, OtherVT>
141]>;
142
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000143def SDTSelect : SDTypeProfile<1, 3, [ // select
Duraid Madina59669552005-11-02 02:37:18 +0000144 SDTCisInt<1>, SDTCisSameAs<0, 2>, SDTCisSameAs<2, 3>
145]>;
146
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000147def SDTSelectCC : SDTypeProfile<1, 5, [ // select_cc
Chris Lattner3aed79e2005-12-11 08:35:54 +0000148 SDTCisSameAs<1, 2>, SDTCisSameAs<3, 4>, SDTCisSameAs<0, 3>,
149 SDTCisVT<5, OtherVT>
150]>;
151
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000152def SDTBr : SDTypeProfile<0, 1, [ // br
Evan Chengf8ac8142005-12-04 08:13:17 +0000153 SDTCisVT<0, OtherVT>
154]>;
155
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000156def SDTBrcond : SDTypeProfile<0, 2, [ // brcond
Andrew Lenharth993ff1c2006-01-01 22:16:43 +0000157 SDTCisInt<0>, SDTCisVT<1, OtherVT>
158]>;
159
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000160def SDTBrind : SDTypeProfile<0, 1, [ // brind
Nate Begeman37efe672006-04-22 18:53:45 +0000161 SDTCisPtrTy<0>
162]>;
163
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000164def SDTNone : SDTypeProfile<0, 0, []>; // ret, trap
Evan Chengf8ac8142005-12-04 08:13:17 +0000165
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000166def SDTLoad : SDTypeProfile<1, 1, [ // load
Chris Lattnerd8fe3b32005-12-09 22:58:42 +0000167 SDTCisPtrTy<1>
Evan Chengf20da7e2005-12-08 04:28:48 +0000168]>;
169
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000170def SDTStore : SDTypeProfile<0, 2, [ // store
Evan Chengb612ff92005-12-10 01:59:36 +0000171 SDTCisPtrTy<1>
Evan Chengb51a0592005-12-10 00:48:20 +0000172]>;
173
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000174def SDTIStore : SDTypeProfile<1, 3, [ // indexed store
Evan Cheng81fd6072006-11-08 23:02:11 +0000175 SDTCisSameAs<0, 2>, SDTCisPtrTy<0>, SDTCisPtrTy<3>
176]>;
177
Chris Lattnerfa818d02006-03-20 05:40:45 +0000178def SDTVecShuffle : SDTypeProfile<1, 3, [
179 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisIntVectorOfSameSize<3, 0>
180]>;
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000181def SDTVecExtract : SDTypeProfile<1, 2, [ // vector extract
Nate Begemanb5af3342008-02-09 01:37:05 +0000182 SDTCisEltOfVec<0, 1>, SDTCisPtrTy<2>
183]>;
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000184def SDTVecInsert : SDTypeProfile<1, 3, [ // vector insert
Nate Begeman14d12ca2008-02-11 04:19:36 +0000185 SDTCisEltOfVec<2, 1>, SDTCisSameAs<0, 1>, SDTCisPtrTy<3>
Nate Begemanb5af3342008-02-09 01:37:05 +0000186]>;
Chris Lattnerfa818d02006-03-20 05:40:45 +0000187
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000188def STDPrefetch : SDTypeProfile<0, 3, [ // prefetch
Evan Cheng27b7db52008-03-08 00:58:38 +0000189 SDTCisPtrTy<0>, SDTCisSameAs<1, 2>, SDTCisInt<1>
190]>;
191
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000192def STDMemBarrier : SDTypeProfile<0, 5, [ // memory barier
Andrew Lenharth22c5c1b2008-02-16 01:24:58 +0000193 SDTCisSameAs<0,1>, SDTCisSameAs<0,2>, SDTCisSameAs<0,3>, SDTCisSameAs<0,4>,
194 SDTCisInt<0>
195]>;
Andrew Lenharthab0b9492008-02-21 06:45:13 +0000196def STDAtomic3 : SDTypeProfile<1, 3, [
197 SDTCisSameAs<0,2>, SDTCisSameAs<0,3>, SDTCisInt<0>, SDTCisPtrTy<1>
198]>;
199def STDAtomic2 : SDTypeProfile<1, 2, [
200 SDTCisSameAs<0,2>, SDTCisInt<0>, SDTCisPtrTy<1>
201]>;
Andrew Lenharth22c5c1b2008-02-16 01:24:58 +0000202
Mon P Wang77cdf302008-11-10 20:54:11 +0000203def SDTConvertOp : SDTypeProfile<1, 5, [ //cvtss, su, us, uu, ff, fs, fu, sf, su
204 SDTCisVT<2, OtherVT>, SDTCisVT<3, OtherVT>, SDTCisPtrTy<4>, SDTCisPtrTy<5>
205]>;
206
Bill Wendlingc69107c2007-11-13 09:19:02 +0000207class SDCallSeqStart<list<SDTypeConstraint> constraints> :
208 SDTypeProfile<0, 1, constraints>;
209class SDCallSeqEnd<list<SDTypeConstraint> constraints> :
210 SDTypeProfile<0, 2, constraints>;
211
Chris Lattner17f2cf02005-10-10 06:00:30 +0000212//===----------------------------------------------------------------------===//
213// Selection DAG Node Properties.
214//
215// Note: These are hard coded into tblgen.
216//
217class SDNodeProperty;
218def SDNPCommutative : SDNodeProperty; // X op Y == Y op X
219def SDNPAssociative : SDNodeProperty; // (X op Y) op Z == X op (Y op Z)
Evan Chengf8ac8142005-12-04 08:13:17 +0000220def SDNPHasChain : SDNodeProperty; // R/W chain operand and result
Evan Cheng6da8d992006-01-09 18:28:21 +0000221def SDNPOutFlag : SDNodeProperty; // Write a flag result
222def SDNPInFlag : SDNodeProperty; // Read a flag operand
223def SDNPOptInFlag : SDNodeProperty; // Optionally read a flag operand
Chris Lattner2e48a702008-01-06 08:36:04 +0000224def SDNPMayStore : SDNodeProperty; // May write to memory, sets 'mayStore'.
Chris Lattner8947dd52008-01-10 04:44:32 +0000225def SDNPMayLoad : SDNodeProperty; // May read memory, sets 'mayLoad'.
Chris Lattnerb8f217f2008-01-10 05:48:23 +0000226def SDNPSideEffect : SDNodeProperty; // Sets 'HasUnmodelledSideEffects'.
Mon P Wang28873102008-06-25 08:15:39 +0000227def SDNPMemOperand : SDNodeProperty; // Touches memory, has assoc MemOperand
Chris Lattner17f2cf02005-10-10 06:00:30 +0000228
229//===----------------------------------------------------------------------===//
230// Selection DAG Node definitions.
231//
232class SDNode<string opcode, SDTypeProfile typeprof,
233 list<SDNodeProperty> props = [], string sdclass = "SDNode"> {
234 string Opcode = opcode;
235 string SDClass = sdclass;
236 list<SDNodeProperty> Properties = props;
237 SDTypeProfile TypeProfile = typeprof;
238}
239
240def set;
Evan Chengd23aa5a2007-09-25 01:48:59 +0000241def implicit;
Evan Cheng85dbe1a2007-09-12 23:30:14 +0000242def parallel;
Chris Lattner17f2cf02005-10-10 06:00:30 +0000243def node;
Evan Cheng3d2331d2005-12-14 02:21:01 +0000244def srcvalue;
Chris Lattner17f2cf02005-10-10 06:00:30 +0000245
Chris Lattner84384542005-12-11 07:45:04 +0000246def imm : SDNode<"ISD::Constant" , SDTIntLeaf , [], "ConstantSDNode">;
Bill Wendling7ab1fc12008-10-31 21:26:08 +0000247def timm : SDNode<"ISD::TargetConstant",SDTIntLeaf, [], "ConstantSDNode">;
Nate Begemane1795842008-02-14 08:57:00 +0000248def fpimm : SDNode<"ISD::ConstantFP", SDTFPLeaf , [], "ConstantFPSDNode">;
Evan Chengf8ac8142005-12-04 08:13:17 +0000249def vt : SDNode<"ISD::VALUETYPE" , SDTOther , [], "VTSDNode">;
250def bb : SDNode<"ISD::BasicBlock", SDTOther , [], "BasicBlockSDNode">;
251def cond : SDNode<"ISD::CONDCODE" , SDTOther , [], "CondCodeSDNode">;
Chris Lattner97898262005-10-25 21:03:14 +0000252def undef : SDNode<"ISD::UNDEF" , SDTUNDEF , []>;
Andrew Lenharth330851a2005-12-24 23:36:59 +0000253def globaladdr : SDNode<"ISD::GlobalAddress", SDTPtrLeaf, [],
Chris Lattnerdb40dc22005-11-17 07:20:15 +0000254 "GlobalAddressSDNode">;
Andrew Lenharth330851a2005-12-24 23:36:59 +0000255def tglobaladdr : SDNode<"ISD::TargetGlobalAddress", SDTPtrLeaf, [],
256 "GlobalAddressSDNode">;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000257def globaltlsaddr : SDNode<"ISD::GlobalTLSAddress", SDTPtrLeaf, [],
258 "GlobalAddressSDNode">;
259def tglobaltlsaddr : SDNode<"ISD::TargetGlobalTLSAddress", SDTPtrLeaf, [],
260 "GlobalAddressSDNode">;
Andrew Lenharth330851a2005-12-24 23:36:59 +0000261def constpool : SDNode<"ISD::ConstantPool", SDTPtrLeaf, [],
262 "ConstantPoolSDNode">;
263def tconstpool : SDNode<"ISD::TargetConstantPool", SDTPtrLeaf, [],
264 "ConstantPoolSDNode">;
Nate Begeman37efe672006-04-22 18:53:45 +0000265def jumptable : SDNode<"ISD::JumpTable", SDTPtrLeaf, [],
266 "JumpTableSDNode">;
267def tjumptable : SDNode<"ISD::TargetJumpTable", SDTPtrLeaf, [],
268 "JumpTableSDNode">;
Andrew Lenharth330851a2005-12-24 23:36:59 +0000269def frameindex : SDNode<"ISD::FrameIndex", SDTPtrLeaf, [],
270 "FrameIndexSDNode">;
271def tframeindex : SDNode<"ISD::TargetFrameIndex", SDTPtrLeaf, [],
272 "FrameIndexSDNode">;
Bill Wendling056292f2008-09-16 21:48:12 +0000273def externalsym : SDNode<"ISD::ExternalSymbol", SDTPtrLeaf, [],
274 "ExternalSymbolSDNode">;
275def texternalsym: SDNode<"ISD::TargetExternalSymbol", SDTPtrLeaf, [],
276 "ExternalSymbolSDNode">;
Andrew Lenharth330851a2005-12-24 23:36:59 +0000277
Chris Lattner17f2cf02005-10-10 06:00:30 +0000278def add : SDNode<"ISD::ADD" , SDTIntBinOp ,
279 [SDNPCommutative, SDNPAssociative]>;
280def sub : SDNode<"ISD::SUB" , SDTIntBinOp>;
281def mul : SDNode<"ISD::MUL" , SDTIntBinOp,
282 [SDNPCommutative, SDNPAssociative]>;
283def mulhs : SDNode<"ISD::MULHS" , SDTIntBinOp, [SDNPCommutative]>;
284def mulhu : SDNode<"ISD::MULHU" , SDTIntBinOp, [SDNPCommutative]>;
285def sdiv : SDNode<"ISD::SDIV" , SDTIntBinOp>;
286def udiv : SDNode<"ISD::UDIV" , SDTIntBinOp>;
287def srem : SDNode<"ISD::SREM" , SDTIntBinOp>;
288def urem : SDNode<"ISD::UREM" , SDTIntBinOp>;
Chris Lattner68bfd9c2005-12-05 02:37:26 +0000289def srl : SDNode<"ISD::SRL" , SDTIntShiftOp>;
290def sra : SDNode<"ISD::SRA" , SDTIntShiftOp>;
291def shl : SDNode<"ISD::SHL" , SDTIntShiftOp>;
Nate Begeman35ef9132006-01-11 21:21:00 +0000292def rotl : SDNode<"ISD::ROTL" , SDTIntShiftOp>;
293def rotr : SDNode<"ISD::ROTR" , SDTIntShiftOp>;
Chris Lattner17f2cf02005-10-10 06:00:30 +0000294def and : SDNode<"ISD::AND" , SDTIntBinOp,
295 [SDNPCommutative, SDNPAssociative]>;
296def or : SDNode<"ISD::OR" , SDTIntBinOp,
297 [SDNPCommutative, SDNPAssociative]>;
298def xor : SDNode<"ISD::XOR" , SDTIntBinOp,
299 [SDNPCommutative, SDNPAssociative]>;
Nate Begeman551bf3f2006-02-17 05:43:56 +0000300def addc : SDNode<"ISD::ADDC" , SDTIntBinOp,
301 [SDNPCommutative, SDNPOutFlag]>;
302def adde : SDNode<"ISD::ADDE" , SDTIntBinOp,
303 [SDNPCommutative, SDNPOutFlag, SDNPInFlag]>;
304def subc : SDNode<"ISD::SUBC" , SDTIntBinOp,
305 [SDNPOutFlag]>;
306def sube : SDNode<"ISD::SUBE" , SDTIntBinOp,
307 [SDNPOutFlag, SDNPInFlag]>;
Chris Lattner444215d2005-10-14 06:40:20 +0000308
309def sext_inreg : SDNode<"ISD::SIGN_EXTEND_INREG", SDTExtInreg>;
Nate Begemand88fc032006-01-14 03:14:10 +0000310def bswap : SDNode<"ISD::BSWAP" , SDTIntUnaryOp>;
Chris Lattner444215d2005-10-14 06:40:20 +0000311def ctlz : SDNode<"ISD::CTLZ" , SDTIntUnaryOp>;
Andrew Lenharthd684e1a2005-10-20 19:38:11 +0000312def cttz : SDNode<"ISD::CTTZ" , SDTIntUnaryOp>;
313def ctpop : SDNode<"ISD::CTPOP" , SDTIntUnaryOp>;
Chris Lattner444215d2005-10-14 06:40:20 +0000314def sext : SDNode<"ISD::SIGN_EXTEND", SDTIntExtendOp>;
315def zext : SDNode<"ISD::ZERO_EXTEND", SDTIntExtendOp>;
316def anyext : SDNode<"ISD::ANY_EXTEND" , SDTIntExtendOp>;
317def trunc : SDNode<"ISD::TRUNCATE" , SDTIntTruncOp>;
Chris Lattnerc29e1262006-03-16 01:29:53 +0000318def bitconvert : SDNode<"ISD::BIT_CONVERT", SDTUnaryOp>;
Nate Begemanb5af3342008-02-09 01:37:05 +0000319def extractelt : SDNode<"ISD::EXTRACT_VECTOR_ELT", SDTVecExtract>;
320def insertelt : SDNode<"ISD::INSERT_VECTOR_ELT", SDTVecInsert>;
321
Chris Lattner444215d2005-10-14 06:40:20 +0000322
Chris Lattner17f2cf02005-10-10 06:00:30 +0000323def fadd : SDNode<"ISD::FADD" , SDTFPBinOp, [SDNPCommutative]>;
324def fsub : SDNode<"ISD::FSUB" , SDTFPBinOp>;
325def fmul : SDNode<"ISD::FMUL" , SDTFPBinOp, [SDNPCommutative]>;
326def fdiv : SDNode<"ISD::FDIV" , SDTFPBinOp>;
327def frem : SDNode<"ISD::FREM" , SDTFPBinOp>;
328def fabs : SDNode<"ISD::FABS" , SDTFPUnaryOp>;
329def fneg : SDNode<"ISD::FNEG" , SDTFPUnaryOp>;
330def fsqrt : SDNode<"ISD::FSQRT" , SDTFPUnaryOp>;
Chris Lattner5c82f4d2005-12-21 16:22:46 +0000331def fsin : SDNode<"ISD::FSIN" , SDTFPUnaryOp>;
332def fcos : SDNode<"ISD::FCOS" , SDTFPUnaryOp>;
Dan Gohman509e84f2008-08-21 17:55:02 +0000333def frint : SDNode<"ISD::FRINT" , SDTFPUnaryOp>;
334def ftrunc : SDNode<"ISD::FTRUNC" , SDTFPUnaryOp>;
335def fceil : SDNode<"ISD::FCEIL" , SDTFPUnaryOp>;
336def ffloor : SDNode<"ISD::FFLOOR" , SDTFPUnaryOp>;
337def fnearbyint : SDNode<"ISD::FNEARBYINT" , SDTFPUnaryOp>;
Chris Lattner17f2cf02005-10-10 06:00:30 +0000338
Chris Lattner13664a62005-10-14 04:55:10 +0000339def fround : SDNode<"ISD::FP_ROUND" , SDTFPRoundOp>;
340def fextend : SDNode<"ISD::FP_EXTEND" , SDTFPExtendOp>;
Andrew Lenharthd26b8f92006-03-09 17:47:22 +0000341def fcopysign : SDNode<"ISD::FCOPYSIGN" , SDTFPSignOp>;
Chris Lattner13664a62005-10-14 04:55:10 +0000342
Duraid Madinae2fd9e22005-11-01 03:07:25 +0000343def sint_to_fp : SDNode<"ISD::SINT_TO_FP" , SDTIntToFPOp>;
344def uint_to_fp : SDNode<"ISD::UINT_TO_FP" , SDTIntToFPOp>;
345def fp_to_sint : SDNode<"ISD::FP_TO_SINT" , SDTFPToIntOp>;
346def fp_to_uint : SDNode<"ISD::FP_TO_UINT" , SDTFPToIntOp>;
347
Chris Lattner1f426de2005-10-26 17:00:25 +0000348def setcc : SDNode<"ISD::SETCC" , SDTSetCC>;
Duraid Madina59669552005-11-02 02:37:18 +0000349def select : SDNode<"ISD::SELECT" , SDTSelect>;
Chris Lattner3aed79e2005-12-11 08:35:54 +0000350def selectcc : SDNode<"ISD::SELECT_CC" , SDTSelectCC>;
Nate Begemanb43e9c12008-05-12 19:40:03 +0000351def vsetcc : SDNode<"ISD::VSETCC" , SDTSetCC>;
Chris Lattner1f426de2005-10-26 17:00:25 +0000352
Andrew Lenharth993ff1c2006-01-01 22:16:43 +0000353def brcond : SDNode<"ISD::BRCOND" , SDTBrcond, [SDNPHasChain]>;
Nate Begeman37efe672006-04-22 18:53:45 +0000354def brind : SDNode<"ISD::BRIND" , SDTBrind, [SDNPHasChain]>;
Evan Chengf8ac8142005-12-04 08:13:17 +0000355def br : SDNode<"ISD::BR" , SDTBr, [SDNPHasChain]>;
Chris Lattner48be23c2008-01-15 22:02:54 +0000356def ret : SDNode<"ISD::RET" , SDTNone, [SDNPHasChain]>;
357def trap : SDNode<"ISD::TRAP" , SDTNone,
358 [SDNPHasChain, SDNPSideEffect]>;
Evan Cheng27b7db52008-03-08 00:58:38 +0000359
360def prefetch : SDNode<"ISD::PREFETCH" , STDPrefetch,
361 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
362
363def membarrier : SDNode<"ISD::MEMBARRIER" , STDMemBarrier,
Andrew Lenharth22c5c1b2008-02-16 01:24:58 +0000364 [SDNPHasChain, SDNPSideEffect]>;
Evan Cheng27b7db52008-03-08 00:58:38 +0000365
Dale Johannesene00a8a22008-08-28 02:44:49 +0000366def atomic_cmp_swap_8 : SDNode<"ISD::ATOMIC_CMP_SWAP_8" , STDAtomic3,
Mon P Wang28873102008-06-25 08:15:39 +0000367 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesene00a8a22008-08-28 02:44:49 +0000368def atomic_load_add_8 : SDNode<"ISD::ATOMIC_LOAD_ADD_8" , STDAtomic2,
Mon P Wang28873102008-06-25 08:15:39 +0000369 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesene00a8a22008-08-28 02:44:49 +0000370def atomic_swap_8 : SDNode<"ISD::ATOMIC_SWAP_8", STDAtomic2,
Bill Wendling108ecf32008-08-19 23:09:18 +0000371 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesene00a8a22008-08-28 02:44:49 +0000372def atomic_load_sub_8 : SDNode<"ISD::ATOMIC_LOAD_SUB_8" , STDAtomic2,
Bill Wendling5bf1b4e2008-08-20 00:28:16 +0000373 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesene00a8a22008-08-28 02:44:49 +0000374def atomic_load_and_8 : SDNode<"ISD::ATOMIC_LOAD_AND_8" , STDAtomic2,
Mon P Wang28873102008-06-25 08:15:39 +0000375 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesene00a8a22008-08-28 02:44:49 +0000376def atomic_load_or_8 : SDNode<"ISD::ATOMIC_LOAD_OR_8" , STDAtomic2,
Mon P Wang28873102008-06-25 08:15:39 +0000377 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesene00a8a22008-08-28 02:44:49 +0000378def atomic_load_xor_8 : SDNode<"ISD::ATOMIC_LOAD_XOR_8" , STDAtomic2,
Mon P Wang28873102008-06-25 08:15:39 +0000379 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesene00a8a22008-08-28 02:44:49 +0000380def atomic_load_nand_8: SDNode<"ISD::ATOMIC_LOAD_NAND_8", STDAtomic2,
Mon P Wang28873102008-06-25 08:15:39 +0000381 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesene00a8a22008-08-28 02:44:49 +0000382def atomic_load_min_8 : SDNode<"ISD::ATOMIC_LOAD_MIN_8", STDAtomic2,
Mon P Wang28873102008-06-25 08:15:39 +0000383 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesene00a8a22008-08-28 02:44:49 +0000384def atomic_load_max_8 : SDNode<"ISD::ATOMIC_LOAD_MAX_8", STDAtomic2,
Mon P Wang28873102008-06-25 08:15:39 +0000385 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesene00a8a22008-08-28 02:44:49 +0000386def atomic_load_umin_8 : SDNode<"ISD::ATOMIC_LOAD_UMIN_8", STDAtomic2,
Mon P Wang28873102008-06-25 08:15:39 +0000387 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesene00a8a22008-08-28 02:44:49 +0000388def atomic_load_umax_8 : SDNode<"ISD::ATOMIC_LOAD_UMAX_8", STDAtomic2,
389 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
390def atomic_cmp_swap_16 : SDNode<"ISD::ATOMIC_CMP_SWAP_16" , STDAtomic3,
391 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
392def atomic_load_add_16 : SDNode<"ISD::ATOMIC_LOAD_ADD_16" , STDAtomic2,
393 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
394def atomic_swap_16 : SDNode<"ISD::ATOMIC_SWAP_16", STDAtomic2,
395 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
396def atomic_load_sub_16 : SDNode<"ISD::ATOMIC_LOAD_SUB_16" , STDAtomic2,
397 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
398def atomic_load_and_16 : SDNode<"ISD::ATOMIC_LOAD_AND_16" , STDAtomic2,
399 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
400def atomic_load_or_16 : SDNode<"ISD::ATOMIC_LOAD_OR_16" , STDAtomic2,
401 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
402def atomic_load_xor_16 : SDNode<"ISD::ATOMIC_LOAD_XOR_16" , STDAtomic2,
403 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
404def atomic_load_nand_16: SDNode<"ISD::ATOMIC_LOAD_NAND_16", STDAtomic2,
405 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
406def atomic_load_min_16 : SDNode<"ISD::ATOMIC_LOAD_MIN_16", STDAtomic2,
407 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
408def atomic_load_max_16 : SDNode<"ISD::ATOMIC_LOAD_MAX_16", STDAtomic2,
409 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
410def atomic_load_umin_16 : SDNode<"ISD::ATOMIC_LOAD_UMIN_16", STDAtomic2,
411 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
412def atomic_load_umax_16 : SDNode<"ISD::ATOMIC_LOAD_UMAX_16", STDAtomic2,
413 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
414def atomic_cmp_swap_32 : SDNode<"ISD::ATOMIC_CMP_SWAP_32" , STDAtomic3,
415 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
416def atomic_load_add_32 : SDNode<"ISD::ATOMIC_LOAD_ADD_32" , STDAtomic2,
417 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
418def atomic_swap_32 : SDNode<"ISD::ATOMIC_SWAP_32", STDAtomic2,
419 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
420def atomic_load_sub_32 : SDNode<"ISD::ATOMIC_LOAD_SUB_32" , STDAtomic2,
421 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
422def atomic_load_and_32 : SDNode<"ISD::ATOMIC_LOAD_AND_32" , STDAtomic2,
423 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
424def atomic_load_or_32 : SDNode<"ISD::ATOMIC_LOAD_OR_32" , STDAtomic2,
425 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
426def atomic_load_xor_32 : SDNode<"ISD::ATOMIC_LOAD_XOR_32" , STDAtomic2,
427 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
428def atomic_load_nand_32: SDNode<"ISD::ATOMIC_LOAD_NAND_32", STDAtomic2,
429 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
430def atomic_load_min_32 : SDNode<"ISD::ATOMIC_LOAD_MIN_32", STDAtomic2,
431 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
432def atomic_load_max_32 : SDNode<"ISD::ATOMIC_LOAD_MAX_32", STDAtomic2,
433 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
434def atomic_load_umin_32 : SDNode<"ISD::ATOMIC_LOAD_UMIN_32", STDAtomic2,
435 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
436def atomic_load_umax_32 : SDNode<"ISD::ATOMIC_LOAD_UMAX_32", STDAtomic2,
437 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
438def atomic_cmp_swap_64 : SDNode<"ISD::ATOMIC_CMP_SWAP_64" , STDAtomic3,
439 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
440def atomic_load_add_64 : SDNode<"ISD::ATOMIC_LOAD_ADD_64" , STDAtomic2,
441 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
442def atomic_swap_64 : SDNode<"ISD::ATOMIC_SWAP_64", STDAtomic2,
443 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
444def atomic_load_sub_64 : SDNode<"ISD::ATOMIC_LOAD_SUB_64" , STDAtomic2,
445 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
446def atomic_load_and_64 : SDNode<"ISD::ATOMIC_LOAD_AND_64" , STDAtomic2,
447 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
448def atomic_load_or_64 : SDNode<"ISD::ATOMIC_LOAD_OR_64" , STDAtomic2,
449 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
450def atomic_load_xor_64 : SDNode<"ISD::ATOMIC_LOAD_XOR_64" , STDAtomic2,
451 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
452def atomic_load_nand_64: SDNode<"ISD::ATOMIC_LOAD_NAND_64", STDAtomic2,
453 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
454def atomic_load_min_64 : SDNode<"ISD::ATOMIC_LOAD_MIN_64", STDAtomic2,
455 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
456def atomic_load_max_64 : SDNode<"ISD::ATOMIC_LOAD_MAX_64", STDAtomic2,
457 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
458def atomic_load_umin_64 : SDNode<"ISD::ATOMIC_LOAD_UMIN_64", STDAtomic2,
459 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
460def atomic_load_umax_64 : SDNode<"ISD::ATOMIC_LOAD_UMAX_64", STDAtomic2,
Mon P Wang28873102008-06-25 08:15:39 +0000461 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
Evan Chengf8ac8142005-12-04 08:13:17 +0000462
Evan Cheng8b2794a2006-10-13 21:14:26 +0000463// Do not use ld, st directly. Use load, extload, sextload, zextload, store,
464// and truncst (see below).
Chris Lattner8947dd52008-01-10 04:44:32 +0000465def ld : SDNode<"ISD::LOAD" , SDTLoad,
Mon P Wang28873102008-06-25 08:15:39 +0000466 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
Chris Lattnerc8478d82008-01-06 06:44:58 +0000467def st : SDNode<"ISD::STORE" , SDTStore,
Mon P Wang28873102008-06-25 08:15:39 +0000468 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
Chris Lattnerc8478d82008-01-06 06:44:58 +0000469def ist : SDNode<"ISD::STORE" , SDTIStore,
Mon P Wang28873102008-06-25 08:15:39 +0000470 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
Evan Cheng3d2331d2005-12-14 02:21:01 +0000471
Chris Lattnerfa818d02006-03-20 05:40:45 +0000472def vector_shuffle : SDNode<"ISD::VECTOR_SHUFFLE", SDTVecShuffle, []>;
Duncan Sands53388fc2008-07-28 19:17:21 +0000473def build_vector : SDNode<"ISD::BUILD_VECTOR", SDTypeProfile<1, -1, []>, []>;
Evan Cheng811ec1c2006-03-21 00:33:35 +0000474def scalar_to_vector : SDNode<"ISD::SCALAR_TO_VECTOR", SDTypeProfile<1, 1, []>,
475 []>;
Evan Cheng1eda6e72006-03-31 19:21:16 +0000476def vector_extract : SDNode<"ISD::EXTRACT_VECTOR_ELT",
Evan Cheng31f7be92006-06-15 08:19:05 +0000477 SDTypeProfile<1, 2, [SDTCisPtrTy<2>]>, []>;
Evan Cheng1eda6e72006-03-31 19:21:16 +0000478def vector_insert : SDNode<"ISD::INSERT_VECTOR_ELT",
Evan Cheng31f7be92006-06-15 08:19:05 +0000479 SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisPtrTy<3>]>, []>;
Christopher Lamb557c3632007-07-26 07:34:40 +0000480
481def extract_subreg : SDNode<"ISD::EXTRACT_SUBREG",
482 SDTypeProfile<1, 2, []>>;
483def insert_subreg : SDNode<"ISD::INSERT_SUBREG",
484 SDTypeProfile<1, 3, []>>;
Chris Lattnerfa818d02006-03-20 05:40:45 +0000485
Chris Lattnerea93f632006-03-25 02:29:35 +0000486// Nodes for intrinsics, you should use the intrinsic itself and let tblgen use
487// these internally. Don't reference these directly.
Chris Lattner48b61a72006-03-28 00:40:33 +0000488def intrinsic_void : SDNode<"ISD::INTRINSIC_VOID",
Chris Lattnerea93f632006-03-25 02:29:35 +0000489 SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>,
490 [SDNPHasChain]>;
Chris Lattner48b61a72006-03-28 00:40:33 +0000491def intrinsic_w_chain : SDNode<"ISD::INTRINSIC_W_CHAIN",
Chris Lattnerea93f632006-03-25 02:29:35 +0000492 SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>,
493 [SDNPHasChain]>;
Chris Lattner48b61a72006-03-28 00:40:33 +0000494def intrinsic_wo_chain : SDNode<"ISD::INTRINSIC_WO_CHAIN",
Chris Lattnerea93f632006-03-25 02:29:35 +0000495 SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>, []>;
496
Mon P Wang77cdf302008-11-10 20:54:11 +0000497// Do not use cvt directly. Use cvt forms below
498def cvt : SDNode<"ISD::CONVERT_RNDSAT", SDTConvertOp>;
Chris Lattnerea93f632006-03-25 02:29:35 +0000499
Chris Lattner1f426de2005-10-26 17:00:25 +0000500//===----------------------------------------------------------------------===//
501// Selection DAG Condition Codes
502
503class CondCode; // ISD::CondCode enums
504def SETOEQ : CondCode; def SETOGT : CondCode;
505def SETOGE : CondCode; def SETOLT : CondCode; def SETOLE : CondCode;
506def SETONE : CondCode; def SETO : CondCode; def SETUO : CondCode;
507def SETUEQ : CondCode; def SETUGT : CondCode; def SETUGE : CondCode;
508def SETULT : CondCode; def SETULE : CondCode; def SETUNE : CondCode;
509
510def SETEQ : CondCode; def SETGT : CondCode; def SETGE : CondCode;
511def SETLT : CondCode; def SETLE : CondCode; def SETNE : CondCode;
512
513
Chris Lattner17f2cf02005-10-10 06:00:30 +0000514//===----------------------------------------------------------------------===//
515// Selection DAG Node Transformation Functions.
516//
517// This mechanism allows targets to manipulate nodes in the output DAG once a
518// match has been formed. This is typically used to manipulate immediate
519// values.
520//
521class SDNodeXForm<SDNode opc, code xformFunction> {
522 SDNode Opcode = opc;
523 code XFormFunction = xformFunction;
524}
525
526def NOOP_SDNodeXForm : SDNodeXForm<imm, [{}]>;
527
528
529//===----------------------------------------------------------------------===//
530// Selection DAG Pattern Fragments.
531//
532// Pattern fragments are reusable chunks of dags that match specific things.
533// They can take arguments and have C++ predicates that control whether they
534// match. They are intended to make the patterns for common instructions more
535// compact and readable.
536//
537
538/// PatFrag - Represents a pattern fragment. This can match something on the
539/// DAG, frame a single node to multiply nested other fragments.
540///
541class PatFrag<dag ops, dag frag, code pred = [{}],
542 SDNodeXForm xform = NOOP_SDNodeXForm> {
543 dag Operands = ops;
544 dag Fragment = frag;
545 code Predicate = pred;
546 SDNodeXForm OperandTransform = xform;
547}
548
549// PatLeaf's are pattern fragments that have no operands. This is just a helper
550// to define immediates and other common things concisely.
551class PatLeaf<dag frag, code pred = [{}], SDNodeXForm xform = NOOP_SDNodeXForm>
552 : PatFrag<(ops), frag, pred, xform>;
553
554// Leaf fragments.
555
Duncan Sands83ec4b62008-06-06 12:08:01 +0000556def vtInt : PatLeaf<(vt), [{ return N->getVT().isInteger(); }]>;
557def vtFP : PatLeaf<(vt), [{ return N->getVT().isFloatingPoint(); }]>;
Chris Lattner17f2cf02005-10-10 06:00:30 +0000558
Chris Lattnerc985d822006-03-25 23:00:08 +0000559def immAllOnes : PatLeaf<(imm), [{ return N->isAllOnesValue(); }]>;
560def immAllOnesV: PatLeaf<(build_vector), [{
Evan Cheng999f3b52006-03-27 06:59:32 +0000561 return ISD::isBuildVectorAllOnes(N);
Chris Lattnerc985d822006-03-25 23:00:08 +0000562}]>;
Chris Lattner1fcee4e2006-04-15 23:39:14 +0000563def immAllOnesV_bc: PatLeaf<(bitconvert), [{
564 return ISD::isBuildVectorAllOnes(N);
565}]>;
Chris Lattnerffc04d32007-11-24 19:02:07 +0000566def immAllZerosV: PatLeaf<(build_vector), [{
567 return ISD::isBuildVectorAllZeros(N);
568}]>;
569def immAllZerosV_bc: PatLeaf<(bitconvert), [{
570 return ISD::isBuildVectorAllZeros(N);
571}]>;
572
Chris Lattner1fcee4e2006-04-15 23:39:14 +0000573
574
Chris Lattnerc985d822006-03-25 23:00:08 +0000575// Other helper fragments.
Chris Lattner17f2cf02005-10-10 06:00:30 +0000576def not : PatFrag<(ops node:$in), (xor node:$in, immAllOnes)>;
Chris Lattnerc985d822006-03-25 23:00:08 +0000577def vnot : PatFrag<(ops node:$in), (xor node:$in, immAllOnesV)>;
Chris Lattner1fcee4e2006-04-15 23:39:14 +0000578def vnot_conv : PatFrag<(ops node:$in), (xor node:$in, immAllOnesV_bc)>;
Chris Lattnereae6d642005-10-20 23:30:37 +0000579def ineg : PatFrag<(ops node:$in), (sub 0, node:$in)>;
Chris Lattner17f2cf02005-10-10 06:00:30 +0000580
Evan Cheng87e08132006-10-26 21:55:50 +0000581// load fragments.
Dan Gohman33586292008-10-15 06:50:19 +0000582def unindexedload : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
583 return cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
584}]>;
585def load : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{
586 return cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
Evan Cheng466685d2006-10-09 20:57:25 +0000587}]>;
588
Evan Cheng8b2794a2006-10-13 21:14:26 +0000589// extending load fragments.
Dan Gohman33586292008-10-15 06:50:19 +0000590def extload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{
591 return cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
Evan Cheng466685d2006-10-09 20:57:25 +0000592}]>;
Dan Gohman33586292008-10-15 06:50:19 +0000593def sextload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{
594 return cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
Evan Cheng466685d2006-10-09 20:57:25 +0000595}]>;
Dan Gohman33586292008-10-15 06:50:19 +0000596def zextload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{
597 return cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
Dale Johannesen59a58732007-08-05 18:49:15 +0000598}]>;
Evan Cheng466685d2006-10-09 20:57:25 +0000599
Dan Gohman33586292008-10-15 06:50:19 +0000600def extloadi1 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{
601 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i1;
Evan Cheng466685d2006-10-09 20:57:25 +0000602}]>;
Dan Gohman33586292008-10-15 06:50:19 +0000603def extloadi8 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{
604 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8;
Evan Cheng466685d2006-10-09 20:57:25 +0000605}]>;
Dan Gohman33586292008-10-15 06:50:19 +0000606def extloadi16 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{
607 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16;
Evan Cheng466685d2006-10-09 20:57:25 +0000608}]>;
Dan Gohman33586292008-10-15 06:50:19 +0000609def extloadi32 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{
610 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i32;
611}]>;
612def extloadf32 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{
613 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::f32;
614}]>;
615def extloadf64 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{
616 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::f64;
Evan Cheng466685d2006-10-09 20:57:25 +0000617}]>;
618
Dan Gohman33586292008-10-15 06:50:19 +0000619def sextloadi1 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{
620 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i1;
Evan Cheng466685d2006-10-09 20:57:25 +0000621}]>;
Dan Gohman33586292008-10-15 06:50:19 +0000622def sextloadi8 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{
623 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8;
Evan Cheng466685d2006-10-09 20:57:25 +0000624}]>;
Dan Gohman33586292008-10-15 06:50:19 +0000625def sextloadi16 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{
626 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16;
Evan Cheng466685d2006-10-09 20:57:25 +0000627}]>;
Dan Gohman33586292008-10-15 06:50:19 +0000628def sextloadi32 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{
629 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i32;
630}]>;
631
632def zextloadi1 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{
633 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i1;
634}]>;
635def zextloadi8 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{
636 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8;
637}]>;
638def zextloadi16 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{
639 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16;
640}]>;
641def zextloadi32 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{
642 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i32;
Evan Cheng466685d2006-10-09 20:57:25 +0000643}]>;
644
Evan Cheng87e08132006-10-26 21:55:50 +0000645// store fragments.
Dan Gohman33586292008-10-15 06:50:19 +0000646def unindexedstore : PatFrag<(ops node:$val, node:$ptr),
647 (st node:$val, node:$ptr), [{
648 return cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
649}]>;
Evan Cheng8b2794a2006-10-13 21:14:26 +0000650def store : PatFrag<(ops node:$val, node:$ptr),
Dan Gohman33586292008-10-15 06:50:19 +0000651 (unindexedstore node:$val, node:$ptr), [{
652 return !cast<StoreSDNode>(N)->isTruncatingStore();
Evan Cheng8b2794a2006-10-13 21:14:26 +0000653}]>;
654
655// truncstore fragments.
Dan Gohman33586292008-10-15 06:50:19 +0000656def truncstore : PatFrag<(ops node:$val, node:$ptr),
657 (unindexedstore node:$val, node:$ptr), [{
658 return cast<StoreSDNode>(N)->isTruncatingStore();
659}]>;
Evan Cheng8b2794a2006-10-13 21:14:26 +0000660def truncstorei8 : PatFrag<(ops node:$val, node:$ptr),
Dan Gohman33586292008-10-15 06:50:19 +0000661 (truncstore node:$val, node:$ptr), [{
662 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i8;
Evan Cheng8b2794a2006-10-13 21:14:26 +0000663}]>;
664def truncstorei16 : PatFrag<(ops node:$val, node:$ptr),
Dan Gohman33586292008-10-15 06:50:19 +0000665 (truncstore node:$val, node:$ptr), [{
666 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i16;
Evan Cheng8b2794a2006-10-13 21:14:26 +0000667}]>;
668def truncstorei32 : PatFrag<(ops node:$val, node:$ptr),
Dan Gohman33586292008-10-15 06:50:19 +0000669 (truncstore node:$val, node:$ptr), [{
670 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i32;
Evan Cheng8b2794a2006-10-13 21:14:26 +0000671}]>;
672def truncstoref32 : PatFrag<(ops node:$val, node:$ptr),
Dan Gohman33586292008-10-15 06:50:19 +0000673 (truncstore node:$val, node:$ptr), [{
674 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::f32;
Evan Cheng81fd6072006-11-08 23:02:11 +0000675}]>;
Dale Johannesen59a58732007-08-05 18:49:15 +0000676def truncstoref64 : PatFrag<(ops node:$val, node:$ptr),
Dan Gohman33586292008-10-15 06:50:19 +0000677 (truncstore node:$val, node:$ptr), [{
678 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::f64;
Dale Johannesen59a58732007-08-05 18:49:15 +0000679}]>;
Evan Cheng81fd6072006-11-08 23:02:11 +0000680
681// indexed store fragments.
Dan Gohman33586292008-10-15 06:50:19 +0000682def istore : PatFrag<(ops node:$val, node:$base, node:$offset),
683 (ist node:$val, node:$base, node:$offset), [{
684 return !cast<StoreSDNode>(N)->isTruncatingStore();
Evan Cheng81fd6072006-11-08 23:02:11 +0000685}]>;
686
Dan Gohman33586292008-10-15 06:50:19 +0000687def pre_store : PatFrag<(ops node:$val, node:$base, node:$offset),
688 (istore node:$val, node:$base, node:$offset), [{
689 ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
690 return AM == ISD::PRE_INC || AM == ISD::PRE_DEC;
691}]>;
692
693def itruncstore : PatFrag<(ops node:$val, node:$base, node:$offset),
694 (ist node:$val, node:$base, node:$offset), [{
695 return cast<StoreSDNode>(N)->isTruncatingStore();
696}]>;
697def pre_truncst : PatFrag<(ops node:$val, node:$base, node:$offset),
698 (itruncstore node:$val, node:$base, node:$offset), [{
699 ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
700 return AM == ISD::PRE_INC || AM == ISD::PRE_DEC;
701}]>;
Evan Cheng81fd6072006-11-08 23:02:11 +0000702def pre_truncsti1 : PatFrag<(ops node:$val, node:$base, node:$offset),
Dan Gohman33586292008-10-15 06:50:19 +0000703 (pre_truncst node:$val, node:$base, node:$offset), [{
704 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i1;
Evan Cheng81fd6072006-11-08 23:02:11 +0000705}]>;
706def pre_truncsti8 : PatFrag<(ops node:$val, node:$base, node:$offset),
Dan Gohman33586292008-10-15 06:50:19 +0000707 (pre_truncst node:$val, node:$base, node:$offset), [{
708 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i8;
Evan Cheng81fd6072006-11-08 23:02:11 +0000709}]>;
710def pre_truncsti16 : PatFrag<(ops node:$val, node:$base, node:$offset),
Dan Gohman33586292008-10-15 06:50:19 +0000711 (pre_truncst node:$val, node:$base, node:$offset), [{
712 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i16;
Evan Cheng81fd6072006-11-08 23:02:11 +0000713}]>;
714def pre_truncsti32 : PatFrag<(ops node:$val, node:$base, node:$offset),
Dan Gohman33586292008-10-15 06:50:19 +0000715 (pre_truncst node:$val, node:$base, node:$offset), [{
716 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i32;
Evan Cheng81fd6072006-11-08 23:02:11 +0000717}]>;
718def pre_truncstf32 : PatFrag<(ops node:$val, node:$base, node:$offset),
Dan Gohman33586292008-10-15 06:50:19 +0000719 (pre_truncst node:$val, node:$base, node:$offset), [{
720 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::f32;
Evan Cheng81fd6072006-11-08 23:02:11 +0000721}]>;
722
723def post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
Dan Gohman33586292008-10-15 06:50:19 +0000724 (istore node:$val, node:$ptr, node:$offset), [{
725 ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
726 return AM == ISD::POST_INC || AM == ISD::POST_DEC;
Evan Cheng81fd6072006-11-08 23:02:11 +0000727}]>;
728
Dan Gohman33586292008-10-15 06:50:19 +0000729def post_truncst : PatFrag<(ops node:$val, node:$base, node:$offset),
730 (itruncstore node:$val, node:$base, node:$offset), [{
731 ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
732 return AM == ISD::POST_INC || AM == ISD::POST_DEC;
733}]>;
Evan Cheng81fd6072006-11-08 23:02:11 +0000734def post_truncsti1 : PatFrag<(ops node:$val, node:$base, node:$offset),
Dan Gohman33586292008-10-15 06:50:19 +0000735 (post_truncst node:$val, node:$base, node:$offset), [{
736 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i1;
Evan Cheng81fd6072006-11-08 23:02:11 +0000737}]>;
738def post_truncsti8 : PatFrag<(ops node:$val, node:$base, node:$offset),
Dan Gohman33586292008-10-15 06:50:19 +0000739 (post_truncst node:$val, node:$base, node:$offset), [{
740 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i8;
Evan Cheng81fd6072006-11-08 23:02:11 +0000741}]>;
742def post_truncsti16 : PatFrag<(ops node:$val, node:$base, node:$offset),
Dan Gohman33586292008-10-15 06:50:19 +0000743 (post_truncst node:$val, node:$base, node:$offset), [{
744 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i16;
Evan Cheng81fd6072006-11-08 23:02:11 +0000745}]>;
746def post_truncsti32 : PatFrag<(ops node:$val, node:$base, node:$offset),
Dan Gohman33586292008-10-15 06:50:19 +0000747 (post_truncst node:$val, node:$base, node:$offset), [{
748 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i32;
Evan Cheng81fd6072006-11-08 23:02:11 +0000749}]>;
750def post_truncstf32 : PatFrag<(ops node:$val, node:$base, node:$offset),
Dan Gohman33586292008-10-15 06:50:19 +0000751 (post_truncst node:$val, node:$base, node:$offset), [{
752 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::f32;
Evan Cheng8b2794a2006-10-13 21:14:26 +0000753}]>;
Chris Lattner1f426de2005-10-26 17:00:25 +0000754
755// setcc convenience fragments.
756def setoeq : PatFrag<(ops node:$lhs, node:$rhs),
757 (setcc node:$lhs, node:$rhs, SETOEQ)>;
758def setogt : PatFrag<(ops node:$lhs, node:$rhs),
759 (setcc node:$lhs, node:$rhs, SETOGT)>;
760def setoge : PatFrag<(ops node:$lhs, node:$rhs),
761 (setcc node:$lhs, node:$rhs, SETOGE)>;
762def setolt : PatFrag<(ops node:$lhs, node:$rhs),
763 (setcc node:$lhs, node:$rhs, SETOLT)>;
764def setole : PatFrag<(ops node:$lhs, node:$rhs),
765 (setcc node:$lhs, node:$rhs, SETOLE)>;
766def setone : PatFrag<(ops node:$lhs, node:$rhs),
767 (setcc node:$lhs, node:$rhs, SETONE)>;
768def seto : PatFrag<(ops node:$lhs, node:$rhs),
769 (setcc node:$lhs, node:$rhs, SETO)>;
770def setuo : PatFrag<(ops node:$lhs, node:$rhs),
771 (setcc node:$lhs, node:$rhs, SETUO)>;
772def setueq : PatFrag<(ops node:$lhs, node:$rhs),
773 (setcc node:$lhs, node:$rhs, SETUEQ)>;
774def setugt : PatFrag<(ops node:$lhs, node:$rhs),
775 (setcc node:$lhs, node:$rhs, SETUGT)>;
776def setuge : PatFrag<(ops node:$lhs, node:$rhs),
777 (setcc node:$lhs, node:$rhs, SETUGE)>;
778def setult : PatFrag<(ops node:$lhs, node:$rhs),
779 (setcc node:$lhs, node:$rhs, SETULT)>;
780def setule : PatFrag<(ops node:$lhs, node:$rhs),
781 (setcc node:$lhs, node:$rhs, SETULE)>;
782def setune : PatFrag<(ops node:$lhs, node:$rhs),
783 (setcc node:$lhs, node:$rhs, SETUNE)>;
784def seteq : PatFrag<(ops node:$lhs, node:$rhs),
785 (setcc node:$lhs, node:$rhs, SETEQ)>;
786def setgt : PatFrag<(ops node:$lhs, node:$rhs),
787 (setcc node:$lhs, node:$rhs, SETGT)>;
788def setge : PatFrag<(ops node:$lhs, node:$rhs),
789 (setcc node:$lhs, node:$rhs, SETGE)>;
790def setlt : PatFrag<(ops node:$lhs, node:$rhs),
791 (setcc node:$lhs, node:$rhs, SETLT)>;
792def setle : PatFrag<(ops node:$lhs, node:$rhs),
793 (setcc node:$lhs, node:$rhs, SETLE)>;
794def setne : PatFrag<(ops node:$lhs, node:$rhs),
795 (setcc node:$lhs, node:$rhs, SETNE)>;
796
Chris Lattner17f2cf02005-10-10 06:00:30 +0000797//===----------------------------------------------------------------------===//
Mon P Wang77cdf302008-11-10 20:54:11 +0000798// Selection DAG CONVERT_RNDSAT patterns
799
800def cvtff : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
801 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
802 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_FF;
803 }]>;
804
805def cvtss : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
806 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
807 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_SS;
808 }]>;
809
810def cvtsu : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
811 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
812 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_SU;
813 }]>;
814
815def cvtus : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
816 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
817 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_US;
818 }]>;
819
820def cvtuu : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
821 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
822 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_UU;
823 }]>;
824
825def cvtsf : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
826 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
827 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_SF;
828 }]>;
829
830def cvtuf : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
831 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
832 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_UF;
833 }]>;
834
835def cvtfs : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
836 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
837 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_FS;
838 }]>;
839
840def cvtfu : PatFrag<(ops node:$val, node:$dty, node:$sty, node:$rd, node:$sat),
841 (cvt node:$val, node:$dty, node:$sty, node:$rd, node:$sat), [{
842 return cast<CvtRndSatSDNode>(N)->getCvtCode() == ISD::CVT_FU;
843 }]>;
844
845//===----------------------------------------------------------------------===//
Chris Lattner17f2cf02005-10-10 06:00:30 +0000846// Selection DAG Pattern Support.
847//
848// Patterns are what are actually matched against the target-flavored
849// instruction selection DAG. Instructions defined by the target implicitly
850// define patterns in most cases, but patterns can also be explicitly added when
851// an operation is defined by a sequence of instructions (e.g. loading a large
852// immediate value on RISC targets that do not support immediates as large as
853// their GPRs).
854//
855
856class Pattern<dag patternToMatch, list<dag> resultInstrs> {
Evan Chengf5e1dc22006-04-19 20:38:28 +0000857 dag PatternToMatch = patternToMatch;
858 list<dag> ResultInstrs = resultInstrs;
859 list<Predicate> Predicates = []; // See class Instruction in Target.td.
860 int AddedComplexity = 0; // See class Instruction in Target.td.
Chris Lattner17f2cf02005-10-10 06:00:30 +0000861}
862
863// Pat - A simple (but common) form of a pattern, which produces a simple result
864// not needing a full list.
865class Pat<dag pattern, dag result> : Pattern<pattern, [result]>;
866
Evan Chengf20da7e2005-12-08 04:28:48 +0000867//===----------------------------------------------------------------------===//
868// Complex pattern definitions.
869//
Christopher Lamb85356242008-01-31 07:27:46 +0000870
871class CPAttribute;
872// Pass the parent Operand as root to CP function rather
873// than the root of the sub-DAG
874def CPAttrParentAsRoot : CPAttribute;
875
Evan Chengf20da7e2005-12-08 04:28:48 +0000876// Complex patterns, e.g. X86 addressing mode, requires pattern matching code
877// in C++. NumOperands is the number of operands returned by the select function;
878// SelectFunc is the name of the function used to pattern match the max. pattern;
879// RootNodes are the list of possible root nodes of the sub-dags to match.
880// e.g. X86 addressing mode - def addr : ComplexPattern<4, "SelectAddr", [add]>;
881//
Evan Chengaf9db752006-10-11 21:03:53 +0000882class ComplexPattern<ValueType ty, int numops, string fn,
Christopher Lamb85356242008-01-31 07:27:46 +0000883 list<SDNode> roots = [], list<SDNodeProperty> props = [],
884 list<CPAttribute> attrs = []> {
Evan Chengf20da7e2005-12-08 04:28:48 +0000885 ValueType Ty = ty;
886 int NumOperands = numops;
887 string SelectFunc = fn;
888 list<SDNode> RootNodes = roots;
Evan Chengaf9db752006-10-11 21:03:53 +0000889 list<SDNodeProperty> Properties = props;
Christopher Lamb85356242008-01-31 07:27:46 +0000890 list<CPAttribute> Attributes = attrs;
Evan Chengf20da7e2005-12-08 04:28:48 +0000891}
Jim Laskeyf5395ce2005-12-16 22:45:29 +0000892
893//===----------------------------------------------------------------------===//
894// Dwarf support.
895//
Jim Laskeyabf6d172006-01-05 01:25:28 +0000896def SDT_dwarf_loc : SDTypeProfile<0, 3,
897 [SDTCisInt<0>, SDTCisInt<1>, SDTCisInt<2>]>;
898def dwarf_loc : SDNode<"ISD::DEBUG_LOC", SDT_dwarf_loc,[SDNPHasChain]>;