1 // RUN: llvm-tblgen -gen-dag-isel -I %p/../../include -I %p/Common %s 2>&1 | FileCheck -check-prefixes=SDAG,SCUSTOM %s
2 // RUN: llvm-tblgen -gen-dag-isel -I %p/../../include -I %p/Common %s -DHASONEUSE 2>&1 | FileCheck -check-prefixes=SDAG,SBUILTIN %s
3 // RUN: llvm-tblgen -gen-global-isel -I %p/../../include -I %p/Common %s 2>&1 | FileCheck -check-prefixes=GISEL,GCUSTOM %s
4 // RUN: llvm-tblgen -gen-global-isel -I %p/../../include -I %p/Common %s -DHASONEUSE 2>&1 | FileCheck -check-prefixes=GISEL,GBUILTIN %s
6 include "llvm/Target/Target.td"
7 include "GlobalISelEmitterCommon.td"
9 // Test that a predicate works when there are multiple pattern trees
12 def int_tgt_mul24 : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty]>;
13 def int_tgt_mul24_2 : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty]>;
15 def TGTmul24_impl : SDNode<"TargetISD::MUL24", SDTIntBinOp>;
17 def TGTmul24 : PatFrags<(ops node:$src0, node:$src1),
18 [(int_tgt_mul24 node:$src0, node:$src1),
19 (TGTmul24_impl node:$src0, node:$src1)]>;
22 def G_TGT_MUL24 : GenericInstruction {
23 let Namespace = "MyTarget";
24 let OutOperandList = (outs type0:$dst);
25 let InOperandList = (ins type0:$src1, type0:$src2);
26 let hasSideEffects = 0;
31 def : GINodeEquiv<G_TGT_MUL24, TGTmul24_impl>;
34 def TGTmul24_oneuse : PatFrag<
35 (ops node:$src0, node:$src1),
36 (TGTmul24 $src0, $src1)
38 , [{ return N->hasOneUse(); }]> {
39 let GISelPredicateCode = [{
40 return MRI->hasOneNonDBGUse(MI.getOperand(0).getReg());
48 // SDAG: OPC_CheckOpcode, TARGET_VAL(ISD::INTRINSIC_W_CHAIN),
49 // SDAG: OPC_CheckPredicate0, // Predicate_TGTmul24_oneuse
51 // SDAG: OPC_CheckOpcode, TARGET_VAL(TargetISD::MUL24),
52 // SDAG: OPC_CheckPredicate0, // Predicate_TGTmul24_oneuse
54 // SCUSTOM: return N->hasOneUse();
55 // SBUILTIN: if (!SDValue(N, 0).hasOneUse()) return false;
57 // GISEL: GIM_CheckOpcode, /*MI*/1, GIMT_Encode2(TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS),
58 // GISEL: GIM_CheckIntrinsicID, /*MI*/1, /*Op*/1, GIMT_Encode2(Intrinsic::tgt_mul24),
59 // GBUILTIN: GIM_CheckHasOneUse, /*MI*/1,
60 // GCUSTOM: GIM_CheckCxxInsnPredicate, /*MI*/1, /*FnId*/GIMT_Encode2(GICXXPred_MI_Predicate_TGTmul24_oneuse),
62 // GISEL: GIM_CheckOpcode, /*MI*/1, GIMT_Encode2(TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS),
63 // GISEL: GIM_CheckIntrinsicID, /*MI*/1, /*Op*/1, GIMT_Encode2(Intrinsic::tgt_mul24),
64 // GBUILTIN: GIM_CheckHasOneUse, /*MI*/1,
65 // GCUSTOM: GIM_CheckCxxInsnPredicate, /*MI*/1, /*FnId*/GIMT_Encode2(GICXXPred_MI_Predicate_TGTmul24_oneuse),
67 // GISEL: GIM_CheckOpcode, /*MI*/1, GIMT_Encode2(MyTarget::G_TGT_MUL24),
68 // GBUILTIN: GIM_CheckHasOneUse, /*MI*/1,
69 // GCUSTOM: GIM_CheckCxxInsnPredicate, /*MI*/1, /*FnId*/GIMT_Encode2(GICXXPred_MI_Predicate_TGTmul24_oneuse),
71 // GISEL: GIM_CheckOpcode, /*MI*/1, GIMT_Encode2(MyTarget::G_TGT_MUL24),
72 // GBUILTIN: GIM_CheckHasOneUse, /*MI*/1,
73 // GCUSTOM: GIM_CheckCxxInsnPredicate, /*MI*/1, /*FnId*/GIMT_Encode2(GICXXPred_MI_Predicate_TGTmul24_oneuse),
76 (ins GPR32:$src0, GPR32:$src1, GPR32:$src2),
77 [(set GPR32:$dst, (add (TGTmul24_oneuse i32:$src0, i32:$src1), i32:$src2))]>;