1// RUN: llvm-tblgen -gen-global-isel -warn-on-skipped-patterns -optimize-match-table=false -I %p/../../include -I %p/Common %s -o - | FileCheck -check-prefix=GISEL %s 2 3include "llvm/Target/Target.td" 4include "GlobalISelEmitterCommon.td" 5 6def int_mytarget_sleep : Intrinsic<[], [llvm_i32_ty], [ImmArg<ArgIndex<0>>]>; 7 8def G_TGT_CAT : MyTargetGenericInstruction { 9 let OutOperandList = (outs type0:$dst); 10 let InOperandList = (ins type1:$src0, untyped_imm_0:$immfield); 11} 12 13def TgtCat : SDNode<"MyTgt::CAT", SDTIntBinOp>; 14def : GINodeEquiv<G_TGT_CAT, TgtCat>; 15 16 17def SLEEP0 : I<(outs), (ins), []>; 18def SLEEP1 : I<(outs), (ins), []>; 19def CAT0 : I<(outs GPR32:$dst), (ins GPR32:$src0), []>; 20def CAT1 : I<(outs GPR32:$dst), (ins GPR32:$src0), []>; 21 22// Test immarg intrinsic pattern 23 24// Make sure there is no type check. 25// GISEL: GIM_CheckOpcode, /*MI*/0, TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS, 26// GISEL: GIM_CheckIntrinsicID, /*MI*/0, /*Op*/0, Intrinsic::mytarget_sleep, 27// GISEL-NEXT: // MIs[0] Operand 1 28// GISEL-NEXT: GIM_CheckLiteralInt, /*MI*/0, /*Op*/1, 0, 29def : Pat< 30 (int_mytarget_sleep 0), 31 (SLEEP0) 32>; 33 34// GISEL: GIM_CheckOpcode, /*MI*/0, TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS, 35// GISEL: GIM_CheckIntrinsicID, /*MI*/0, /*Op*/0, Intrinsic::mytarget_sleep, 36// GISEL-NEXT: // MIs[0] Operand 1 37// GISEL-NEXT: GIM_CheckLiteralInt, /*MI*/0, /*Op*/1, 1, 38def : Pat< 39 (int_mytarget_sleep 1), 40 (SLEEP1) 41>; 42 43// Check a non-intrinsic instruction with an immediate parameter. 44 45// GISEL: GIM_CheckOpcode, /*MI*/0, MyTarget::G_TGT_CAT, 46// GISEL: GIM_CheckType, /*MI*/0, /*Op*/1, /*Type*/GILLT_s32, 47// GISEL-NEXT: // MIs[0] Operand 2 48// GISEL-NEXT: GIM_CheckLiteralInt, /*MI*/0, /*Op*/2, 0, 49def : Pat< 50 (TgtCat i32:$src0, 0), 51 (CAT0 GPR32:$src0) 52>; 53 54// GISEL: GIM_CheckOpcode, /*MI*/0, MyTarget::G_TGT_CAT, 55// GISEL: GIM_CheckType, /*MI*/0, /*Op*/1, /*Type*/GILLT_s32, 56// GISEL-NEXT: // MIs[0] Operand 2 57// GISEL-NEXT: GIM_CheckLiteralInt, /*MI*/0, /*Op*/2, 93, 58def : Pat< 59 (TgtCat i32:$src0, 93), 60 (CAT1 GPR32:$src0) 61>; 62 63