1// RUN: llvm-tblgen %s -gen-global-isel -optimize-match-table=true -I %p/../../include -I %p/Common -o - | FileCheck %s
2
3include "llvm/Target/Target.td"
4include "GlobalISelEmitterCommon.td"
5
6def InstTwoOperands : I<(outs GPR32:$dst), (ins GPR32:$src1, GPR32:$src2), []>;
7def InstThreeOperands : I<(outs GPR32:$dst), (ins GPR32:$cond, GPR32:$src,GPR32:$src2), []>;
8
9// Make sure the GIM_CheckIsSameOperand check is not hoisted into the common header group
10
11// CHECK:       GIM_Try, /*On fail goto*//*Label 1*/
12// CHECK-NEXT:  GIM_CheckRegBankForClass, /*MI*/0, /*Op*/0, /*RC*/MyTarget::GPR32RegClassID,
13// CHECK-NOT:   GIM_CheckIsSameOperand
14// CHECK-NEXT:  GIM_Try, /*On fail goto*//*Label 2*/
15// CHECK:       GIM_CheckIsSameOperand, /*MI*/0, /*OpIdx*/3, /*OtherMI*/2, /*OtherOpIdx*/1,
16// CHECK:       // Label 2
17// CHECK-NEXT:  GIM_Try, /*On fail goto*//*Label 3*/
18// CHECK:       GIM_CheckIsSameOperand, /*MI*/0, /*OpIdx*/3, /*OtherMI*/2, /*OtherOpIdx*/2,
19// CHECK:       // Label 1
20def : Pat<(i32 (select GPR32:$cond, GPR32:$src1, GPR32:$src2)),
21          (InstThreeOperands GPR32:$cond, GPR32:$src1, GPR32:$src2)>;
22
23def : Pat<(i32 (select (i32 (setcc GPR32:$cond, (i32 0), (OtherVT SETEQ))),
24                      (i32 (add GPR32:$src1, GPR32:$const)),
25                       GPR32:$src1)),
26          (InstThreeOperands GPR32:$cond, GPR32:$src1, GPR32:$const)>;
27