1 //===- TargetSelectionDAG.td - Common code for DAG isels ---*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the target-independent interfaces used by SelectionDAG
11 // instruction selection generators.
13 //===----------------------------------------------------------------------===//
15 //===----------------------------------------------------------------------===//
16 // Selection DAG Type Constraint definitions.
18 // Note that the semantics of these constraints are hard coded into tblgen. To
19 // modify or add constraints, you have to hack tblgen.
22 class SDTypeConstraint<int opnum> {
23 int OperandNum = opnum;
26 // SDTCisVT - The specified operand has exactly this VT.
27 class SDTCisVT<int OpNum, ValueType vt> : SDTypeConstraint<OpNum> {
31 class SDTCisPtrTy<int OpNum> : SDTypeConstraint<OpNum>;
33 // SDTCisInt - The specified operand is has integer type.
34 class SDTCisInt<int OpNum> : SDTypeConstraint<OpNum>;
36 // SDTCisFP - The specified operand is has floating point type.
37 class SDTCisFP<int OpNum> : SDTypeConstraint<OpNum>;
39 // SDTCisSameAs - The two specified operands have identical types.
40 class SDTCisSameAs<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> {
41 int OtherOperandNum = OtherOp;
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;
50 class SDTCisOpSmallerThanOp<int SmallOp, int BigOp> : SDTypeConstraint<SmallOp>{
51 int BigOperandNum = BigOp;
54 /// SDTCisIntVectorOfSameSize - This indicates that ThisOp and OtherOp are
55 /// packed vector types, and that ThisOp is the result of
56 /// MVT::getIntVectorWithNumElements with the number of elements that ThisOp
58 class SDTCisIntVectorOfSameSize<int ThisOp, int OtherOp>
59 : SDTypeConstraint<ThisOp> {
60 int OtherOpNum = OtherOp;
63 //===----------------------------------------------------------------------===//
64 // Selection DAG Type Profile definitions.
66 // These use the constraints defined above to describe the type requirements of
67 // the various nodes. These are not hard coded into tblgen, allowing targets to
68 // add their own if needed.
71 // SDTypeProfile - This profile describes the type requirements of a Selection
73 class SDTypeProfile<int numresults, int numoperands,
74 list<SDTypeConstraint> constraints> {
75 int NumResults = numresults;
76 int NumOperands = numoperands;
77 list<SDTypeConstraint> Constraints = constraints;
81 def SDTIntLeaf: SDTypeProfile<1, 0, [SDTCisInt<0>]>; // for 'imm'.
82 def SDTFPLeaf : SDTypeProfile<1, 0, [SDTCisFP<0>]>; // for 'fpimm'.
83 def SDTPtrLeaf: SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>; // for '&g'.
84 def SDTOther : SDTypeProfile<1, 0, [SDTCisVT<0, OtherVT>]>; // for 'vt'.
85 def SDTUNDEF : SDTypeProfile<1, 0, []>; // for 'undef'.
86 def SDTUnaryOp : SDTypeProfile<1, 1, []>; // bitconvert
88 def SDTIntBinOp : SDTypeProfile<1, 2, [ // add, and, or, xor, udiv, etc.
89 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<0>
91 def SDTIntShiftOp : SDTypeProfile<1, 2, [ // shl, sra, srl
92 SDTCisSameAs<0, 1>, SDTCisInt<0>, SDTCisInt<2>
94 def SDTFPBinOp : SDTypeProfile<1, 2, [ // fadd, fmul, etc.
95 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisFP<0>
97 def SDTFPSignOp : SDTypeProfile<1, 2, [ // fcopysign.
98 SDTCisSameAs<0, 1>, SDTCisFP<0>, SDTCisFP<2>
100 def SDTFPTernaryOp : SDTypeProfile<1, 3, [ // fmadd, fnmsub, etc.
101 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>, SDTCisFP<0>
103 def SDTIntUnaryOp : SDTypeProfile<1, 1, [ // ctlz
104 SDTCisSameAs<0, 1>, SDTCisInt<0>
106 def SDTIntExtendOp : SDTypeProfile<1, 1, [ // sext, zext, anyext
107 SDTCisInt<0>, SDTCisInt<1>, SDTCisOpSmallerThanOp<1, 0>
109 def SDTIntTruncOp : SDTypeProfile<1, 1, [ // trunc
110 SDTCisInt<0>, SDTCisInt<1>, SDTCisOpSmallerThanOp<0, 1>
112 def SDTFPUnaryOp : SDTypeProfile<1, 1, [ // fneg, fsqrt, etc
113 SDTCisSameAs<0, 1>, SDTCisFP<0>
115 def SDTFPRoundOp : SDTypeProfile<1, 1, [ // fround
116 SDTCisFP<0>, SDTCisFP<1>, SDTCisOpSmallerThanOp<0, 1>
118 def SDTFPExtendOp : SDTypeProfile<1, 1, [ // fextend
119 SDTCisFP<0>, SDTCisFP<1>, SDTCisOpSmallerThanOp<1, 0>
121 def SDTIntToFPOp : SDTypeProfile<1, 1, [ // [su]int_to_fp
122 SDTCisFP<0>, SDTCisInt<1>
124 def SDTFPToIntOp : SDTypeProfile<1, 1, [ // fp_to_[su]int
125 SDTCisInt<0>, SDTCisFP<1>
127 def SDTExtInreg : SDTypeProfile<1, 2, [ // sext_inreg
128 SDTCisSameAs<0, 1>, SDTCisInt<0>, SDTCisVT<2, OtherVT>,
129 SDTCisVTSmallerThanOp<2, 1>
132 def SDTSetCC : SDTypeProfile<1, 3, [ // setcc
133 SDTCisInt<0>, SDTCisSameAs<1, 2>, SDTCisVT<3, OtherVT>
136 def SDTSelect : SDTypeProfile<1, 3, [ // select
137 SDTCisInt<1>, SDTCisSameAs<0, 2>, SDTCisSameAs<2, 3>
140 def SDTSelectCC : SDTypeProfile<1, 5, [ // select_cc
141 SDTCisSameAs<1, 2>, SDTCisSameAs<3, 4>, SDTCisSameAs<0, 3>,
145 def SDTBr : SDTypeProfile<0, 1, [ // br
149 def SDTBrcond : SDTypeProfile<0, 2, [ // brcond
150 SDTCisInt<0>, SDTCisVT<1, OtherVT>
153 def SDTBrind : SDTypeProfile<0, 1, [ // brind
157 def SDTRet : SDTypeProfile<0, 0, []>; // ret
159 def SDTLoad : SDTypeProfile<1, 1, [ // load
163 def SDTStore : SDTypeProfile<0, 2, [ // store
167 def SDTVecShuffle : SDTypeProfile<1, 3, [
168 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisIntVectorOfSameSize<3, 0>
171 //===----------------------------------------------------------------------===//
172 // Selection DAG Node Properties.
174 // Note: These are hard coded into tblgen.
176 class SDNodeProperty;
177 def SDNPCommutative : SDNodeProperty; // X op Y == Y op X
178 def SDNPAssociative : SDNodeProperty; // (X op Y) op Z == X op (Y op Z)
179 def SDNPHasChain : SDNodeProperty; // R/W chain operand and result
180 def SDNPOutFlag : SDNodeProperty; // Write a flag result
181 def SDNPInFlag : SDNodeProperty; // Read a flag operand
182 def SDNPOptInFlag : SDNodeProperty; // Optionally read a flag operand
184 //===----------------------------------------------------------------------===//
185 // Selection DAG Node definitions.
187 class SDNode<string opcode, SDTypeProfile typeprof,
188 list<SDNodeProperty> props = [], string sdclass = "SDNode"> {
189 string Opcode = opcode;
190 string SDClass = sdclass;
191 list<SDNodeProperty> Properties = props;
192 SDTypeProfile TypeProfile = typeprof;
199 def imm : SDNode<"ISD::Constant" , SDTIntLeaf , [], "ConstantSDNode">;
200 def fpimm : SDNode<"ISD::TargetConstantFP",
201 SDTFPLeaf, [], "ConstantFPSDNode">;
202 def vt : SDNode<"ISD::VALUETYPE" , SDTOther , [], "VTSDNode">;
203 def bb : SDNode<"ISD::BasicBlock", SDTOther , [], "BasicBlockSDNode">;
204 def cond : SDNode<"ISD::CONDCODE" , SDTOther , [], "CondCodeSDNode">;
205 def undef : SDNode<"ISD::UNDEF" , SDTUNDEF , []>;
206 def globaladdr : SDNode<"ISD::GlobalAddress", SDTPtrLeaf, [],
207 "GlobalAddressSDNode">;
208 def tglobaladdr : SDNode<"ISD::TargetGlobalAddress", SDTPtrLeaf, [],
209 "GlobalAddressSDNode">;
210 def constpool : SDNode<"ISD::ConstantPool", SDTPtrLeaf, [],
211 "ConstantPoolSDNode">;
212 def tconstpool : SDNode<"ISD::TargetConstantPool", SDTPtrLeaf, [],
213 "ConstantPoolSDNode">;
214 def jumptable : SDNode<"ISD::JumpTable", SDTPtrLeaf, [],
216 def tjumptable : SDNode<"ISD::TargetJumpTable", SDTPtrLeaf, [],
218 def frameindex : SDNode<"ISD::FrameIndex", SDTPtrLeaf, [],
220 def tframeindex : SDNode<"ISD::TargetFrameIndex", SDTPtrLeaf, [],
222 def externalsym : SDNode<"ISD::ExternalSymbol", SDTPtrLeaf, [],
223 "ExternalSymbolSDNode">;
224 def texternalsym: SDNode<"ISD::TargetExternalSymbol", SDTPtrLeaf, [],
225 "ExternalSymbolSDNode">;
227 def add : SDNode<"ISD::ADD" , SDTIntBinOp ,
228 [SDNPCommutative, SDNPAssociative]>;
229 def sub : SDNode<"ISD::SUB" , SDTIntBinOp>;
230 def mul : SDNode<"ISD::MUL" , SDTIntBinOp,
231 [SDNPCommutative, SDNPAssociative]>;
232 def mulhs : SDNode<"ISD::MULHS" , SDTIntBinOp, [SDNPCommutative]>;
233 def mulhu : SDNode<"ISD::MULHU" , SDTIntBinOp, [SDNPCommutative]>;
234 def sdiv : SDNode<"ISD::SDIV" , SDTIntBinOp>;
235 def udiv : SDNode<"ISD::UDIV" , SDTIntBinOp>;
236 def srem : SDNode<"ISD::SREM" , SDTIntBinOp>;
237 def urem : SDNode<"ISD::UREM" , SDTIntBinOp>;
238 def srl : SDNode<"ISD::SRL" , SDTIntShiftOp>;
239 def sra : SDNode<"ISD::SRA" , SDTIntShiftOp>;
240 def shl : SDNode<"ISD::SHL" , SDTIntShiftOp>;
241 def rotl : SDNode<"ISD::ROTL" , SDTIntShiftOp>;
242 def rotr : SDNode<"ISD::ROTR" , SDTIntShiftOp>;
243 def and : SDNode<"ISD::AND" , SDTIntBinOp,
244 [SDNPCommutative, SDNPAssociative]>;
245 def or : SDNode<"ISD::OR" , SDTIntBinOp,
246 [SDNPCommutative, SDNPAssociative]>;
247 def xor : SDNode<"ISD::XOR" , SDTIntBinOp,
248 [SDNPCommutative, SDNPAssociative]>;
249 def addc : SDNode<"ISD::ADDC" , SDTIntBinOp,
250 [SDNPCommutative, SDNPOutFlag]>;
251 def adde : SDNode<"ISD::ADDE" , SDTIntBinOp,
252 [SDNPCommutative, SDNPOutFlag, SDNPInFlag]>;
253 def subc : SDNode<"ISD::SUBC" , SDTIntBinOp,
255 def sube : SDNode<"ISD::SUBE" , SDTIntBinOp,
256 [SDNPOutFlag, SDNPInFlag]>;
258 def sext_inreg : SDNode<"ISD::SIGN_EXTEND_INREG", SDTExtInreg>;
259 def bswap : SDNode<"ISD::BSWAP" , SDTIntUnaryOp>;
260 def ctlz : SDNode<"ISD::CTLZ" , SDTIntUnaryOp>;
261 def cttz : SDNode<"ISD::CTTZ" , SDTIntUnaryOp>;
262 def ctpop : SDNode<"ISD::CTPOP" , SDTIntUnaryOp>;
263 def sext : SDNode<"ISD::SIGN_EXTEND", SDTIntExtendOp>;
264 def zext : SDNode<"ISD::ZERO_EXTEND", SDTIntExtendOp>;
265 def anyext : SDNode<"ISD::ANY_EXTEND" , SDTIntExtendOp>;
266 def trunc : SDNode<"ISD::TRUNCATE" , SDTIntTruncOp>;
267 def bitconvert : SDNode<"ISD::BIT_CONVERT", SDTUnaryOp>;
269 def fadd : SDNode<"ISD::FADD" , SDTFPBinOp, [SDNPCommutative]>;
270 def fsub : SDNode<"ISD::FSUB" , SDTFPBinOp>;
271 def fmul : SDNode<"ISD::FMUL" , SDTFPBinOp, [SDNPCommutative]>;
272 def fdiv : SDNode<"ISD::FDIV" , SDTFPBinOp>;
273 def frem : SDNode<"ISD::FREM" , SDTFPBinOp>;
274 def fabs : SDNode<"ISD::FABS" , SDTFPUnaryOp>;
275 def fneg : SDNode<"ISD::FNEG" , SDTFPUnaryOp>;
276 def fsqrt : SDNode<"ISD::FSQRT" , SDTFPUnaryOp>;
277 def fsin : SDNode<"ISD::FSIN" , SDTFPUnaryOp>;
278 def fcos : SDNode<"ISD::FCOS" , SDTFPUnaryOp>;
280 def fround : SDNode<"ISD::FP_ROUND" , SDTFPRoundOp>;
281 def fextend : SDNode<"ISD::FP_EXTEND" , SDTFPExtendOp>;
282 def fcopysign : SDNode<"ISD::FCOPYSIGN" , SDTFPSignOp>;
284 def sint_to_fp : SDNode<"ISD::SINT_TO_FP" , SDTIntToFPOp>;
285 def uint_to_fp : SDNode<"ISD::UINT_TO_FP" , SDTIntToFPOp>;
286 def fp_to_sint : SDNode<"ISD::FP_TO_SINT" , SDTFPToIntOp>;
287 def fp_to_uint : SDNode<"ISD::FP_TO_UINT" , SDTFPToIntOp>;
289 def setcc : SDNode<"ISD::SETCC" , SDTSetCC>;
290 def select : SDNode<"ISD::SELECT" , SDTSelect>;
291 def selectcc : SDNode<"ISD::SELECT_CC" , SDTSelectCC>;
293 def brcond : SDNode<"ISD::BRCOND" , SDTBrcond, [SDNPHasChain]>;
294 def brind : SDNode<"ISD::BRIND" , SDTBrind, [SDNPHasChain]>;
295 def br : SDNode<"ISD::BR" , SDTBr, [SDNPHasChain]>;
296 def ret : SDNode<"ISD::RET" , SDTRet, [SDNPHasChain]>;
298 // Do not use ld, st directly. Use load, extload, sextload, zextload, store,
299 // and truncst (see below).
300 def ld : SDNode<"ISD::LOAD" , SDTLoad, [SDNPHasChain]>;
301 def st : SDNode<"ISD::STORE" , SDTStore, [SDNPHasChain]>;
303 def vector_shuffle : SDNode<"ISD::VECTOR_SHUFFLE", SDTVecShuffle, []>;
304 def build_vector : SDNode<"ISD::BUILD_VECTOR", SDTypeProfile<1, 0, []>, []>;
305 def scalar_to_vector : SDNode<"ISD::SCALAR_TO_VECTOR", SDTypeProfile<1, 1, []>,
307 def vector_extract : SDNode<"ISD::EXTRACT_VECTOR_ELT",
308 SDTypeProfile<1, 2, [SDTCisPtrTy<2>]>, []>;
309 def vector_insert : SDNode<"ISD::INSERT_VECTOR_ELT",
310 SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisPtrTy<3>]>, []>;
312 // Nodes for intrinsics, you should use the intrinsic itself and let tblgen use
313 // these internally. Don't reference these directly.
314 def intrinsic_void : SDNode<"ISD::INTRINSIC_VOID",
315 SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>,
317 def intrinsic_w_chain : SDNode<"ISD::INTRINSIC_W_CHAIN",
318 SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>,
320 def intrinsic_wo_chain : SDNode<"ISD::INTRINSIC_WO_CHAIN",
321 SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>, []>;
324 //===----------------------------------------------------------------------===//
325 // Selection DAG Condition Codes
327 class CondCode; // ISD::CondCode enums
328 def SETOEQ : CondCode; def SETOGT : CondCode;
329 def SETOGE : CondCode; def SETOLT : CondCode; def SETOLE : CondCode;
330 def SETONE : CondCode; def SETO : CondCode; def SETUO : CondCode;
331 def SETUEQ : CondCode; def SETUGT : CondCode; def SETUGE : CondCode;
332 def SETULT : CondCode; def SETULE : CondCode; def SETUNE : CondCode;
334 def SETEQ : CondCode; def SETGT : CondCode; def SETGE : CondCode;
335 def SETLT : CondCode; def SETLE : CondCode; def SETNE : CondCode;
338 //===----------------------------------------------------------------------===//
339 // Selection DAG Node Transformation Functions.
341 // This mechanism allows targets to manipulate nodes in the output DAG once a
342 // match has been formed. This is typically used to manipulate immediate
345 class SDNodeXForm<SDNode opc, code xformFunction> {
347 code XFormFunction = xformFunction;
350 def NOOP_SDNodeXForm : SDNodeXForm<imm, [{}]>;
353 //===----------------------------------------------------------------------===//
354 // Selection DAG Pattern Fragments.
356 // Pattern fragments are reusable chunks of dags that match specific things.
357 // They can take arguments and have C++ predicates that control whether they
358 // match. They are intended to make the patterns for common instructions more
359 // compact and readable.
362 /// PatFrag - Represents a pattern fragment. This can match something on the
363 /// DAG, frame a single node to multiply nested other fragments.
365 class PatFrag<dag ops, dag frag, code pred = [{}],
366 SDNodeXForm xform = NOOP_SDNodeXForm> {
369 code Predicate = pred;
370 SDNodeXForm OperandTransform = xform;
373 // PatLeaf's are pattern fragments that have no operands. This is just a helper
374 // to define immediates and other common things concisely.
375 class PatLeaf<dag frag, code pred = [{}], SDNodeXForm xform = NOOP_SDNodeXForm>
376 : PatFrag<(ops), frag, pred, xform>;
380 def vtInt : PatLeaf<(vt), [{ return MVT::isInteger(N->getVT()); }]>;
381 def vtFP : PatLeaf<(vt), [{ return MVT::isFloatingPoint(N->getVT()); }]>;
383 def immAllOnes : PatLeaf<(imm), [{ return N->isAllOnesValue(); }]>;
384 def immAllOnesV: PatLeaf<(build_vector), [{
385 return ISD::isBuildVectorAllOnes(N);
387 def immAllZerosV: PatLeaf<(build_vector), [{
388 return ISD::isBuildVectorAllZeros(N);
391 def immAllOnesV_bc: PatLeaf<(bitconvert), [{
392 return ISD::isBuildVectorAllOnes(N);
396 // Other helper fragments.
397 def not : PatFrag<(ops node:$in), (xor node:$in, immAllOnes)>;
398 def vnot : PatFrag<(ops node:$in), (xor node:$in, immAllOnesV)>;
399 def vnot_conv : PatFrag<(ops node:$in), (xor node:$in, immAllOnesV_bc)>;
400 def ineg : PatFrag<(ops node:$in), (sub 0, node:$in)>;
402 def load : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
403 return ISD::isNON_EXTLoad(N);
406 // extending load fragments.
407 def extloadi1 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
408 if (ISD::isEXTLoad(N))
409 return cast<LoadSDNode>(N)->getLoadedVT() == MVT::i1;
412 def extloadi8 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
413 if (ISD::isEXTLoad(N))
414 return cast<LoadSDNode>(N)->getLoadedVT() == MVT::i8;
417 def extloadi16 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
418 if (ISD::isEXTLoad(N))
419 return cast<LoadSDNode>(N)->getLoadedVT() == MVT::i16;
422 def extloadi32 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
423 if (ISD::isEXTLoad(N))
424 return cast<LoadSDNode>(N)->getLoadedVT() == MVT::i32;
427 def extloadf32 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
428 if (ISD::isEXTLoad(N))
429 return cast<LoadSDNode>(N)->getLoadedVT() == MVT::f32;
433 def sextloadi1 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
434 if (ISD::isSEXTLoad(N))
435 return cast<LoadSDNode>(N)->getLoadedVT() == MVT::i1;
438 def sextloadi8 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
439 if (ISD::isSEXTLoad(N))
440 return cast<LoadSDNode>(N)->getLoadedVT() == MVT::i8;
443 def sextloadi16 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
444 if (ISD::isSEXTLoad(N))
445 return cast<LoadSDNode>(N)->getLoadedVT() == MVT::i16;
448 def sextloadi32 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
449 if (ISD::isSEXTLoad(N))
450 return cast<LoadSDNode>(N)->getLoadedVT() == MVT::i32;
454 def zextloadi1 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
455 if (ISD::isZEXTLoad(N))
456 return cast<LoadSDNode>(N)->getLoadedVT() == MVT::i1;
459 def zextloadi8 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
460 if (ISD::isZEXTLoad(N))
461 return cast<LoadSDNode>(N)->getLoadedVT() == MVT::i8;
464 def zextloadi16 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
465 if (ISD::isZEXTLoad(N))
466 return cast<LoadSDNode>(N)->getLoadedVT() == MVT::i16;
469 def zextloadi32 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
470 if (ISD::isZEXTLoad(N))
471 return cast<LoadSDNode>(N)->getLoadedVT() == MVT::i32;
475 def store : PatFrag<(ops node:$val, node:$ptr),
476 (st node:$val, node:$ptr), [{
477 return ISD::isNON_TRUNCStore(N);
480 // truncstore fragments.
481 def truncstorei1 : PatFrag<(ops node:$val, node:$ptr),
482 (st node:$val, node:$ptr), [{
483 if (ISD::isTRUNCStore(N))
484 return cast<StoreSDNode>(N)->getStoredVT() == MVT::i1;
487 def truncstorei8 : PatFrag<(ops node:$val, node:$ptr),
488 (st node:$val, node:$ptr), [{
489 if (ISD::isTRUNCStore(N))
490 return cast<StoreSDNode>(N)->getStoredVT() == MVT::i8;
493 def truncstorei16 : PatFrag<(ops node:$val, node:$ptr),
494 (st node:$val, node:$ptr), [{
495 if (ISD::isTRUNCStore(N))
496 return cast<StoreSDNode>(N)->getStoredVT() == MVT::i16;
499 def truncstorei32 : PatFrag<(ops node:$val, node:$ptr),
500 (st node:$val, node:$ptr), [{
501 if (ISD::isTRUNCStore(N))
502 return cast<StoreSDNode>(N)->getStoredVT() == MVT::i32;
505 def truncstoref32 : PatFrag<(ops node:$val, node:$ptr),
506 (st node:$val, node:$ptr), [{
507 if (ISD::isTRUNCStore(N))
508 return cast<StoreSDNode>(N)->getStoredVT() == MVT::f32;
512 // setcc convenience fragments.
513 def setoeq : PatFrag<(ops node:$lhs, node:$rhs),
514 (setcc node:$lhs, node:$rhs, SETOEQ)>;
515 def setogt : PatFrag<(ops node:$lhs, node:$rhs),
516 (setcc node:$lhs, node:$rhs, SETOGT)>;
517 def setoge : PatFrag<(ops node:$lhs, node:$rhs),
518 (setcc node:$lhs, node:$rhs, SETOGE)>;
519 def setolt : PatFrag<(ops node:$lhs, node:$rhs),
520 (setcc node:$lhs, node:$rhs, SETOLT)>;
521 def setole : PatFrag<(ops node:$lhs, node:$rhs),
522 (setcc node:$lhs, node:$rhs, SETOLE)>;
523 def setone : PatFrag<(ops node:$lhs, node:$rhs),
524 (setcc node:$lhs, node:$rhs, SETONE)>;
525 def seto : PatFrag<(ops node:$lhs, node:$rhs),
526 (setcc node:$lhs, node:$rhs, SETO)>;
527 def setuo : PatFrag<(ops node:$lhs, node:$rhs),
528 (setcc node:$lhs, node:$rhs, SETUO)>;
529 def setueq : PatFrag<(ops node:$lhs, node:$rhs),
530 (setcc node:$lhs, node:$rhs, SETUEQ)>;
531 def setugt : PatFrag<(ops node:$lhs, node:$rhs),
532 (setcc node:$lhs, node:$rhs, SETUGT)>;
533 def setuge : PatFrag<(ops node:$lhs, node:$rhs),
534 (setcc node:$lhs, node:$rhs, SETUGE)>;
535 def setult : PatFrag<(ops node:$lhs, node:$rhs),
536 (setcc node:$lhs, node:$rhs, SETULT)>;
537 def setule : PatFrag<(ops node:$lhs, node:$rhs),
538 (setcc node:$lhs, node:$rhs, SETULE)>;
539 def setune : PatFrag<(ops node:$lhs, node:$rhs),
540 (setcc node:$lhs, node:$rhs, SETUNE)>;
541 def seteq : PatFrag<(ops node:$lhs, node:$rhs),
542 (setcc node:$lhs, node:$rhs, SETEQ)>;
543 def setgt : PatFrag<(ops node:$lhs, node:$rhs),
544 (setcc node:$lhs, node:$rhs, SETGT)>;
545 def setge : PatFrag<(ops node:$lhs, node:$rhs),
546 (setcc node:$lhs, node:$rhs, SETGE)>;
547 def setlt : PatFrag<(ops node:$lhs, node:$rhs),
548 (setcc node:$lhs, node:$rhs, SETLT)>;
549 def setle : PatFrag<(ops node:$lhs, node:$rhs),
550 (setcc node:$lhs, node:$rhs, SETLE)>;
551 def setne : PatFrag<(ops node:$lhs, node:$rhs),
552 (setcc node:$lhs, node:$rhs, SETNE)>;
554 //===----------------------------------------------------------------------===//
555 // Selection DAG Pattern Support.
557 // Patterns are what are actually matched against the target-flavored
558 // instruction selection DAG. Instructions defined by the target implicitly
559 // define patterns in most cases, but patterns can also be explicitly added when
560 // an operation is defined by a sequence of instructions (e.g. loading a large
561 // immediate value on RISC targets that do not support immediates as large as
565 class Pattern<dag patternToMatch, list<dag> resultInstrs> {
566 dag PatternToMatch = patternToMatch;
567 list<dag> ResultInstrs = resultInstrs;
568 list<Predicate> Predicates = []; // See class Instruction in Target.td.
569 int AddedComplexity = 0; // See class Instruction in Target.td.
572 // Pat - A simple (but common) form of a pattern, which produces a simple result
573 // not needing a full list.
574 class Pat<dag pattern, dag result> : Pattern<pattern, [result]>;
576 //===----------------------------------------------------------------------===//
577 // Complex pattern definitions.
579 // Complex patterns, e.g. X86 addressing mode, requires pattern matching code
580 // in C++. NumOperands is the number of operands returned by the select function;
581 // SelectFunc is the name of the function used to pattern match the max. pattern;
582 // RootNodes are the list of possible root nodes of the sub-dags to match.
583 // e.g. X86 addressing mode - def addr : ComplexPattern<4, "SelectAddr", [add]>;
585 class ComplexPattern<ValueType ty, int numops, string fn,
586 list<SDNode> roots = [], list<SDNodeProperty> props = []> {
588 int NumOperands = numops;
589 string SelectFunc = fn;
590 list<SDNode> RootNodes = roots;
591 list<SDNodeProperty> Properties = props;
594 //===----------------------------------------------------------------------===//
597 def SDT_dwarf_loc : SDTypeProfile<0, 3,
598 [SDTCisInt<0>, SDTCisInt<1>, SDTCisInt<2>]>;
599 def dwarf_loc : SDNode<"ISD::DEBUG_LOC", SDT_dwarf_loc,[SDNPHasChain]>;
601 def SDT_dwarf_label : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
602 def dwarf_label : SDNode<"ISD::DEBUG_LABEL", SDT_dwarf_label,[SDNPHasChain]>;