Bump version to 19.1.0-rc3
[llvm-project.git] / llvm / test / TableGen / GlobalISelEmitter.td
blob853831366fa531e9a8e429bf0bcddb4ff68e661e
1 // RUN: llvm-tblgen -gen-global-isel -I %p/../../include -I %p/Common -optimize-match-table=false %s -o %T/non-optimized.cpp
2 // RUN: llvm-tblgen -gen-global-isel -I %p/../../include -I %p/Common -optimize-match-table=true  %s -o %T/optimized.cpp
3 // RUN: llvm-tblgen -gen-global-isel -I %p/../../include -I %p/Common %s -o %T/default.cpp
5 // RUN: FileCheck %s --check-prefixes=CHECK,R19C,R19N -input-file=%T/non-optimized.cpp
6 // RUN: FileCheck %s --check-prefixes=CHECK,R19C,R19O -input-file=%T/optimized.cpp
8 // RUN: FileCheck %s --check-prefixes=CHECK,R21C,R21N -input-file=%T/non-optimized.cpp
9 // RUN: FileCheck %s --check-prefixes=CHECK,R21C,R21O -input-file=%T/optimized.cpp
11 // RUN: FileCheck %s --check-prefixes=CHECK,R20C,R20N -input-file=%T/non-optimized.cpp
12 // RUN: FileCheck %s --check-prefixes=CHECK,R20C,R20O -input-file=%T/optimized.cpp
14 // RUN: FileCheck %s --check-prefixes=CHECK,R00C,R00N -input-file=%T/non-optimized.cpp
15 // RUN: FileCheck %s --check-prefixes=CHECK,R00C,R00O -input-file=%T/optimized.cpp
17 // RUN: FileCheck %s --check-prefixes=CHECK,R01C,R01N -input-file=%T/non-optimized.cpp
18 // RUN: FileCheck %s --check-prefixes=CHECK,R01C,R01O -input-file=%T/optimized.cpp
20 // RUN: FileCheck %s --check-prefixes=CHECK,R02C,R02N,NOOPT -input-file=%T/non-optimized.cpp
21 // RUN: FileCheck %s --check-prefixes=CHECK,R02C,R02O       -input-file=%T/optimized.cpp
23 // RUN: diff %T/default.cpp %T/optimized.cpp
25 include "llvm/Target/Target.td"
26 include "GlobalISelEmitterCommon.td"
28 //===- Define the necessary boilerplate for our test target. --------------===//
30 let TargetPrefix = "mytarget" in {
31 def int_mytarget_nop : Intrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrNoMem]>;
34 def complex : Operand<i32>, ComplexPattern<i32, 2, "SelectComplexPattern", []> {
35   let MIOperandInfo = (ops i32imm, i32imm);
37 def gi_complex :
38     GIComplexOperandMatcher<s32, "selectComplexPattern">,
39     GIComplexPatternEquiv<complex>;
40 def complex_rr : Operand<i32>, ComplexPattern<i32, 2, "SelectComplexPatternRR", []> {
41   let MIOperandInfo = (ops GPR32, GPR32);
43 def gi_complex_rr :
44     GIComplexOperandMatcher<s32, "selectComplexPatternRR">,
45     GIComplexPatternEquiv<complex_rr>;
47 def cimm8_xform : SDNodeXForm<imm, [{
48     uint64_t Val = N->getZExtValue() << 1;
49     return CurDAG->getTargetConstant(Val, SDLoc(N), MVT::i64);
50   }]>;
52 def cimm8 : Operand<i32>, ImmLeaf<i32, [{return isInt<8>(Imm);}], cimm8_xform>;
54 def gi_cimm8 : GICustomOperandRenderer<"renderImm">,
55                 GISDNodeXFormEquiv<cimm8_xform>;
57 def gi_cimm9 : GICustomOperandRenderer<"renderImm">;
59 def m1 : OperandWithDefaultOps <i32, (ops (i32 -1))>;
60 def Z : OperandWithDefaultOps <i32, (ops R0)>;
61 def m1Z : OperandWithDefaultOps <i32, (ops (i32 -1), R0)>;
62 def mb : OperandWithDefaultOps <i32, (ops (i32 0b1101))>;
64 def HasA : Predicate<"Subtarget->hasA()">;
65 def HasB : Predicate<"Subtarget->hasB()">;
66 def HasC : Predicate<"Subtarget->hasC()"> { let RecomputePerFunction = 1; }
68 //===- Test the function boilerplate. -------------------------------------===//
70 // CHECK: const unsigned MAX_SUBTARGET_PREDICATES = 3;
71 // CHECK: using PredicateBitset = llvm::Bitset<MAX_SUBTARGET_PREDICATES>;
73 // CHECK-LABEL: #ifdef GET_GLOBALISEL_TEMPORARIES_DECL
74 // CHECK-NEXT:    mutable MatcherState State;
75 // CHECK-NEXT:    typedef ComplexRendererFns(MyTargetInstructionSelector::*ComplexMatcherMemFn)(MachineOperand &) const;
76 // CHECK-NEXT:    typedef void(MyTargetInstructionSelector::*CustomRendererFn)(MachineInstrBuilder &, const MachineInstr &, int) const;
77 // CHECK-NEXT:    const ExecInfoTy<PredicateBitset, ComplexMatcherMemFn, CustomRendererFn> ExecInfo;
78 // CHECK-NEXT:    static MyTargetInstructionSelector::ComplexMatcherMemFn ComplexPredicateFns[];
79 // CHECK-NEXT:    static MyTargetInstructionSelector::CustomRendererFn CustomRenderers[];
80 // CHECK-NEXT:    bool testImmPredicate_I64(unsigned PredicateID, int64_t Imm) const override;
81 // CHECK-NEXT:    bool testImmPredicate_APInt(unsigned PredicateID, const APInt &Imm) const override;
82 // CHECK-NEXT:    bool testImmPredicate_APFloat(unsigned PredicateID, const APFloat &Imm) const override;
83 // CHECK-NEXT:    const uint8_t *getMatchTable() const override;
84 // CHECK-NEXT:    bool testMIPredicate_MI(unsigned PredicateID, const MachineInstr &MI, const MatcherState &State) const override;
85 // CHECK-NEXT:    bool testSimplePredicate(unsigned PredicateID) const override;
86 // CHECK-NEXT:    bool runCustomAction(unsigned FnID, const MatcherState &State, NewMIVector &OutMIs) const override;
87 // CHECK-NEXT:  #endif // ifdef GET_GLOBALISEL_TEMPORARIES_DECL
89 // CHECK-LABEL: #ifdef GET_GLOBALISEL_TEMPORARIES_INIT
90 // CHECK-NEXT:    , State(3),
91 // CHECK-NEXT:    ExecInfo(TypeObjects, NumTypeObjects, FeatureBitsets, ComplexPredicateFns, CustomRenderers)
92 // CHECK-NEXT:  #endif // ifdef GET_GLOBALISEL_TEMPORARIES_INIT
94 // CHECK-LABEL: // LLT Objects.
95 // CHECK-NEXT:  enum {
96 // CHECK-NEXT:    GILLT_p0s32
97 // CHECK-NEXT:    GILLT_s32,
98 // CHECK-NEXT:  }
99 // CHECK-NEXT:  const static size_t NumTypeObjects = 2;
100 // CHECK-NEXT:  const static LLT TypeObjects[] = {
101 // CHECK-NEXT:    LLT::pointer(0, 32),
102 // CHECK-NEXT:    LLT::scalar(32),
103 // CHECK-NEXT:  };
105 // CHECK-LABEL: enum SubtargetFeatureBits : uint8_t {
106 // CHECK-NEXT:    Feature_HasABit = 0,
107 // CHECK-NEXT:    Feature_HasBBit = 1,
108 // CHECK-NEXT:    Feature_HasCBit = 2,
109 // CHECK-NEXT:  };
111 // CHECK-LABEL: PredicateBitset MyTargetInstructionSelector::
112 // CHECK-NEXT:  computeAvailableModuleFeatures(const MyTargetSubtarget *Subtarget) const {
113 // CHECK-NEXT:    PredicateBitset Features{};
114 // CHECK-NEXT:    if (Subtarget->hasA())
115 // CHECK-NEXT:      Features.set(Feature_HasABit);
116 // CHECK-NEXT:    if (Subtarget->hasB())
117 // CHECK-NEXT:      Features.set(Feature_HasBBit);
118 // CHECK-NEXT:    return Features;
119 // CHECK-NEXT:  }
121 // CHECK-LABEL: PredicateBitset MyTargetInstructionSelector::
122 // CHECK-NEXT:  computeAvailableFunctionFeatures(const MyTargetSubtarget *Subtarget, const MachineFunction *MF) const {
123 // CHECK-NEXT:    PredicateBitset Features{};
124 // CHECK-NEXT:    if (Subtarget->hasC())
125 // CHECK-NEXT:      Features.set(Feature_HasCBit);
126 // CHECK-NEXT:    return Features;
127 // CHECK-NEXT:  }
129 // CHECK-LABEL: // Feature bitsets.
130 // CHECK-NEXT:  enum {
131 // CHECK-NEXT:    GIFBS_Invalid,
132 // CHECK-NEXT:    GIFBS_HasA,
133 // CHECK-NEXT:    GIFBS_HasA_HasB_HasC,
134 // CHECK-NEXT:  }
135 // CHECK-NEXT:  constexpr static PredicateBitset FeatureBitsets[] {
136 // CHECK-NEXT:    {}, // GIFBS_Invalid
137 // CHECK-NEXT:    {Feature_HasABit, },
138 // CHECK-NEXT:    {Feature_HasABit, Feature_HasBBit, Feature_HasCBit, },
139 // CHECK-NEXT:  };
141 // CHECK-LABEL: // ComplexPattern predicates.
142 // CHECK-NEXT:  enum {
143 // CHECK-NEXT:    GICP_Invalid,
144 // CHECK-NEXT:    GICP_gi_complex,
145 // CHECK-NEXT:    GICP_gi_complex_rr,
146 // CHECK-NEXT:  };
148 // CHECK-LABEL: MyTargetInstructionSelector::ComplexMatcherMemFn
149 // CHECK-NEXT:  MyTargetInstructionSelector::ComplexPredicateFns[] = {
150 // CHECK-NEXT:    nullptr, // GICP_Invalid
151 // CHECK-NEXT:    &MyTargetInstructionSelector::selectComplexPattern, // gi_complex
152 // CHECK-NEXT:    &MyTargetInstructionSelector::selectComplexPatternRR, // gi_complex_rr
153 // CHECK-NEXT:  }
155 // CHECK-LABEL: // PatFrag predicates.
156 // CHECK-NEXT:  enum {
157 // CHECK-NEXT:   GICXXPred_MI_Predicate_frag = GICXXPred_Invalid + 1,
158 // CHECK-NEXT:  };
160 // CHECK-LABEL: // PatFrag predicates.
161 // CHECK-NEXT:  enum {
162 // CHECK-NEXT:    GICXXPred_I64_Predicate_cimm8 = GICXXPred_Invalid + 1,
163 // CHECK-NEXT:    GICXXPred_I64_Predicate_simm8,
164 // CHECK-NEXT:  };
166 // CHECK-NEXT: bool MyTargetInstructionSelector::testImmPredicate_I64(unsigned PredicateID, int64_t Imm) const {
167 // CHECK-NEXT:   switch (PredicateID) {
168 // CHECK-NEXT:   case GICXXPred_I64_Predicate_cimm8: {
169 // CHECK-NEXT:     return isInt<8>(Imm);
170 // CHECK-NEXT:   }
171 // CHECK-NEXT:   case GICXXPred_I64_Predicate_simm8: {
172 // CHECK-NEXT:     return isInt<8>(Imm);
173 // CHECK-NEXT:   }
174 // CHECK-NEXT:   }
175 // CHECK-NEXT:   llvm_unreachable("Unknown predicate");
176 // CHECK-NEXT:   return false;
177 // CHECK-NEXT: }
179 // CHECK-LABEL: // PatFrag predicates.
180 // CHECK-NEXT:  enum {
181 // CHECK-NEXT:    GICXXPred_APFloat_Predicate_fpimmz = GICXXPred_Invalid + 1,
182 // CHECK-NEXT:  };
183 // CHECK-NEXT:  bool MyTargetInstructionSelector::testImmPredicate_APFloat(unsigned PredicateID, const APFloat & Imm) const {
184 // CHECK-NEXT:    switch (PredicateID) {
185 // CHECK-NEXT:    case GICXXPred_APFloat_Predicate_fpimmz: {
186 // CHECK-NEXT:      return Imm->isExactlyValue(0.0);
187 // CHECK-NEXT:    }
188 // CHECK-NEXT:    }
189 // CHECK-NEXT:    llvm_unreachable("Unknown predicate");
190 // CHECK-NEXT:    return false;
191 // CHECK-NEXT:  }
193 // CHECK-LABEL: // PatFrag predicates.
194 // CHECK-NEXT:  enum {
195 // CHECK-NEXT:    GICXXPred_APInt_Predicate_simm9 = GICXXPred_Invalid + 1,
196 // CHECK-NEXT:  };
197 // CHECK-NEXT:  bool MyTargetInstructionSelector::testImmPredicate_APInt(unsigned PredicateID, const APInt & Imm) const {
198 // CHECK-NEXT:    switch (PredicateID) {
199 // CHECK-NEXT:    case GICXXPred_APInt_Predicate_simm9: {
200 // CHECK-NEXT:      return isInt<9>(Imm->getSExtValue());
201 // CHECK-NEXT:    }
202 // CHECK-NEXT:    }
203 // CHECK-NEXT:    llvm_unreachable("Unknown predicate");
204 // CHECK-NEXT:    return false;
205 // CHECK-NEXT:  }
207 // CHECK-LABEL: // Custom renderers.
208 // CHECK-NEXT: enum {
209 // CHECK-NEXT:   GICR_Invalid,
210 // CHECK-NEXT:   GICR_renderImm,
211 // CHECK-NEXT: };
212 // CHECK-NEXT: MyTargetInstructionSelector::CustomRendererFn
213 // CHECK-NEXT: MyTargetInstructionSelector::CustomRenderers[] = {
214 // CHECK-NEXT:   nullptr, // GICR_Invalid
215 // CHECK-NEXT:   &MyTargetInstructionSelector::renderImm,
216 // CHECK-NEXT: };
218 // CHECK: bool MyTargetInstructionSelector::selectImpl(MachineInstr &I, CodeGenCoverage &CoverageInfo) const {
219 // CHECK-NEXT: const PredicateBitset AvailableFeatures = getAvailableFeatures();
220 // CHECK-NEXT: MachineIRBuilder B(I);
221 // CHECK-NEXT: State.MIs.clear();
222 // CHECK-NEXT: State.MIs.push_back(&I);
224 // CHECK:      if (executeMatchTable(*this, State, ExecInfo, B, getMatchTable(), TII, MF->getRegInfo(), TRI, RBI, AvailableFeatures, &CoverageInfo)) {
225 // CHECK-NEXT:   return true;
226 // CHECK-NEXT: }
228 // CHECK: const uint8_t *
229 // CHECK-LABEL: MyTargetInstructionSelector::getMatchTable() const {
230 // CHECK-NEXT: MatchTable0[] = {
232 //===- Test a pattern with multiple ComplexPatterns in multiple instrs ----===//
234 // R19O-NEXT:  GIM_SwitchOpcode, /*MI*/0, /*[*/GIMT_Encode2({{[0-9]+}}), GIMT_Encode2({{[0-9]+}}), /*)*//*default:*//*Label [[DEFAULT_NUM:[0-9]+]]*/ GIMT_Encode4([[DEFAULT:[0-9]+]]),
235 // R19O-NEXT:  /*TargetOpcode::G_ADD*//*Label [[CASE_ADD_NUM:[0-9]+]]*/ GIMT_Encode4([[CASE_ADD:[0-9]+]]),
236 // R19O:       /*TargetOpcode::G_SELECT*//*Label [[CASE_SELECT_NUM:[0-9]+]]*/ GIMT_Encode4([[CASE_SELECT:[0-9]+]]),
237 // R19O:       // Label [[CASE_ADD_NUM]]: @[[CASE_ADD]]
238 // R19O:       // Label [[CASE_SELECT_NUM]]: @[[CASE_SELECT]]
239 // R19O-NEXT:  GIM_Try, /*On fail goto*//*Label [[GROUP_NUM:[0-9]+]]*/ GIMT_Encode4([[GROUP:[0-9]+]]),
240 // R19O-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
241 // R19O-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
242 // R19O-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
243 // R19O-NEXT:    GIM_RootCheckType, /*Op*/3, /*Type*/GILLT_s32,
245 // R19C-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
247 // R19O-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
248 // R19O-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
249 // R19N-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/4,
250 // R19N-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_SELECT),
251 // R19N-NEXT:    // MIs[0] DstI[dst]
252 // R19N-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
253 // R19N-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
254 // R19N-NEXT:    // MIs[0] src1
255 // R19N-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
256 // R19N-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
257 // R19N-NEXT:    // MIs[0] complex_rr:src2a:src2b
258 // R19N-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
260 // R19N-NEXT:    GIM_CheckComplexPattern, /*MI*/0, /*Op*/2, /*Renderer*/GIMT_Encode2(0), GIMT_Encode2(GICP_gi_complex_rr),
261 // R19N-NEXT:    // MIs[0] Operand 3
262 // R19N-NEXT:    GIM_RootCheckType, /*Op*/3, /*Type*/GILLT_s32,
263 // R19C-NEXT:    GIM_RecordInsn, /*DefineMI*/1, /*MI*/0, /*OpIdx*/3, // MIs[1]
264 // R19N-NEXT:    GIM_CheckNumOperands, /*MI*/1, /*Expected*/4,
265 // R19C-NEXT:    GIM_CheckOpcode, /*MI*/1, GIMT_Encode2(TargetOpcode::G_SELECT),
266 // R19N-NEXT:    // MIs[1] Operand 0
267 // R19N-NEXT:    GIM_CheckType, /*MI*/1, /*Op*/0, /*Type*/GILLT_s32,
268 // R19N-NEXT:    // MIs[1] src3
269 // R19C-NEXT:    GIM_CheckType, /*MI*/1, /*Op*/1, /*Type*/GILLT_s32,
270 // R19O-NEXT:    GIM_CheckType, /*MI*/1, /*Op*/2, /*Type*/GILLT_s32,
271 // R19O-NEXT:    GIM_CheckType, /*MI*/1, /*Op*/3, /*Type*/GILLT_s32,
272 // R19N-NEXT:    GIM_CheckRegBankForClass, /*MI*/1, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
273 // R19N-NEXT:    // MIs[1] src4
274 // R19N-NEXT:    GIM_CheckType, /*MI*/1, /*Op*/2, /*Type*/GILLT_s32,
275 // R19N-NEXT:    GIM_CheckComplexPattern, /*MI*/1, /*Op*/2, /*Renderer*/GIMT_Encode2(1), GIMT_Encode2(GICP_gi_complex),
276 // R19N-NEXT:    // MIs[1] complex:src5a:src5b
277 // R19N-NEXT:    GIM_CheckType, /*MI*/1, /*Op*/3, /*Type*/GILLT_s32,
278 // R19N-NEXT:    GIM_CheckComplexPattern, /*MI*/1, /*Op*/3, /*Renderer*/GIMT_Encode2(2), GIMT_Encode2(GICP_gi_complex),
279 // R19O-NEXT:    GIM_CheckRegBankForClass, /*MI*/1, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
280 // R19C-NEXT:    GIM_CheckIsSafeToFold, /*NumInsns*/1,
281 // R19O-NEXT:    GIM_CheckComplexPattern, /*MI*/0, /*Op*/2, /*Renderer*/GIMT_Encode2(0), GIMT_Encode2(GICP_gi_complex_rr),
282 // R19O-NEXT:    GIM_CheckComplexPattern, /*MI*/1, /*Op*/2, /*Renderer*/GIMT_Encode2(1), GIMT_Encode2(GICP_gi_complex),
283 // R19O-NEXT:    GIM_CheckComplexPattern, /*MI*/1, /*Op*/3, /*Renderer*/GIMT_Encode2(2), GIMT_Encode2(GICP_gi_complex),
284 // R19C-NEXT:    // (select:{ *:[i32] } GPR32:{ *:[i32] }:$src1, (complex_rr:{ *:[i32] } GPR32:{ *:[i32] }:$src2a, GPR32:{ *:[i32] }:$src2b), (select:{ *:[i32] } GPR32:{ *:[i32] }:$src3, complex:{ *:[i32] }:$src4, (complex:{ *:[i32] } i32imm:{ *:[i32] }:$src5a, i32imm:{ *:[i32] }:$src5b)))  =>  (INSN3:{ *:[i32] } GPR32:{ *:[i32] }:$src1, GPR32:{ *:[i32] }:$src2b, GPR32:{ *:[i32] }:$src2a, (INSN4:{ *:[i32] } GPR32:{ *:[i32] }:$src3, complex:{ *:[i32] }:$src4, i32imm:{ *:[i32] }:$src5a, i32imm:{ *:[i32] }:$src5b))
285 // R19C-NEXT:    GIR_MakeTempReg, /*TempRegID*/0, /*TypeID*/GILLT_s32,
286 // R19C-NEXT:    GIR_BuildMI, /*InsnID*/1, /*Opcode*/GIMT_Encode2(MyTarget::INSN4),
287 // R19C-NEXT:    GIR_AddTempRegister, /*InsnID*/1, /*TempRegID*/0, /*TempRegFlags*/GIMT_Encode2(RegState::Define),
288 // R19C-NEXT:    GIR_Copy, /*NewInsnID*/1, /*OldInsnID*/1, /*OpIdx*/1, // src3
289 // R19C-NEXT:    GIR_ComplexRenderer, /*InsnID*/1, /*RendererID*/GIMT_Encode2(1),
290 // R19C-NEXT:    GIR_ComplexSubOperandRenderer, /*InsnID*/1, /*RendererID*/GIMT_Encode2(2), /*SubOperand*/0, // src5a
291 // R19C-NEXT:    GIR_ComplexSubOperandRenderer, /*InsnID*/1, /*RendererID*/GIMT_Encode2(2), /*SubOperand*/1, // src5b
292 // R19C-NEXT:    GIR_ConstrainSelectedInstOperands, /*InsnID*/1,
293 // R19C-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::INSN3),
294 // R19C-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, //  DstI[dst]
295 // R19C-NEXT:    GIR_RootToRootCopy, /*OpIdx*/1, // src1
296 // R19C-NEXT:    GIR_ComplexSubOperandRenderer, /*InsnID*/0, /*RendererID*/GIMT_Encode2(0), /*SubOperand*/1, // src2b
297 // R19C-NEXT:    GIR_ComplexSubOperandRenderer, /*InsnID*/0, /*RendererID*/GIMT_Encode2(0), /*SubOperand*/0, // src2a
298 // R19C-NEXT:    GIR_AddSimpleTempRegister, /*InsnID*/0, /*TempRegID*/0,
299 // R19C-NEXT:    GIR_RootConstrainSelectedInstOperands,
300 // R19C-NEXT:    // GIR_Coverage, 20,
301 // R19C-NEXT:    GIR_EraseRootFromParent_Done,
302 // R19C-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
304 // R19O:       // Label [[GROUP_NUM]]: @[[GROUP]]
305 // R19O-NEXT:  GIM_Reject,
306 // R19O:       // Label [[DEFAULT_NUM]]: @[[DEFAULT]]
307 // R19O-NEXT:  GIM_Reject,
308 // R19O-NEXT:  };
310 def INSN3 : I<(outs GPR32:$dst),
311               (ins GPR32Op:$src1, GPR32:$src2a, GPR32:$src2b, GPR32:$scr), []>;
312 def INSN4 : I<(outs GPR32:$scr),
313               (ins GPR32:$src3, complex:$src4, i32imm:$src5a, i32imm:$src5b), []>;
314 def : Pat<(select GPR32:$src1, (complex_rr GPR32:$src2a, GPR32:$src2b),
315                                (select GPR32:$src3,
316                                        complex:$src4,
317                                        (complex i32imm:$src5a, i32imm:$src5b))),
318           (INSN3 GPR32:$src1, GPR32:$src2b, GPR32:$src2a,
319                  (INSN4 GPR32:$src3, complex:$src4, i32imm:$src5a,
320                         i32imm:$src5b))>;
322 // R21O-NEXT:  GIM_SwitchOpcode, /*MI*/0, /*[*/GIMT_Encode2({{[0-9]+}}), GIMT_Encode2({{[0-9]+}}), /*)*//*default:*//*Label [[DEFAULT_NUM:[0-9]+]]*/ GIMT_Encode4([[DEFAULT:[0-9]+]]),
323 // R21O-NEXT:  /*TargetOpcode::G_ADD*//*Label [[CASE_ADD_NUM:[0-9]+]]*/ GIMT_Encode4([[CASE_ADD:[0-9]+]]),
324 // R21O:       /*TargetOpcode::G_SELECT*//*Label [[CASE_SELECT_NUM:[0-9]+]]*/ GIMT_Encode4([[CASE_SELECT:[0-9]+]]),
325 // R21O:       // Label [[CASE_ADD_NUM]]: @[[CASE_ADD]]
326 // R21O:       // Label [[CASE_SELECT_NUM]]: @[[CASE_SELECT]]
327 // R21O-NEXT:  GIM_Try, /*On fail goto*//*Label [[GROUP_NUM:[0-9]+]]*/ GIMT_Encode4([[GROUP:[0-9]+]]),
328 // R21O-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
329 // R21O-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
330 // R21O-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
331 // R21O-NEXT:    GIM_RootCheckType, /*Op*/3, /*Type*/GILLT_s32,
333 // R21C-NEXT:  GIM_Try, /*On fail goto*//*Label [[PREV_NUM:[0-9]+]]*/ GIMT_Encode4([[PREV:[0-9]+]]), // Rule ID 20 //
334 // R21C-NOT:     GIR_EraseRootFromParent_Done,
335 // R21C:         // GIR_Coverage, 20,
336 // R21C-NEXT:    GIR_EraseRootFromParent_Done,
337 // R21C-NEXT:  // Label [[PREV_NUM]]: @[[PREV]]
338 // R21C-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]), // Rule ID 22 //
340 // R21O-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
341 // R21O-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
342 // R21N-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/4,
343 // R21N-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_SELECT),
344 // R21N-NEXT:    // MIs[0] DstI[dst]
345 // R21N-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
346 // R21N-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
347 // R21N-NEXT:    // MIs[0] src1
348 // R21N-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
349 // R21N-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
350 // R21N-NEXT:    // MIs[0] src2
351 // R21N-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
353 // R21O-NEXT:    GIM_CheckCxxInsnPredicate, /*MI*/0, /*FnId*/GIMT_Encode2(GICXXPred_MI_Predicate_frag),
354 // R21C-NEXT:    GIM_CheckComplexPattern, /*MI*/0, /*Op*/2, /*Renderer*/GIMT_Encode2(0), GIMT_Encode2(GICP_gi_complex),
355 // R21N-NEXT:    // MIs[0] src3
356 // R21N-NEXT:    GIM_RootCheckType, /*Op*/3, /*Type*/GILLT_s32,
357 // R21C-NEXT:    GIM_CheckComplexPattern, /*MI*/0, /*Op*/3, /*Renderer*/GIMT_Encode2(1), GIMT_Encode2(GICP_gi_complex),
358 // R21N-NEXT:    GIM_CheckCxxInsnPredicate, /*MI*/0, /*FnId*/GIMT_Encode2(GICXXPred_MI_Predicate_frag),
359 // R21C-NEXT:    // (select:{ *:[i32] } GPR32:{ *:[i32] }:$src1, complex:{ *:[i32] }:$src2, complex:{ *:[i32] }:$src3)<<P:Predicate_frag>> => (INSN2:{ *:[i32] } GPR32:{ *:[i32] }:$src1, complex:{ *:[i32] }:$src3, complex:{ *:[i32] }:$src2)
361 // R21C-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::INSN2),
362 // R21C-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, //  DstI[dst]
363 // R21C-NEXT:    GIR_RootToRootCopy, /*OpIdx*/1, // src1
364 // R21C-NEXT:    GIR_ComplexRenderer, /*InsnID*/0, /*RendererID*/GIMT_Encode2(1),
365 // R21C-NEXT:    GIR_ComplexRenderer, /*InsnID*/0, /*RendererID*/GIMT_Encode2(0),
366 // R21C-NEXT:    GIR_MergeMemOperands, /*InsnID*/0, /*NumInsns*/1, /*MergeInsnID's*/0
367 // R21C-NEXT:    GIR_RootConstrainSelectedInstOperands,
368 // R21C-NEXT:    // GIR_Coverage, 22,
369 // R21C-NEXT:    GIR_EraseRootFromParent_Done,
370 // R21C-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
372 // R21O-NEXT:  GIM_Reject,
373 // R21O-NEXT:  // Label [[GROUP_NUM]]: @[[GROUP]]
374 // R21O-NEXT:  GIM_Reject,
375 // R21O:       // Label [[DEFAULT_NUM]]: @[[DEFAULT]]
376 // R21O-NEXT:  GIM_Reject,
377 // R21O-NEXT:  };
379 //===- Test a pattern with ComplexPattern operands. -----------------------===//
381 // R20O-NEXT:  GIM_SwitchOpcode, /*MI*/0, /*[*/GIMT_Encode2({{[0-9]+}}), GIMT_Encode2({{[0-9]+}}), /*)*//*default:*//*Label [[DEFAULT_NUM:[0-9]+]]*/ GIMT_Encode4([[DEFAULT:[0-9]+]]),
382 // R20O-NEXT:  /*TargetOpcode::G_ADD*//*Label [[CASE_ADD_NUM:[0-9]+]]*/ GIMT_Encode4([[CASE_ADD:[0-9]+]]),
383 // R20O:       /*TargetOpcode::G_SUB*//*Label [[CASE_SUB_NUM:[0-9]+]]*/ GIMT_Encode4([[CASE_SUB:[0-9]+]]),
384 // R20O:       // Label [[CASE_ADD_NUM]]: @[[CASE_ADD]]
385 // R20O:       // Label [[CASE_SUB_NUM]]: @[[CASE_SUB]]
386 // R20O-NEXT:  GIM_Try, /*On fail goto*//*Label [[GROUP_NUM:[0-9]+]]*/ GIMT_Encode4([[GROUP:[0-9]+]]),
387 // R20O-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
388 // R20O-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
389 // R20O-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
390 // R20O-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
392 // R20N:       GIM_Try, /*On fail goto*//*Label [[PREV_NUM:[0-9]+]]*/ GIMT_Encode4([[PREV:[0-9]+]]), // Rule ID 22 //
393 // R20N:       // Label [[PREV_NUM]]: @[[PREV]]
395 // R20C-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]), // Rule ID 21 //
397 // R20N-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/3,
398 // R20N-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_SUB),
399 // R20N-NEXT:    // MIs[0] DstI[dst]
400 // R20N-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
401 // R20N-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
402 // R20N-NEXT:    // MIs[0] src1
403 // R20N-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
405 // R20N-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
406 // R20N-NEXT:    // MIs[0] src2
407 // R20N-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
408 // R20O-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
409 // R20C-NEXT:    GIM_CheckComplexPattern, /*MI*/0, /*Op*/2, /*Renderer*/GIMT_Encode2(0), GIMT_Encode2(GICP_gi_complex),
410 // R20C-NEXT:    // (sub:{ *:[i32] } GPR32:{ *:[i32] }:$src1, complex:{ *:[i32] }:$src2) => (INSN1:{ *:[i32] } GPR32:{ *:[i32] }:$src1, complex:{ *:[i32] }:$src2)
411 // R20C-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::INSN1),
412 // R20C-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, //  DstI[dst]
413 // R20C-NEXT:    GIR_RootToRootCopy, /*OpIdx*/1, // src1
414 // R20C-NEXT:    GIR_ComplexRenderer, /*InsnID*/0, /*RendererID*/GIMT_Encode2(0),
415 // R20C-NEXT:    GIR_RootConstrainSelectedInstOperands,
416 // R20C-NEXT:    // GIR_Coverage, 21,
417 // R20C-NEXT:    GIR_EraseRootFromParent_Done,
418 // R20C-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
420 // R20O:       // Label [[GROUP_NUM]]: @[[GROUP]]
421 // R20O-NEXT:  GIM_Reject,
422 // R20O:       // Label [[DEFAULT_NUM]]: @[[DEFAULT]]
423 // R20O-NEXT:  GIM_Reject,
424 // R20O-NEXT:  };
426 def INSN1 : I<(outs GPR32:$dst), (ins GPR32:$src1, complex:$src2), []>;
427 def : Pat<(sub GPR32:$src1, complex:$src2), (INSN1 GPR32:$src1, complex:$src2)>;
429 //===- Test a pattern with multiple ComplexPattern operands. --------------===//
431 def : GINodeEquiv<G_SELECT, select>;
432 let mayLoad = 1 in {
433   def INSN2 : I<(outs GPR32:$dst), (ins GPR32Op:$src1, complex:$src2, complex:$src3), []>;
435 def frag : PatFrag<(ops node:$a, node:$b, node:$c),
436                    (select node:$a, node:$b, node:$c),
437                    [{ return true; // C++ code }]> {
438   let GISelPredicateCode = [{ return true; // C++ code }];
440 def : Pat<(frag GPR32:$src1, complex:$src2, complex:$src3),
441           (INSN2 GPR32:$src1, complex:$src3, complex:$src2)>;
443 //===- Test a more complex multi-instruction match. -----------------------===//
445 // R00O-NEXT:  GIM_SwitchOpcode, /*MI*/0, /*[*/GIMT_Encode2({{[0-9]+}}), GIMT_Encode2({{[0-9]+}}), /*)*//*default:*//*Label [[DEFAULT_NUM:[0-9]+]]*/ GIMT_Encode4([[DEFAULT:[0-9]+]]),
446 // R00O-NEXT:  /*TargetOpcode::G_ADD*//*Label [[CASE_ADD_NUM:[0-9]+]]*/ GIMT_Encode4([[CASE_ADD:[0-9]+]]),
447 // R00O:       /*TargetOpcode::G_SUB*//*Label [[CASE_SUB_NUM:[0-9]+]]*/ GIMT_Encode4([[CASE_SUB:[0-9]+]]),
448 // R00O:       // Label [[CASE_ADD_NUM]]: @[[CASE_ADD]]
449 // R00O:       // Label [[CASE_SUB_NUM]]: @[[CASE_SUB]]
450 // R00O-NEXT:  GIM_Try, /*On fail goto*//*Label [[GROUP_NUM:[0-9]+]]*/ GIMT_Encode4([[GROUP:[0-9]+]]),
451 // R00O-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
452 // R00O-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
453 // R00O-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
454 // R00O-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
456 // R00C:       GIM_Try, /*On fail goto*//*Label [[PREV_NUM:[0-9]+]]*/ GIMT_Encode4([[PREV:[0-9]+]]), // Rule ID 21 //
457 // R00C:       // Label [[PREV_NUM]]: @[[PREV]]
459 // R00C-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]), // Rule ID 0 //
460 // R00C-NEXT:    GIM_CheckFeatures, GIMT_Encode2(GIFBS_HasA),
461 // R00N-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/3,
462 // R00N-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_SUB),
463 // R00N-NEXT:    // MIs[0] DstI[dst]
464 // R00N-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
465 // R00N-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
466 // R00N-NEXT:    // MIs[0] Operand 1
467 // R00N-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
468 // R00C-NEXT:    GIM_RecordInsn, /*DefineMI*/1, /*MI*/0, /*OpIdx*/1, // MIs[1]
469 // R00N-NEXT:    GIM_CheckNumOperands, /*MI*/1, /*Expected*/3,
470 // R00C-NEXT:    GIM_CheckOpcode, /*MI*/1, GIMT_Encode2(TargetOpcode::G_SUB),
471 // R00N-NEXT:    // MIs[1] Operand 0
472 // R00N-NEXT:    GIM_CheckType, /*MI*/1, /*Op*/0, /*Type*/GILLT_s32,
473 // R00N-NEXT:    // MIs[1] src1
474 // R00C-NEXT:    GIM_CheckType, /*MI*/1, /*Op*/1, /*Type*/GILLT_s32,
475 // R00O-NEXT:    GIM_CheckType, /*MI*/1, /*Op*/2, /*Type*/GILLT_s32,
476 // R00N-NEXT:    GIM_CheckRegBankForClass, /*MI*/1, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
477 // R00N-NEXT:    // MIs[1] src2
478 // R00N-NEXT:    GIM_CheckType, /*MI*/1, /*Op*/2, /*Type*/GILLT_s32,
479 // R00N-NEXT:    GIM_CheckRegBankForClass, /*MI*/1, /*Op*/2, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
480 // R00N-NEXT:    // MIs[0] Operand 2
481 // R00N-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
482 // R00O-NEXT:    GIM_CheckRegBankForClass, /*MI*/1, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
483 // R00O-NEXT:    GIM_CheckRegBankForClass, /*MI*/1, /*Op*/2, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
484 // R00C-NEXT:    GIM_RecordInsn, /*DefineMI*/2, /*MI*/0, /*OpIdx*/2, // MIs[2]
485 // R00N-NEXT:    GIM_CheckNumOperands, /*MI*/2, /*Expected*/3,
486 // R00C-NEXT:    GIM_CheckOpcode, /*MI*/2, GIMT_Encode2(TargetOpcode::G_SUB),
487 // R00N-NEXT:    // MIs[2] Operand 0
488 // R00N-NEXT:    GIM_CheckType, /*MI*/2, /*Op*/0, /*Type*/GILLT_s32,
489 // R00N-NEXT:    // MIs[2] src3
490 // R00C-NEXT:    GIM_CheckType, /*MI*/2, /*Op*/1, /*Type*/GILLT_s32,
491 // R00O-NEXT:    GIM_CheckType, /*MI*/2, /*Op*/2, /*Type*/GILLT_s32,
492 // R00N-NEXT:    GIM_CheckRegBankForClass, /*MI*/2, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
493 // R00N-NEXT:    // MIs[2] src4
494 // R00N-NEXT:    GIM_CheckType, /*MI*/2, /*Op*/2, /*Type*/GILLT_s32,
495 // R00N-NEXT:    GIM_CheckRegBankForClass, /*MI*/2, /*Op*/2, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
496 // R00O-NEXT:    GIM_CheckRegBankForClass, /*MI*/2, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
497 // R00O-NEXT:    GIM_CheckRegBankForClass, /*MI*/2, /*Op*/2, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
498 // R00C-NEXT:    GIM_CheckIsSafeToFold, /*NumInsns*/2,
499 // R00C-NEXT:    // (sub:{ *:[i32] } (sub:{ *:[i32] } GPR32:{ *:[i32] }:$src1, GPR32:{ *:[i32] }:$src2), (sub:{ *:[i32] } GPR32:{ *:[i32] }:$src3, GPR32:{ *:[i32] }:$src4)) => (INSNBOB:{ *:[i32] } GPR32:{ *:[i32] }:$src1, GPR32:{ *:[i32] }:$src2, GPR32:{ *:[i32] }:$src3, GPR32:{ *:[i32] }:$src4)
500 // R00C-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::INSNBOB),
501 // R00C-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, //  DstI[dst]
502 // R00C-NEXT:    GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/1, /*OpIdx*/1, // src1
503 // R00C-NEXT:    GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/1, /*OpIdx*/2, // src2
504 // R00C-NEXT:    GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/2, /*OpIdx*/1, // src3
505 // R00C-NEXT:    GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/2, /*OpIdx*/2, // src4
506 // R00C-NEXT:    GIR_RootConstrainSelectedInstOperands,
507 // R00C-NEXT:    // GIR_Coverage, 0,
508 // R00C-NEXT:    GIR_EraseRootFromParent_Done,
509 // R00C-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
511 // R00O-NEXT:  GIM_Reject,
512 // R00O-NEXT:  // Label [[GROUP_NUM]]: @[[GROUP]]
513 // R00O-NEXT:  GIM_Reject,
514 // R00O:       // Label [[DEFAULT_NUM]]: @[[DEFAULT]]
515 // R00O-NEXT:  GIM_Reject,
516 // R00O-NEXT:  }; // Size: 1816 bytes
518 def INSNBOB : I<(outs GPR32:$dst), (ins GPR32:$src1, GPR32:$src2, GPR32:$src3, GPR32:$src4),
519                  [(set GPR32:$dst,
520                       (sub (sub GPR32:$src1, GPR32:$src2), (sub GPR32:$src3, GPR32:$src4)))]>,
521                Requires<[HasA]>;
523 //===- Test a simple pattern with an intrinsic. ---------------------------===//
525 // R01O-NEXT:  GIM_SwitchOpcode, /*MI*/0, /*[*/GIMT_Encode2({{[0-9]+}}), GIMT_Encode2({{[0-9]+}}), /*)*//*default:*//*Label [[DEFAULT_NUM:[0-9]+]]*/ GIMT_Encode4([[DEFAULT:[0-9]+]]),
526 // R01O-NEXT:  /*TargetOpcode::G_ADD*//*Label [[CASE_ADD_NUM:[0-9]+]]*/ GIMT_Encode4([[CASE_ADD:[0-9]+]]),
527 // R01O:       /*TargetOpcode::G_INTRINSIC*//*Label [[CASE_INTRINSIC_NUM:[0-9]+]]*/ GIMT_Encode4([[CASE_INTRINSIC:[0-9]+]]),
528 // R01O:       // Label [[CASE_ADD_NUM]]: @[[CASE_ADD]]
529 // R01O:       // Label [[CASE_INTRINSIC_NUM]]: @[[CASE_INTRINSIC]]
531 // R01N:       GIM_Try, /*On fail goto*//*Label [[PREV_NUM:[0-9]+]]*/ GIMT_Encode4([[PREV:[0-9]+]]), // Rule ID 0 //
532 // R01N:       // Label [[PREV_NUM]]: @[[PREV]]
534 // R01C-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]), // Rule ID 1 //
535 // R01C-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/3,
537 // R01O-NEXT:    GIM_CheckIntrinsicID, /*MI*/0, /*Op*/1, GIMT_Encode2(Intrinsic::mytarget_nop),
538 // R01O-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
539 // R01O-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
540 // R01O-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
542 // R01N-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_INTRINSIC),
543 // R01N-NEXT:    // MIs[0] DstI[dst]
544 // R01N-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
545 // R01N-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
546 // R01N-NEXT:    // MIs[0] Operand 1
547 // R01N-NEXT:    GIM_CheckIntrinsicID, /*MI*/0, /*Op*/1, GIMT_Encode2(Intrinsic::mytarget_nop),
548 // R01N-NEXT:    // MIs[0] src1
549 // R01N-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
551 // R01C-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/2, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
552 // R01C-NEXT:    // (intrinsic_wo_chain:{ *:[i32] } [[ID:[0-9]+]]:{ *:[iPTR] }, GPR32:{ *:[i32] }:$src1) => (MOV:{ *:[i32] } GPR32:{ *:[i32] }:$src1)
553 // R01C-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::MOV),
554 // R01C-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, //  DstI[dst]
555 // R01C-NEXT:    GIR_RootToRootCopy, /*OpIdx*/2, // src1
556 // R01C-NEXT:    GIR_RootConstrainSelectedInstOperands,
557 // R01C-NEXT:    // GIR_Coverage, 1,
558 // R01C-NEXT:    GIR_EraseRootFromParent_Done,
559 // R01C-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
561 // R01O-NEXT:  GIM_Reject,
562 // R01O:       // Label [[DEFAULT_NUM]]: @[[DEFAULT]]
563 // R01O-NEXT:  GIM_Reject,
565 def MOV : I<(outs GPR32:$dst), (ins GPR32:$src1),
566             [(set GPR32:$dst, (int_mytarget_nop GPR32:$src1))]>;
568 //===- Test a simple pattern with a default operand. ----------------------===//
570 // R02O-NEXT:  GIM_SwitchOpcode, /*MI*/0, /*[*/GIMT_Encode2({{[0-9]+}}), GIMT_Encode2({{[0-9]+}}), /*)*//*default:*//*Label [[DEFAULT_NUM:[0-9]+]]*/ GIMT_Encode4([[DEFAULT:[0-9]+]]),
571 // R02O-NEXT:  /*TargetOpcode::G_ADD*//*Label [[CASE_ADD_NUM:[0-9]+]]*/ GIMT_Encode4([[CASE_ADD:[0-9]+]]),
572 // R02O:       /*TargetOpcode::G_XOR*//*Label [[CASE_XOR_NUM:[0-9]+]]*/ GIMT_Encode4([[CASE_XOR:[0-9]+]]),
573 // R02O:       // Label [[CASE_ADD_NUM]]: @[[CASE_ADD]]
574 // R02O:       // Label [[CASE_XOR_NUM]]: @[[CASE_XOR]]
575 // R02O-NEXT:  GIM_Try, /*On fail goto*//*Label [[GROUP_NUM:[0-9]+]]*/ GIMT_Encode4([[GROUP:[0-9]+]]),
576 // R02O-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
577 // R02O-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
578 // R02O-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
579 // R02O-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
580 // R02O-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
582 // R02N:       GIM_Try, /*On fail goto*//*Label [[PREV_NUM:[0-9]+]]*/ GIMT_Encode4([[PREV:[0-9]+]]), // Rule ID 1 //
583 // R02N:       // Label [[PREV_NUM]]: @[[PREV]]
585 // R02C-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]), // Rule ID 2 //
587 // R02N-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/3,
588 // R02N-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_XOR),
589 // R02N-NEXT:    // MIs[0] DstI[dst]
590 // R02N-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
591 // R02N-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
592 // R02N-NEXT:    // MIs[0] src1
593 // R02N-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
594 // R02N-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
595 // R02N-NEXT:    // MIs[0] Operand 2
596 // R02N-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
598 // R02C-NEXT:    GIM_CheckConstantInt8, /*MI*/0, /*Op*/2, uint8_t(-2)
599 // R02C-NEXT:    // (xor:{ *:[i32] } GPR32:{ *:[i32] }:$src1, -2:{ *:[i32] }) => (XORI:{ *:[i32] } GPR32:{ *:[i32] }:$src1)
600 // R02C-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::XORI),
601 // R02C-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, // DstI[dst]
602 // R02C-NEXT:    GIR_AddImm8, /*InsnID*/0, /*Imm*/uint8_t(-1),
603 // R02C-NEXT:    GIR_RootToRootCopy, /*OpIdx*/1, // src1
604 // R02C-NEXT:    GIR_RootConstrainSelectedInstOperands,
605 // R02C-NEXT:    // GIR_Coverage, 2,
606 // R02C-NEXT:    GIR_EraseRootFromParent_Done,
607 // R02C-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
609 // R02O:       // Label [[DEFAULT_NUM]]: @[[DEFAULT]]
610 // R02O-NEXT:  GIM_Reject,
612 // The -2 is just to distinguish it from the 'not' case below.
613 def XORI : I<(outs GPR32:$dst), (ins m1:$src2, GPR32:$src1),
614              [(set GPR32:$dst, (xor GPR32:$src1, -2))]>;
616 //===- Test a simple pattern with a default register operand. -------------===//
618 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
619 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/3,
620 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_XOR),
621 // NOOPT-NEXT:    // MIs[0] DstI[dst]
622 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
623 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
624 // NOOPT-NEXT:    // MIs[0] src1
625 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
626 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
627 // NOOPT-NEXT:    // MIs[0] Operand 2
628 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
629 // NOOPT-NEXT:    GIM_CheckConstantInt8, /*MI*/0, /*Op*/2, uint8_t(-3)
630 // NOOPT-NEXT:    // (xor:{ *:[i32] } GPR32:{ *:[i32] }:$src1, -3:{ *:[i32] }) => (XOR:{ *:[i32] } GPR32:{ *:[i32] }:$src1)
631 // NOOPT-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::XOR),
632 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, //  DstI[dst]
633 // NOOPT-NEXT:    GIR_AddRegister, /*InsnID*/0, GIMT_Encode2(MyTarget::R0),
634 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/1, // src1
635 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
636 // NOOPT-NEXT:    // GIR_Coverage, 3,
637 // NOOPT-NEXT:    GIR_EraseRootFromParent_Done,
638 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
640 // The -3 is just to distinguish it from the 'not' case below and the other default op case above.
641 def XOR : I<(outs GPR32:$dst), (ins Z:$src2, GPR32:$src1),
642             [(set GPR32:$dst, (xor GPR32:$src1, -3))]>;
644 //===- Test a simple pattern with a multiple default operands. ------------===//
646 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
647 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/3,
648 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_XOR),
649 // NOOPT-NEXT:    // MIs[0] DstI[dst]
650 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
651 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
652 // NOOPT-NEXT:    // MIs[0] src1
653 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
654 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
655 // NOOPT-NEXT:    // MIs[0] Operand 2
656 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
657 // NOOPT-NEXT:    GIM_CheckConstantInt8, /*MI*/0, /*Op*/2, uint8_t(-4)
658 // NOOPT-NEXT:    // (xor:{ *:[i32] } GPR32:{ *:[i32] }:$src1, -4:{ *:[i32] }) => (XORlike:{ *:[i32] } GPR32:{ *:[i32] }:$src1)
659 // NOOPT-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::XORlike),
660 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, // DstI[dst]
661 // NOOPT-NEXT:    GIR_AddImm8, /*InsnID*/0, /*Imm*/uint8_t(-1),
662 // NOOPT-NEXT:    GIR_AddRegister, /*InsnID*/0, GIMT_Encode2(MyTarget::R0),
663 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/1, // src1
664 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
665 // NOOPT-NEXT:    // GIR_Coverage, 4,
666 // NOOPT-NEXT:    GIR_EraseRootFromParent_Done,
667 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
669 // The -4 is just to distinguish it from the other 'not' cases.
670 def XORlike : I<(outs GPR32:$dst), (ins m1Z:$src2, GPR32:$src1),
671                 [(set GPR32:$dst, (xor GPR32:$src1, -4))]>;
673 //===- Test a simple pattern with multiple operands with defaults. --------===//
675 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
676 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/3,
677 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_XOR),
678 // NOOPT-NEXT:    // MIs[0] DstI[dst]
679 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
680 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
681 // NOOPT-NEXT:    // MIs[0] src1
682 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
683 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
684 // NOOPT-NEXT:    // MIs[0] Operand 2
685 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
686 // NOOPT-NEXT:    GIM_CheckConstantInt8, /*MI*/0, /*Op*/2, uint8_t(-5),
687 // NOOPT-NEXT:    // (xor:{ *:[i32] } GPR32:{ *:[i32] }:$src1, -5:{ *:[i32] }) => (XORManyDefaults:{ *:[i32] } GPR32:{ *:[i32] }:$src1)
688 // NOOPT-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::XORManyDefaults),
689 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, // DstI[dst]
690 // NOOPT-NEXT:    GIR_AddImm8, /*InsnID*/0, /*Imm*/uint8_t(-1),
691 // NOOPT-NEXT:    GIR_AddRegister, /*InsnID*/0, GIMT_Encode2(MyTarget::R0),
692 // NOOPT-NEXT:    GIR_AddRegister, /*InsnID*/0, GIMT_Encode2(MyTarget::R0),
693 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/1, // src1
694 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
695 // NOOPT-NEXT:    // GIR_Coverage, 5,
696 // NOOPT-NEXT:    GIR_EraseRootFromParent_Done,
697 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
699 // The -5 is just to distinguish it from the other cases.
700 def XORManyDefaults : I<(outs GPR32:$dst), (ins m1Z:$src3, Z:$src2, GPR32:$src1),
701                         [(set GPR32:$dst, (xor GPR32:$src1, -5))]>;
703 //===- Test a simple pattern with a default bits operand. -----------------===//
705 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
706 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/3,
707 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_XOR),
708 // NOOPT-NEXT:    // MIs[0] DstI[dst]
709 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
710 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
711 // NOOPT-NEXT:    // MIs[0] src1
712 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
713 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
714 // NOOPT-NEXT:    // MIs[0] Operand 2
715 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
716 // NOOPT-NEXT:    GIM_CheckConstantInt8, /*MI*/0, /*Op*/2, uint8_t(-6)
717 // NOOPT-NEXT:    // (xor:{ *:[i32] } GPR32:{ *:[i32] }:$src1, -6:{ *:[i32] }) => (XORIb:{ *:[i32] } GPR32:{ *:[i32] }:$src1)
718 // NOOPT-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::XORIb),
719 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, // DstI[dst]
720 // NOOPT-NEXT:    GIR_AddImm8, /*InsnID*/0, /*Imm*/13,
721 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/1, // src1
722 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
723 // NOOPT-NEXT:    // GIR_Coverage, 6,
724 // NOOPT-NEXT:    GIR_EraseRootFromParent_Done,
725 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
727 // The -6 is just to distinguish it from the other cases.
728 def XORIb : I<(outs GPR32:$dst), (ins mb:$src2, GPR32:$src1),
729               [(set GPR32:$dst, (xor GPR32:$src1, -6))]>;
731 //===- Test a simple pattern with constant immediate operands. ------------===//
733 // This must precede the 3-register variants because constant immediates have
734 // priority over register banks.
736 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
737 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/3,
738 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_XOR),
739 // NOOPT-NEXT:    // MIs[0] DstI[dst]
740 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
741 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
742 // NOOPT-NEXT:    // MIs[0] Wm
743 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
744 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
745 // NOOPT-NEXT:    // MIs[0] Operand 2
746 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
747 // NOOPT-NEXT:    GIM_CheckConstantInt8, /*MI*/0, /*Op*/2, uint8_t(-1),
748 // NOOPT-NEXT:    // (xor:{ *:[i32] } GPR32:{ *:[i32] }:$Wm, -1:{ *:[i32] }) => (ORN:{ *:[i32] } R0:{ *:[i32] }, GPR32:{ *:[i32] }:$Wm)
749 // NOOPT-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::ORN),
750 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, //  DstI[dst]
751 // NOOPT-NEXT:    GIR_AddRegister, /*InsnID*/0, GIMT_Encode2(MyTarget::R0),
752 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/1, // Wm
753 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
754 // NOOPT-NEXT:    // GIR_Coverage, 23,
755 // NOOPT-NEXT:    GIR_EraseRootFromParent_Done,
756 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
758 def ORN : I<(outs GPR32:$dst), (ins GPR32:$src1, GPR32:$src2), []>;
759 def : Pat<(not GPR32:$Wm), (ORN R0, GPR32:$Wm)>;
761 //===- Test a nested instruction match. -----------------------------------===//
763 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
764 // NOOPT-NEXT:    GIM_CheckFeatures, GIMT_Encode2(GIFBS_HasA),
765 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/3,
766 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_MUL),
767 // NOOPT-NEXT:    // MIs[0] DstI[dst]
768 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
769 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
770 // NOOPT-NEXT:    // MIs[0] Operand 1
771 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
772 // NOOPT-NEXT:    GIM_RecordInsn, /*DefineMI*/1, /*MI*/0, /*OpIdx*/1, // MIs[1]
773 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/1, /*Expected*/3,
774 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/1, GIMT_Encode2(TargetOpcode::G_ADD),
775 // NOOPT-NEXT:    // MIs[1] Operand 0
776 // NOOPT-NEXT:    GIM_CheckType, /*MI*/1, /*Op*/0, /*Type*/GILLT_s32,
777 // NOOPT-NEXT:    // MIs[1] src1
778 // NOOPT-NEXT:    GIM_CheckType, /*MI*/1, /*Op*/1, /*Type*/GILLT_s32,
779 // NOOPT-NEXT:    GIM_CheckRegBankForClass, /*MI*/1, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
780 // NOOPT-NEXT:    // MIs[1] src2
781 // NOOPT-NEXT:    GIM_CheckType, /*MI*/1, /*Op*/2, /*Type*/GILLT_s32,
782 // NOOPT-NEXT:    GIM_CheckRegBankForClass, /*MI*/1, /*Op*/2, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
783 // NOOPT-NEXT:    // MIs[0] src3
784 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
785 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/2, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
786 // NOOPT-NEXT:    GIM_CheckIsSafeToFold, /*NumInsns*/1,
787 // NOOPT-NEXT:    // (mul:{ *:[i32] } (add:{ *:[i32] } GPR32:{ *:[i32] }:$src1, GPR32:{ *:[i32] }:$src2), GPR32:{ *:[i32] }:$src3)  =>  (MULADD:{ *:[i32] } GPR32:{ *:[i32] }:$src1, GPR32:{ *:[i32] }:$src2, GPR32:{ *:[i32] }:$src3)
788 // NOOPT-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::MULADD),
789 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, //  DstI[dst]
790 // NOOPT-NEXT:    GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/1, /*OpIdx*/1, // src1
791 // NOOPT-NEXT:    GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/1, /*OpIdx*/2, // src2
792 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/2, // src3
793 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
794 // NOOPT-NEXT:    // GIR_Coverage, 7,
795 // NOOPT-NEXT:    GIR_EraseRootFromParent_Done,
796 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
798 // We also get a second rule by commutativity.
800 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
801 // NOOPT-NEXT:    GIM_CheckFeatures, GIMT_Encode2(GIFBS_HasA),
802 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/3,
803 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_MUL),
804 // NOOPT-NEXT:    // MIs[0] DstI[dst]
805 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
806 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
807 // NOOPT-NEXT:    // MIs[0] src3
808 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
809 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
810 // NOOPT-NEXT:    // MIs[0] Operand 2
811 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
812 // NOOPT-NEXT:    GIM_RecordInsn, /*DefineMI*/1, /*MI*/0, /*OpIdx*/2,
813 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/1, /*Expected*/3,
814 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/1, GIMT_Encode2(TargetOpcode::G_ADD),
815 // NOOPT-NEXT:    // MIs[1] Operand 0
816 // NOOPT-NEXT:    GIM_CheckType, /*MI*/1, /*Op*/0, /*Type*/GILLT_s32,
817 // NOOPT-NEXT:    // MIs[1] src1
818 // NOOPT-NEXT:    GIM_CheckType, /*MI*/1, /*Op*/1, /*Type*/GILLT_s32,
819 // NOOPT-NEXT:    GIM_CheckRegBankForClass, /*MI*/1, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
820 // NOOPT-NEXT:    // MIs[1] src2
821 // NOOPT-NEXT:    GIM_CheckType, /*MI*/1, /*Op*/2, /*Type*/GILLT_s32,
822 // NOOPT-NEXT:    GIM_CheckRegBankForClass, /*MI*/1, /*Op*/2, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
823 // NOOPT-NEXT:    GIM_CheckIsSafeToFold, /*NumInsns*/1,
824 // NOOPT-NEXT:    // (mul:{ *:[i32] } GPR32:{ *:[i32] }:$src3, (add:{ *:[i32] } GPR32:{ *:[i32] }:$src1, GPR32:{ *:[i32] }:$src2))  =>  (MULADD:{ *:[i32] } GPR32:{ *:[i32] }:$src1, GPR32:{ *:[i32] }:$src2, GPR32:{ *:[i32] }:$src3)
825 // NOOPT-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::MULADD),
826 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, //  DstI[dst]
827 // NOOPT-NEXT:    GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/1, /*OpIdx*/1, // src1
828 // NOOPT-NEXT:    GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/1, /*OpIdx*/2, // src2
829 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/1, // src3
830 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
831 // NOOPT-NEXT:    // GIR_Coverage, 28,
832 // NOOPT-NEXT:    GIR_EraseRootFromParent_Done,
833 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
835 def MULADD : I<(outs GPR32:$dst), (ins GPR32:$src1, GPR32:$src2, GPR32:$src3),
836                [(set GPR32:$dst,
837                      (mul (add GPR32:$src1, GPR32:$src2), GPR32:$src3))]>,
838              Requires<[HasA]>;
840 //===- Test a simple pattern with just a specific leaf immediate. ---------===//
842 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
843 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/2,
844 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_CONSTANT),
845 // NOOPT-NEXT:    // MIs[0] DstI[dst]
846 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
847 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
848 // NOOPT-NEXT:    // MIs[0] Operand 1
849 // NOOPT-NEXT:    GIM_CheckLiteralInt, /*MI*/0, /*Op*/1, GIMT_Encode8(1),
850 // NOOPT-NEXT:    // 1:{ *:[i32] }  =>  (MOV1:{ *:[i32] })
851 // NOOPT-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::MOV1),
852 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, //  DstI[dst]
853 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
854 // NOOPT-NEXT:    // GIR_Coverage, 8,
855 // NOOPT-NEXT:    GIR_EraseRootFromParent_Done,
856 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
858 def MOV1 : I<(outs GPR32:$dst), (ins), [(set GPR32:$dst, 1)]>;
860 //===- Test a simple pattern with a leaf immediate and a predicate. -------===//
862 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
863 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/2,
864 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_CONSTANT),
865 // NOOPT-NEXT:    GIM_CheckI64ImmPredicate, /*MI*/0, /*Predicate*/GIMT_Encode2(GICXXPred_I64_Predicate_simm8),
866 // NOOPT-NEXT:    // MIs[0] DstI[dst]
867 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
868 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
869 // NOOPT-NEXT:    // MIs[0] Operand 1
870 // NOOPT-NEXT:    // No operand predicates
871 // NOOPT-NEXT:    // (imm:{ *:[i32] })<<P:Predicate_simm8>>:$imm => (MOVimm8:{ *:[i32] } (imm:{ *:[i32] }):$imm)
872 // NOOPT-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::MOVimm8),
873 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, //  DstI[dst]
874 // NOOPT-NEXT:    GIR_CopyConstantAsSImm, /*NewInsnID*/0, /*OldInsnID*/0, // imm
875 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
876 // NOOPT-NEXT:    // GIR_Coverage, 9,
877 // NOOPT-NEXT:    GIR_EraseRootFromParent_Done,
878 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
880 def simm8 : ImmLeaf<i32, [{ return isInt<8>(Imm); }]>;
881 def MOVimm8 : I<(outs GPR32:$dst), (ins i32imm:$imm), [(set GPR32:$dst, simm8:$imm)]>;
883 //===- Same again but use an IntImmLeaf. ----------------------------------===//
885 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
886 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/2,
887 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_CONSTANT),
888 // NOOPT-NEXT:    GIM_CheckAPIntImmPredicate, /*MI*/0, /*Predicate*/GIMT_Encode2(GICXXPred_APInt_Predicate_simm9),
889 // NOOPT-NEXT:    // MIs[0] DstI[dst]
890 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
891 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
892 // NOOPT-NEXT:    // MIs[0] Operand 1
893 // NOOPT-NEXT:    // No operand predicates
894 // NOOPT-NEXT:    // (imm:{ *:[i32] })<<P:Predicate_simm9>>:$imm =>  (MOVimm9:{ *:[i32] } (imm:{ *:[i32] }):$imm)
895 // NOOPT-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::MOVimm9),
896 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, //  DstI[dst]
897 // NOOPT-NEXT:    GIR_CopyConstantAsSImm, /*NewInsnID*/0, /*OldInsnID*/0, // imm
898 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
899 // NOOPT-NEXT:    // GIR_Coverage, 10,
900 // NOOPT-NEXT:    GIR_EraseRootFromParent_Done,
901 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
903 def simm9 : IntImmLeaf<i32, [{ return isInt<9>(Imm->getSExtValue()); }]>;
904 def MOVimm9 : I<(outs GPR32:$dst), (ins i32imm:$imm), [(set GPR32:$dst, simm9:$imm)]>;
906 //===- Test a pattern with a custom renderer. -----------------------------===//
908 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
909 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/2,
910 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_CONSTANT),
911 // NOOPT-NEXT:    GIM_CheckI64ImmPredicate, /*MI*/0, /*Predicate*/GIMT_Encode2(GICXXPred_I64_Predicate_cimm8),
912 // NOOPT-NEXT:    // MIs[0] DstI[dst]
913 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
914 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
915 // NOOPT-NEXT:    // MIs[0] Operand 1
916 // NOOPT-NEXT:    // No operand predicates
917 // NOOPT-NEXT:    // (imm:{ *:[i32] })<<P:Predicate_cimm8>><<X:cimm8_xform>>:$imm  =>  (MOVcimm8:{ *:[i32] } (cimm8_xform:{ *:[i32] } (imm:{ *:[i32] }):$imm))
918 // NOOPT-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::MOVcimm8),
919 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, //  DstI[dst]
920 // NOOPT-NEXT:    GIR_CustomRenderer, /*InsnID*/0, /*OldInsnID*/0, /*Renderer*/GIMT_Encode2(GICR_renderImm), // imm
921 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
922 // NOOPT-NEXT:    // GIR_Coverage, 11,
923 // NOOPT-NEXT:    GIR_EraseRootFromParent_Done,
924 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
926 def MOVcimm8 : I<(outs GPR32:$dst), (ins i32imm:$imm), [(set GPR32:$dst, cimm8:$imm)]>;
928 //===- Test a simple pattern with a FP immediate and a predicate. ---------===//
930 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
931 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/2,
932 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_FCONSTANT),
933 // NOOPT-NEXT:    GIM_CheckAPFloatImmPredicate, /*MI*/0, /*Predicate*/GIMT_Encode2(GICXXPred_APFloat_Predicate_fpimmz),
934 // NOOPT-NEXT:    // MIs[0] DstI[dst]
935 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
936 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::FPR32RegClassID),
937 // NOOPT-NEXT:    // MIs[0] Operand 1
938 // NOOPT-NEXT:    // No operand predicates
939 // NOOPT-NEXT:    // (fpimm:{ *:[f32] })<<P:Predicate_fpimmz>>:$imm =>  (MOVfpimmz:{ *:[f32] } (fpimm:{ *:[f32] }):$imm)
940 // NOOPT-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::MOVfpimmz),
941 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, //  DstI[dst]
942 // NOOPT-NEXT:    GIR_CopyFConstantAsFPImm, /*NewInsnID*/0, /*OldInsnID*/0, // imm
943 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
944 // NOOPT-NEXT:    // GIR_Coverage, 18,
945 // NOOPT-NEXT:    GIR_EraseRootFromParent_Done,
946 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
948 //===- Test a simple pattern with inferred pointer operands. ---------------===//
950 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
951 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/2,
952 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_LOAD),
953 // NOOPT-NEXT:    GIM_CheckMemorySizeEqualToLLT, /*MI*/0, /*MMO*/0, /*OpIdx*/0,
954 // NOOPT-NEXT:    GIM_CheckAtomicOrdering, /*MI*/0, /*Order*/(uint8_t)AtomicOrdering::NotAtomic,
955 // NOOPT-NEXT:    // MIs[0] DstI[dst]
956 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
957 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
958 // NOOPT-NEXT:    // MIs[0] src1
959 // NOOPT-NEXT:    GIM_CheckPointerToAny, /*MI*/0, /*Op*/1, /*SizeInBits*/32,
960 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
961 // NOOPT-NEXT:    // (ld:{ *:[i32] } GPR32:{ *:[i32] }:$src1)<<P:Predicate_unindexedload>><<P:Predicate_load>> => (LOAD:{ *:[i32] } GPR32:{ *:[i32] }:$src1)
962 // NOOPT-NEXT:    GIR_MutateOpcode, /*InsnID*/0, /*RecycleInsnID*/0, /*Opcode*/GIMT_Encode2(MyTarget::LOAD),
963 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
964 // NOOPT-NEXT:    // GIR_Coverage, 12,
965 // NOOPT-NEXT:    GIR_Done,
966 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
968 def LOAD : I<(outs GPR32:$dst), (ins GPR32:$src1),
969             [(set GPR32:$dst, (load GPR32:$src1))]>;
971 //===- Test a simple pattern with explicit pointer operands. ---------------===//
973 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
974 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/2,
975 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_LOAD),
976 // NOOPT-NEXT:    GIM_CheckMemorySizeEqualToLLT, /*MI*/0, /*MMO*/0, /*OpIdx*/0,
977 // NOOPT-NEXT:    GIM_CheckAtomicOrdering, /*MI*/0, /*Order*/(uint8_t)AtomicOrdering::NotAtomic,
978 // NOOPT-NEXT:    // MIs[0] DstI[dst]
979 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_p0s32,
980 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
981 // NOOPT-NEXT:    // MIs[0] src
982 // NOOPT-NEXT:    GIM_CheckPointerToAny, /*MI*/0, /*Op*/1, /*SizeInBits*/32,
983 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
984 // NOOPT-NEXT:    // (ld:{ *:[i32] } GPR32:{ *:[i32] }:$src)<<P:Predicate_unindexedload>><<P:Predicate_load>>  =>  (LOAD:{ *:[i32] } GPR32:{ *:[i32] }:$src)
985 // NOOPT-NEXT:    GIR_MutateOpcode, /*InsnID*/0, /*RecycleInsnID*/0, /*Opcode*/GIMT_Encode2(MyTarget::LOAD),
986 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
987 // NOOPT-NEXT:    // GIR_Coverage, 24,
988 // NOOPT-NEXT:    GIR_Done,
989 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
991 def : Pat<(load GPR32:$src),
992           (p0 (LOAD GPR32:$src))>;
994 //===- Test a simple pattern with a sextload -------------------------------===//
996 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
997 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/2,
998 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_SEXTLOAD),
999 // NOOPT-NEXT:    GIM_CheckMemorySizeEqualTo, /*MI*/0, /*MMO*/0, /*Size*/GIMT_Encode4(2),
1000 // NOOPT-NEXT:    GIM_CheckAtomicOrdering, /*MI*/0, /*Order*/(uint8_t)AtomicOrdering::NotAtomic,
1001 // NOOPT-NEXT:    // MIs[0] DstI[dst]
1002 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
1003 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
1004 // NOOPT-NEXT:    // MIs[0] src1
1005 // NOOPT-NEXT:    GIM_CheckPointerToAny, /*MI*/0, /*Op*/1, /*SizeInBits*/32,
1006 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
1007 // NOOPT-NEXT:    // (ld:{ *:[i32] } GPR32:{ *:[i32] }:$src1)<<P:Predicate_unindexedload>><<P:Predicate_sextload>><<P:Predicate_sextloadi16>>  =>  (SEXTLOAD:{ *:[i32] } GPR32:{ *:[i32] }:$src1)
1008 // NOOPT-NEXT:    GIR_MutateOpcode, /*InsnID*/0, /*RecycleInsnID*/0, /*Opcode*/GIMT_Encode2(MyTarget::SEXTLOAD),
1009 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
1010 // NOOPT-NEXT:    // GIR_Coverage, 13,
1011 // NOOPT-NEXT:    GIR_Done,
1012 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
1014 def SEXTLOAD : I<(outs GPR32:$dst), (ins GPR32:$src1),
1015                  [(set GPR32:$dst, (sextloadi16 GPR32:$src1))]>;
1017 //===- Test a simple pattern with regclass operands. ----------------------===//
1019 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
1020 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/3,
1021 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_ADD),
1022 // NOOPT-NEXT:    // MIs[0] DstI[dst]
1023 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
1024 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
1025 // NOOPT-NEXT:    // MIs[0] src1
1026 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
1027 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID)
1028 // NOOPT-NEXT:    // MIs[0] src2
1029 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
1030 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/2, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
1031 // NOOPT-NEXT:    // (add:{ *:[i32] } GPR32:{ *:[i32] }:$src1, GPR32:{ *:[i32] }:$src2) => (ADD:{ *:[i32] } GPR32:{ *:[i32] }:$src1, GPR32:{ *:[i32] }:$src2)
1032 // NOOPT-NEXT:    GIR_MutateOpcode, /*InsnID*/0, /*RecycleInsnID*/0, /*Opcode*/GIMT_Encode2(MyTarget::ADD),
1033 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
1034 // NOOPT-NEXT:    // GIR_Coverage, 14,
1035 // NOOPT-NEXT:    GIR_Done,
1036 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
1038 def ADD : I<(outs GPR32:$dst), (ins GPR32:$src1, GPR32:$src2),
1039             [(set GPR32:$dst, (add GPR32:$src1, GPR32:$src2))]>;
1041 //===- Test a pattern with a tied operand in the matcher ------------------===//
1043 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
1044 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/3,
1045 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_ADD),
1046 // NOOPT-NEXT:    // MIs[0] DstI[dst]
1047 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
1048 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
1049 // NOOPT-NEXT:    // MIs[0] src{{$}}
1050 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
1051 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
1052 // NOOPT-NEXT:    // MIs[0] src{{$}}
1053 // NOOPT-NEXT:    GIM_CheckIsSameOperand, /*MI*/0, /*OpIdx*/2, /*OtherMI*/0, /*OtherOpIdx*/1,
1054 // NOOPT-NEXT:    // (add:{ *:[i32] } GPR32:{ *:[i32] }:$src, GPR32:{ *:[i32] }:$src) => (DOUBLE:{ *:[i32] } GPR32:{ *:[i32] }:$src)
1055 // NOOPT-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::DOUBLE),
1056 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, //  DstI[dst]
1057 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/1, // src
1058 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
1059 // NOOPT-NEXT:    // GIR_Coverage, 15,
1060 // NOOPT-NEXT:    GIR_EraseRootFromParent_Done,
1061 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
1063 def DOUBLE : I<(outs GPR32:$dst), (ins GPR32:$src), [(set GPR32:$dst, (add GPR32:$src, GPR32:$src))]>;
1065 //===- Test a pattern with unintended operand name clash. ----------------===//
1067 // Check that using the same name for
1068 // - Def operand of the instruction corresponding to the root node of the
1069 //   pattern's destination
1070 // - one of operands in the pattern itself
1071 // does not introduce unexpected GIM_CheckIsSameOperand predicate.
1073 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
1074 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/3,
1075 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_ADD),
1076 // NOOPT-NEXT:    // MIs[0] DstI[samename]
1077 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
1078 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
1079 // NOOPT-NEXT:    // MIs[0] samename
1080 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
1081 // NOOPT-NEXT:    // MIs[0] othername
1082 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
1083 // NOOPT-NEXT:    // (add:{ *:[i32] } i32:{ *:[i32] }:$samename, i32:{ *:[i32] }:$othername)  =>  (InsnWithSpeciallyNamedDef:{ *:[i32] } i32:{ *:[i32] }:$samename, i32:{ *:[i32] }:$othername)
1084 // NOOPT-NEXT:    GIR_MutateOpcode, /*InsnID*/0, /*RecycleInsnID*/0, /*Opcode*/GIMT_Encode2(MyTarget::InsnWithSpeciallyNamedDef),
1085 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
1086 // NOOPT-NEXT:    // GIR_Coverage, 25,
1087 // NOOPT-NEXT:    GIR_Done,
1088 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
1090 def InsnWithSpeciallyNamedDef : I<(outs GPR32:$samename), (ins GPR32:$src1, GPR32:$src2), []>;
1091 def : Pat<(add i32:$samename, i32:$othername),
1092           (InsnWithSpeciallyNamedDef i32:$samename, i32:$othername)>;
1094 //===- Test a simple pattern with ValueType operands. ----------------------===//
1096 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
1097 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/3,
1098 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_ADD),
1099 // NOOPT-NEXT:    // MIs[0] DstI[dst]
1100 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
1101 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
1102 // NOOPT-NEXT:    // MIs[0] src1
1103 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
1104 // NOOPT-NEXT:    // MIs[0] src2
1105 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
1106 // NOOPT-NEXT:    // (add:{ *:[i32] } i32:{ *:[i32] }:$src1, i32:{ *:[i32] }:$src2) => (ADD:{ *:[i32] } i32:{ *:[i32] }:$src1, i32:{ *:[i32] }:$src2)
1107 // NOOPT-NEXT:    GIR_MutateOpcode, /*InsnID*/0, /*RecycleInsnID*/0, /*Opcode*/GIMT_Encode2(MyTarget::ADD),
1108 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
1109 // NOOPT-NEXT:    // GIR_Coverage, 26,
1110 // NOOPT-NEXT:    GIR_Done,
1111 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
1113 def : Pat<(add i32:$src1, i32:$src2),
1114           (ADD i32:$src1, i32:$src2)>;
1116 //===- Test another simple pattern with regclass operands. ----------------===//
1118 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
1119 // NOOPT-NEXT:    GIM_CheckFeatures, GIMT_Encode2(GIFBS_HasA_HasB_HasC),
1120 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/3,
1121 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_MUL),
1122 // NOOPT-NEXT:    // MIs[0] DstI[dst]
1123 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
1124 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
1125 // NOOPT-NEXT:    // MIs[0] src1
1126 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
1127 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
1128 // NOOPT-NEXT:    // MIs[0] src2
1129 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32,
1130 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/2, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
1131 // NOOPT-NEXT:    // (mul:{ *:[i32] } GPR32:{ *:[i32] }:$src1, GPR32:{ *:[i32] }:$src2) => (MUL:{ *:[i32] } GPR32:{ *:[i32] }:$src2, GPR32:{ *:[i32] }:$src1)
1132 // NOOPT-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::MUL),
1133 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, //  DstI[dst]
1134 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/2, // src2
1135 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/1, // src1
1136 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
1137 // NOOPT-NEXT:    // GIR_Coverage, 16,
1138 // NOOPT-NEXT:    GIR_EraseRootFromParent_Done,
1139 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
1141 def MUL : I<(outs GPR32:$dst), (ins GPR32:$src2, GPR32:$src1),
1142              [(set GPR32:$dst, (mul GPR32:$src1, GPR32:$src2))]>,
1143           Requires<[HasA, HasB, HasC]>;
1145 //===- Test a COPY_TO_REGCLASS --------------------------------------------===//
1148 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
1149 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/2,
1150 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_BITCAST),
1151 // NOOPT-NEXT:    // MIs[0] DstI[dst]
1152 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
1153 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
1154 // NOOPT-NEXT:    // MIs[0] src1
1155 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,
1156 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::FPR32RegClassID),
1157 // NOOPT-NEXT:    // (bitconvert:{ *:[i32] } FPR32:{ *:[f32] }:$src1) => (COPY_TO_REGCLASS:{ *:[i32] } FPR32:{ *:[f32] }:$src1, GPR32:{ *:[i32] })
1158 // NOOPT-NEXT:    GIR_MutateOpcode, /*InsnID*/0, /*RecycleInsnID*/0, /*Opcode*/GIMT_Encode2(TargetOpcode::COPY),
1159 // NOOPT-NEXT:    GIR_ConstrainOperandRC, /*InsnID*/0, /*Op*/0, GIMT_Encode2(MyTarget::GPR32RegClassID),
1160 // NOOPT-NEXT:    // GIR_Coverage, 27,
1161 // NOOPT-NEXT:    GIR_Done,
1162 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
1164 def : Pat<(i32 (bitconvert FPR32:$src1)),
1165           (COPY_TO_REGCLASS FPR32:$src1, GPR32)>;
1167 //===- Test a simple pattern with just a leaf immediate. ------------------===//
1169 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
1170 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/2,
1171 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_CONSTANT),
1172 // NOOPT-NEXT:    // MIs[0] DstI[dst]
1173 // NOOPT-NEXT:    GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_s32,
1174 // NOOPT-NEXT:    GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID),
1175 // NOOPT-NEXT:    // MIs[0] Operand 1
1176 // NOOPT-NEXT:    // No operand predicates
1177 // NOOPT-NEXT:    // (imm:{ *:[i32] }):$imm =>  (MOVimm:{ *:[i32] } (imm:{ *:[i32] }):$imm)
1178 // NOOPT-NEXT:    GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::MOVimm),
1179 // NOOPT-NEXT:    GIR_RootToRootCopy, /*OpIdx*/0, //  DstI[dst]
1180 // NOOPT-NEXT:    GIR_CopyConstantAsSImm, /*NewInsnID*/0, /*OldInsnID*/0, // imm
1181 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
1182 // NOOPT-NEXT:    // GIR_Coverage, 17,
1183 // NOOPT-NEXT:    GIR_EraseRootFromParent_Done,
1184 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
1186 def MOVimm : I<(outs GPR32:$dst), (ins i32imm:$imm), [(set GPR32:$dst, imm:$imm)]>;
1188 def fpimmz : FPImmLeaf<f32, [{ return Imm->isExactlyValue(0.0); }]>;
1189 def MOVfpimmz : I<(outs FPR32:$dst), (ins f32imm:$imm), [(set FPR32:$dst, fpimmz:$imm)]>;
1191 //===- Test a pattern with an MBB operand. --------------------------------===//
1193 // NOOPT-NEXT:  GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]),
1194 // NOOPT-NEXT:    GIM_CheckNumOperands, /*MI*/0, /*Expected*/1,
1195 // NOOPT-NEXT:    GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_BR),
1196 // NOOPT-NEXT:    // MIs[0] target
1197 // NOOPT-NEXT:    GIM_CheckIsMBB, /*MI*/0, /*Op*/0,
1198 // NOOPT-NEXT:    // (br (bb:{ *:[Other] }):$target) => (BR (bb:{ *:[Other] }):$target)
1199 // NOOPT-NEXT:    GIR_MutateOpcode, /*InsnID*/0, /*RecycleInsnID*/0, /*Opcode*/GIMT_Encode2(MyTarget::BR),
1200 // NOOPT-NEXT:    GIR_RootConstrainSelectedInstOperands,
1201 // NOOPT-NEXT:    // GIR_Coverage, 19,
1202 // NOOPT-NEXT:    GIR_Done,
1203 // NOOPT-NEXT:  // Label [[LABEL_NUM]]: @[[LABEL]]
1205 def BR : I<(outs), (ins unknown:$target),
1206             [(br bb:$target)]>;
1208 // NOOPT-NEXT:    GIM_Reject,
1209 // NOOPT-NEXT:  }; // Size: 1459 bytes
1210 // NOOPT-NEXT:  return MatchTable0;