[ARM] Add support for MVE pre and post inc loads and stores
[llvm-core.git] / include / llvm / Target / TargetSelectionDAG.td
blob453948a6a5b5c7f788667124e5af4aca345c6247
1 //===- TargetSelectionDAG.td - Common code for DAG isels ---*- tablegen -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the target-independent interfaces used by SelectionDAG
10 // instruction selection generators.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 // Selection DAG Type Constraint definitions.
17 // Note that the semantics of these constraints are hard coded into tblgen.  To
18 // modify or add constraints, you have to hack tblgen.
21 class SDTypeConstraint<int opnum> {
22   int OperandNum = opnum;
25 // SDTCisVT - The specified operand has exactly this VT.
26 class SDTCisVT<int OpNum, ValueType vt> : SDTypeConstraint<OpNum> {
27   ValueType VT = vt;
30 class SDTCisPtrTy<int OpNum> : SDTypeConstraint<OpNum>;
32 // SDTCisInt - The specified operand has integer type.
33 class SDTCisInt<int OpNum> : SDTypeConstraint<OpNum>;
35 // SDTCisFP - The specified operand has floating-point type.
36 class SDTCisFP<int OpNum> : SDTypeConstraint<OpNum>;
38 // SDTCisVec - The specified operand has a vector type.
39 class SDTCisVec<int OpNum> : SDTypeConstraint<OpNum>;
41 // SDTCisSameAs - The two specified operands have identical types.
42 class SDTCisSameAs<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> {
43   int OtherOperandNum = OtherOp;
46 // SDTCisVTSmallerThanOp - The specified operand is a VT SDNode, and its type is
47 // smaller than the 'Other' operand.
48 class SDTCisVTSmallerThanOp<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> {
49   int OtherOperandNum = OtherOp;
52 class SDTCisOpSmallerThanOp<int SmallOp, int BigOp> : SDTypeConstraint<SmallOp>{
53   int BigOperandNum = BigOp;
56 /// SDTCisEltOfVec - This indicates that ThisOp is a scalar type of the same
57 /// type as the element type of OtherOp, which is a vector type.
58 class SDTCisEltOfVec<int ThisOp, int OtherOp>
59   : SDTypeConstraint<ThisOp> {
60   int OtherOpNum = OtherOp;
63 /// SDTCisSubVecOfVec - This indicates that ThisOp is a vector type
64 /// with length less that of OtherOp, which is a vector type.
65 class SDTCisSubVecOfVec<int ThisOp, int OtherOp>
66   : SDTypeConstraint<ThisOp> {
67   int OtherOpNum = OtherOp;
70 // SDTCVecEltisVT - The specified operand is vector type with element type
71 // of VT.
72 class SDTCVecEltisVT<int OpNum, ValueType vt> : SDTypeConstraint<OpNum> {
73   ValueType VT = vt;
76 // SDTCisSameNumEltsAs - The two specified operands have identical number
77 // of elements.
78 class SDTCisSameNumEltsAs<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> {
79   int OtherOperandNum = OtherOp;
82 // SDTCisSameSizeAs - The two specified operands have identical size.
83 class SDTCisSameSizeAs<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> {
84   int OtherOperandNum = OtherOp;
87 //===----------------------------------------------------------------------===//
88 // Selection DAG Type Profile definitions.
90 // These use the constraints defined above to describe the type requirements of
91 // the various nodes.  These are not hard coded into tblgen, allowing targets to
92 // add their own if needed.
95 // SDTypeProfile - This profile describes the type requirements of a Selection
96 // DAG node.
97 class SDTypeProfile<int numresults, int numoperands,
98                     list<SDTypeConstraint> constraints> {
99   int NumResults = numresults;
100   int NumOperands = numoperands;
101   list<SDTypeConstraint> Constraints = constraints;
104 // Builtin profiles.
105 def SDTIntLeaf: SDTypeProfile<1, 0, [SDTCisInt<0>]>;         // for 'imm'.
106 def SDTFPLeaf : SDTypeProfile<1, 0, [SDTCisFP<0>]>;          // for 'fpimm'.
107 def SDTPtrLeaf: SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;       // for '&g'.
108 def SDTOther  : SDTypeProfile<1, 0, [SDTCisVT<0, OtherVT>]>; // for 'vt'.
109 def SDTUNDEF  : SDTypeProfile<1, 0, []>;                     // for 'undef'.
110 def SDTUnaryOp  : SDTypeProfile<1, 1, []>;                   // for bitconvert.
112 def SDTIntBinOp : SDTypeProfile<1, 2, [     // add, and, or, xor, udiv, etc.
113   SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<0>
115 def SDTIntShiftOp : SDTypeProfile<1, 2, [   // shl, sra, srl
116   SDTCisSameAs<0, 1>, SDTCisInt<0>, SDTCisInt<2>
118 def SDTIntShiftDOp: SDTypeProfile<1, 3, [   // fshl, fshr
119   SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<0>, SDTCisInt<3>
121 def SDTIntSatNoShOp : SDTypeProfile<1, 2, [   // ssat with no shift
122   SDTCisSameAs<0, 1>, SDTCisInt<2>
124 def SDTIntBinHiLoOp : SDTypeProfile<2, 2, [ // mulhi, mullo, sdivrem, udivrem
125   SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>,SDTCisInt<0>
127 def SDTIntScaledBinOp : SDTypeProfile<1, 3, [  // smulfix, umulfix
128   SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<0>, SDTCisInt<3>
131 def SDTFPBinOp : SDTypeProfile<1, 2, [      // fadd, fmul, etc.
132   SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisFP<0>
134 def SDTFPSignOp : SDTypeProfile<1, 2, [     // fcopysign.
135   SDTCisSameAs<0, 1>, SDTCisFP<0>, SDTCisFP<2>
137 def SDTFPTernaryOp : SDTypeProfile<1, 3, [  // fmadd, fnmsub, etc.
138   SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>, SDTCisFP<0>
140 def SDTIntUnaryOp : SDTypeProfile<1, 1, [   // ctlz, cttz
141   SDTCisSameAs<0, 1>, SDTCisInt<0>
143 def SDTIntExtendOp : SDTypeProfile<1, 1, [  // sext, zext, anyext
144   SDTCisInt<0>, SDTCisInt<1>, SDTCisOpSmallerThanOp<1, 0>, SDTCisSameNumEltsAs<0, 1>
146 def SDTIntTruncOp  : SDTypeProfile<1, 1, [  // trunc
147   SDTCisInt<0>, SDTCisInt<1>, SDTCisOpSmallerThanOp<0, 1>, SDTCisSameNumEltsAs<0, 1>
149 def SDTFPUnaryOp  : SDTypeProfile<1, 1, [   // fneg, fsqrt, etc
150   SDTCisSameAs<0, 1>, SDTCisFP<0>
152 def SDTFPRoundOp  : SDTypeProfile<1, 1, [   // fround
153   SDTCisFP<0>, SDTCisFP<1>, SDTCisOpSmallerThanOp<0, 1>, SDTCisSameNumEltsAs<0, 1>
155 def SDTFPExtendOp  : SDTypeProfile<1, 1, [  // fextend
156   SDTCisFP<0>, SDTCisFP<1>, SDTCisOpSmallerThanOp<1, 0>, SDTCisSameNumEltsAs<0, 1>
158 def SDTIntToFPOp : SDTypeProfile<1, 1, [    // [su]int_to_fp
159   SDTCisFP<0>, SDTCisInt<1>, SDTCisSameNumEltsAs<0, 1>
161 def SDTFPToIntOp : SDTypeProfile<1, 1, [    // fp_to_[su]int
162   SDTCisInt<0>, SDTCisFP<1>, SDTCisSameNumEltsAs<0, 1>
164 def SDTExtInreg : SDTypeProfile<1, 2, [     // sext_inreg
165   SDTCisSameAs<0, 1>, SDTCisInt<0>, SDTCisVT<2, OtherVT>,
166   SDTCisVTSmallerThanOp<2, 1>
168 def SDTExtInvec : SDTypeProfile<1, 1, [     // sext_invec
169   SDTCisInt<0>, SDTCisVec<0>, SDTCisInt<1>, SDTCisVec<1>,
170   SDTCisOpSmallerThanOp<1, 0>
173 def SDTSetCC : SDTypeProfile<1, 3, [        // setcc
174   SDTCisInt<0>, SDTCisSameAs<1, 2>, SDTCisVT<3, OtherVT>
177 def SDTSelect : SDTypeProfile<1, 3, [       // select
178   SDTCisInt<1>, SDTCisSameAs<0, 2>, SDTCisSameAs<2, 3>
181 def SDTVSelect : SDTypeProfile<1, 3, [       // vselect
182   SDTCisVec<0>, SDTCisInt<1>, SDTCisSameAs<0, 2>, SDTCisSameAs<2, 3>, SDTCisSameNumEltsAs<0, 1>
185 def SDTSelectCC : SDTypeProfile<1, 5, [     // select_cc
186   SDTCisSameAs<1, 2>, SDTCisSameAs<3, 4>, SDTCisSameAs<0, 3>,
187   SDTCisVT<5, OtherVT>
190 def SDTBr : SDTypeProfile<0, 1, [           // br
191   SDTCisVT<0, OtherVT>
194 def SDTBrCC : SDTypeProfile<0, 4, [       // brcc
195   SDTCisVT<0, OtherVT>, SDTCisSameAs<1, 2>, SDTCisVT<3, OtherVT>
198 def SDTBrcond : SDTypeProfile<0, 2, [       // brcond
199   SDTCisInt<0>, SDTCisVT<1, OtherVT>
202 def SDTBrind : SDTypeProfile<0, 1, [        // brind
203   SDTCisPtrTy<0>
206 def SDTCatchret : SDTypeProfile<0, 2, [     // catchret
207   SDTCisVT<0, OtherVT>, SDTCisVT<1, OtherVT>
210 def SDTNone : SDTypeProfile<0, 0, []>;      // ret, trap
212 def SDTLoad : SDTypeProfile<1, 1, [         // load
213   SDTCisPtrTy<1>
216 def SDTStore : SDTypeProfile<0, 2, [        // store
217   SDTCisPtrTy<1>
220 def SDTIStore : SDTypeProfile<1, 3, [       // indexed store
221   SDTCisSameAs<0, 2>, SDTCisPtrTy<0>, SDTCisPtrTy<3>
224 def SDTMaskedStore: SDTypeProfile<0, 3, [       // masked store
225   SDTCisVec<0>, SDTCisPtrTy<1>, SDTCisVec<2>, SDTCisSameNumEltsAs<0, 2>
228 def SDTMaskedLoad: SDTypeProfile<1, 3, [       // masked load
229   SDTCisVec<0>, SDTCisPtrTy<1>, SDTCisVec<2>, SDTCisSameAs<0, 3>,
230   SDTCisSameNumEltsAs<0, 2>
233 def SDTVecShuffle : SDTypeProfile<1, 2, [
234   SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>
236 def SDTVecExtract : SDTypeProfile<1, 2, [   // vector extract
237   SDTCisEltOfVec<0, 1>, SDTCisPtrTy<2>
239 def SDTVecInsert : SDTypeProfile<1, 3, [    // vector insert
240   SDTCisEltOfVec<2, 1>, SDTCisSameAs<0, 1>, SDTCisPtrTy<3>
243 def SDTSubVecExtract : SDTypeProfile<1, 2, [// subvector extract
244   SDTCisSubVecOfVec<0,1>, SDTCisInt<2>
246 def SDTSubVecInsert : SDTypeProfile<1, 3, [ // subvector insert
247   SDTCisSubVecOfVec<2, 1>, SDTCisSameAs<0,1>, SDTCisInt<3>
250 def SDTPrefetch : SDTypeProfile<0, 4, [     // prefetch
251   SDTCisPtrTy<0>, SDTCisSameAs<1, 2>, SDTCisSameAs<1, 3>, SDTCisInt<1>
254 def SDTMemBarrier : SDTypeProfile<0, 5, [   // memory barrier
255   SDTCisSameAs<0,1>,  SDTCisSameAs<0,2>,  SDTCisSameAs<0,3>, SDTCisSameAs<0,4>,
256   SDTCisInt<0>
258 def SDTAtomicFence : SDTypeProfile<0, 2, [
259   SDTCisSameAs<0,1>, SDTCisPtrTy<0>
261 def SDTAtomic3 : SDTypeProfile<1, 3, [
262   SDTCisSameAs<0,2>,  SDTCisSameAs<0,3>, SDTCisInt<0>, SDTCisPtrTy<1>
264 def SDTAtomic2 : SDTypeProfile<1, 2, [
265   SDTCisSameAs<0,2>, SDTCisInt<0>, SDTCisPtrTy<1>
268 def SDTFPAtomic2 : SDTypeProfile<1, 2, [
269   SDTCisSameAs<0,2>, SDTCisFP<0>, SDTCisPtrTy<1>
272 def SDTAtomicStore : SDTypeProfile<0, 2, [
273   SDTCisPtrTy<0>, SDTCisInt<1>
275 def SDTAtomicLoad : SDTypeProfile<1, 1, [
276   SDTCisInt<0>, SDTCisPtrTy<1>
279 def SDTConvertOp : SDTypeProfile<1, 5, [ //cvtss, su, us, uu, ff, fs, fu, sf, su
280   SDTCisVT<2, OtherVT>, SDTCisVT<3, OtherVT>, SDTCisPtrTy<4>, SDTCisPtrTy<5>
283 class SDCallSeqStart<list<SDTypeConstraint> constraints> :
284         SDTypeProfile<0, 2, constraints>;
285 class SDCallSeqEnd<list<SDTypeConstraint> constraints> :
286         SDTypeProfile<0, 2, constraints>;
288 //===----------------------------------------------------------------------===//
289 // Selection DAG Node definitions.
291 class SDNode<string opcode, SDTypeProfile typeprof,
292              list<SDNodeProperty> props = [], string sdclass = "SDNode">
293              : SDPatternOperator {
294   string Opcode  = opcode;
295   string SDClass = sdclass;
296   let Properties = props;
297   SDTypeProfile TypeProfile = typeprof;
300 // Special TableGen-recognized dag nodes
301 def set;
302 def implicit;
303 def node;
304 def srcvalue;
306 def imm        : SDNode<"ISD::Constant"  , SDTIntLeaf , [], "ConstantSDNode">;
307 def timm       : SDNode<"ISD::TargetConstant",SDTIntLeaf, [], "ConstantSDNode">;
308 def fpimm      : SDNode<"ISD::ConstantFP", SDTFPLeaf  , [], "ConstantFPSDNode">;
309 def vt         : SDNode<"ISD::VALUETYPE" , SDTOther   , [], "VTSDNode">;
310 def bb         : SDNode<"ISD::BasicBlock", SDTOther   , [], "BasicBlockSDNode">;
311 def cond       : SDNode<"ISD::CONDCODE"  , SDTOther   , [], "CondCodeSDNode">;
312 def undef      : SDNode<"ISD::UNDEF"     , SDTUNDEF   , []>;
313 def globaladdr : SDNode<"ISD::GlobalAddress",         SDTPtrLeaf, [],
314                         "GlobalAddressSDNode">;
315 def tglobaladdr : SDNode<"ISD::TargetGlobalAddress",  SDTPtrLeaf, [],
316                          "GlobalAddressSDNode">;
317 def globaltlsaddr : SDNode<"ISD::GlobalTLSAddress",         SDTPtrLeaf, [],
318                           "GlobalAddressSDNode">;
319 def tglobaltlsaddr : SDNode<"ISD::TargetGlobalTLSAddress",  SDTPtrLeaf, [],
320                            "GlobalAddressSDNode">;
321 def constpool   : SDNode<"ISD::ConstantPool",         SDTPtrLeaf, [],
322                          "ConstantPoolSDNode">;
323 def tconstpool  : SDNode<"ISD::TargetConstantPool",   SDTPtrLeaf, [],
324                          "ConstantPoolSDNode">;
325 def jumptable   : SDNode<"ISD::JumpTable",            SDTPtrLeaf, [],
326                          "JumpTableSDNode">;
327 def tjumptable  : SDNode<"ISD::TargetJumpTable",      SDTPtrLeaf, [],
328                          "JumpTableSDNode">;
329 def frameindex  : SDNode<"ISD::FrameIndex",           SDTPtrLeaf, [],
330                          "FrameIndexSDNode">;
331 def tframeindex : SDNode<"ISD::TargetFrameIndex",     SDTPtrLeaf, [],
332                          "FrameIndexSDNode">;
333 def externalsym : SDNode<"ISD::ExternalSymbol",       SDTPtrLeaf, [],
334                          "ExternalSymbolSDNode">;
335 def texternalsym: SDNode<"ISD::TargetExternalSymbol", SDTPtrLeaf, [],
336                          "ExternalSymbolSDNode">;
337 def mcsym: SDNode<"ISD::MCSymbol", SDTPtrLeaf, [], "MCSymbolSDNode">;
338 def blockaddress : SDNode<"ISD::BlockAddress",        SDTPtrLeaf, [],
339                          "BlockAddressSDNode">;
340 def tblockaddress: SDNode<"ISD::TargetBlockAddress",  SDTPtrLeaf, [],
341                          "BlockAddressSDNode">;
343 def add        : SDNode<"ISD::ADD"       , SDTIntBinOp   ,
344                         [SDNPCommutative, SDNPAssociative]>;
345 def sub        : SDNode<"ISD::SUB"       , SDTIntBinOp>;
346 def mul        : SDNode<"ISD::MUL"       , SDTIntBinOp,
347                         [SDNPCommutative, SDNPAssociative]>;
348 def mulhs      : SDNode<"ISD::MULHS"     , SDTIntBinOp, [SDNPCommutative]>;
349 def mulhu      : SDNode<"ISD::MULHU"     , SDTIntBinOp, [SDNPCommutative]>;
350 def smullohi   : SDNode<"ISD::SMUL_LOHI" , SDTIntBinHiLoOp, [SDNPCommutative]>;
351 def umullohi   : SDNode<"ISD::UMUL_LOHI" , SDTIntBinHiLoOp, [SDNPCommutative]>;
352 def sdiv       : SDNode<"ISD::SDIV"      , SDTIntBinOp>;
353 def udiv       : SDNode<"ISD::UDIV"      , SDTIntBinOp>;
354 def srem       : SDNode<"ISD::SREM"      , SDTIntBinOp>;
355 def urem       : SDNode<"ISD::UREM"      , SDTIntBinOp>;
356 def sdivrem    : SDNode<"ISD::SDIVREM"   , SDTIntBinHiLoOp>;
357 def udivrem    : SDNode<"ISD::UDIVREM"   , SDTIntBinHiLoOp>;
358 def srl        : SDNode<"ISD::SRL"       , SDTIntShiftOp>;
359 def sra        : SDNode<"ISD::SRA"       , SDTIntShiftOp>;
360 def shl        : SDNode<"ISD::SHL"       , SDTIntShiftOp>;
361 def rotl       : SDNode<"ISD::ROTL"      , SDTIntShiftOp>;
362 def rotr       : SDNode<"ISD::ROTR"      , SDTIntShiftOp>;
363 def fshl       : SDNode<"ISD::FSHL"      , SDTIntShiftDOp>;
364 def fshr       : SDNode<"ISD::FSHR"      , SDTIntShiftDOp>;
365 def and        : SDNode<"ISD::AND"       , SDTIntBinOp,
366                         [SDNPCommutative, SDNPAssociative]>;
367 def or         : SDNode<"ISD::OR"        , SDTIntBinOp,
368                         [SDNPCommutative, SDNPAssociative]>;
369 def xor        : SDNode<"ISD::XOR"       , SDTIntBinOp,
370                         [SDNPCommutative, SDNPAssociative]>;
371 def addc       : SDNode<"ISD::ADDC"      , SDTIntBinOp,
372                         [SDNPCommutative, SDNPOutGlue]>;
373 def adde       : SDNode<"ISD::ADDE"      , SDTIntBinOp,
374                         [SDNPCommutative, SDNPOutGlue, SDNPInGlue]>;
375 def subc       : SDNode<"ISD::SUBC"      , SDTIntBinOp,
376                         [SDNPOutGlue]>;
377 def sube       : SDNode<"ISD::SUBE"      , SDTIntBinOp,
378                         [SDNPOutGlue, SDNPInGlue]>;
379 def smin       : SDNode<"ISD::SMIN"      , SDTIntBinOp,
380                                   [SDNPCommutative, SDNPAssociative]>;
381 def smax       : SDNode<"ISD::SMAX"      , SDTIntBinOp,
382                                   [SDNPCommutative, SDNPAssociative]>;
383 def umin       : SDNode<"ISD::UMIN"      , SDTIntBinOp,
384                                   [SDNPCommutative, SDNPAssociative]>;
385 def umax       : SDNode<"ISD::UMAX"      , SDTIntBinOp,
386                                   [SDNPCommutative, SDNPAssociative]>;
388 def saddsat    : SDNode<"ISD::SADDSAT"   , SDTIntBinOp, [SDNPCommutative]>;
389 def uaddsat    : SDNode<"ISD::UADDSAT"   , SDTIntBinOp, [SDNPCommutative]>;
390 def ssubsat    : SDNode<"ISD::SSUBSAT"   , SDTIntBinOp>;
391 def usubsat    : SDNode<"ISD::USUBSAT"   , SDTIntBinOp>;
393 def smulfix    : SDNode<"ISD::SMULFIX"   , SDTIntScaledBinOp, [SDNPCommutative]>;
394 def smulfixsat : SDNode<"ISD::SMULFIXSAT", SDTIntScaledBinOp, [SDNPCommutative]>;
395 def umulfix    : SDNode<"ISD::UMULFIX"   , SDTIntScaledBinOp, [SDNPCommutative]>;
397 def sext_inreg : SDNode<"ISD::SIGN_EXTEND_INREG", SDTExtInreg>;
398 def sext_invec : SDNode<"ISD::SIGN_EXTEND_VECTOR_INREG", SDTExtInvec>;
399 def zext_invec : SDNode<"ISD::ZERO_EXTEND_VECTOR_INREG", SDTExtInvec>;
401 def abs        : SDNode<"ISD::ABS"        , SDTIntUnaryOp>;
402 def bitreverse : SDNode<"ISD::BITREVERSE" , SDTIntUnaryOp>;
403 def bswap      : SDNode<"ISD::BSWAP"      , SDTIntUnaryOp>;
404 def ctlz       : SDNode<"ISD::CTLZ"       , SDTIntUnaryOp>;
405 def cttz       : SDNode<"ISD::CTTZ"       , SDTIntUnaryOp>;
406 def ctpop      : SDNode<"ISD::CTPOP"      , SDTIntUnaryOp>;
407 def ctlz_zero_undef : SDNode<"ISD::CTLZ_ZERO_UNDEF", SDTIntUnaryOp>;
408 def cttz_zero_undef : SDNode<"ISD::CTTZ_ZERO_UNDEF", SDTIntUnaryOp>;
409 def sext       : SDNode<"ISD::SIGN_EXTEND", SDTIntExtendOp>;
410 def zext       : SDNode<"ISD::ZERO_EXTEND", SDTIntExtendOp>;
411 def anyext     : SDNode<"ISD::ANY_EXTEND" , SDTIntExtendOp>;
412 def trunc      : SDNode<"ISD::TRUNCATE"   , SDTIntTruncOp>;
413 def bitconvert : SDNode<"ISD::BITCAST"    , SDTUnaryOp>;
414 def addrspacecast : SDNode<"ISD::ADDRSPACECAST", SDTUnaryOp>;
415 def extractelt : SDNode<"ISD::EXTRACT_VECTOR_ELT", SDTVecExtract>;
416 def insertelt  : SDNode<"ISD::INSERT_VECTOR_ELT", SDTVecInsert>;
418 def fadd       : SDNode<"ISD::FADD"       , SDTFPBinOp, [SDNPCommutative]>;
419 def fsub       : SDNode<"ISD::FSUB"       , SDTFPBinOp>;
420 def fmul       : SDNode<"ISD::FMUL"       , SDTFPBinOp, [SDNPCommutative]>;
421 def fdiv       : SDNode<"ISD::FDIV"       , SDTFPBinOp>;
422 def frem       : SDNode<"ISD::FREM"       , SDTFPBinOp>;
423 def fma        : SDNode<"ISD::FMA"        , SDTFPTernaryOp>;
424 def fmad       : SDNode<"ISD::FMAD"       , SDTFPTernaryOp>;
425 def fabs       : SDNode<"ISD::FABS"       , SDTFPUnaryOp>;
426 def fminnum    : SDNode<"ISD::FMINNUM"    , SDTFPBinOp,
427                                   [SDNPCommutative, SDNPAssociative]>;
428 def fmaxnum    : SDNode<"ISD::FMAXNUM"    , SDTFPBinOp,
429                                   [SDNPCommutative, SDNPAssociative]>;
430 def fminnum_ieee : SDNode<"ISD::FMINNUM_IEEE", SDTFPBinOp,
431                           [SDNPCommutative]>;
432 def fmaxnum_ieee  : SDNode<"ISD::FMAXNUM_IEEE", SDTFPBinOp,
433                            [SDNPCommutative]>;
434 def fminimum   : SDNode<"ISD::FMINIMUM"   , SDTFPBinOp,
435                         [SDNPCommutative, SDNPAssociative]>;
436 def fmaximum   : SDNode<"ISD::FMAXIMUM"   , SDTFPBinOp,
437                         [SDNPCommutative, SDNPAssociative]>;
438 def fgetsign   : SDNode<"ISD::FGETSIGN"   , SDTFPToIntOp>;
439 def fcanonicalize : SDNode<"ISD::FCANONICALIZE", SDTFPUnaryOp>;
440 def fneg       : SDNode<"ISD::FNEG"       , SDTFPUnaryOp>;
441 def fsqrt      : SDNode<"ISD::FSQRT"      , SDTFPUnaryOp>;
442 def fsin       : SDNode<"ISD::FSIN"       , SDTFPUnaryOp>;
443 def fcos       : SDNode<"ISD::FCOS"       , SDTFPUnaryOp>;
444 def fexp2      : SDNode<"ISD::FEXP2"      , SDTFPUnaryOp>;
445 def fpow       : SDNode<"ISD::FPOW"       , SDTFPBinOp>;
446 def flog2      : SDNode<"ISD::FLOG2"      , SDTFPUnaryOp>;
447 def frint      : SDNode<"ISD::FRINT"      , SDTFPUnaryOp>;
448 def ftrunc     : SDNode<"ISD::FTRUNC"     , SDTFPUnaryOp>;
449 def fceil      : SDNode<"ISD::FCEIL"      , SDTFPUnaryOp>;
450 def ffloor     : SDNode<"ISD::FFLOOR"     , SDTFPUnaryOp>;
451 def fnearbyint : SDNode<"ISD::FNEARBYINT" , SDTFPUnaryOp>;
452 def fround     : SDNode<"ISD::FROUND"     , SDTFPUnaryOp>;
454 def lround     : SDNode<"ISD::LROUND"     , SDTFPToIntOp>;
455 def llround    : SDNode<"ISD::LLROUND"    , SDTFPToIntOp>;
456 def lrint      : SDNode<"ISD::LRINT"      , SDTFPToIntOp>;
457 def llrint     : SDNode<"ISD::LLRINT"     , SDTFPToIntOp>;
459 def fpround    : SDNode<"ISD::FP_ROUND"   , SDTFPRoundOp>;
460 def fpextend   : SDNode<"ISD::FP_EXTEND"  , SDTFPExtendOp>;
461 def fcopysign  : SDNode<"ISD::FCOPYSIGN"  , SDTFPSignOp>;
463 def sint_to_fp : SDNode<"ISD::SINT_TO_FP" , SDTIntToFPOp>;
464 def uint_to_fp : SDNode<"ISD::UINT_TO_FP" , SDTIntToFPOp>;
465 def fp_to_sint : SDNode<"ISD::FP_TO_SINT" , SDTFPToIntOp>;
466 def fp_to_uint : SDNode<"ISD::FP_TO_UINT" , SDTFPToIntOp>;
467 def f16_to_fp  : SDNode<"ISD::FP16_TO_FP" , SDTIntToFPOp>;
468 def fp_to_f16  : SDNode<"ISD::FP_TO_FP16" , SDTFPToIntOp>;
470 def strict_fadd       : SDNode<"ISD::STRICT_FADD",
471                                SDTFPBinOp, [SDNPHasChain, SDNPCommutative]>;
472 def strict_fsub       : SDNode<"ISD::STRICT_FSUB",
473                                SDTFPBinOp, [SDNPHasChain]>;
474 def strict_fmul       : SDNode<"ISD::STRICT_FMUL",
475                                SDTFPBinOp, [SDNPHasChain, SDNPCommutative]>;
476 def strict_fdiv       : SDNode<"ISD::STRICT_FDIV",
477                                SDTFPBinOp, [SDNPHasChain]>;
478 def strict_frem       : SDNode<"ISD::STRICT_FREM",
479                                SDTFPBinOp, [SDNPHasChain]>;
480 def strict_fma        : SDNode<"ISD::STRICT_FMA",
481                                SDTFPTernaryOp, [SDNPHasChain]>;
482 def strict_fsqrt      : SDNode<"ISD::STRICT_FSQRT",
483                                SDTFPUnaryOp, [SDNPHasChain]>;
484 def strict_fsin       : SDNode<"ISD::STRICT_FSIN",
485                                SDTFPUnaryOp, [SDNPHasChain]>;
486 def strict_fcos       : SDNode<"ISD::STRICT_FCOS",
487                                SDTFPUnaryOp, [SDNPHasChain]>;
488 def strict_fexp2      : SDNode<"ISD::STRICT_FEXP2",
489                                SDTFPUnaryOp, [SDNPHasChain]>;
490 def strict_fpow       : SDNode<"ISD::STRICT_FPOW",
491                                SDTFPBinOp, [SDNPHasChain]>;
492 def strict_flog2      : SDNode<"ISD::STRICT_FLOG2",
493                                SDTFPUnaryOp, [SDNPHasChain]>;
494 def strict_frint      : SDNode<"ISD::STRICT_FRINT",
495                                SDTFPUnaryOp, [SDNPHasChain]>;
496 def strict_fnearbyint : SDNode<"ISD::STRICT_FNEARBYINT",
497                                SDTFPUnaryOp, [SDNPHasChain]>;
498 def strict_fceil      : SDNode<"ISD::STRICT_FCEIL",
499                                SDTFPUnaryOp, [SDNPHasChain]>;
500 def strict_ffloor     : SDNode<"ISD::STRICT_FFLOOR",
501                                SDTFPUnaryOp, [SDNPHasChain]>;
502 def strict_fround     : SDNode<"ISD::STRICT_FROUND",
503                                SDTFPUnaryOp, [SDNPHasChain]>;
504 def strict_ftrunc     : SDNode<"ISD::STRICT_FTRUNC",
505                                SDTFPUnaryOp, [SDNPHasChain]>;
506 def strict_fminnum    : SDNode<"ISD::STRICT_FMINNUM",
507                                SDTFPBinOp, [SDNPHasChain,
508                                             SDNPCommutative, SDNPAssociative]>;
509 def strict_fmaxnum    : SDNode<"ISD::STRICT_FMAXNUM",
510                                SDTFPBinOp, [SDNPHasChain,
511                                             SDNPCommutative, SDNPAssociative]>;
512 def strict_fpround    : SDNode<"ISD::STRICT_FP_ROUND",
513                                SDTFPRoundOp, [SDNPHasChain]>;
514 def strict_fpextend   : SDNode<"ISD::STRICT_FP_EXTEND",
515                                SDTFPExtendOp, [SDNPHasChain]>;
517 def setcc      : SDNode<"ISD::SETCC"      , SDTSetCC>;
518 def select     : SDNode<"ISD::SELECT"     , SDTSelect>;
519 def vselect    : SDNode<"ISD::VSELECT"    , SDTVSelect>;
520 def selectcc   : SDNode<"ISD::SELECT_CC"  , SDTSelectCC>;
522 def brcc       : SDNode<"ISD::BR_CC"      , SDTBrCC,   [SDNPHasChain]>;
523 def brcond     : SDNode<"ISD::BRCOND"     , SDTBrcond, [SDNPHasChain]>;
524 def brind      : SDNode<"ISD::BRIND"      , SDTBrind,  [SDNPHasChain]>;
525 def br         : SDNode<"ISD::BR"         , SDTBr,     [SDNPHasChain]>;
526 def catchret   : SDNode<"ISD::CATCHRET"   , SDTCatchret,
527                         [SDNPHasChain, SDNPSideEffect]>;
528 def cleanupret : SDNode<"ISD::CLEANUPRET" , SDTNone,   [SDNPHasChain]>;
529 def catchpad   : SDNode<"ISD::CATCHPAD"   , SDTNone,
530                         [SDNPHasChain, SDNPSideEffect]>;
532 def trap       : SDNode<"ISD::TRAP"       , SDTNone,
533                         [SDNPHasChain, SDNPSideEffect]>;
534 def debugtrap  : SDNode<"ISD::DEBUGTRAP"  , SDTNone,
535                         [SDNPHasChain, SDNPSideEffect]>;
537 def prefetch   : SDNode<"ISD::PREFETCH"   , SDTPrefetch,
538                         [SDNPHasChain, SDNPMayLoad, SDNPMayStore,
539                          SDNPMemOperand]>;
541 def readcyclecounter : SDNode<"ISD::READCYCLECOUNTER", SDTIntLeaf,
542                      [SDNPHasChain, SDNPSideEffect]>;
544 def atomic_fence : SDNode<"ISD::ATOMIC_FENCE" , SDTAtomicFence,
545                           [SDNPHasChain, SDNPSideEffect]>;
547 def atomic_cmp_swap : SDNode<"ISD::ATOMIC_CMP_SWAP" , SDTAtomic3,
548                     [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
549 def atomic_load_add : SDNode<"ISD::ATOMIC_LOAD_ADD" , SDTAtomic2,
550                     [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
551 def atomic_swap     : SDNode<"ISD::ATOMIC_SWAP", SDTAtomic2,
552                     [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
553 def atomic_load_sub : SDNode<"ISD::ATOMIC_LOAD_SUB" , SDTAtomic2,
554                     [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
555 def atomic_load_and : SDNode<"ISD::ATOMIC_LOAD_AND" , SDTAtomic2,
556                     [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
557 def atomic_load_clr : SDNode<"ISD::ATOMIC_LOAD_CLR" , SDTAtomic2,
558                     [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
559 def atomic_load_or  : SDNode<"ISD::ATOMIC_LOAD_OR" , SDTAtomic2,
560                     [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
561 def atomic_load_xor : SDNode<"ISD::ATOMIC_LOAD_XOR" , SDTAtomic2,
562                     [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
563 def atomic_load_nand: SDNode<"ISD::ATOMIC_LOAD_NAND", SDTAtomic2,
564                     [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
565 def atomic_load_min : SDNode<"ISD::ATOMIC_LOAD_MIN", SDTAtomic2,
566                     [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
567 def atomic_load_max : SDNode<"ISD::ATOMIC_LOAD_MAX", SDTAtomic2,
568                     [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
569 def atomic_load_umin : SDNode<"ISD::ATOMIC_LOAD_UMIN", SDTAtomic2,
570                     [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
571 def atomic_load_umax : SDNode<"ISD::ATOMIC_LOAD_UMAX", SDTAtomic2,
572                     [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
573 def atomic_load_fadd : SDNode<"ISD::ATOMIC_LOAD_FADD" , SDTFPAtomic2,
574                     [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
575 def atomic_load_fsub : SDNode<"ISD::ATOMIC_LOAD_FSUB" , SDTFPAtomic2,
576                     [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
578 def atomic_load      : SDNode<"ISD::ATOMIC_LOAD", SDTAtomicLoad,
579                     [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
580 def atomic_store     : SDNode<"ISD::ATOMIC_STORE", SDTAtomicStore,
581                     [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
583 def masked_st    : SDNode<"ISD::MSTORE",  SDTMaskedStore,
584                        [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
585 def masked_ld    : SDNode<"ISD::MLOAD",  SDTMaskedLoad,
586                        [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
588 // Do not use ld, st directly. Use load, extload, sextload, zextload, store,
589 // and truncst (see below).
590 def ld         : SDNode<"ISD::LOAD"       , SDTLoad,
591                         [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
592 def st         : SDNode<"ISD::STORE"      , SDTStore,
593                         [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
594 def ist        : SDNode<"ISD::STORE"      , SDTIStore,
595                         [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
597 def vector_shuffle : SDNode<"ISD::VECTOR_SHUFFLE", SDTVecShuffle, []>;
598 def build_vector : SDNode<"ISD::BUILD_VECTOR", SDTypeProfile<1, -1, []>, []>;
599 def scalar_to_vector : SDNode<"ISD::SCALAR_TO_VECTOR", SDTypeProfile<1, 1, []>,
600                               []>;
602 // vector_extract/vector_insert are deprecated. extractelt/insertelt
603 // are preferred.
604 def vector_extract : SDNode<"ISD::EXTRACT_VECTOR_ELT",
605     SDTypeProfile<1, 2, [SDTCisPtrTy<2>]>, []>;
606 def vector_insert : SDNode<"ISD::INSERT_VECTOR_ELT",
607     SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisPtrTy<3>]>, []>;
608 def concat_vectors : SDNode<"ISD::CONCAT_VECTORS",
609     SDTypeProfile<1, 2, [SDTCisSubVecOfVec<1, 0>, SDTCisSameAs<1, 2>]>,[]>;
611 // This operator does not do subvector type checking.  The ARM
612 // backend, at least, needs it.
613 def vector_extract_subvec : SDNode<"ISD::EXTRACT_SUBVECTOR",
614     SDTypeProfile<1, 2, [SDTCisInt<2>, SDTCisVec<1>, SDTCisVec<0>]>,
615     []>;
617 // This operator does subvector type checking.
618 def extract_subvector : SDNode<"ISD::EXTRACT_SUBVECTOR", SDTSubVecExtract, []>;
619 def insert_subvector : SDNode<"ISD::INSERT_SUBVECTOR", SDTSubVecInsert, []>;
621 // Nodes for intrinsics, you should use the intrinsic itself and let tblgen use
622 // these internally.  Don't reference these directly.
623 def intrinsic_void : SDNode<"ISD::INTRINSIC_VOID",
624                             SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>,
625                             [SDNPHasChain]>;
626 def intrinsic_w_chain : SDNode<"ISD::INTRINSIC_W_CHAIN",
627                                SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>,
628                                [SDNPHasChain]>;
629 def intrinsic_wo_chain : SDNode<"ISD::INTRINSIC_WO_CHAIN",
630                                 SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>, []>;
632 def SDT_assertext : SDTypeProfile<1, 1,
633   [SDTCisInt<0>, SDTCisInt<1>, SDTCisSameAs<1, 0>]>;
634 def assertsext : SDNode<"ISD::AssertSext", SDT_assertext>;
635 def assertzext : SDNode<"ISD::AssertZext", SDT_assertext>;
638 //===----------------------------------------------------------------------===//
639 // Selection DAG Condition Codes
641 class CondCode; // ISD::CondCode enums
642 def SETOEQ : CondCode; def SETOGT : CondCode;
643 def SETOGE : CondCode; def SETOLT : CondCode; def SETOLE : CondCode;
644 def SETONE : CondCode; def SETO   : CondCode; def SETUO  : CondCode;
645 def SETUEQ : CondCode; def SETUGT : CondCode; def SETUGE : CondCode;
646 def SETULT : CondCode; def SETULE : CondCode; def SETUNE : CondCode;
648 def SETEQ : CondCode; def SETGT : CondCode; def SETGE : CondCode;
649 def SETLT : CondCode; def SETLE : CondCode; def SETNE : CondCode;
652 //===----------------------------------------------------------------------===//
653 // Selection DAG Node Transformation Functions.
655 // This mechanism allows targets to manipulate nodes in the output DAG once a
656 // match has been formed.  This is typically used to manipulate immediate
657 // values.
659 class SDNodeXForm<SDNode opc, code xformFunction> {
660   SDNode Opcode = opc;
661   code XFormFunction = xformFunction;
664 def NOOP_SDNodeXForm : SDNodeXForm<imm, [{}]>;
666 //===----------------------------------------------------------------------===//
667 // PatPred Subclasses.
669 // These allow specifying different sorts of predicates that control whether a
670 // node is matched.
672 class PatPred;
674 class CodePatPred<code predicate> : PatPred {
675   code PredicateCode = predicate;
679 //===----------------------------------------------------------------------===//
680 // Selection DAG Pattern Fragments.
682 // Pattern fragments are reusable chunks of dags that match specific things.
683 // They can take arguments and have C++ predicates that control whether they
684 // match.  They are intended to make the patterns for common instructions more
685 // compact and readable.
688 /// PatFrags - Represents a set of pattern fragments.  Each single fragment
689 /// can match something on the DAG, from a single node to multiple nested other
690 /// fragments.   The whole set of fragments matches if any of the single
691 /// fragemnts match.  This allows e.g. matching and "add with overflow" and
692 /// a regular "add" with the same fragment set.
694 class PatFrags<dag ops, list<dag> frags, code pred = [{}],
695                SDNodeXForm xform = NOOP_SDNodeXForm> : SDPatternOperator {
696   dag Operands = ops;
697   list<dag> Fragments = frags;
698   code PredicateCode = pred;
699   code GISelPredicateCode = [{}];
700   code ImmediateCode = [{}];
701   SDNodeXForm OperandTransform = xform;
703   // When this is set, the PredicateCode may refer to a constant Operands
704   // vector which contains the captured nodes of the DAG, in the order listed
705   // by the Operands field above.
706   //
707   // This is useful when Fragments involves associative / commutative
708   // operators: a single piece of code can easily refer to all operands even
709   // when re-associated / commuted variants of the fragment are matched.
710   bit PredicateCodeUsesOperands = 0;
712   // Define a few pre-packaged predicates. This helps GlobalISel import
713   // existing rules from SelectionDAG for many common cases.
714   // They will be tested prior to the code in pred and must not be used in
715   // ImmLeaf and its subclasses.
717   // Is the desired pre-packaged predicate for a load?
718   bit IsLoad = ?;
719   // Is the desired pre-packaged predicate for a store?
720   bit IsStore = ?;
721   // Is the desired pre-packaged predicate for an atomic?
722   bit IsAtomic = ?;
724   // cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
725   // cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
726   bit IsUnindexed = ?;
728   // cast<LoadSDNode>(N)->getExtensionType() != ISD::NON_EXTLOAD
729   bit IsNonExtLoad = ?;
730   // cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
731   bit IsAnyExtLoad = ?;
732   // cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
733   bit IsSignExtLoad = ?;
734   // cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
735   bit IsZeroExtLoad = ?;
736   // !cast<StoreSDNode>(N)->isTruncatingStore();
737   // cast<StoreSDNode>(N)->isTruncatingStore();
738   bit IsTruncStore = ?;
740   // cast<MemSDNode>(N)->getAddressSpace() ==
741   // If this empty, accept any address space.
742   list<int> AddressSpaces = ?;
744   // cast<MemSDNode>(N)->getAlignment() >=
745   // If this is empty, accept any alignment.
746   int MinAlignment = ?;
748   // cast<AtomicSDNode>(N)->getOrdering() == AtomicOrdering::Monotonic
749   bit IsAtomicOrderingMonotonic = ?;
750   // cast<AtomicSDNode>(N)->getOrdering() == AtomicOrdering::Acquire
751   bit IsAtomicOrderingAcquire = ?;
752   // cast<AtomicSDNode>(N)->getOrdering() == AtomicOrdering::Release
753   bit IsAtomicOrderingRelease = ?;
754   // cast<AtomicSDNode>(N)->getOrdering() == AtomicOrdering::AcquireRelease
755   bit IsAtomicOrderingAcquireRelease = ?;
756   // cast<AtomicSDNode>(N)->getOrdering() == AtomicOrdering::SequentiallyConsistent
757   bit IsAtomicOrderingSequentiallyConsistent = ?;
759   // isAcquireOrStronger(cast<AtomicSDNode>(N)->getOrdering())
760   // !isAcquireOrStronger(cast<AtomicSDNode>(N)->getOrdering())
761   bit IsAtomicOrderingAcquireOrStronger = ?;
763   // isReleaseOrStronger(cast<AtomicSDNode>(N)->getOrdering())
764   // !isReleaseOrStronger(cast<AtomicSDNode>(N)->getOrdering())
765   bit IsAtomicOrderingReleaseOrStronger = ?;
767   // cast<LoadSDNode>(N)->getMemoryVT() == MVT::<VT>;
768   // cast<StoreSDNode>(N)->getMemoryVT() == MVT::<VT>;
769   ValueType MemoryVT = ?;
770   // cast<LoadSDNode>(N)->getMemoryVT().getScalarType() == MVT::<VT>;
771   // cast<StoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::<VT>;
772   ValueType ScalarMemoryVT = ?;
775 // PatFrag - A version of PatFrags matching only a single fragment.
776 class PatFrag<dag ops, dag frag, code pred = [{}],
777               SDNodeXForm xform = NOOP_SDNodeXForm>
778   : PatFrags<ops, [frag], pred, xform>;
780 // OutPatFrag is a pattern fragment that is used as part of an output pattern
781 // (not an input pattern). These do not have predicates or transforms, but are
782 // used to avoid repeated subexpressions in output patterns.
783 class OutPatFrag<dag ops, dag frag>
784  : PatFrag<ops, frag, [{}], NOOP_SDNodeXForm>;
786 // PatLeaf's are pattern fragments that have no operands.  This is just a helper
787 // to define immediates and other common things concisely.
788 class PatLeaf<dag frag, code pred = [{}], SDNodeXForm xform = NOOP_SDNodeXForm>
789  : PatFrag<(ops), frag, pred, xform>;
792 // ImmLeaf is a pattern fragment with a constraint on the immediate.  The
793 // constraint is a function that is run on the immediate (always with the value
794 // sign extended out to an int64_t) as Imm.  For example:
796 //  def immSExt8 : ImmLeaf<i16, [{ return (char)Imm == Imm; }]>;
798 // this is a more convenient form to match 'imm' nodes in than PatLeaf and also
799 // is preferred over using PatLeaf because it allows the code generator to
800 // reason more about the constraint.
802 // If FastIsel should ignore all instructions that have an operand of this type,
803 // the FastIselShouldIgnore flag can be set.  This is an optimization to reduce
804 // the code size of the generated fast instruction selector.
805 class ImmLeaf<ValueType vt, code pred, SDNodeXForm xform = NOOP_SDNodeXForm,
806               SDNode ImmNode = imm>
807   : PatFrag<(ops), (vt ImmNode), [{}], xform> {
808   let ImmediateCode = pred;
809   bit FastIselShouldIgnore = 0;
811   // Is the data type of the immediate an APInt?
812   bit IsAPInt = 0;
814   // Is the data type of the immediate an APFloat?
815   bit IsAPFloat = 0;
818 // An ImmLeaf except that Imm is an APInt. This is useful when you need to
819 // zero-extend the immediate instead of sign-extend it.
821 // Note that FastISel does not currently understand IntImmLeaf and will not
822 // generate code for rules that make use of it. As such, it does not make sense
823 // to replace ImmLeaf with IntImmLeaf. However, replacing PatLeaf with an
824 // IntImmLeaf will allow GlobalISel to import the rule.
825 class IntImmLeaf<ValueType vt, code pred, SDNodeXForm xform = NOOP_SDNodeXForm>
826     : ImmLeaf<vt, pred, xform> {
827   let IsAPInt = 1;
828   let FastIselShouldIgnore = 1;
831 // An ImmLeaf except that Imm is an APFloat.
833 // Note that FastISel does not currently understand FPImmLeaf and will not
834 // generate code for rules that make use of it.
835 class FPImmLeaf<ValueType vt, code pred, SDNodeXForm xform = NOOP_SDNodeXForm>
836   : ImmLeaf<vt, pred, xform, fpimm> {
837   let IsAPFloat = 1;
838   let FastIselShouldIgnore = 1;
841 // Leaf fragments.
843 def vtInt      : PatLeaf<(vt),  [{ return N->getVT().isInteger(); }]>;
844 def vtFP       : PatLeaf<(vt),  [{ return N->getVT().isFloatingPoint(); }]>;
846 // Use ISD::isBuildVectorAllOnes or ISD::isBuildVectorAllZeros to look for
847 // the corresponding build_vector. Will look through bitcasts except when used
848 // as a pattern root.
849 def immAllOnesV; // ISD::isBuildVectorAllOnes
850 def immAllZerosV; // ISD::isBuildVectorAllZeros
852 // Other helper fragments.
853 def not  : PatFrag<(ops node:$in), (xor node:$in, -1)>;
854 def vnot : PatFrag<(ops node:$in), (xor node:$in, immAllOnesV)>;
855 def ineg : PatFrag<(ops node:$in), (sub 0, node:$in)>;
857 // null_frag - The null pattern operator is used in multiclass instantiations
858 // which accept an SDPatternOperator for use in matching patterns for internal
859 // definitions. When expanding a pattern, if the null fragment is referenced
860 // in the expansion, the pattern is discarded and it is as-if '[]' had been
861 // specified. This allows multiclasses to have the isel patterns be optional.
862 def null_frag : SDPatternOperator;
864 // load fragments.
865 def unindexedload : PatFrag<(ops node:$ptr), (ld node:$ptr)> {
866   let IsLoad = 1;
867   let IsUnindexed = 1;
869 def load : PatFrag<(ops node:$ptr), (unindexedload node:$ptr)> {
870   let IsLoad = 1;
871   let IsNonExtLoad = 1;
874 // extending load fragments.
875 def extload   : PatFrag<(ops node:$ptr), (unindexedload node:$ptr)> {
876   let IsLoad = 1;
877   let IsAnyExtLoad = 1;
879 def sextload  : PatFrag<(ops node:$ptr), (unindexedload node:$ptr)> {
880   let IsLoad = 1;
881   let IsSignExtLoad = 1;
883 def zextload  : PatFrag<(ops node:$ptr), (unindexedload node:$ptr)> {
884   let IsLoad = 1;
885   let IsZeroExtLoad = 1;
888 def extloadi1  : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
889   let IsLoad = 1;
890   let MemoryVT = i1;
892 def extloadi8  : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
893   let IsLoad = 1;
894   let MemoryVT = i8;
896 def extloadi16 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
897   let IsLoad = 1;
898   let MemoryVT = i16;
900 def extloadi32 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
901   let IsLoad = 1;
902   let MemoryVT = i32;
904 def extloadf32 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
905   let IsLoad = 1;
906   let MemoryVT = f32;
908 def extloadf64 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
909   let IsLoad = 1;
910   let MemoryVT = f64;
913 def sextloadi1  : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
914   let IsLoad = 1;
915   let MemoryVT = i1;
917 def sextloadi8  : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
918   let IsLoad = 1;
919   let MemoryVT = i8;
921 def sextloadi16 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
922   let IsLoad = 1;
923   let MemoryVT = i16;
925 def sextloadi32 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
926   let IsLoad = 1;
927   let MemoryVT = i32;
930 def zextloadi1  : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
931   let IsLoad = 1;
932   let MemoryVT = i1;
934 def zextloadi8  : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
935   let IsLoad = 1;
936   let MemoryVT = i8;
938 def zextloadi16 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
939   let IsLoad = 1;
940   let MemoryVT = i16;
942 def zextloadi32 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
943   let IsLoad = 1;
944   let MemoryVT = i32;
947 def extloadvi1  : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
948   let IsLoad = 1;
949   let ScalarMemoryVT = i1;
951 def extloadvi8  : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
952   let IsLoad = 1;
953   let ScalarMemoryVT = i8;
955 def extloadvi16 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
956   let IsLoad = 1;
957   let ScalarMemoryVT = i16;
959 def extloadvi32 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
960   let IsLoad = 1;
961   let ScalarMemoryVT = i32;
963 def extloadvf32 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
964   let IsLoad = 1;
965   let ScalarMemoryVT = f32;
967 def extloadvf64 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
968   let IsLoad = 1;
969   let ScalarMemoryVT = f64;
972 def sextloadvi1  : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
973   let IsLoad = 1;
974   let ScalarMemoryVT = i1;
976 def sextloadvi8  : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
977   let IsLoad = 1;
978   let ScalarMemoryVT = i8;
980 def sextloadvi16 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
981   let IsLoad = 1;
982   let ScalarMemoryVT = i16;
984 def sextloadvi32 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
985   let IsLoad = 1;
986   let ScalarMemoryVT = i32;
989 def zextloadvi1  : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
990   let IsLoad = 1;
991   let ScalarMemoryVT = i1;
993 def zextloadvi8  : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
994   let IsLoad = 1;
995   let ScalarMemoryVT = i8;
997 def zextloadvi16 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
998   let IsLoad = 1;
999   let ScalarMemoryVT = i16;
1001 def zextloadvi32 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
1002   let IsLoad = 1;
1003   let ScalarMemoryVT = i32;
1006 // store fragments.
1007 def unindexedstore : PatFrag<(ops node:$val, node:$ptr),
1008                              (st node:$val, node:$ptr)> {
1009   let IsStore = 1;
1010   let IsUnindexed = 1;
1012 def store : PatFrag<(ops node:$val, node:$ptr),
1013                     (unindexedstore node:$val, node:$ptr)> {
1014   let IsStore = 1;
1015   let IsTruncStore = 0;
1018 // truncstore fragments.
1019 def truncstore : PatFrag<(ops node:$val, node:$ptr),
1020                          (unindexedstore node:$val, node:$ptr)> {
1021   let IsStore = 1;
1022   let IsTruncStore = 1;
1024 def truncstorei8 : PatFrag<(ops node:$val, node:$ptr),
1025                            (truncstore node:$val, node:$ptr)> {
1026   let IsStore = 1;
1027   let MemoryVT = i8;
1029 def truncstorei16 : PatFrag<(ops node:$val, node:$ptr),
1030                             (truncstore node:$val, node:$ptr)> {
1031   let IsStore = 1;
1032   let MemoryVT = i16;
1034 def truncstorei32 : PatFrag<(ops node:$val, node:$ptr),
1035                             (truncstore node:$val, node:$ptr)> {
1036   let IsStore = 1;
1037   let MemoryVT = i32;
1039 def truncstoref32 : PatFrag<(ops node:$val, node:$ptr),
1040                             (truncstore node:$val, node:$ptr)> {
1041   let IsStore = 1;
1042   let MemoryVT = f32;
1044 def truncstoref64 : PatFrag<(ops node:$val, node:$ptr),
1045                             (truncstore node:$val, node:$ptr)> {
1046   let IsStore = 1;
1047   let MemoryVT = f64;
1050 def truncstorevi8 : PatFrag<(ops node:$val, node:$ptr),
1051                             (truncstore node:$val, node:$ptr)> {
1052   let IsStore = 1;
1053   let ScalarMemoryVT = i8;
1056 def truncstorevi16 : PatFrag<(ops node:$val, node:$ptr),
1057                              (truncstore node:$val, node:$ptr)> {
1058   let IsStore = 1;
1059   let ScalarMemoryVT = i16;
1062 def truncstorevi32 : PatFrag<(ops node:$val, node:$ptr),
1063                              (truncstore node:$val, node:$ptr)> {
1064   let IsStore = 1;
1065   let ScalarMemoryVT = i32;
1068 // indexed store fragments.
1069 def istore : PatFrag<(ops node:$val, node:$base, node:$offset),
1070                      (ist node:$val, node:$base, node:$offset)> {
1071   let IsStore = 1;
1072   let IsTruncStore = 0;
1075 def pre_store : PatFrag<(ops node:$val, node:$base, node:$offset),
1076                         (istore node:$val, node:$base, node:$offset), [{
1077   ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
1078   return AM == ISD::PRE_INC || AM == ISD::PRE_DEC;
1079 }]>;
1081 def itruncstore : PatFrag<(ops node:$val, node:$base, node:$offset),
1082                           (ist node:$val, node:$base, node:$offset)> {
1083   let IsStore = 1;
1084   let IsTruncStore = 1;
1086 def pre_truncst : PatFrag<(ops node:$val, node:$base, node:$offset),
1087                           (itruncstore node:$val, node:$base, node:$offset), [{
1088   ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
1089   return AM == ISD::PRE_INC || AM == ISD::PRE_DEC;
1090 }]>;
1091 def pre_truncsti1 : PatFrag<(ops node:$val, node:$base, node:$offset),
1092                             (pre_truncst node:$val, node:$base, node:$offset)> {
1093   let IsStore = 1;
1094   let MemoryVT = i1;
1096 def pre_truncsti8 : PatFrag<(ops node:$val, node:$base, node:$offset),
1097                             (pre_truncst node:$val, node:$base, node:$offset)> {
1098   let IsStore = 1;
1099   let MemoryVT = i8;
1101 def pre_truncsti16 : PatFrag<(ops node:$val, node:$base, node:$offset),
1102                              (pre_truncst node:$val, node:$base, node:$offset)> {
1103   let IsStore = 1;
1104   let MemoryVT = i16;
1106 def pre_truncsti32 : PatFrag<(ops node:$val, node:$base, node:$offset),
1107                              (pre_truncst node:$val, node:$base, node:$offset)> {
1108   let IsStore = 1;
1109   let MemoryVT = i32;
1111 def pre_truncstf32 : PatFrag<(ops node:$val, node:$base, node:$offset),
1112                              (pre_truncst node:$val, node:$base, node:$offset)> {
1113   let IsStore = 1;
1114   let MemoryVT = f32;
1116 def pre_truncstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset),
1117                              (pre_truncst node:$val, node:$base, node:$offset)> {
1118   let IsStore = 1;
1119   let ScalarMemoryVT = i8;
1121 def pre_truncstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset),
1122                               (pre_truncst node:$val, node:$base, node:$offset)> {
1123   let IsStore = 1;
1124   let ScalarMemoryVT = i16;
1127 def post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
1128                          (istore node:$val, node:$ptr, node:$offset), [{
1129   ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
1130   return AM == ISD::POST_INC || AM == ISD::POST_DEC;
1131 }]>;
1133 def post_truncst : PatFrag<(ops node:$val, node:$base, node:$offset),
1134                            (itruncstore node:$val, node:$base, node:$offset), [{
1135   ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
1136   return AM == ISD::POST_INC || AM == ISD::POST_DEC;
1137 }]>;
1138 def post_truncsti1 : PatFrag<(ops node:$val, node:$base, node:$offset),
1139                              (post_truncst node:$val, node:$base, node:$offset)> {
1140   let IsStore = 1;
1141   let MemoryVT = i1;
1143 def post_truncsti8 : PatFrag<(ops node:$val, node:$base, node:$offset),
1144                              (post_truncst node:$val, node:$base, node:$offset)> {
1145   let IsStore = 1;
1146   let MemoryVT = i8;
1148 def post_truncsti16 : PatFrag<(ops node:$val, node:$base, node:$offset),
1149                               (post_truncst node:$val, node:$base, node:$offset)> {
1150   let IsStore = 1;
1151   let MemoryVT = i16;
1153 def post_truncsti32 : PatFrag<(ops node:$val, node:$base, node:$offset),
1154                               (post_truncst node:$val, node:$base, node:$offset)> {
1155   let IsStore = 1;
1156   let MemoryVT = i32;
1158 def post_truncstf32 : PatFrag<(ops node:$val, node:$base, node:$offset),
1159                               (post_truncst node:$val, node:$base, node:$offset)> {
1160   let IsStore = 1;
1161   let MemoryVT = f32;
1163 def post_truncstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset),
1164                               (post_truncst node:$val, node:$base, node:$offset)> {
1165   let IsStore = 1;
1166   let ScalarMemoryVT = i8;
1168 def post_truncstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset),
1169                                (post_truncst node:$val, node:$base, node:$offset)> {
1170   let IsStore = 1;
1171   let ScalarMemoryVT = i16;
1174 def nonvolatile_load : PatFrag<(ops node:$ptr),
1175                                (load node:$ptr), [{
1176   return !cast<LoadSDNode>(N)->isVolatile();
1177 }]>;
1178 def nonvolatile_store : PatFrag<(ops node:$val, node:$ptr),
1179                                 (store node:$val, node:$ptr), [{
1180   return !cast<StoreSDNode>(N)->isVolatile();
1181 }]>;
1183 // nontemporal store fragments.
1184 def nontemporalstore : PatFrag<(ops node:$val, node:$ptr),
1185                                (store node:$val, node:$ptr), [{
1186   return cast<StoreSDNode>(N)->isNonTemporal();
1187 }]>;
1189 def alignednontemporalstore : PatFrag<(ops node:$val, node:$ptr),
1190                                       (nontemporalstore node:$val, node:$ptr), [{
1191   StoreSDNode *St = cast<StoreSDNode>(N);
1192   return St->getAlignment() >= St->getMemoryVT().getStoreSize();
1193 }]>;
1195 def unalignednontemporalstore : PatFrag<(ops node:$val, node:$ptr),
1196                                         (nontemporalstore node:$val, node:$ptr), [{
1197   StoreSDNode *St = cast<StoreSDNode>(N);
1198   return St->getAlignment() < St->getMemoryVT().getStoreSize();
1199 }]>;
1201 // nontemporal load fragments.
1202 def nontemporalload : PatFrag<(ops node:$ptr),
1203                                (load node:$ptr), [{
1204   return cast<LoadSDNode>(N)->isNonTemporal();
1205 }]>;
1207 def alignednontemporalload : PatFrag<(ops node:$ptr),
1208                                       (nontemporalload node:$ptr), [{
1209   LoadSDNode *Ld = cast<LoadSDNode>(N);
1210   return Ld->getAlignment() >= Ld->getMemoryVT().getStoreSize();
1211 }]>;
1213 // setcc convenience fragments.
1214 def setoeq : PatFrag<(ops node:$lhs, node:$rhs),
1215                      (setcc node:$lhs, node:$rhs, SETOEQ)>;
1216 def setogt : PatFrag<(ops node:$lhs, node:$rhs),
1217                      (setcc node:$lhs, node:$rhs, SETOGT)>;
1218 def setoge : PatFrag<(ops node:$lhs, node:$rhs),
1219                      (setcc node:$lhs, node:$rhs, SETOGE)>;
1220 def setolt : PatFrag<(ops node:$lhs, node:$rhs),
1221                      (setcc node:$lhs, node:$rhs, SETOLT)>;
1222 def setole : PatFrag<(ops node:$lhs, node:$rhs),
1223                      (setcc node:$lhs, node:$rhs, SETOLE)>;
1224 def setone : PatFrag<(ops node:$lhs, node:$rhs),
1225                      (setcc node:$lhs, node:$rhs, SETONE)>;
1226 def seto   : PatFrag<(ops node:$lhs, node:$rhs),
1227                      (setcc node:$lhs, node:$rhs, SETO)>;
1228 def setuo  : PatFrag<(ops node:$lhs, node:$rhs),
1229                      (setcc node:$lhs, node:$rhs, SETUO)>;
1230 def setueq : PatFrag<(ops node:$lhs, node:$rhs),
1231                      (setcc node:$lhs, node:$rhs, SETUEQ)>;
1232 def setugt : PatFrag<(ops node:$lhs, node:$rhs),
1233                      (setcc node:$lhs, node:$rhs, SETUGT)>;
1234 def setuge : PatFrag<(ops node:$lhs, node:$rhs),
1235                      (setcc node:$lhs, node:$rhs, SETUGE)>;
1236 def setult : PatFrag<(ops node:$lhs, node:$rhs),
1237                      (setcc node:$lhs, node:$rhs, SETULT)>;
1238 def setule : PatFrag<(ops node:$lhs, node:$rhs),
1239                      (setcc node:$lhs, node:$rhs, SETULE)>;
1240 def setune : PatFrag<(ops node:$lhs, node:$rhs),
1241                      (setcc node:$lhs, node:$rhs, SETUNE)>;
1242 def seteq  : PatFrag<(ops node:$lhs, node:$rhs),
1243                      (setcc node:$lhs, node:$rhs, SETEQ)>;
1244 def setgt  : PatFrag<(ops node:$lhs, node:$rhs),
1245                      (setcc node:$lhs, node:$rhs, SETGT)>;
1246 def setge  : PatFrag<(ops node:$lhs, node:$rhs),
1247                      (setcc node:$lhs, node:$rhs, SETGE)>;
1248 def setlt  : PatFrag<(ops node:$lhs, node:$rhs),
1249                      (setcc node:$lhs, node:$rhs, SETLT)>;
1250 def setle  : PatFrag<(ops node:$lhs, node:$rhs),
1251                      (setcc node:$lhs, node:$rhs, SETLE)>;
1252 def setne  : PatFrag<(ops node:$lhs, node:$rhs),
1253                      (setcc node:$lhs, node:$rhs, SETNE)>;
1255 // We don't have strict FP extended loads as single DAG nodes, but we can
1256 // still provide convenience fragments to match those operations.
1257 def strict_extloadf32 : PatFrag<(ops node:$ptr),
1258                                 (strict_fpextend (f32 (load node:$ptr)))>;
1259 def strict_extloadf64 : PatFrag<(ops node:$ptr),
1260                                 (strict_fpextend (f64 (load node:$ptr)))>;
1262 // Convenience fragments to match both strict and non-strict fp operations
1263 def any_fadd       : PatFrags<(ops node:$lhs, node:$rhs),
1264                               [(strict_fadd node:$lhs, node:$rhs),
1265                                (fadd node:$lhs, node:$rhs)]>;
1266 def any_fsub       : PatFrags<(ops node:$lhs, node:$rhs),
1267                               [(strict_fsub node:$lhs, node:$rhs),
1268                                (fsub node:$lhs, node:$rhs)]>;
1269 def any_fmul       : PatFrags<(ops node:$lhs, node:$rhs),
1270                               [(strict_fmul node:$lhs, node:$rhs),
1271                                (fmul node:$lhs, node:$rhs)]>;
1272 def any_fdiv       : PatFrags<(ops node:$lhs, node:$rhs),
1273                               [(strict_fdiv node:$lhs, node:$rhs),
1274                                (fdiv node:$lhs, node:$rhs)]>;
1275 def any_frem       : PatFrags<(ops node:$lhs, node:$rhs),
1276                               [(strict_frem node:$lhs, node:$rhs),
1277                                (frem node:$lhs, node:$rhs)]>;
1278 def any_fma        : PatFrags<(ops node:$src1, node:$src2, node:$src3),
1279                               [(strict_fma node:$src1, node:$src2, node:$src3),
1280                                (fma node:$src1, node:$src2, node:$src3)]>;
1281 def any_fsqrt      : PatFrags<(ops node:$src),
1282                               [(strict_fsqrt node:$src),
1283                                (fsqrt node:$src)]>;
1284 def any_fsin       : PatFrags<(ops node:$src),
1285                               [(strict_fsin node:$src),
1286                                (fsin node:$src)]>;
1287 def any_fcos       : PatFrags<(ops node:$src),
1288                               [(strict_fcos node:$src),
1289                                (fcos node:$src)]>;
1290 def any_fexp2      : PatFrags<(ops node:$src),
1291                               [(strict_fexp2 node:$src),
1292                                (fexp2 node:$src)]>;
1293 def any_fpow       : PatFrags<(ops node:$lhs, node:$rhs),
1294                               [(strict_fpow node:$lhs, node:$rhs),
1295                                (fpow node:$lhs, node:$rhs)]>;
1296 def any_flog2      : PatFrags<(ops node:$src),
1297                               [(strict_flog2 node:$src),
1298                                (flog2 node:$src)]>;
1299 def any_frint      : PatFrags<(ops node:$src),
1300                               [(strict_frint node:$src),
1301                                (frint node:$src)]>;
1302 def any_fnearbyint : PatFrags<(ops node:$src),
1303                               [(strict_fnearbyint node:$src),
1304                                (fnearbyint node:$src)]>;
1305 def any_fceil      : PatFrags<(ops node:$src),
1306                               [(strict_fceil node:$src),
1307                                (fceil node:$src)]>;
1308 def any_ffloor     : PatFrags<(ops node:$src),
1309                               [(strict_ffloor node:$src),
1310                                (ffloor node:$src)]>;
1311 def any_fround     : PatFrags<(ops node:$src),
1312                               [(strict_fround node:$src),
1313                                (fround node:$src)]>;
1314 def any_ftrunc     : PatFrags<(ops node:$src),
1315                               [(strict_ftrunc node:$src),
1316                                (ftrunc node:$src)]>;
1317 def any_fmaxnum    : PatFrags<(ops node:$lhs, node:$rhs),
1318                               [(strict_fmaxnum node:$lhs, node:$rhs),
1319                                (fmaxnum node:$lhs, node:$rhs)]>;
1320 def any_fminnum    : PatFrags<(ops node:$lhs, node:$rhs),
1321                               [(strict_fminnum node:$lhs, node:$rhs),
1322                                (fminnum node:$lhs, node:$rhs)]>;
1323 def any_fpround    : PatFrags<(ops node:$src),
1324                               [(strict_fpround node:$src),
1325                                (fpround node:$src)]>;
1326 def any_fpextend   : PatFrags<(ops node:$src),
1327                               [(strict_fpextend node:$src),
1328                                (fpextend node:$src)]>;
1329 def any_extloadf32 : PatFrags<(ops node:$ptr),
1330                               [(strict_extloadf32 node:$ptr),
1331                                (extloadf32 node:$ptr)]>;
1332 def any_extloadf64 : PatFrags<(ops node:$ptr),
1333                               [(strict_extloadf64 node:$ptr),
1334                                (extloadf64 node:$ptr)]>;
1336 multiclass binary_atomic_op_ord<SDNode atomic_op> {
1337   def #NAME#_monotonic : PatFrag<(ops node:$ptr, node:$val),
1338       (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$val)> {
1339     let IsAtomic = 1;
1340     let IsAtomicOrderingMonotonic = 1;
1341   }
1342   def #NAME#_acquire : PatFrag<(ops node:$ptr, node:$val),
1343       (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$val)> {
1344     let IsAtomic = 1;
1345     let IsAtomicOrderingAcquire = 1;
1346   }
1347   def #NAME#_release : PatFrag<(ops node:$ptr, node:$val),
1348       (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$val)> {
1349     let IsAtomic = 1;
1350     let IsAtomicOrderingRelease = 1;
1351   }
1352   def #NAME#_acq_rel : PatFrag<(ops node:$ptr, node:$val),
1353       (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$val)> {
1354     let IsAtomic = 1;
1355     let IsAtomicOrderingAcquireRelease = 1;
1356   }
1357   def #NAME#_seq_cst : PatFrag<(ops node:$ptr, node:$val),
1358       (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$val)> {
1359     let IsAtomic = 1;
1360     let IsAtomicOrderingSequentiallyConsistent = 1;
1361   }
1364 multiclass ternary_atomic_op_ord<SDNode atomic_op> {
1365   def #NAME#_monotonic : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
1366       (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$cmp, node:$val)> {
1367     let IsAtomic = 1;
1368     let IsAtomicOrderingMonotonic = 1;
1369   }
1370   def #NAME#_acquire : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
1371       (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$cmp, node:$val)> {
1372     let IsAtomic = 1;
1373     let IsAtomicOrderingAcquire = 1;
1374   }
1375   def #NAME#_release : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
1376       (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$cmp, node:$val)> {
1377     let IsAtomic = 1;
1378     let IsAtomicOrderingRelease = 1;
1379   }
1380   def #NAME#_acq_rel : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
1381       (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$cmp, node:$val)> {
1382     let IsAtomic = 1;
1383     let IsAtomicOrderingAcquireRelease = 1;
1384   }
1385   def #NAME#_seq_cst : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
1386       (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$cmp, node:$val)> {
1387     let IsAtomic = 1;
1388     let IsAtomicOrderingSequentiallyConsistent = 1;
1389   }
1392 multiclass binary_atomic_op<SDNode atomic_op, bit IsInt = 1> {
1393   def _8 : PatFrag<(ops node:$ptr, node:$val),
1394                    (atomic_op  node:$ptr, node:$val)> {
1395     let IsAtomic = 1;
1396     let MemoryVT = !if(IsInt, i8, ?);
1397   }
1398   def _16 : PatFrag<(ops node:$ptr, node:$val),
1399                     (atomic_op node:$ptr, node:$val)> {
1400     let IsAtomic = 1;
1401     let MemoryVT = !if(IsInt, i16, f16);
1402   }
1403   def _32 : PatFrag<(ops node:$ptr, node:$val),
1404                     (atomic_op node:$ptr, node:$val)> {
1405     let IsAtomic = 1;
1406     let MemoryVT = !if(IsInt, i32, f32);
1407   }
1408   def _64 : PatFrag<(ops node:$ptr, node:$val),
1409                     (atomic_op node:$ptr, node:$val)> {
1410     let IsAtomic = 1;
1411     let MemoryVT = !if(IsInt, i64, f64);
1412   }
1414   defm NAME#_8  : binary_atomic_op_ord<atomic_op>;
1415   defm NAME#_16 : binary_atomic_op_ord<atomic_op>;
1416   defm NAME#_32 : binary_atomic_op_ord<atomic_op>;
1417   defm NAME#_64 : binary_atomic_op_ord<atomic_op>;
1420 multiclass ternary_atomic_op<SDNode atomic_op> {
1421   def _8 : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
1422                    (atomic_op  node:$ptr, node:$cmp, node:$val)> {
1423     let IsAtomic = 1;
1424     let MemoryVT = i8;
1425   }
1426   def _16 : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
1427                     (atomic_op node:$ptr, node:$cmp, node:$val)> {
1428     let IsAtomic = 1;
1429     let MemoryVT = i16;
1430   }
1431   def _32 : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
1432                     (atomic_op node:$ptr, node:$cmp, node:$val)> {
1433     let IsAtomic = 1;
1434     let MemoryVT = i32;
1435   }
1436   def _64 : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
1437                     (atomic_op node:$ptr, node:$cmp, node:$val)> {
1438     let IsAtomic = 1;
1439     let MemoryVT = i64;
1440   }
1442   defm NAME#_8  : ternary_atomic_op_ord<atomic_op>;
1443   defm NAME#_16 : ternary_atomic_op_ord<atomic_op>;
1444   defm NAME#_32 : ternary_atomic_op_ord<atomic_op>;
1445   defm NAME#_64 : ternary_atomic_op_ord<atomic_op>;
1448 defm atomic_load_add  : binary_atomic_op<atomic_load_add>;
1449 defm atomic_swap      : binary_atomic_op<atomic_swap>;
1450 defm atomic_load_sub  : binary_atomic_op<atomic_load_sub>;
1451 defm atomic_load_and  : binary_atomic_op<atomic_load_and>;
1452 defm atomic_load_clr  : binary_atomic_op<atomic_load_clr>;
1453 defm atomic_load_or   : binary_atomic_op<atomic_load_or>;
1454 defm atomic_load_xor  : binary_atomic_op<atomic_load_xor>;
1455 defm atomic_load_nand : binary_atomic_op<atomic_load_nand>;
1456 defm atomic_load_min  : binary_atomic_op<atomic_load_min>;
1457 defm atomic_load_max  : binary_atomic_op<atomic_load_max>;
1458 defm atomic_load_umin : binary_atomic_op<atomic_load_umin>;
1459 defm atomic_load_umax : binary_atomic_op<atomic_load_umax>;
1460 defm atomic_store     : binary_atomic_op<atomic_store>;
1461 defm atomic_cmp_swap  : ternary_atomic_op<atomic_cmp_swap>;
1463 def atomic_load_8 :
1464   PatFrag<(ops node:$ptr),
1465           (atomic_load node:$ptr)> {
1466   let IsAtomic = 1;
1467   let MemoryVT = i8;
1469 def atomic_load_16 :
1470   PatFrag<(ops node:$ptr),
1471           (atomic_load node:$ptr)> {
1472   let IsAtomic = 1;
1473   let MemoryVT = i16;
1475 def atomic_load_32 :
1476   PatFrag<(ops node:$ptr),
1477           (atomic_load node:$ptr)> {
1478   let IsAtomic = 1;
1479   let MemoryVT = i32;
1481 def atomic_load_64 :
1482   PatFrag<(ops node:$ptr),
1483           (atomic_load node:$ptr)> {
1484   let IsAtomic = 1;
1485   let MemoryVT = i64;
1488 //===----------------------------------------------------------------------===//
1489 // Selection DAG Pattern Support.
1491 // Patterns are what are actually matched against by the target-flavored
1492 // instruction selection DAG.  Instructions defined by the target implicitly
1493 // define patterns in most cases, but patterns can also be explicitly added when
1494 // an operation is defined by a sequence of instructions (e.g. loading a large
1495 // immediate value on RISC targets that do not support immediates as large as
1496 // their GPRs).
1499 class Pattern<dag patternToMatch, list<dag> resultInstrs> {
1500   dag             PatternToMatch  = patternToMatch;
1501   list<dag>       ResultInstrs    = resultInstrs;
1502   list<Predicate> Predicates      = [];  // See class Instruction in Target.td.
1503   int             AddedComplexity = 0;   // See class Instruction in Target.td.
1506 // Pat - A simple (but common) form of a pattern, which produces a simple result
1507 // not needing a full list.
1508 class Pat<dag pattern, dag result> : Pattern<pattern, [result]>;
1510 //===----------------------------------------------------------------------===//
1511 // Complex pattern definitions.
1514 // Complex patterns, e.g. X86 addressing mode, requires pattern matching code
1515 // in C++. NumOperands is the number of operands returned by the select function;
1516 // SelectFunc is the name of the function used to pattern match the max. pattern;
1517 // RootNodes are the list of possible root nodes of the sub-dags to match.
1518 // e.g. X86 addressing mode - def addr : ComplexPattern<4, "SelectAddr", [add]>;
1520 class ComplexPattern<ValueType ty, int numops, string fn,
1521                      list<SDNode> roots = [], list<SDNodeProperty> props = [],
1522                      int complexity = -1> {
1523   ValueType Ty = ty;
1524   int NumOperands = numops;
1525   string SelectFunc = fn;
1526   list<SDNode> RootNodes = roots;
1527   list<SDNodeProperty> Properties = props;
1528   int Complexity = complexity;