1 //===- TargetSelectionDAG.td - Common code for DAG isels ---*- tablegen -*-===//
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
7 //===----------------------------------------------------------------------===//
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> {
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
72 class SDTCVecEltisVT<int OpNum, ValueType vt> : SDTypeConstraint<OpNum> {
76 // SDTCisSameNumEltsAs - The two specified operands have identical number
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
97 class SDTypeProfile<int numresults, int numoperands,
98 list<SDTypeConstraint> constraints> {
99 int NumResults = numresults;
100 int NumOperands = numoperands;
101 list<SDTypeConstraint> Constraints = constraints;
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>,
190 def SDTBr : SDTypeProfile<0, 1, [ // br
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
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
216 def SDTStore : SDTypeProfile<0, 2, [ // store
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>
242 def SDTVecReduce : SDTypeProfile<1, 1, [ // vector reduction
243 SDTCisInt<0>, SDTCisVec<1>
246 def SDTSubVecExtract : SDTypeProfile<1, 2, [// subvector extract
247 SDTCisSubVecOfVec<0,1>, SDTCisInt<2>
249 def SDTSubVecInsert : SDTypeProfile<1, 3, [ // subvector insert
250 SDTCisSubVecOfVec<2, 1>, SDTCisSameAs<0,1>, SDTCisInt<3>
253 def SDTPrefetch : SDTypeProfile<0, 4, [ // prefetch
254 SDTCisPtrTy<0>, SDTCisSameAs<1, 2>, SDTCisSameAs<1, 3>, SDTCisInt<1>
257 def SDTMemBarrier : SDTypeProfile<0, 5, [ // memory barrier
258 SDTCisSameAs<0,1>, SDTCisSameAs<0,2>, SDTCisSameAs<0,3>, SDTCisSameAs<0,4>,
261 def SDTAtomicFence : SDTypeProfile<0, 2, [
262 SDTCisSameAs<0,1>, SDTCisPtrTy<0>
264 def SDTAtomic3 : SDTypeProfile<1, 3, [
265 SDTCisSameAs<0,2>, SDTCisSameAs<0,3>, SDTCisInt<0>, SDTCisPtrTy<1>
267 def SDTAtomic2 : SDTypeProfile<1, 2, [
268 SDTCisSameAs<0,2>, SDTCisInt<0>, SDTCisPtrTy<1>
271 def SDTFPAtomic2 : SDTypeProfile<1, 2, [
272 SDTCisSameAs<0,2>, SDTCisFP<0>, SDTCisPtrTy<1>
275 def SDTAtomicStore : SDTypeProfile<0, 2, [
276 SDTCisPtrTy<0>, SDTCisInt<1>
278 def SDTAtomicLoad : SDTypeProfile<1, 1, [
279 SDTCisInt<0>, SDTCisPtrTy<1>
282 def SDTConvertOp : SDTypeProfile<1, 5, [ //cvtss, su, us, uu, ff, fs, fu, sf, su
283 SDTCisVT<2, OtherVT>, SDTCisVT<3, OtherVT>, SDTCisPtrTy<4>, SDTCisPtrTy<5>
286 class SDCallSeqStart<list<SDTypeConstraint> constraints> :
287 SDTypeProfile<0, 2, constraints>;
288 class SDCallSeqEnd<list<SDTypeConstraint> constraints> :
289 SDTypeProfile<0, 2, constraints>;
291 //===----------------------------------------------------------------------===//
292 // Selection DAG Node definitions.
294 class SDNode<string opcode, SDTypeProfile typeprof,
295 list<SDNodeProperty> props = [], string sdclass = "SDNode">
296 : SDPatternOperator {
297 string Opcode = opcode;
298 string SDClass = sdclass;
299 let Properties = props;
300 SDTypeProfile TypeProfile = typeprof;
303 // Special TableGen-recognized dag nodes
309 def imm : SDNode<"ISD::Constant" , SDTIntLeaf , [], "ConstantSDNode">;
310 def timm : SDNode<"ISD::TargetConstant",SDTIntLeaf, [], "ConstantSDNode">;
311 def fpimm : SDNode<"ISD::ConstantFP", SDTFPLeaf , [], "ConstantFPSDNode">;
312 def vt : SDNode<"ISD::VALUETYPE" , SDTOther , [], "VTSDNode">;
313 def bb : SDNode<"ISD::BasicBlock", SDTOther , [], "BasicBlockSDNode">;
314 def cond : SDNode<"ISD::CONDCODE" , SDTOther , [], "CondCodeSDNode">;
315 def undef : SDNode<"ISD::UNDEF" , SDTUNDEF , []>;
316 def globaladdr : SDNode<"ISD::GlobalAddress", SDTPtrLeaf, [],
317 "GlobalAddressSDNode">;
318 def tglobaladdr : SDNode<"ISD::TargetGlobalAddress", SDTPtrLeaf, [],
319 "GlobalAddressSDNode">;
320 def globaltlsaddr : SDNode<"ISD::GlobalTLSAddress", SDTPtrLeaf, [],
321 "GlobalAddressSDNode">;
322 def tglobaltlsaddr : SDNode<"ISD::TargetGlobalTLSAddress", SDTPtrLeaf, [],
323 "GlobalAddressSDNode">;
324 def constpool : SDNode<"ISD::ConstantPool", SDTPtrLeaf, [],
325 "ConstantPoolSDNode">;
326 def tconstpool : SDNode<"ISD::TargetConstantPool", SDTPtrLeaf, [],
327 "ConstantPoolSDNode">;
328 def jumptable : SDNode<"ISD::JumpTable", SDTPtrLeaf, [],
330 def tjumptable : SDNode<"ISD::TargetJumpTable", SDTPtrLeaf, [],
332 def frameindex : SDNode<"ISD::FrameIndex", SDTPtrLeaf, [],
334 def tframeindex : SDNode<"ISD::TargetFrameIndex", SDTPtrLeaf, [],
336 def externalsym : SDNode<"ISD::ExternalSymbol", SDTPtrLeaf, [],
337 "ExternalSymbolSDNode">;
338 def texternalsym: SDNode<"ISD::TargetExternalSymbol", SDTPtrLeaf, [],
339 "ExternalSymbolSDNode">;
340 def mcsym: SDNode<"ISD::MCSymbol", SDTPtrLeaf, [], "MCSymbolSDNode">;
341 def blockaddress : SDNode<"ISD::BlockAddress", SDTPtrLeaf, [],
342 "BlockAddressSDNode">;
343 def tblockaddress: SDNode<"ISD::TargetBlockAddress", SDTPtrLeaf, [],
344 "BlockAddressSDNode">;
346 def add : SDNode<"ISD::ADD" , SDTIntBinOp ,
347 [SDNPCommutative, SDNPAssociative]>;
348 def sub : SDNode<"ISD::SUB" , SDTIntBinOp>;
349 def mul : SDNode<"ISD::MUL" , SDTIntBinOp,
350 [SDNPCommutative, SDNPAssociative]>;
351 def mulhs : SDNode<"ISD::MULHS" , SDTIntBinOp, [SDNPCommutative]>;
352 def mulhu : SDNode<"ISD::MULHU" , SDTIntBinOp, [SDNPCommutative]>;
353 def smullohi : SDNode<"ISD::SMUL_LOHI" , SDTIntBinHiLoOp, [SDNPCommutative]>;
354 def umullohi : SDNode<"ISD::UMUL_LOHI" , SDTIntBinHiLoOp, [SDNPCommutative]>;
355 def sdiv : SDNode<"ISD::SDIV" , SDTIntBinOp>;
356 def udiv : SDNode<"ISD::UDIV" , SDTIntBinOp>;
357 def srem : SDNode<"ISD::SREM" , SDTIntBinOp>;
358 def urem : SDNode<"ISD::UREM" , SDTIntBinOp>;
359 def sdivrem : SDNode<"ISD::SDIVREM" , SDTIntBinHiLoOp>;
360 def udivrem : SDNode<"ISD::UDIVREM" , SDTIntBinHiLoOp>;
361 def srl : SDNode<"ISD::SRL" , SDTIntShiftOp>;
362 def sra : SDNode<"ISD::SRA" , SDTIntShiftOp>;
363 def shl : SDNode<"ISD::SHL" , SDTIntShiftOp>;
364 def rotl : SDNode<"ISD::ROTL" , SDTIntShiftOp>;
365 def rotr : SDNode<"ISD::ROTR" , SDTIntShiftOp>;
366 def fshl : SDNode<"ISD::FSHL" , SDTIntShiftDOp>;
367 def fshr : SDNode<"ISD::FSHR" , SDTIntShiftDOp>;
368 def and : SDNode<"ISD::AND" , SDTIntBinOp,
369 [SDNPCommutative, SDNPAssociative]>;
370 def or : SDNode<"ISD::OR" , SDTIntBinOp,
371 [SDNPCommutative, SDNPAssociative]>;
372 def xor : SDNode<"ISD::XOR" , SDTIntBinOp,
373 [SDNPCommutative, SDNPAssociative]>;
374 def addc : SDNode<"ISD::ADDC" , SDTIntBinOp,
375 [SDNPCommutative, SDNPOutGlue]>;
376 def adde : SDNode<"ISD::ADDE" , SDTIntBinOp,
377 [SDNPCommutative, SDNPOutGlue, SDNPInGlue]>;
378 def subc : SDNode<"ISD::SUBC" , SDTIntBinOp,
380 def sube : SDNode<"ISD::SUBE" , SDTIntBinOp,
381 [SDNPOutGlue, SDNPInGlue]>;
382 def smin : SDNode<"ISD::SMIN" , SDTIntBinOp,
383 [SDNPCommutative, SDNPAssociative]>;
384 def smax : SDNode<"ISD::SMAX" , SDTIntBinOp,
385 [SDNPCommutative, SDNPAssociative]>;
386 def umin : SDNode<"ISD::UMIN" , SDTIntBinOp,
387 [SDNPCommutative, SDNPAssociative]>;
388 def umax : SDNode<"ISD::UMAX" , SDTIntBinOp,
389 [SDNPCommutative, SDNPAssociative]>;
391 def saddsat : SDNode<"ISD::SADDSAT" , SDTIntBinOp, [SDNPCommutative]>;
392 def uaddsat : SDNode<"ISD::UADDSAT" , SDTIntBinOp, [SDNPCommutative]>;
393 def ssubsat : SDNode<"ISD::SSUBSAT" , SDTIntBinOp>;
394 def usubsat : SDNode<"ISD::USUBSAT" , SDTIntBinOp>;
396 def smulfix : SDNode<"ISD::SMULFIX" , SDTIntScaledBinOp, [SDNPCommutative]>;
397 def smulfixsat : SDNode<"ISD::SMULFIXSAT", SDTIntScaledBinOp, [SDNPCommutative]>;
398 def umulfix : SDNode<"ISD::UMULFIX" , SDTIntScaledBinOp, [SDNPCommutative]>;
400 def sext_inreg : SDNode<"ISD::SIGN_EXTEND_INREG", SDTExtInreg>;
401 def sext_invec : SDNode<"ISD::SIGN_EXTEND_VECTOR_INREG", SDTExtInvec>;
402 def zext_invec : SDNode<"ISD::ZERO_EXTEND_VECTOR_INREG", SDTExtInvec>;
404 def abs : SDNode<"ISD::ABS" , SDTIntUnaryOp>;
405 def bitreverse : SDNode<"ISD::BITREVERSE" , SDTIntUnaryOp>;
406 def bswap : SDNode<"ISD::BSWAP" , SDTIntUnaryOp>;
407 def ctlz : SDNode<"ISD::CTLZ" , SDTIntUnaryOp>;
408 def cttz : SDNode<"ISD::CTTZ" , SDTIntUnaryOp>;
409 def ctpop : SDNode<"ISD::CTPOP" , SDTIntUnaryOp>;
410 def ctlz_zero_undef : SDNode<"ISD::CTLZ_ZERO_UNDEF", SDTIntUnaryOp>;
411 def cttz_zero_undef : SDNode<"ISD::CTTZ_ZERO_UNDEF", SDTIntUnaryOp>;
412 def sext : SDNode<"ISD::SIGN_EXTEND", SDTIntExtendOp>;
413 def zext : SDNode<"ISD::ZERO_EXTEND", SDTIntExtendOp>;
414 def anyext : SDNode<"ISD::ANY_EXTEND" , SDTIntExtendOp>;
415 def trunc : SDNode<"ISD::TRUNCATE" , SDTIntTruncOp>;
416 def bitconvert : SDNode<"ISD::BITCAST" , SDTUnaryOp>;
417 def addrspacecast : SDNode<"ISD::ADDRSPACECAST", SDTUnaryOp>;
418 def extractelt : SDNode<"ISD::EXTRACT_VECTOR_ELT", SDTVecExtract>;
419 def insertelt : SDNode<"ISD::INSERT_VECTOR_ELT", SDTVecInsert>;
421 def vecreduce_add : SDNode<"ISD::VECREDUCE_ADD", SDTVecReduce>;
423 def fadd : SDNode<"ISD::FADD" , SDTFPBinOp, [SDNPCommutative]>;
424 def fsub : SDNode<"ISD::FSUB" , SDTFPBinOp>;
425 def fmul : SDNode<"ISD::FMUL" , SDTFPBinOp, [SDNPCommutative]>;
426 def fdiv : SDNode<"ISD::FDIV" , SDTFPBinOp>;
427 def frem : SDNode<"ISD::FREM" , SDTFPBinOp>;
428 def fma : SDNode<"ISD::FMA" , SDTFPTernaryOp>;
429 def fmad : SDNode<"ISD::FMAD" , SDTFPTernaryOp>;
430 def fabs : SDNode<"ISD::FABS" , SDTFPUnaryOp>;
431 def fminnum : SDNode<"ISD::FMINNUM" , SDTFPBinOp,
432 [SDNPCommutative, SDNPAssociative]>;
433 def fmaxnum : SDNode<"ISD::FMAXNUM" , SDTFPBinOp,
434 [SDNPCommutative, SDNPAssociative]>;
435 def fminnum_ieee : SDNode<"ISD::FMINNUM_IEEE", SDTFPBinOp,
437 def fmaxnum_ieee : SDNode<"ISD::FMAXNUM_IEEE", SDTFPBinOp,
439 def fminimum : SDNode<"ISD::FMINIMUM" , SDTFPBinOp,
440 [SDNPCommutative, SDNPAssociative]>;
441 def fmaximum : SDNode<"ISD::FMAXIMUM" , SDTFPBinOp,
442 [SDNPCommutative, SDNPAssociative]>;
443 def fgetsign : SDNode<"ISD::FGETSIGN" , SDTFPToIntOp>;
444 def fcanonicalize : SDNode<"ISD::FCANONICALIZE", SDTFPUnaryOp>;
445 def fneg : SDNode<"ISD::FNEG" , SDTFPUnaryOp>;
446 def fsqrt : SDNode<"ISD::FSQRT" , SDTFPUnaryOp>;
447 def fsin : SDNode<"ISD::FSIN" , SDTFPUnaryOp>;
448 def fcos : SDNode<"ISD::FCOS" , SDTFPUnaryOp>;
449 def fexp2 : SDNode<"ISD::FEXP2" , SDTFPUnaryOp>;
450 def fpow : SDNode<"ISD::FPOW" , SDTFPBinOp>;
451 def flog2 : SDNode<"ISD::FLOG2" , SDTFPUnaryOp>;
452 def frint : SDNode<"ISD::FRINT" , SDTFPUnaryOp>;
453 def ftrunc : SDNode<"ISD::FTRUNC" , SDTFPUnaryOp>;
454 def fceil : SDNode<"ISD::FCEIL" , SDTFPUnaryOp>;
455 def ffloor : SDNode<"ISD::FFLOOR" , SDTFPUnaryOp>;
456 def fnearbyint : SDNode<"ISD::FNEARBYINT" , SDTFPUnaryOp>;
457 def fround : SDNode<"ISD::FROUND" , SDTFPUnaryOp>;
459 def lround : SDNode<"ISD::LROUND" , SDTFPToIntOp>;
460 def llround : SDNode<"ISD::LLROUND" , SDTFPToIntOp>;
461 def lrint : SDNode<"ISD::LRINT" , SDTFPToIntOp>;
462 def llrint : SDNode<"ISD::LLRINT" , SDTFPToIntOp>;
464 def fpround : SDNode<"ISD::FP_ROUND" , SDTFPRoundOp>;
465 def fpextend : SDNode<"ISD::FP_EXTEND" , SDTFPExtendOp>;
466 def fcopysign : SDNode<"ISD::FCOPYSIGN" , SDTFPSignOp>;
468 def sint_to_fp : SDNode<"ISD::SINT_TO_FP" , SDTIntToFPOp>;
469 def uint_to_fp : SDNode<"ISD::UINT_TO_FP" , SDTIntToFPOp>;
470 def fp_to_sint : SDNode<"ISD::FP_TO_SINT" , SDTFPToIntOp>;
471 def fp_to_uint : SDNode<"ISD::FP_TO_UINT" , SDTFPToIntOp>;
472 def f16_to_fp : SDNode<"ISD::FP16_TO_FP" , SDTIntToFPOp>;
473 def fp_to_f16 : SDNode<"ISD::FP_TO_FP16" , SDTFPToIntOp>;
475 def strict_fadd : SDNode<"ISD::STRICT_FADD",
476 SDTFPBinOp, [SDNPHasChain, SDNPCommutative]>;
477 def strict_fsub : SDNode<"ISD::STRICT_FSUB",
478 SDTFPBinOp, [SDNPHasChain]>;
479 def strict_fmul : SDNode<"ISD::STRICT_FMUL",
480 SDTFPBinOp, [SDNPHasChain, SDNPCommutative]>;
481 def strict_fdiv : SDNode<"ISD::STRICT_FDIV",
482 SDTFPBinOp, [SDNPHasChain]>;
483 def strict_frem : SDNode<"ISD::STRICT_FREM",
484 SDTFPBinOp, [SDNPHasChain]>;
485 def strict_fma : SDNode<"ISD::STRICT_FMA",
486 SDTFPTernaryOp, [SDNPHasChain]>;
487 def strict_fsqrt : SDNode<"ISD::STRICT_FSQRT",
488 SDTFPUnaryOp, [SDNPHasChain]>;
489 def strict_fsin : SDNode<"ISD::STRICT_FSIN",
490 SDTFPUnaryOp, [SDNPHasChain]>;
491 def strict_fcos : SDNode<"ISD::STRICT_FCOS",
492 SDTFPUnaryOp, [SDNPHasChain]>;
493 def strict_fexp2 : SDNode<"ISD::STRICT_FEXP2",
494 SDTFPUnaryOp, [SDNPHasChain]>;
495 def strict_fpow : SDNode<"ISD::STRICT_FPOW",
496 SDTFPBinOp, [SDNPHasChain]>;
497 def strict_flog2 : SDNode<"ISD::STRICT_FLOG2",
498 SDTFPUnaryOp, [SDNPHasChain]>;
499 def strict_frint : SDNode<"ISD::STRICT_FRINT",
500 SDTFPUnaryOp, [SDNPHasChain]>;
501 def strict_fnearbyint : SDNode<"ISD::STRICT_FNEARBYINT",
502 SDTFPUnaryOp, [SDNPHasChain]>;
503 def strict_fceil : SDNode<"ISD::STRICT_FCEIL",
504 SDTFPUnaryOp, [SDNPHasChain]>;
505 def strict_ffloor : SDNode<"ISD::STRICT_FFLOOR",
506 SDTFPUnaryOp, [SDNPHasChain]>;
507 def strict_fround : SDNode<"ISD::STRICT_FROUND",
508 SDTFPUnaryOp, [SDNPHasChain]>;
509 def strict_ftrunc : SDNode<"ISD::STRICT_FTRUNC",
510 SDTFPUnaryOp, [SDNPHasChain]>;
511 def strict_fminnum : SDNode<"ISD::STRICT_FMINNUM",
512 SDTFPBinOp, [SDNPHasChain,
513 SDNPCommutative, SDNPAssociative]>;
514 def strict_fmaxnum : SDNode<"ISD::STRICT_FMAXNUM",
515 SDTFPBinOp, [SDNPHasChain,
516 SDNPCommutative, SDNPAssociative]>;
517 def strict_fpround : SDNode<"ISD::STRICT_FP_ROUND",
518 SDTFPRoundOp, [SDNPHasChain]>;
519 def strict_fpextend : SDNode<"ISD::STRICT_FP_EXTEND",
520 SDTFPExtendOp, [SDNPHasChain]>;
521 def strict_fp_to_sint : SDNode<"ISD::STRICT_FP_TO_SINT",
522 SDTFPToIntOp, [SDNPHasChain]>;
523 def strict_fp_to_uint : SDNode<"ISD::STRICT_FP_TO_UINT",
524 SDTFPToIntOp, [SDNPHasChain]>;
526 def setcc : SDNode<"ISD::SETCC" , SDTSetCC>;
527 def select : SDNode<"ISD::SELECT" , SDTSelect>;
528 def vselect : SDNode<"ISD::VSELECT" , SDTVSelect>;
529 def selectcc : SDNode<"ISD::SELECT_CC" , SDTSelectCC>;
531 def brcc : SDNode<"ISD::BR_CC" , SDTBrCC, [SDNPHasChain]>;
532 def brcond : SDNode<"ISD::BRCOND" , SDTBrcond, [SDNPHasChain]>;
533 def brind : SDNode<"ISD::BRIND" , SDTBrind, [SDNPHasChain]>;
534 def br : SDNode<"ISD::BR" , SDTBr, [SDNPHasChain]>;
535 def catchret : SDNode<"ISD::CATCHRET" , SDTCatchret,
536 [SDNPHasChain, SDNPSideEffect]>;
537 def cleanupret : SDNode<"ISD::CLEANUPRET" , SDTNone, [SDNPHasChain]>;
538 def catchpad : SDNode<"ISD::CATCHPAD" , SDTNone,
539 [SDNPHasChain, SDNPSideEffect]>;
541 def trap : SDNode<"ISD::TRAP" , SDTNone,
542 [SDNPHasChain, SDNPSideEffect]>;
543 def debugtrap : SDNode<"ISD::DEBUGTRAP" , SDTNone,
544 [SDNPHasChain, SDNPSideEffect]>;
546 def prefetch : SDNode<"ISD::PREFETCH" , SDTPrefetch,
547 [SDNPHasChain, SDNPMayLoad, SDNPMayStore,
550 def readcyclecounter : SDNode<"ISD::READCYCLECOUNTER", SDTIntLeaf,
551 [SDNPHasChain, SDNPSideEffect]>;
553 def atomic_fence : SDNode<"ISD::ATOMIC_FENCE" , SDTAtomicFence,
554 [SDNPHasChain, SDNPSideEffect]>;
556 def atomic_cmp_swap : SDNode<"ISD::ATOMIC_CMP_SWAP" , SDTAtomic3,
557 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
558 def atomic_load_add : SDNode<"ISD::ATOMIC_LOAD_ADD" , SDTAtomic2,
559 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
560 def atomic_swap : SDNode<"ISD::ATOMIC_SWAP", SDTAtomic2,
561 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
562 def atomic_load_sub : SDNode<"ISD::ATOMIC_LOAD_SUB" , SDTAtomic2,
563 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
564 def atomic_load_and : SDNode<"ISD::ATOMIC_LOAD_AND" , SDTAtomic2,
565 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
566 def atomic_load_clr : SDNode<"ISD::ATOMIC_LOAD_CLR" , SDTAtomic2,
567 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
568 def atomic_load_or : SDNode<"ISD::ATOMIC_LOAD_OR" , SDTAtomic2,
569 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
570 def atomic_load_xor : SDNode<"ISD::ATOMIC_LOAD_XOR" , SDTAtomic2,
571 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
572 def atomic_load_nand: SDNode<"ISD::ATOMIC_LOAD_NAND", SDTAtomic2,
573 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
574 def atomic_load_min : SDNode<"ISD::ATOMIC_LOAD_MIN", SDTAtomic2,
575 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
576 def atomic_load_max : SDNode<"ISD::ATOMIC_LOAD_MAX", SDTAtomic2,
577 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
578 def atomic_load_umin : SDNode<"ISD::ATOMIC_LOAD_UMIN", SDTAtomic2,
579 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
580 def atomic_load_umax : SDNode<"ISD::ATOMIC_LOAD_UMAX", SDTAtomic2,
581 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
582 def atomic_load_fadd : SDNode<"ISD::ATOMIC_LOAD_FADD" , SDTFPAtomic2,
583 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
584 def atomic_load_fsub : SDNode<"ISD::ATOMIC_LOAD_FSUB" , SDTFPAtomic2,
585 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
587 def atomic_load : SDNode<"ISD::ATOMIC_LOAD", SDTAtomicLoad,
588 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
589 def atomic_store : SDNode<"ISD::ATOMIC_STORE", SDTAtomicStore,
590 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
592 def masked_st : SDNode<"ISD::MSTORE", SDTMaskedStore,
593 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
594 def masked_ld : SDNode<"ISD::MLOAD", SDTMaskedLoad,
595 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
597 // Do not use ld, st directly. Use load, extload, sextload, zextload, store,
598 // and truncst (see below).
599 def ld : SDNode<"ISD::LOAD" , SDTLoad,
600 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
601 def st : SDNode<"ISD::STORE" , SDTStore,
602 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
603 def ist : SDNode<"ISD::STORE" , SDTIStore,
604 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
606 def vector_shuffle : SDNode<"ISD::VECTOR_SHUFFLE", SDTVecShuffle, []>;
607 def build_vector : SDNode<"ISD::BUILD_VECTOR", SDTypeProfile<1, -1, []>, []>;
608 def scalar_to_vector : SDNode<"ISD::SCALAR_TO_VECTOR", SDTypeProfile<1, 1, []>,
611 // vector_extract/vector_insert are deprecated. extractelt/insertelt
613 def vector_extract : SDNode<"ISD::EXTRACT_VECTOR_ELT",
614 SDTypeProfile<1, 2, [SDTCisPtrTy<2>]>, []>;
615 def vector_insert : SDNode<"ISD::INSERT_VECTOR_ELT",
616 SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisPtrTy<3>]>, []>;
617 def concat_vectors : SDNode<"ISD::CONCAT_VECTORS",
618 SDTypeProfile<1, 2, [SDTCisSubVecOfVec<1, 0>, SDTCisSameAs<1, 2>]>,[]>;
620 // This operator does not do subvector type checking. The ARM
621 // backend, at least, needs it.
622 def vector_extract_subvec : SDNode<"ISD::EXTRACT_SUBVECTOR",
623 SDTypeProfile<1, 2, [SDTCisInt<2>, SDTCisVec<1>, SDTCisVec<0>]>,
626 // This operator does subvector type checking.
627 def extract_subvector : SDNode<"ISD::EXTRACT_SUBVECTOR", SDTSubVecExtract, []>;
628 def insert_subvector : SDNode<"ISD::INSERT_SUBVECTOR", SDTSubVecInsert, []>;
630 // Nodes for intrinsics, you should use the intrinsic itself and let tblgen use
631 // these internally. Don't reference these directly.
632 def intrinsic_void : SDNode<"ISD::INTRINSIC_VOID",
633 SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>,
635 def intrinsic_w_chain : SDNode<"ISD::INTRINSIC_W_CHAIN",
636 SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>,
638 def intrinsic_wo_chain : SDNode<"ISD::INTRINSIC_WO_CHAIN",
639 SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>, []>;
641 def SDT_assertext : SDTypeProfile<1, 1,
642 [SDTCisInt<0>, SDTCisInt<1>, SDTCisSameAs<1, 0>]>;
643 def assertsext : SDNode<"ISD::AssertSext", SDT_assertext>;
644 def assertzext : SDNode<"ISD::AssertZext", SDT_assertext>;
647 //===----------------------------------------------------------------------===//
648 // Selection DAG Condition Codes
650 class CondCode<string fcmpName = "", string icmpName = ""> {
651 string ICmpPredicate = icmpName;
652 string FCmpPredicate = fcmpName;
655 // ISD::CondCode enums, and mapping to CmpInst::Predicate names
656 def SETOEQ : CondCode<"FCMP_OEQ">;
657 def SETOGT : CondCode<"FCMP_OGT">;
658 def SETOGE : CondCode<"FCMP_OGE">;
659 def SETOLT : CondCode<"FCMP_OLT">;
660 def SETOLE : CondCode<"FCMP_OLE">;
661 def SETONE : CondCode<"FCMP_ONE">;
662 def SETO : CondCode<"FCMP_ORD">;
663 def SETUO : CondCode<"FCMP_UNO">;
664 def SETUEQ : CondCode<"FCMP_UEQ">;
665 def SETUGT : CondCode<"FCMP_UGT", "ICMP_UGT">;
666 def SETUGE : CondCode<"FCMP_UGE", "ICMP_UGE">;
667 def SETULT : CondCode<"FCMP_ULT", "ICMP_ULT">;
668 def SETULE : CondCode<"FCMP_ULE", "ICMP_ULE">;
669 def SETUNE : CondCode<"FCMP_UNE">;
670 def SETEQ : CondCode<"", "ICMP_EQ">;
671 def SETGT : CondCode<"", "ICMP_SGT">;
672 def SETGE : CondCode<"", "ICMP_SGE">;
673 def SETLT : CondCode<"", "ICMP_SLT">;
674 def SETLE : CondCode<"", "ICMP_SLE">;
675 def SETNE : CondCode<"", "ICMP_NE">;
677 //===----------------------------------------------------------------------===//
678 // Selection DAG Node Transformation Functions.
680 // This mechanism allows targets to manipulate nodes in the output DAG once a
681 // match has been formed. This is typically used to manipulate immediate
684 class SDNodeXForm<SDNode opc, code xformFunction> {
686 code XFormFunction = xformFunction;
689 def NOOP_SDNodeXForm : SDNodeXForm<imm, [{}]>;
691 //===----------------------------------------------------------------------===//
692 // PatPred Subclasses.
694 // These allow specifying different sorts of predicates that control whether a
699 class CodePatPred<code predicate> : PatPred {
700 code PredicateCode = predicate;
704 //===----------------------------------------------------------------------===//
705 // Selection DAG Pattern Fragments.
707 // Pattern fragments are reusable chunks of dags that match specific things.
708 // They can take arguments and have C++ predicates that control whether they
709 // match. They are intended to make the patterns for common instructions more
710 // compact and readable.
713 /// PatFrags - Represents a set of pattern fragments. Each single fragment
714 /// can match something on the DAG, from a single node to multiple nested other
715 /// fragments. The whole set of fragments matches if any of the single
716 /// fragemnts match. This allows e.g. matching and "add with overflow" and
717 /// a regular "add" with the same fragment set.
719 class PatFrags<dag ops, list<dag> frags, code pred = [{}],
720 SDNodeXForm xform = NOOP_SDNodeXForm> : SDPatternOperator {
722 list<dag> Fragments = frags;
723 code PredicateCode = pred;
724 code GISelPredicateCode = [{}];
725 code ImmediateCode = [{}];
726 SDNodeXForm OperandTransform = xform;
728 // When this is set, the PredicateCode may refer to a constant Operands
729 // vector which contains the captured nodes of the DAG, in the order listed
730 // by the Operands field above.
732 // This is useful when Fragments involves associative / commutative
733 // operators: a single piece of code can easily refer to all operands even
734 // when re-associated / commuted variants of the fragment are matched.
735 bit PredicateCodeUsesOperands = 0;
737 // Define a few pre-packaged predicates. This helps GlobalISel import
738 // existing rules from SelectionDAG for many common cases.
739 // They will be tested prior to the code in pred and must not be used in
740 // ImmLeaf and its subclasses.
742 // Is the desired pre-packaged predicate for a load?
744 // Is the desired pre-packaged predicate for a store?
746 // Is the desired pre-packaged predicate for an atomic?
749 // cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
750 // cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
753 // cast<LoadSDNode>(N)->getExtensionType() != ISD::NON_EXTLOAD
754 bit IsNonExtLoad = ?;
755 // cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
756 bit IsAnyExtLoad = ?;
757 // cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
758 bit IsSignExtLoad = ?;
759 // cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
760 bit IsZeroExtLoad = ?;
761 // !cast<StoreSDNode>(N)->isTruncatingStore();
762 // cast<StoreSDNode>(N)->isTruncatingStore();
763 bit IsTruncStore = ?;
765 // cast<MemSDNode>(N)->getAddressSpace() ==
766 // If this empty, accept any address space.
767 list<int> AddressSpaces = ?;
769 // cast<MemSDNode>(N)->getAlignment() >=
770 // If this is empty, accept any alignment.
771 int MinAlignment = ?;
773 // cast<AtomicSDNode>(N)->getOrdering() == AtomicOrdering::Monotonic
774 bit IsAtomicOrderingMonotonic = ?;
775 // cast<AtomicSDNode>(N)->getOrdering() == AtomicOrdering::Acquire
776 bit IsAtomicOrderingAcquire = ?;
777 // cast<AtomicSDNode>(N)->getOrdering() == AtomicOrdering::Release
778 bit IsAtomicOrderingRelease = ?;
779 // cast<AtomicSDNode>(N)->getOrdering() == AtomicOrdering::AcquireRelease
780 bit IsAtomicOrderingAcquireRelease = ?;
781 // cast<AtomicSDNode>(N)->getOrdering() == AtomicOrdering::SequentiallyConsistent
782 bit IsAtomicOrderingSequentiallyConsistent = ?;
784 // isAcquireOrStronger(cast<AtomicSDNode>(N)->getOrdering())
785 // !isAcquireOrStronger(cast<AtomicSDNode>(N)->getOrdering())
786 bit IsAtomicOrderingAcquireOrStronger = ?;
788 // isReleaseOrStronger(cast<AtomicSDNode>(N)->getOrdering())
789 // !isReleaseOrStronger(cast<AtomicSDNode>(N)->getOrdering())
790 bit IsAtomicOrderingReleaseOrStronger = ?;
792 // cast<LoadSDNode>(N)->getMemoryVT() == MVT::<VT>;
793 // cast<StoreSDNode>(N)->getMemoryVT() == MVT::<VT>;
794 ValueType MemoryVT = ?;
795 // cast<LoadSDNode>(N)->getMemoryVT().getScalarType() == MVT::<VT>;
796 // cast<StoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::<VT>;
797 ValueType ScalarMemoryVT = ?;
800 // PatFrag - A version of PatFrags matching only a single fragment.
801 class PatFrag<dag ops, dag frag, code pred = [{}],
802 SDNodeXForm xform = NOOP_SDNodeXForm>
803 : PatFrags<ops, [frag], pred, xform>;
805 // OutPatFrag is a pattern fragment that is used as part of an output pattern
806 // (not an input pattern). These do not have predicates or transforms, but are
807 // used to avoid repeated subexpressions in output patterns.
808 class OutPatFrag<dag ops, dag frag>
809 : PatFrag<ops, frag, [{}], NOOP_SDNodeXForm>;
811 // PatLeaf's are pattern fragments that have no operands. This is just a helper
812 // to define immediates and other common things concisely.
813 class PatLeaf<dag frag, code pred = [{}], SDNodeXForm xform = NOOP_SDNodeXForm>
814 : PatFrag<(ops), frag, pred, xform>;
817 // ImmLeaf is a pattern fragment with a constraint on the immediate. The
818 // constraint is a function that is run on the immediate (always with the value
819 // sign extended out to an int64_t) as Imm. For example:
821 // def immSExt8 : ImmLeaf<i16, [{ return (char)Imm == Imm; }]>;
823 // this is a more convenient form to match 'imm' nodes in than PatLeaf and also
824 // is preferred over using PatLeaf because it allows the code generator to
825 // reason more about the constraint.
827 // If FastIsel should ignore all instructions that have an operand of this type,
828 // the FastIselShouldIgnore flag can be set. This is an optimization to reduce
829 // the code size of the generated fast instruction selector.
830 class ImmLeaf<ValueType vt, code pred, SDNodeXForm xform = NOOP_SDNodeXForm,
831 SDNode ImmNode = imm>
832 : PatFrag<(ops), (vt ImmNode), [{}], xform> {
833 let ImmediateCode = pred;
834 bit FastIselShouldIgnore = 0;
836 // Is the data type of the immediate an APInt?
839 // Is the data type of the immediate an APFloat?
843 // An ImmLeaf except that Imm is an APInt. This is useful when you need to
844 // zero-extend the immediate instead of sign-extend it.
846 // Note that FastISel does not currently understand IntImmLeaf and will not
847 // generate code for rules that make use of it. As such, it does not make sense
848 // to replace ImmLeaf with IntImmLeaf. However, replacing PatLeaf with an
849 // IntImmLeaf will allow GlobalISel to import the rule.
850 class IntImmLeaf<ValueType vt, code pred, SDNodeXForm xform = NOOP_SDNodeXForm>
851 : ImmLeaf<vt, pred, xform> {
853 let FastIselShouldIgnore = 1;
856 // An ImmLeaf except that Imm is an APFloat.
858 // Note that FastISel does not currently understand FPImmLeaf and will not
859 // generate code for rules that make use of it.
860 class FPImmLeaf<ValueType vt, code pred, SDNodeXForm xform = NOOP_SDNodeXForm>
861 : ImmLeaf<vt, pred, xform, fpimm> {
863 let FastIselShouldIgnore = 1;
868 def vtInt : PatLeaf<(vt), [{ return N->getVT().isInteger(); }]>;
869 def vtFP : PatLeaf<(vt), [{ return N->getVT().isFloatingPoint(); }]>;
871 // Use ISD::isBuildVectorAllOnes or ISD::isBuildVectorAllZeros to look for
872 // the corresponding build_vector. Will look through bitcasts except when used
873 // as a pattern root.
874 def immAllOnesV; // ISD::isBuildVectorAllOnes
875 def immAllZerosV; // ISD::isBuildVectorAllZeros
877 // Other helper fragments.
878 def not : PatFrag<(ops node:$in), (xor node:$in, -1)>;
879 def vnot : PatFrag<(ops node:$in), (xor node:$in, immAllOnesV)>;
880 def ineg : PatFrag<(ops node:$in), (sub 0, node:$in)>;
882 // null_frag - The null pattern operator is used in multiclass instantiations
883 // which accept an SDPatternOperator for use in matching patterns for internal
884 // definitions. When expanding a pattern, if the null fragment is referenced
885 // in the expansion, the pattern is discarded and it is as-if '[]' had been
886 // specified. This allows multiclasses to have the isel patterns be optional.
887 def null_frag : SDPatternOperator;
890 def unindexedload : PatFrag<(ops node:$ptr), (ld node:$ptr)> {
894 def load : PatFrag<(ops node:$ptr), (unindexedload node:$ptr)> {
896 let IsNonExtLoad = 1;
899 // extending load fragments.
900 def extload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr)> {
902 let IsAnyExtLoad = 1;
904 def sextload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr)> {
906 let IsSignExtLoad = 1;
908 def zextload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr)> {
910 let IsZeroExtLoad = 1;
913 def extloadi1 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
917 def extloadi8 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
921 def extloadi16 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
925 def extloadi32 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
929 def extloadf32 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
933 def extloadf64 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
938 def sextloadi1 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
942 def sextloadi8 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
946 def sextloadi16 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
950 def sextloadi32 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
955 def zextloadi1 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
959 def zextloadi8 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
963 def zextloadi16 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
967 def zextloadi32 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
972 def extloadvi1 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
974 let ScalarMemoryVT = i1;
976 def extloadvi8 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
978 let ScalarMemoryVT = i8;
980 def extloadvi16 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
982 let ScalarMemoryVT = i16;
984 def extloadvi32 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
986 let ScalarMemoryVT = i32;
988 def extloadvf32 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
990 let ScalarMemoryVT = f32;
992 def extloadvf64 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
994 let ScalarMemoryVT = f64;
997 def sextloadvi1 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
999 let ScalarMemoryVT = i1;
1001 def sextloadvi8 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
1003 let ScalarMemoryVT = i8;
1005 def sextloadvi16 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
1007 let ScalarMemoryVT = i16;
1009 def sextloadvi32 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
1011 let ScalarMemoryVT = i32;
1014 def zextloadvi1 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
1016 let ScalarMemoryVT = i1;
1018 def zextloadvi8 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
1020 let ScalarMemoryVT = i8;
1022 def zextloadvi16 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
1024 let ScalarMemoryVT = i16;
1026 def zextloadvi32 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
1028 let ScalarMemoryVT = i32;
1032 def unindexedstore : PatFrag<(ops node:$val, node:$ptr),
1033 (st node:$val, node:$ptr)> {
1035 let IsUnindexed = 1;
1037 def store : PatFrag<(ops node:$val, node:$ptr),
1038 (unindexedstore node:$val, node:$ptr)> {
1040 let IsTruncStore = 0;
1043 // truncstore fragments.
1044 def truncstore : PatFrag<(ops node:$val, node:$ptr),
1045 (unindexedstore node:$val, node:$ptr)> {
1047 let IsTruncStore = 1;
1049 def truncstorei8 : PatFrag<(ops node:$val, node:$ptr),
1050 (truncstore node:$val, node:$ptr)> {
1054 def truncstorei16 : PatFrag<(ops node:$val, node:$ptr),
1055 (truncstore node:$val, node:$ptr)> {
1059 def truncstorei32 : PatFrag<(ops node:$val, node:$ptr),
1060 (truncstore node:$val, node:$ptr)> {
1064 def truncstoref32 : PatFrag<(ops node:$val, node:$ptr),
1065 (truncstore node:$val, node:$ptr)> {
1069 def truncstoref64 : PatFrag<(ops node:$val, node:$ptr),
1070 (truncstore node:$val, node:$ptr)> {
1075 def truncstorevi8 : PatFrag<(ops node:$val, node:$ptr),
1076 (truncstore node:$val, node:$ptr)> {
1078 let ScalarMemoryVT = i8;
1081 def truncstorevi16 : PatFrag<(ops node:$val, node:$ptr),
1082 (truncstore node:$val, node:$ptr)> {
1084 let ScalarMemoryVT = i16;
1087 def truncstorevi32 : PatFrag<(ops node:$val, node:$ptr),
1088 (truncstore node:$val, node:$ptr)> {
1090 let ScalarMemoryVT = i32;
1093 // indexed store fragments.
1094 def istore : PatFrag<(ops node:$val, node:$base, node:$offset),
1095 (ist node:$val, node:$base, node:$offset)> {
1097 let IsTruncStore = 0;
1100 def pre_store : PatFrag<(ops node:$val, node:$base, node:$offset),
1101 (istore node:$val, node:$base, node:$offset), [{
1102 ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
1103 return AM == ISD::PRE_INC || AM == ISD::PRE_DEC;
1106 def itruncstore : PatFrag<(ops node:$val, node:$base, node:$offset),
1107 (ist node:$val, node:$base, node:$offset)> {
1109 let IsTruncStore = 1;
1111 def pre_truncst : PatFrag<(ops node:$val, node:$base, node:$offset),
1112 (itruncstore node:$val, node:$base, node:$offset), [{
1113 ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
1114 return AM == ISD::PRE_INC || AM == ISD::PRE_DEC;
1116 def pre_truncsti1 : PatFrag<(ops node:$val, node:$base, node:$offset),
1117 (pre_truncst node:$val, node:$base, node:$offset)> {
1121 def pre_truncsti8 : PatFrag<(ops node:$val, node:$base, node:$offset),
1122 (pre_truncst node:$val, node:$base, node:$offset)> {
1126 def pre_truncsti16 : PatFrag<(ops node:$val, node:$base, node:$offset),
1127 (pre_truncst node:$val, node:$base, node:$offset)> {
1131 def pre_truncsti32 : PatFrag<(ops node:$val, node:$base, node:$offset),
1132 (pre_truncst node:$val, node:$base, node:$offset)> {
1136 def pre_truncstf32 : PatFrag<(ops node:$val, node:$base, node:$offset),
1137 (pre_truncst node:$val, node:$base, node:$offset)> {
1141 def pre_truncstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset),
1142 (pre_truncst node:$val, node:$base, node:$offset)> {
1144 let ScalarMemoryVT = i8;
1146 def pre_truncstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset),
1147 (pre_truncst node:$val, node:$base, node:$offset)> {
1149 let ScalarMemoryVT = i16;
1152 def post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
1153 (istore node:$val, node:$ptr, node:$offset), [{
1154 ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
1155 return AM == ISD::POST_INC || AM == ISD::POST_DEC;
1158 def post_truncst : PatFrag<(ops node:$val, node:$base, node:$offset),
1159 (itruncstore node:$val, node:$base, node:$offset), [{
1160 ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
1161 return AM == ISD::POST_INC || AM == ISD::POST_DEC;
1163 def post_truncsti1 : PatFrag<(ops node:$val, node:$base, node:$offset),
1164 (post_truncst node:$val, node:$base, node:$offset)> {
1168 def post_truncsti8 : PatFrag<(ops node:$val, node:$base, node:$offset),
1169 (post_truncst node:$val, node:$base, node:$offset)> {
1173 def post_truncsti16 : PatFrag<(ops node:$val, node:$base, node:$offset),
1174 (post_truncst node:$val, node:$base, node:$offset)> {
1178 def post_truncsti32 : PatFrag<(ops node:$val, node:$base, node:$offset),
1179 (post_truncst node:$val, node:$base, node:$offset)> {
1183 def post_truncstf32 : PatFrag<(ops node:$val, node:$base, node:$offset),
1184 (post_truncst node:$val, node:$base, node:$offset)> {
1188 def post_truncstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset),
1189 (post_truncst node:$val, node:$base, node:$offset)> {
1191 let ScalarMemoryVT = i8;
1193 def post_truncstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset),
1194 (post_truncst node:$val, node:$base, node:$offset)> {
1196 let ScalarMemoryVT = i16;
1199 def nonvolatile_load : PatFrag<(ops node:$ptr),
1200 (load node:$ptr), [{
1201 return !cast<LoadSDNode>(N)->isVolatile();
1203 def nonvolatile_store : PatFrag<(ops node:$val, node:$ptr),
1204 (store node:$val, node:$ptr), [{
1205 return !cast<StoreSDNode>(N)->isVolatile();
1208 // nontemporal store fragments.
1209 def nontemporalstore : PatFrag<(ops node:$val, node:$ptr),
1210 (store node:$val, node:$ptr), [{
1211 return cast<StoreSDNode>(N)->isNonTemporal();
1214 def alignednontemporalstore : PatFrag<(ops node:$val, node:$ptr),
1215 (nontemporalstore node:$val, node:$ptr), [{
1216 StoreSDNode *St = cast<StoreSDNode>(N);
1217 return St->getAlignment() >= St->getMemoryVT().getStoreSize();
1220 def unalignednontemporalstore : PatFrag<(ops node:$val, node:$ptr),
1221 (nontemporalstore node:$val, node:$ptr), [{
1222 StoreSDNode *St = cast<StoreSDNode>(N);
1223 return St->getAlignment() < St->getMemoryVT().getStoreSize();
1226 // nontemporal load fragments.
1227 def nontemporalload : PatFrag<(ops node:$ptr),
1228 (load node:$ptr), [{
1229 return cast<LoadSDNode>(N)->isNonTemporal();
1232 def alignednontemporalload : PatFrag<(ops node:$ptr),
1233 (nontemporalload node:$ptr), [{
1234 LoadSDNode *Ld = cast<LoadSDNode>(N);
1235 return Ld->getAlignment() >= Ld->getMemoryVT().getStoreSize();
1238 // setcc convenience fragments.
1239 def setoeq : PatFrag<(ops node:$lhs, node:$rhs),
1240 (setcc node:$lhs, node:$rhs, SETOEQ)>;
1241 def setogt : PatFrag<(ops node:$lhs, node:$rhs),
1242 (setcc node:$lhs, node:$rhs, SETOGT)>;
1243 def setoge : PatFrag<(ops node:$lhs, node:$rhs),
1244 (setcc node:$lhs, node:$rhs, SETOGE)>;
1245 def setolt : PatFrag<(ops node:$lhs, node:$rhs),
1246 (setcc node:$lhs, node:$rhs, SETOLT)>;
1247 def setole : PatFrag<(ops node:$lhs, node:$rhs),
1248 (setcc node:$lhs, node:$rhs, SETOLE)>;
1249 def setone : PatFrag<(ops node:$lhs, node:$rhs),
1250 (setcc node:$lhs, node:$rhs, SETONE)>;
1251 def seto : PatFrag<(ops node:$lhs, node:$rhs),
1252 (setcc node:$lhs, node:$rhs, SETO)>;
1253 def setuo : PatFrag<(ops node:$lhs, node:$rhs),
1254 (setcc node:$lhs, node:$rhs, SETUO)>;
1255 def setueq : PatFrag<(ops node:$lhs, node:$rhs),
1256 (setcc node:$lhs, node:$rhs, SETUEQ)>;
1257 def setugt : PatFrag<(ops node:$lhs, node:$rhs),
1258 (setcc node:$lhs, node:$rhs, SETUGT)>;
1259 def setuge : PatFrag<(ops node:$lhs, node:$rhs),
1260 (setcc node:$lhs, node:$rhs, SETUGE)>;
1261 def setult : PatFrag<(ops node:$lhs, node:$rhs),
1262 (setcc node:$lhs, node:$rhs, SETULT)>;
1263 def setule : PatFrag<(ops node:$lhs, node:$rhs),
1264 (setcc node:$lhs, node:$rhs, SETULE)>;
1265 def setune : PatFrag<(ops node:$lhs, node:$rhs),
1266 (setcc node:$lhs, node:$rhs, SETUNE)>;
1267 def seteq : PatFrag<(ops node:$lhs, node:$rhs),
1268 (setcc node:$lhs, node:$rhs, SETEQ)>;
1269 def setgt : PatFrag<(ops node:$lhs, node:$rhs),
1270 (setcc node:$lhs, node:$rhs, SETGT)>;
1271 def setge : PatFrag<(ops node:$lhs, node:$rhs),
1272 (setcc node:$lhs, node:$rhs, SETGE)>;
1273 def setlt : PatFrag<(ops node:$lhs, node:$rhs),
1274 (setcc node:$lhs, node:$rhs, SETLT)>;
1275 def setle : PatFrag<(ops node:$lhs, node:$rhs),
1276 (setcc node:$lhs, node:$rhs, SETLE)>;
1277 def setne : PatFrag<(ops node:$lhs, node:$rhs),
1278 (setcc node:$lhs, node:$rhs, SETNE)>;
1280 // We don't have strict FP extended loads as single DAG nodes, but we can
1281 // still provide convenience fragments to match those operations.
1282 def strict_extloadf32 : PatFrag<(ops node:$ptr),
1283 (strict_fpextend (f32 (load node:$ptr)))>;
1284 def strict_extloadf64 : PatFrag<(ops node:$ptr),
1285 (strict_fpextend (f64 (load node:$ptr)))>;
1287 // Convenience fragments to match both strict and non-strict fp operations
1288 def any_fadd : PatFrags<(ops node:$lhs, node:$rhs),
1289 [(strict_fadd node:$lhs, node:$rhs),
1290 (fadd node:$lhs, node:$rhs)]>;
1291 def any_fsub : PatFrags<(ops node:$lhs, node:$rhs),
1292 [(strict_fsub node:$lhs, node:$rhs),
1293 (fsub node:$lhs, node:$rhs)]>;
1294 def any_fmul : PatFrags<(ops node:$lhs, node:$rhs),
1295 [(strict_fmul node:$lhs, node:$rhs),
1296 (fmul node:$lhs, node:$rhs)]>;
1297 def any_fdiv : PatFrags<(ops node:$lhs, node:$rhs),
1298 [(strict_fdiv node:$lhs, node:$rhs),
1299 (fdiv node:$lhs, node:$rhs)]>;
1300 def any_frem : PatFrags<(ops node:$lhs, node:$rhs),
1301 [(strict_frem node:$lhs, node:$rhs),
1302 (frem node:$lhs, node:$rhs)]>;
1303 def any_fma : PatFrags<(ops node:$src1, node:$src2, node:$src3),
1304 [(strict_fma node:$src1, node:$src2, node:$src3),
1305 (fma node:$src1, node:$src2, node:$src3)]>;
1306 def any_fsqrt : PatFrags<(ops node:$src),
1307 [(strict_fsqrt node:$src),
1308 (fsqrt node:$src)]>;
1309 def any_fsin : PatFrags<(ops node:$src),
1310 [(strict_fsin node:$src),
1312 def any_fcos : PatFrags<(ops node:$src),
1313 [(strict_fcos node:$src),
1315 def any_fexp2 : PatFrags<(ops node:$src),
1316 [(strict_fexp2 node:$src),
1317 (fexp2 node:$src)]>;
1318 def any_fpow : PatFrags<(ops node:$lhs, node:$rhs),
1319 [(strict_fpow node:$lhs, node:$rhs),
1320 (fpow node:$lhs, node:$rhs)]>;
1321 def any_flog2 : PatFrags<(ops node:$src),
1322 [(strict_flog2 node:$src),
1323 (flog2 node:$src)]>;
1324 def any_frint : PatFrags<(ops node:$src),
1325 [(strict_frint node:$src),
1326 (frint node:$src)]>;
1327 def any_fnearbyint : PatFrags<(ops node:$src),
1328 [(strict_fnearbyint node:$src),
1329 (fnearbyint node:$src)]>;
1330 def any_fceil : PatFrags<(ops node:$src),
1331 [(strict_fceil node:$src),
1332 (fceil node:$src)]>;
1333 def any_ffloor : PatFrags<(ops node:$src),
1334 [(strict_ffloor node:$src),
1335 (ffloor node:$src)]>;
1336 def any_fround : PatFrags<(ops node:$src),
1337 [(strict_fround node:$src),
1338 (fround node:$src)]>;
1339 def any_ftrunc : PatFrags<(ops node:$src),
1340 [(strict_ftrunc node:$src),
1341 (ftrunc node:$src)]>;
1342 def any_fmaxnum : PatFrags<(ops node:$lhs, node:$rhs),
1343 [(strict_fmaxnum node:$lhs, node:$rhs),
1344 (fmaxnum node:$lhs, node:$rhs)]>;
1345 def any_fminnum : PatFrags<(ops node:$lhs, node:$rhs),
1346 [(strict_fminnum node:$lhs, node:$rhs),
1347 (fminnum node:$lhs, node:$rhs)]>;
1348 def any_fpround : PatFrags<(ops node:$src),
1349 [(strict_fpround node:$src),
1350 (fpround node:$src)]>;
1351 def any_fpextend : PatFrags<(ops node:$src),
1352 [(strict_fpextend node:$src),
1353 (fpextend node:$src)]>;
1354 def any_extloadf32 : PatFrags<(ops node:$ptr),
1355 [(strict_extloadf32 node:$ptr),
1356 (extloadf32 node:$ptr)]>;
1357 def any_extloadf64 : PatFrags<(ops node:$ptr),
1358 [(strict_extloadf64 node:$ptr),
1359 (extloadf64 node:$ptr)]>;
1360 def any_fp_to_sint : PatFrags<(ops node:$src),
1361 [(strict_fp_to_sint node:$src),
1362 (fp_to_sint node:$src)]>;
1363 def any_fp_to_uint : PatFrags<(ops node:$src),
1364 [(strict_fp_to_uint node:$src),
1365 (fp_to_uint node:$src)]>;
1367 multiclass binary_atomic_op_ord<SDNode atomic_op> {
1368 def #NAME#_monotonic : PatFrag<(ops node:$ptr, node:$val),
1369 (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$val)> {
1371 let IsAtomicOrderingMonotonic = 1;
1373 def #NAME#_acquire : PatFrag<(ops node:$ptr, node:$val),
1374 (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$val)> {
1376 let IsAtomicOrderingAcquire = 1;
1378 def #NAME#_release : PatFrag<(ops node:$ptr, node:$val),
1379 (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$val)> {
1381 let IsAtomicOrderingRelease = 1;
1383 def #NAME#_acq_rel : PatFrag<(ops node:$ptr, node:$val),
1384 (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$val)> {
1386 let IsAtomicOrderingAcquireRelease = 1;
1388 def #NAME#_seq_cst : PatFrag<(ops node:$ptr, node:$val),
1389 (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$val)> {
1391 let IsAtomicOrderingSequentiallyConsistent = 1;
1395 multiclass ternary_atomic_op_ord<SDNode atomic_op> {
1396 def #NAME#_monotonic : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
1397 (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$cmp, node:$val)> {
1399 let IsAtomicOrderingMonotonic = 1;
1401 def #NAME#_acquire : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
1402 (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$cmp, node:$val)> {
1404 let IsAtomicOrderingAcquire = 1;
1406 def #NAME#_release : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
1407 (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$cmp, node:$val)> {
1409 let IsAtomicOrderingRelease = 1;
1411 def #NAME#_acq_rel : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
1412 (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$cmp, node:$val)> {
1414 let IsAtomicOrderingAcquireRelease = 1;
1416 def #NAME#_seq_cst : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
1417 (!cast<SDPatternOperator>(#NAME) node:$ptr, node:$cmp, node:$val)> {
1419 let IsAtomicOrderingSequentiallyConsistent = 1;
1423 multiclass binary_atomic_op<SDNode atomic_op, bit IsInt = 1> {
1424 def _8 : PatFrag<(ops node:$ptr, node:$val),
1425 (atomic_op node:$ptr, node:$val)> {
1427 let MemoryVT = !if(IsInt, i8, ?);
1429 def _16 : PatFrag<(ops node:$ptr, node:$val),
1430 (atomic_op node:$ptr, node:$val)> {
1432 let MemoryVT = !if(IsInt, i16, f16);
1434 def _32 : PatFrag<(ops node:$ptr, node:$val),
1435 (atomic_op node:$ptr, node:$val)> {
1437 let MemoryVT = !if(IsInt, i32, f32);
1439 def _64 : PatFrag<(ops node:$ptr, node:$val),
1440 (atomic_op node:$ptr, node:$val)> {
1442 let MemoryVT = !if(IsInt, i64, f64);
1445 defm NAME#_8 : binary_atomic_op_ord<atomic_op>;
1446 defm NAME#_16 : binary_atomic_op_ord<atomic_op>;
1447 defm NAME#_32 : binary_atomic_op_ord<atomic_op>;
1448 defm NAME#_64 : binary_atomic_op_ord<atomic_op>;
1451 multiclass ternary_atomic_op<SDNode atomic_op> {
1452 def _8 : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
1453 (atomic_op node:$ptr, node:$cmp, node:$val)> {
1457 def _16 : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
1458 (atomic_op node:$ptr, node:$cmp, node:$val)> {
1462 def _32 : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
1463 (atomic_op node:$ptr, node:$cmp, node:$val)> {
1467 def _64 : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
1468 (atomic_op node:$ptr, node:$cmp, node:$val)> {
1473 defm NAME#_8 : ternary_atomic_op_ord<atomic_op>;
1474 defm NAME#_16 : ternary_atomic_op_ord<atomic_op>;
1475 defm NAME#_32 : ternary_atomic_op_ord<atomic_op>;
1476 defm NAME#_64 : ternary_atomic_op_ord<atomic_op>;
1479 defm atomic_load_add : binary_atomic_op<atomic_load_add>;
1480 defm atomic_swap : binary_atomic_op<atomic_swap>;
1481 defm atomic_load_sub : binary_atomic_op<atomic_load_sub>;
1482 defm atomic_load_and : binary_atomic_op<atomic_load_and>;
1483 defm atomic_load_clr : binary_atomic_op<atomic_load_clr>;
1484 defm atomic_load_or : binary_atomic_op<atomic_load_or>;
1485 defm atomic_load_xor : binary_atomic_op<atomic_load_xor>;
1486 defm atomic_load_nand : binary_atomic_op<atomic_load_nand>;
1487 defm atomic_load_min : binary_atomic_op<atomic_load_min>;
1488 defm atomic_load_max : binary_atomic_op<atomic_load_max>;
1489 defm atomic_load_umin : binary_atomic_op<atomic_load_umin>;
1490 defm atomic_load_umax : binary_atomic_op<atomic_load_umax>;
1491 defm atomic_store : binary_atomic_op<atomic_store>;
1492 defm atomic_cmp_swap : ternary_atomic_op<atomic_cmp_swap>;
1495 PatFrag<(ops node:$ptr),
1496 (atomic_load node:$ptr)> {
1500 def atomic_load_16 :
1501 PatFrag<(ops node:$ptr),
1502 (atomic_load node:$ptr)> {
1506 def atomic_load_32 :
1507 PatFrag<(ops node:$ptr),
1508 (atomic_load node:$ptr)> {
1512 def atomic_load_64 :
1513 PatFrag<(ops node:$ptr),
1514 (atomic_load node:$ptr)> {
1519 //===----------------------------------------------------------------------===//
1520 // Selection DAG Pattern Support.
1522 // Patterns are what are actually matched against by the target-flavored
1523 // instruction selection DAG. Instructions defined by the target implicitly
1524 // define patterns in most cases, but patterns can also be explicitly added when
1525 // an operation is defined by a sequence of instructions (e.g. loading a large
1526 // immediate value on RISC targets that do not support immediates as large as
1530 class Pattern<dag patternToMatch, list<dag> resultInstrs> {
1531 dag PatternToMatch = patternToMatch;
1532 list<dag> ResultInstrs = resultInstrs;
1533 list<Predicate> Predicates = []; // See class Instruction in Target.td.
1534 int AddedComplexity = 0; // See class Instruction in Target.td.
1537 // Pat - A simple (but common) form of a pattern, which produces a simple result
1538 // not needing a full list.
1539 class Pat<dag pattern, dag result> : Pattern<pattern, [result]>;
1541 //===----------------------------------------------------------------------===//
1542 // Complex pattern definitions.
1545 // Complex patterns, e.g. X86 addressing mode, requires pattern matching code
1546 // in C++. NumOperands is the number of operands returned by the select function;
1547 // SelectFunc is the name of the function used to pattern match the max. pattern;
1548 // RootNodes are the list of possible root nodes of the sub-dags to match.
1549 // e.g. X86 addressing mode - def addr : ComplexPattern<4, "SelectAddr", [add]>;
1551 class ComplexPattern<ValueType ty, int numops, string fn,
1552 list<SDNode> roots = [], list<SDNodeProperty> props = [],
1553 int complexity = -1> {
1555 int NumOperands = numops;
1556 string SelectFunc = fn;
1557 list<SDNode> RootNodes = roots;
1558 list<SDNodeProperty> Properties = props;
1559 int Complexity = complexity;