1 // RUN: llvm-tblgen -gen-dag-isel -I %p/../../include -I %p/Common %s 2>&1 | FileCheck -check-prefix=SDAG %s
2 // RUN: llvm-tblgen -gen-global-isel -I %p/../../include -I %p/Common %s 2>&1 | FileCheck -check-prefix=GISEL %s
4 include "llvm/Target/Target.td"
5 include "GlobalISelEmitterCommon.td"
7 // Test that a predicate works when there are multiple pattern trees
10 def int_tgt_mul24 : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty]>;
11 def int_tgt_mul24_2 : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty]>;
13 def TGTmul24_impl : SDNode<"TargetISD::MUL24", SDTIntBinOp>;
15 def TGTmul24 : PatFrags<(ops node:$src0, node:$src1),
16 [(int_tgt_mul24 node:$src0, node:$src1),
17 (TGTmul24_impl node:$src0, node:$src1)]>;
20 def G_TGT_MUL24 : GenericInstruction {
21 let Namespace = "MyTarget";
22 let OutOperandList = (outs type0:$dst);
23 let InOperandList = (ins type0:$src1, type0:$src2);
24 let hasSideEffects = 0;
29 def : GINodeEquiv<G_TGT_MUL24, TGTmul24_impl>;
32 def TGTmul24_oneuse : PatFrag<
33 (ops node:$src0, node:$src1),
34 (TGTmul24 $src0, $src1),
35 [{ return N->hasOneUse(); }]> {
36 let GISelPredicateCode = [{
37 return MRI->hasOneNonDBGUse(MI.getOperand(0).getReg());
41 // SDAG: OPC_CheckOpcode, TARGET_VAL(ISD::INTRINSIC_W_CHAIN),
42 // SDAG: OPC_CheckPredicate, 0, // Predicate_TGTmul24_oneuse
44 // SDAG: OPC_CheckOpcode, TARGET_VAL(TargetISD::MUL24),
45 // SDAG: OPC_CheckPredicate, 0, // Predicate_TGTmul24_oneuse
47 // GISEL: GIM_CheckOpcode, /*MI*/1, TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS,
48 // GISEL: GIM_CheckIntrinsicID, /*MI*/1, /*Op*/1, Intrinsic::tgt_mul24,
49 // GISEL: GIM_CheckCxxInsnPredicate, /*MI*/1, /*FnId*/GICXXPred_MI_Predicate_TGTmul24_oneuse,
51 // GISEL: GIM_CheckOpcode, /*MI*/1, TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS,
52 // GISEL: GIM_CheckIntrinsicID, /*MI*/1, /*Op*/1, Intrinsic::tgt_mul24,
53 // GISEL: GIM_CheckCxxInsnPredicate, /*MI*/1, /*FnId*/GICXXPred_MI_Predicate_TGTmul24_oneuse,
55 // GISEL: GIM_CheckOpcode, /*MI*/1, MyTarget::G_TGT_MUL24,
56 // GISEL: GIM_CheckCxxInsnPredicate, /*MI*/1, /*FnId*/GICXXPred_MI_Predicate_TGTmul24_oneuse,
58 // GISEL: GIM_CheckOpcode, /*MI*/1, MyTarget::G_TGT_MUL24,
59 // GISEL: GIM_CheckCxxInsnPredicate, /*MI*/1, /*FnId*/GICXXPred_MI_Predicate_TGTmul24_oneuse,
62 (ins GPR32:$src0, GPR32:$src1, GPR32:$src2),
63 [(set GPR32:$dst, (add (TGTmul24_oneuse i32:$src0, i32:$src1), i32:$src2))]>;