blob: a38d8639edef4cd66ea54734bb8d332e979390b4 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- TargetSelectionDAG.td - Common code for DAG isels ---*- tablegen -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +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.
27class SDTCisVT<int OpNum, ValueType vt> : SDTypeConstraint<OpNum> {
28 ValueType VT = vt;
29}
30
31class SDTCisPtrTy<int OpNum> : SDTypeConstraint<OpNum>;
32
33// SDTCisInt - The specified operand is has integer type.
34class SDTCisInt<int OpNum> : SDTypeConstraint<OpNum>;
35
36// SDTCisFP - The specified operand is has floating point type.
37class SDTCisFP<int OpNum> : SDTypeConstraint<OpNum>;
38
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
50class 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 that ThisOp
57/// has.
58class SDTCisIntVectorOfSameSize<int ThisOp, int OtherOp>
59 : SDTypeConstraint<ThisOp> {
60 int OtherOpNum = OtherOp;
61}
62
Nate Begemanea391a22008-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.
65class SDTCisEltOfVec<int ThisOp, int OtherOp>
66 : SDTypeConstraint<ThisOp> {
67 int OtherOpNum = OtherOp;
68}
69
Dan Gohmanf17a25c2007-07-18 16:29:46 +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.
88def 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'.
91def SDTOther : SDTypeProfile<1, 0, [SDTCisVT<0, OtherVT>]>; // for 'vt'.
92def SDTUNDEF : SDTypeProfile<1, 0, []>; // for 'undef'.
93def SDTUnaryOp : SDTypeProfile<1, 1, []>; // bitconvert
94
95def SDTIntBinOp : SDTypeProfile<1, 2, [ // add, and, or, xor, udiv, etc.
96 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<0>
97]>;
98def SDTIntShiftOp : SDTypeProfile<1, 2, [ // shl, sra, srl
99 SDTCisSameAs<0, 1>, SDTCisInt<0>, SDTCisInt<2>
100]>;
101def SDTFPBinOp : SDTypeProfile<1, 2, [ // fadd, fmul, etc.
102 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisFP<0>
103]>;
104def SDTFPSignOp : SDTypeProfile<1, 2, [ // fcopysign.
105 SDTCisSameAs<0, 1>, SDTCisFP<0>, SDTCisFP<2>
106]>;
107def SDTFPTernaryOp : SDTypeProfile<1, 3, [ // fmadd, fnmsub, etc.
108 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>, SDTCisFP<0>
109]>;
110def SDTIntUnaryOp : SDTypeProfile<1, 1, [ // ctlz
111 SDTCisSameAs<0, 1>, SDTCisInt<0>
112]>;
113def 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]>;
119def SDTFPUnaryOp : SDTypeProfile<1, 1, [ // fneg, fsqrt, etc
120 SDTCisSameAs<0, 1>, SDTCisFP<0>
121]>;
122def SDTFPRoundOp : SDTypeProfile<1, 1, [ // fround
123 SDTCisFP<0>, SDTCisFP<1>, SDTCisOpSmallerThanOp<0, 1>
124]>;
125def SDTFPExtendOp : SDTypeProfile<1, 1, [ // fextend
126 SDTCisFP<0>, SDTCisFP<1>, SDTCisOpSmallerThanOp<1, 0>
127]>;
128def SDTIntToFPOp : SDTypeProfile<1, 1, [ // [su]int_to_fp
129 SDTCisFP<0>, SDTCisInt<1>
130]>;
131def SDTFPToIntOp : SDTypeProfile<1, 1, [ // fp_to_[su]int
132 SDTCisInt<0>, SDTCisFP<1>
133]>;
134def SDTExtInreg : SDTypeProfile<1, 2, [ // sext_inreg
135 SDTCisSameAs<0, 1>, SDTCisInt<0>, SDTCisVT<2, OtherVT>,
136 SDTCisVTSmallerThanOp<2, 1>
137]>;
138
139def SDTSetCC : SDTypeProfile<1, 3, [ // setcc
140 SDTCisInt<0>, SDTCisSameAs<1, 2>, SDTCisVT<3, OtherVT>
141]>;
142
143def SDTSelect : SDTypeProfile<1, 3, [ // select
144 SDTCisInt<1>, SDTCisSameAs<0, 2>, SDTCisSameAs<2, 3>
145]>;
146
147def SDTSelectCC : SDTypeProfile<1, 5, [ // select_cc
148 SDTCisSameAs<1, 2>, SDTCisSameAs<3, 4>, SDTCisSameAs<0, 3>,
149 SDTCisVT<5, OtherVT>
150]>;
151
152def SDTBr : SDTypeProfile<0, 1, [ // br
153 SDTCisVT<0, OtherVT>
154]>;
155
156def SDTBrcond : SDTypeProfile<0, 2, [ // brcond
157 SDTCisInt<0>, SDTCisVT<1, OtherVT>
158]>;
159
160def SDTBrind : SDTypeProfile<0, 1, [ // brind
161 SDTCisPtrTy<0>
162]>;
163
Chris Lattner3d254552008-01-15 22:02:54 +0000164def SDTNone : SDTypeProfile<0, 0, []>; // ret, trap
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000165
166def SDTLoad : SDTypeProfile<1, 1, [ // load
167 SDTCisPtrTy<1>
168]>;
169
170def SDTStore : SDTypeProfile<0, 2, [ // store
171 SDTCisPtrTy<1>
172]>;
173
174def SDTIStore : SDTypeProfile<1, 3, [ // indexed store
175 SDTCisSameAs<0, 2>, SDTCisPtrTy<0>, SDTCisPtrTy<3>
176]>;
177
178def SDTVecShuffle : SDTypeProfile<1, 3, [
179 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisIntVectorOfSameSize<3, 0>
180]>;
Nate Begemanea391a22008-02-09 01:37:05 +0000181def SDTVecExtract : SDTypeProfile<1, 2, [ // vector extract
182 SDTCisEltOfVec<0, 1>, SDTCisPtrTy<2>
183]>;
184def SDTVecInsert : SDTypeProfile<1, 2, [ // vector insert
185 SDTCisEltOfVec<1, 0>, SDTCisPtrTy<2>
186]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000187
Bill Wendling7173da52007-11-13 09:19:02 +0000188class SDCallSeqStart<list<SDTypeConstraint> constraints> :
189 SDTypeProfile<0, 1, constraints>;
190class SDCallSeqEnd<list<SDTypeConstraint> constraints> :
191 SDTypeProfile<0, 2, constraints>;
192
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193//===----------------------------------------------------------------------===//
194// Selection DAG Node Properties.
195//
196// Note: These are hard coded into tblgen.
197//
198class SDNodeProperty;
199def SDNPCommutative : SDNodeProperty; // X op Y == Y op X
200def SDNPAssociative : SDNodeProperty; // (X op Y) op Z == X op (Y op Z)
201def SDNPHasChain : SDNodeProperty; // R/W chain operand and result
202def SDNPOutFlag : SDNodeProperty; // Write a flag result
203def SDNPInFlag : SDNodeProperty; // Read a flag operand
204def SDNPOptInFlag : SDNodeProperty; // Optionally read a flag operand
Chris Lattner6887b142008-01-06 08:36:04 +0000205def SDNPMayStore : SDNodeProperty; // May write to memory, sets 'mayStore'.
Chris Lattnerdfde8132008-01-10 04:44:32 +0000206def SDNPMayLoad : SDNodeProperty; // May read memory, sets 'mayLoad'.
Chris Lattner2e40ad12008-01-10 05:48:23 +0000207def SDNPSideEffect : SDNodeProperty; // Sets 'HasUnmodelledSideEffects'.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000208
209//===----------------------------------------------------------------------===//
210// Selection DAG Node definitions.
211//
212class SDNode<string opcode, SDTypeProfile typeprof,
213 list<SDNodeProperty> props = [], string sdclass = "SDNode"> {
214 string Opcode = opcode;
215 string SDClass = sdclass;
216 list<SDNodeProperty> Properties = props;
217 SDTypeProfile TypeProfile = typeprof;
218}
219
220def set;
Evan Chengf031fcb2007-09-25 01:48:59 +0000221def implicit;
Evan Cheng775baac2007-09-12 23:30:14 +0000222def parallel;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000223def node;
224def srcvalue;
225
226def imm : SDNode<"ISD::Constant" , SDTIntLeaf , [], "ConstantSDNode">;
227def fpimm : SDNode<"ISD::TargetConstantFP",
228 SDTFPLeaf, [], "ConstantFPSDNode">;
229def vt : SDNode<"ISD::VALUETYPE" , SDTOther , [], "VTSDNode">;
230def bb : SDNode<"ISD::BasicBlock", SDTOther , [], "BasicBlockSDNode">;
231def cond : SDNode<"ISD::CONDCODE" , SDTOther , [], "CondCodeSDNode">;
232def undef : SDNode<"ISD::UNDEF" , SDTUNDEF , []>;
233def globaladdr : SDNode<"ISD::GlobalAddress", SDTPtrLeaf, [],
234 "GlobalAddressSDNode">;
235def tglobaladdr : SDNode<"ISD::TargetGlobalAddress", SDTPtrLeaf, [],
236 "GlobalAddressSDNode">;
237def globaltlsaddr : SDNode<"ISD::GlobalTLSAddress", SDTPtrLeaf, [],
238 "GlobalAddressSDNode">;
239def tglobaltlsaddr : SDNode<"ISD::TargetGlobalTLSAddress", SDTPtrLeaf, [],
240 "GlobalAddressSDNode">;
241def constpool : SDNode<"ISD::ConstantPool", SDTPtrLeaf, [],
242 "ConstantPoolSDNode">;
243def tconstpool : SDNode<"ISD::TargetConstantPool", SDTPtrLeaf, [],
244 "ConstantPoolSDNode">;
245def jumptable : SDNode<"ISD::JumpTable", SDTPtrLeaf, [],
246 "JumpTableSDNode">;
247def tjumptable : SDNode<"ISD::TargetJumpTable", SDTPtrLeaf, [],
248 "JumpTableSDNode">;
249def frameindex : SDNode<"ISD::FrameIndex", SDTPtrLeaf, [],
250 "FrameIndexSDNode">;
251def tframeindex : SDNode<"ISD::TargetFrameIndex", SDTPtrLeaf, [],
252 "FrameIndexSDNode">;
253def externalsym : SDNode<"ISD::ExternalSymbol", SDTPtrLeaf, [],
254 "ExternalSymbolSDNode">;
255def texternalsym: SDNode<"ISD::TargetExternalSymbol", SDTPtrLeaf, [],
256 "ExternalSymbolSDNode">;
257
258def add : SDNode<"ISD::ADD" , SDTIntBinOp ,
259 [SDNPCommutative, SDNPAssociative]>;
260def sub : SDNode<"ISD::SUB" , SDTIntBinOp>;
261def mul : SDNode<"ISD::MUL" , SDTIntBinOp,
262 [SDNPCommutative, SDNPAssociative]>;
263def mulhs : SDNode<"ISD::MULHS" , SDTIntBinOp, [SDNPCommutative]>;
264def mulhu : SDNode<"ISD::MULHU" , SDTIntBinOp, [SDNPCommutative]>;
265def sdiv : SDNode<"ISD::SDIV" , SDTIntBinOp>;
266def udiv : SDNode<"ISD::UDIV" , SDTIntBinOp>;
267def srem : SDNode<"ISD::SREM" , SDTIntBinOp>;
268def urem : SDNode<"ISD::UREM" , SDTIntBinOp>;
269def srl : SDNode<"ISD::SRL" , SDTIntShiftOp>;
270def sra : SDNode<"ISD::SRA" , SDTIntShiftOp>;
271def shl : SDNode<"ISD::SHL" , SDTIntShiftOp>;
272def rotl : SDNode<"ISD::ROTL" , SDTIntShiftOp>;
273def rotr : SDNode<"ISD::ROTR" , SDTIntShiftOp>;
274def and : SDNode<"ISD::AND" , SDTIntBinOp,
275 [SDNPCommutative, SDNPAssociative]>;
276def or : SDNode<"ISD::OR" , SDTIntBinOp,
277 [SDNPCommutative, SDNPAssociative]>;
278def xor : SDNode<"ISD::XOR" , SDTIntBinOp,
279 [SDNPCommutative, SDNPAssociative]>;
280def addc : SDNode<"ISD::ADDC" , SDTIntBinOp,
281 [SDNPCommutative, SDNPOutFlag]>;
282def adde : SDNode<"ISD::ADDE" , SDTIntBinOp,
283 [SDNPCommutative, SDNPOutFlag, SDNPInFlag]>;
284def subc : SDNode<"ISD::SUBC" , SDTIntBinOp,
285 [SDNPOutFlag]>;
286def sube : SDNode<"ISD::SUBE" , SDTIntBinOp,
287 [SDNPOutFlag, SDNPInFlag]>;
288
289def sext_inreg : SDNode<"ISD::SIGN_EXTEND_INREG", SDTExtInreg>;
290def bswap : SDNode<"ISD::BSWAP" , SDTIntUnaryOp>;
291def ctlz : SDNode<"ISD::CTLZ" , SDTIntUnaryOp>;
292def cttz : SDNode<"ISD::CTTZ" , SDTIntUnaryOp>;
293def ctpop : SDNode<"ISD::CTPOP" , SDTIntUnaryOp>;
294def sext : SDNode<"ISD::SIGN_EXTEND", SDTIntExtendOp>;
295def zext : SDNode<"ISD::ZERO_EXTEND", SDTIntExtendOp>;
296def anyext : SDNode<"ISD::ANY_EXTEND" , SDTIntExtendOp>;
297def trunc : SDNode<"ISD::TRUNCATE" , SDTIntTruncOp>;
298def bitconvert : SDNode<"ISD::BIT_CONVERT", SDTUnaryOp>;
Nate Begemanea391a22008-02-09 01:37:05 +0000299def extractelt : SDNode<"ISD::EXTRACT_VECTOR_ELT", SDTVecExtract>;
300def insertelt : SDNode<"ISD::INSERT_VECTOR_ELT", SDTVecInsert>;
301
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000302
303def fadd : SDNode<"ISD::FADD" , SDTFPBinOp, [SDNPCommutative]>;
304def fsub : SDNode<"ISD::FSUB" , SDTFPBinOp>;
305def fmul : SDNode<"ISD::FMUL" , SDTFPBinOp, [SDNPCommutative]>;
306def fdiv : SDNode<"ISD::FDIV" , SDTFPBinOp>;
307def frem : SDNode<"ISD::FREM" , SDTFPBinOp>;
308def fabs : SDNode<"ISD::FABS" , SDTFPUnaryOp>;
309def fneg : SDNode<"ISD::FNEG" , SDTFPUnaryOp>;
310def fsqrt : SDNode<"ISD::FSQRT" , SDTFPUnaryOp>;
311def fsin : SDNode<"ISD::FSIN" , SDTFPUnaryOp>;
312def fcos : SDNode<"ISD::FCOS" , SDTFPUnaryOp>;
313
314def fround : SDNode<"ISD::FP_ROUND" , SDTFPRoundOp>;
315def fextend : SDNode<"ISD::FP_EXTEND" , SDTFPExtendOp>;
316def fcopysign : SDNode<"ISD::FCOPYSIGN" , SDTFPSignOp>;
317
318def sint_to_fp : SDNode<"ISD::SINT_TO_FP" , SDTIntToFPOp>;
319def uint_to_fp : SDNode<"ISD::UINT_TO_FP" , SDTIntToFPOp>;
320def fp_to_sint : SDNode<"ISD::FP_TO_SINT" , SDTFPToIntOp>;
321def fp_to_uint : SDNode<"ISD::FP_TO_UINT" , SDTFPToIntOp>;
322
323def setcc : SDNode<"ISD::SETCC" , SDTSetCC>;
324def select : SDNode<"ISD::SELECT" , SDTSelect>;
325def selectcc : SDNode<"ISD::SELECT_CC" , SDTSelectCC>;
326
327def brcond : SDNode<"ISD::BRCOND" , SDTBrcond, [SDNPHasChain]>;
328def brind : SDNode<"ISD::BRIND" , SDTBrind, [SDNPHasChain]>;
329def br : SDNode<"ISD::BR" , SDTBr, [SDNPHasChain]>;
Chris Lattner3d254552008-01-15 22:02:54 +0000330def ret : SDNode<"ISD::RET" , SDTNone, [SDNPHasChain]>;
331def trap : SDNode<"ISD::TRAP" , SDTNone,
332 [SDNPHasChain, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000333
334// Do not use ld, st directly. Use load, extload, sextload, zextload, store,
335// and truncst (see below).
Chris Lattnerdfde8132008-01-10 04:44:32 +0000336def ld : SDNode<"ISD::LOAD" , SDTLoad,
337 [SDNPHasChain, SDNPMayLoad]>;
Chris Lattneref8d6082008-01-06 06:44:58 +0000338def st : SDNode<"ISD::STORE" , SDTStore,
339 [SDNPHasChain, SDNPMayStore]>;
340def ist : SDNode<"ISD::STORE" , SDTIStore,
341 [SDNPHasChain, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000342
343def vector_shuffle : SDNode<"ISD::VECTOR_SHUFFLE", SDTVecShuffle, []>;
344def build_vector : SDNode<"ISD::BUILD_VECTOR", SDTypeProfile<1, 0, []>, []>;
345def scalar_to_vector : SDNode<"ISD::SCALAR_TO_VECTOR", SDTypeProfile<1, 1, []>,
346 []>;
347def vector_extract : SDNode<"ISD::EXTRACT_VECTOR_ELT",
348 SDTypeProfile<1, 2, [SDTCisPtrTy<2>]>, []>;
349def vector_insert : SDNode<"ISD::INSERT_VECTOR_ELT",
350 SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisPtrTy<3>]>, []>;
Christopher Lambb768c2e2007-07-26 07:34:40 +0000351
352def extract_subreg : SDNode<"ISD::EXTRACT_SUBREG",
353 SDTypeProfile<1, 2, []>>;
354def insert_subreg : SDNode<"ISD::INSERT_SUBREG",
355 SDTypeProfile<1, 3, []>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000356
357// Nodes for intrinsics, you should use the intrinsic itself and let tblgen use
358// these internally. Don't reference these directly.
359def intrinsic_void : SDNode<"ISD::INTRINSIC_VOID",
360 SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>,
361 [SDNPHasChain]>;
362def intrinsic_w_chain : SDNode<"ISD::INTRINSIC_W_CHAIN",
363 SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>,
364 [SDNPHasChain]>;
365def intrinsic_wo_chain : SDNode<"ISD::INTRINSIC_WO_CHAIN",
366 SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>, []>;
367
368
369//===----------------------------------------------------------------------===//
370// Selection DAG Condition Codes
371
372class CondCode; // ISD::CondCode enums
373def SETOEQ : CondCode; def SETOGT : CondCode;
374def SETOGE : CondCode; def SETOLT : CondCode; def SETOLE : CondCode;
375def SETONE : CondCode; def SETO : CondCode; def SETUO : CondCode;
376def SETUEQ : CondCode; def SETUGT : CondCode; def SETUGE : CondCode;
377def SETULT : CondCode; def SETULE : CondCode; def SETUNE : CondCode;
378
379def SETEQ : CondCode; def SETGT : CondCode; def SETGE : CondCode;
380def SETLT : CondCode; def SETLE : CondCode; def SETNE : CondCode;
381
382
383//===----------------------------------------------------------------------===//
384// Selection DAG Node Transformation Functions.
385//
386// This mechanism allows targets to manipulate nodes in the output DAG once a
387// match has been formed. This is typically used to manipulate immediate
388// values.
389//
390class SDNodeXForm<SDNode opc, code xformFunction> {
391 SDNode Opcode = opc;
392 code XFormFunction = xformFunction;
393}
394
395def NOOP_SDNodeXForm : SDNodeXForm<imm, [{}]>;
396
397
398//===----------------------------------------------------------------------===//
399// Selection DAG Pattern Fragments.
400//
401// Pattern fragments are reusable chunks of dags that match specific things.
402// They can take arguments and have C++ predicates that control whether they
403// match. They are intended to make the patterns for common instructions more
404// compact and readable.
405//
406
407/// PatFrag - Represents a pattern fragment. This can match something on the
408/// DAG, frame a single node to multiply nested other fragments.
409///
410class PatFrag<dag ops, dag frag, code pred = [{}],
411 SDNodeXForm xform = NOOP_SDNodeXForm> {
412 dag Operands = ops;
413 dag Fragment = frag;
414 code Predicate = pred;
415 SDNodeXForm OperandTransform = xform;
416}
417
418// PatLeaf's are pattern fragments that have no operands. This is just a helper
419// to define immediates and other common things concisely.
420class PatLeaf<dag frag, code pred = [{}], SDNodeXForm xform = NOOP_SDNodeXForm>
421 : PatFrag<(ops), frag, pred, xform>;
422
423// Leaf fragments.
424
425def vtInt : PatLeaf<(vt), [{ return MVT::isInteger(N->getVT()); }]>;
426def vtFP : PatLeaf<(vt), [{ return MVT::isFloatingPoint(N->getVT()); }]>;
427
428def immAllOnes : PatLeaf<(imm), [{ return N->isAllOnesValue(); }]>;
429def immAllOnesV: PatLeaf<(build_vector), [{
430 return ISD::isBuildVectorAllOnes(N);
431}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000432def immAllOnesV_bc: PatLeaf<(bitconvert), [{
433 return ISD::isBuildVectorAllOnes(N);
434}]>;
Chris Lattner8f259c02007-11-24 19:02:07 +0000435def immAllZerosV: PatLeaf<(build_vector), [{
436 return ISD::isBuildVectorAllZeros(N);
437}]>;
438def immAllZerosV_bc: PatLeaf<(bitconvert), [{
439 return ISD::isBuildVectorAllZeros(N);
440}]>;
441
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000442
443
444// Other helper fragments.
445def not : PatFrag<(ops node:$in), (xor node:$in, immAllOnes)>;
446def vnot : PatFrag<(ops node:$in), (xor node:$in, immAllOnesV)>;
447def vnot_conv : PatFrag<(ops node:$in), (xor node:$in, immAllOnesV_bc)>;
448def ineg : PatFrag<(ops node:$in), (sub 0, node:$in)>;
449
450// load fragments.
451def load : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
452 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
453 return LD->getExtensionType() == ISD::NON_EXTLOAD &&
454 LD->getAddressingMode() == ISD::UNINDEXED;
455 return false;
456}]>;
457
458// extending load fragments.
459def extloadi1 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
460 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
461 return LD->getExtensionType() == ISD::EXTLOAD &&
462 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000463 LD->getMemoryVT() == MVT::i1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000464 return false;
465}]>;
466def extloadi8 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
467 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
468 return LD->getExtensionType() == ISD::EXTLOAD &&
469 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000470 LD->getMemoryVT() == MVT::i8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000471 return false;
472}]>;
473def extloadi16 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
474 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
475 return LD->getExtensionType() == ISD::EXTLOAD &&
476 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000477 LD->getMemoryVT() == MVT::i16;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000478 return false;
479}]>;
480def extloadi32 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
481 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
482 return LD->getExtensionType() == ISD::EXTLOAD &&
483 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000484 LD->getMemoryVT() == MVT::i32;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000485 return false;
486}]>;
487def extloadf32 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
488 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
489 return LD->getExtensionType() == ISD::EXTLOAD &&
490 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000491 LD->getMemoryVT() == MVT::f32;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000492 return false;
493}]>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000494def extloadf64 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
495 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
496 return LD->getExtensionType() == ISD::EXTLOAD &&
497 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000498 LD->getMemoryVT() == MVT::f64;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000499 return false;
500}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501
502def sextloadi1 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
503 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
504 return LD->getExtensionType() == ISD::SEXTLOAD &&
505 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000506 LD->getMemoryVT() == MVT::i1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000507 return false;
508}]>;
509def sextloadi8 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
510 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
511 return LD->getExtensionType() == ISD::SEXTLOAD &&
512 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000513 LD->getMemoryVT() == MVT::i8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000514 return false;
515}]>;
516def sextloadi16 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
517 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
518 return LD->getExtensionType() == ISD::SEXTLOAD &&
519 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000520 LD->getMemoryVT() == MVT::i16;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000521 return false;
522}]>;
523def sextloadi32 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
524 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
525 return LD->getExtensionType() == ISD::SEXTLOAD &&
526 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000527 LD->getMemoryVT() == MVT::i32;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000528 return false;
529}]>;
530
531def zextloadi1 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
532 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
533 return LD->getExtensionType() == ISD::ZEXTLOAD &&
534 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000535 LD->getMemoryVT() == MVT::i1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536 return false;
537}]>;
538def zextloadi8 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
539 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
540 return LD->getExtensionType() == ISD::ZEXTLOAD &&
541 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000542 LD->getMemoryVT() == MVT::i8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543 return false;
544}]>;
545def zextloadi16 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
546 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
547 return LD->getExtensionType() == ISD::ZEXTLOAD &&
548 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000549 LD->getMemoryVT() == MVT::i16;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000550 return false;
551}]>;
552def zextloadi32 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
553 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
554 return LD->getExtensionType() == ISD::ZEXTLOAD &&
555 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000556 LD->getMemoryVT() == MVT::i32;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000557 return false;
558}]>;
559
560// store fragments.
561def store : PatFrag<(ops node:$val, node:$ptr),
562 (st node:$val, node:$ptr), [{
563 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
564 return !ST->isTruncatingStore() &&
565 ST->getAddressingMode() == ISD::UNINDEXED;
566 return false;
567}]>;
568
569// truncstore fragments.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000570def truncstorei8 : PatFrag<(ops node:$val, node:$ptr),
571 (st node:$val, node:$ptr), [{
572 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000573 return ST->isTruncatingStore() && ST->getMemoryVT() == MVT::i8 &&
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000574 ST->getAddressingMode() == ISD::UNINDEXED;
575 return false;
576}]>;
577def truncstorei16 : PatFrag<(ops node:$val, node:$ptr),
578 (st node:$val, node:$ptr), [{
579 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000580 return ST->isTruncatingStore() && ST->getMemoryVT() == MVT::i16 &&
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000581 ST->getAddressingMode() == ISD::UNINDEXED;
582 return false;
583}]>;
584def truncstorei32 : PatFrag<(ops node:$val, node:$ptr),
585 (st node:$val, node:$ptr), [{
586 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000587 return ST->isTruncatingStore() && ST->getMemoryVT() == MVT::i32 &&
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000588 ST->getAddressingMode() == ISD::UNINDEXED;
589 return false;
590}]>;
591def truncstoref32 : PatFrag<(ops node:$val, node:$ptr),
592 (st node:$val, node:$ptr), [{
593 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000594 return ST->isTruncatingStore() && ST->getMemoryVT() == MVT::f32 &&
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000595 ST->getAddressingMode() == ISD::UNINDEXED;
596 return false;
597}]>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000598def truncstoref64 : PatFrag<(ops node:$val, node:$ptr),
599 (st node:$val, node:$ptr), [{
600 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000601 return ST->isTruncatingStore() && ST->getMemoryVT() == MVT::f64 &&
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000602 ST->getAddressingMode() == ISD::UNINDEXED;
603 return false;
604}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000605
606// indexed store fragments.
607def pre_store : PatFrag<(ops node:$val, node:$base, node:$offset),
608 (ist node:$val, node:$base, node:$offset), [{
609 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
610 ISD::MemIndexedMode AM = ST->getAddressingMode();
611 return (AM == ISD::PRE_INC || AM == ISD::PRE_DEC) &&
612 !ST->isTruncatingStore();
613 }
614 return false;
615}]>;
616
617def pre_truncsti1 : PatFrag<(ops node:$val, node:$base, node:$offset),
618 (ist node:$val, node:$base, node:$offset), [{
619 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
620 ISD::MemIndexedMode AM = ST->getAddressingMode();
621 return (AM == ISD::PRE_INC || AM == ISD::PRE_DEC) &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000622 ST->isTruncatingStore() && ST->getMemoryVT() == MVT::i1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000623 }
624 return false;
625}]>;
626def pre_truncsti8 : PatFrag<(ops node:$val, node:$base, node:$offset),
627 (ist node:$val, node:$base, node:$offset), [{
628 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
629 ISD::MemIndexedMode AM = ST->getAddressingMode();
630 return (AM == ISD::PRE_INC || AM == ISD::PRE_DEC) &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000631 ST->isTruncatingStore() && ST->getMemoryVT() == MVT::i8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000632 }
633 return false;
634}]>;
635def pre_truncsti16 : PatFrag<(ops node:$val, node:$base, node:$offset),
636 (ist node:$val, node:$base, node:$offset), [{
637 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
638 ISD::MemIndexedMode AM = ST->getAddressingMode();
639 return (AM == ISD::PRE_INC || AM == ISD::PRE_DEC) &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000640 ST->isTruncatingStore() && ST->getMemoryVT() == MVT::i16;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000641 }
642 return false;
643}]>;
644def pre_truncsti32 : PatFrag<(ops node:$val, node:$base, node:$offset),
645 (ist node:$val, node:$base, node:$offset), [{
646 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
647 ISD::MemIndexedMode AM = ST->getAddressingMode();
648 return (AM == ISD::PRE_INC || AM == ISD::PRE_DEC) &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000649 ST->isTruncatingStore() && ST->getMemoryVT() == MVT::i32;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000650 }
651 return false;
652}]>;
653def pre_truncstf32 : PatFrag<(ops node:$val, node:$base, node:$offset),
654 (ist node:$val, node:$base, node:$offset), [{
655 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
656 ISD::MemIndexedMode AM = ST->getAddressingMode();
657 return (AM == ISD::PRE_INC || AM == ISD::PRE_DEC) &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000658 ST->isTruncatingStore() && ST->getMemoryVT() == MVT::f32;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000659 }
660 return false;
661}]>;
662
663def post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
664 (ist node:$val, node:$ptr, node:$offset), [{
665 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
666 ISD::MemIndexedMode AM = ST->getAddressingMode();
667 return !ST->isTruncatingStore() &&
668 (AM == ISD::POST_INC || AM == ISD::POST_DEC);
669 }
670 return false;
671}]>;
672
673def post_truncsti1 : PatFrag<(ops node:$val, node:$base, node:$offset),
674 (ist node:$val, node:$base, node:$offset), [{
675 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
676 ISD::MemIndexedMode AM = ST->getAddressingMode();
677 return (AM == ISD::POST_INC || AM == ISD::POST_DEC) &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000678 ST->isTruncatingStore() && ST->getMemoryVT() == MVT::i1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000679 }
680 return false;
681}]>;
682def post_truncsti8 : PatFrag<(ops node:$val, node:$base, node:$offset),
683 (ist node:$val, node:$base, node:$offset), [{
684 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
685 ISD::MemIndexedMode AM = ST->getAddressingMode();
686 return (AM == ISD::POST_INC || AM == ISD::POST_DEC) &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000687 ST->isTruncatingStore() && ST->getMemoryVT() == MVT::i8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000688 }
689 return false;
690}]>;
691def post_truncsti16 : PatFrag<(ops node:$val, node:$base, node:$offset),
692 (ist node:$val, node:$base, node:$offset), [{
693 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
694 ISD::MemIndexedMode AM = ST->getAddressingMode();
695 return (AM == ISD::POST_INC || AM == ISD::POST_DEC) &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000696 ST->isTruncatingStore() && ST->getMemoryVT() == MVT::i16;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000697 }
698 return false;
699}]>;
700def post_truncsti32 : PatFrag<(ops node:$val, node:$base, node:$offset),
701 (ist node:$val, node:$base, node:$offset), [{
702 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
703 ISD::MemIndexedMode AM = ST->getAddressingMode();
704 return (AM == ISD::POST_INC || AM == ISD::POST_DEC) &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000705 ST->isTruncatingStore() && ST->getMemoryVT() == MVT::i32;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000706 }
707 return false;
708}]>;
709def post_truncstf32 : PatFrag<(ops node:$val, node:$base, node:$offset),
710 (ist node:$val, node:$base, node:$offset), [{
711 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
712 ISD::MemIndexedMode AM = ST->getAddressingMode();
713 return (AM == ISD::POST_INC || AM == ISD::POST_DEC) &&
Dan Gohman9a4c92c2008-01-30 00:15:11 +0000714 ST->isTruncatingStore() && ST->getMemoryVT() == MVT::f32;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000715 }
716 return false;
717}]>;
718
719// setcc convenience fragments.
720def setoeq : PatFrag<(ops node:$lhs, node:$rhs),
721 (setcc node:$lhs, node:$rhs, SETOEQ)>;
722def setogt : PatFrag<(ops node:$lhs, node:$rhs),
723 (setcc node:$lhs, node:$rhs, SETOGT)>;
724def setoge : PatFrag<(ops node:$lhs, node:$rhs),
725 (setcc node:$lhs, node:$rhs, SETOGE)>;
726def setolt : PatFrag<(ops node:$lhs, node:$rhs),
727 (setcc node:$lhs, node:$rhs, SETOLT)>;
728def setole : PatFrag<(ops node:$lhs, node:$rhs),
729 (setcc node:$lhs, node:$rhs, SETOLE)>;
730def setone : PatFrag<(ops node:$lhs, node:$rhs),
731 (setcc node:$lhs, node:$rhs, SETONE)>;
732def seto : PatFrag<(ops node:$lhs, node:$rhs),
733 (setcc node:$lhs, node:$rhs, SETO)>;
734def setuo : PatFrag<(ops node:$lhs, node:$rhs),
735 (setcc node:$lhs, node:$rhs, SETUO)>;
736def setueq : PatFrag<(ops node:$lhs, node:$rhs),
737 (setcc node:$lhs, node:$rhs, SETUEQ)>;
738def setugt : PatFrag<(ops node:$lhs, node:$rhs),
739 (setcc node:$lhs, node:$rhs, SETUGT)>;
740def setuge : PatFrag<(ops node:$lhs, node:$rhs),
741 (setcc node:$lhs, node:$rhs, SETUGE)>;
742def setult : PatFrag<(ops node:$lhs, node:$rhs),
743 (setcc node:$lhs, node:$rhs, SETULT)>;
744def setule : PatFrag<(ops node:$lhs, node:$rhs),
745 (setcc node:$lhs, node:$rhs, SETULE)>;
746def setune : PatFrag<(ops node:$lhs, node:$rhs),
747 (setcc node:$lhs, node:$rhs, SETUNE)>;
748def seteq : PatFrag<(ops node:$lhs, node:$rhs),
749 (setcc node:$lhs, node:$rhs, SETEQ)>;
750def setgt : PatFrag<(ops node:$lhs, node:$rhs),
751 (setcc node:$lhs, node:$rhs, SETGT)>;
752def setge : PatFrag<(ops node:$lhs, node:$rhs),
753 (setcc node:$lhs, node:$rhs, SETGE)>;
754def setlt : PatFrag<(ops node:$lhs, node:$rhs),
755 (setcc node:$lhs, node:$rhs, SETLT)>;
756def setle : PatFrag<(ops node:$lhs, node:$rhs),
757 (setcc node:$lhs, node:$rhs, SETLE)>;
758def setne : PatFrag<(ops node:$lhs, node:$rhs),
759 (setcc node:$lhs, node:$rhs, SETNE)>;
760
761//===----------------------------------------------------------------------===//
762// Selection DAG Pattern Support.
763//
764// Patterns are what are actually matched against the target-flavored
765// instruction selection DAG. Instructions defined by the target implicitly
766// define patterns in most cases, but patterns can also be explicitly added when
767// an operation is defined by a sequence of instructions (e.g. loading a large
768// immediate value on RISC targets that do not support immediates as large as
769// their GPRs).
770//
771
772class Pattern<dag patternToMatch, list<dag> resultInstrs> {
773 dag PatternToMatch = patternToMatch;
774 list<dag> ResultInstrs = resultInstrs;
775 list<Predicate> Predicates = []; // See class Instruction in Target.td.
776 int AddedComplexity = 0; // See class Instruction in Target.td.
777}
778
779// Pat - A simple (but common) form of a pattern, which produces a simple result
780// not needing a full list.
781class Pat<dag pattern, dag result> : Pattern<pattern, [result]>;
782
783//===----------------------------------------------------------------------===//
784// Complex pattern definitions.
785//
Christopher Lamb059c7c92008-01-31 07:27:46 +0000786
787class CPAttribute;
788// Pass the parent Operand as root to CP function rather
789// than the root of the sub-DAG
790def CPAttrParentAsRoot : CPAttribute;
791
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792// Complex patterns, e.g. X86 addressing mode, requires pattern matching code
793// in C++. NumOperands is the number of operands returned by the select function;
794// SelectFunc is the name of the function used to pattern match the max. pattern;
795// RootNodes are the list of possible root nodes of the sub-dags to match.
796// e.g. X86 addressing mode - def addr : ComplexPattern<4, "SelectAddr", [add]>;
797//
798class ComplexPattern<ValueType ty, int numops, string fn,
Christopher Lamb059c7c92008-01-31 07:27:46 +0000799 list<SDNode> roots = [], list<SDNodeProperty> props = [],
800 list<CPAttribute> attrs = []> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000801 ValueType Ty = ty;
802 int NumOperands = numops;
803 string SelectFunc = fn;
804 list<SDNode> RootNodes = roots;
805 list<SDNodeProperty> Properties = props;
Christopher Lamb059c7c92008-01-31 07:27:46 +0000806 list<CPAttribute> Attributes = attrs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000807}
808
809//===----------------------------------------------------------------------===//
810// Dwarf support.
811//
812def SDT_dwarf_loc : SDTypeProfile<0, 3,
813 [SDTCisInt<0>, SDTCisInt<1>, SDTCisInt<2>]>;
814def dwarf_loc : SDNode<"ISD::DEBUG_LOC", SDT_dwarf_loc,[SDNPHasChain]>;
815
816
817