brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.9 KiB · e0b8024 Raw
90 lines · plain
1// RUN: llvm-tblgen -I %p/../../../include -gen-global-isel-combiner \2// RUN:     -combiners=MyCombiner %s | \3// RUN: FileCheck %s4 5include "llvm/Target/Target.td"6include "llvm/Target/GlobalISel/Combine.td"7 8def MyTargetISA : InstrInfo;9def MyTarget : Target { let InstructionSet = MyTargetISA; }10 11// emits a imm12def InstTest0 : GICombineRule<13  (defs root:$a),14  (match (COPY $a, (i32 0))),15  (apply (COPY $a, 0))>;16 17// implicitly emits a G_CONSTANT18def InstTest1 : GICombineRule<19  (defs root:$a),20  (match (G_ZEXT $a, 0)),21  (apply (COPY $a, (i32 0)))>;22 23// emits a CImm because G_CONSTANT is a special case.24def CImmInstTest1 : GICombineRule<25  (defs root:$a),26  (match (G_CONSTANT $a, (i32 0))),27  (apply (G_CONSTANT $a, (i32 42)))>;28 29def MyCombiner: GICombiner<"GenMyCombiner", [30  InstTest0,31  InstTest1,32  CImmInstTest133]>;34 35//      CHECK: const uint8_t *GenMyCombiner::getMatchTable() const {36// CHECK-NEXT:   constexpr static uint8_t MatchTable0[] = {37// CHECK-NEXT:     GIM_SwitchOpcode, /*MI*/0, /*[*/GIMT_Encode2(20), GIMT_Encode2({{[0-9]+}}), /*)*//*default:*//*Label 3*/ GIMT_Encode4([[L579:[0-9]+]]),38// CHECK-NEXT:     /*TargetOpcode::COPY*//*Label 0*/ GIMT_Encode4([[L462:[0-9]+]]), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0),39// CHECK-NEXT:     /*TargetOpcode::G_CONSTANT*//*Label 1*/ GIMT_Encode4([[L493:[0-9]+]]), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0),40// CHECK-NEXT:     /*TargetOpcode::G_ZEXT*//*Label 2*/ GIMT_Encode4({{[0-9]+}}),41// CHECK-NEXT:     // Label 0: @[[L462]]42// CHECK-NEXT:     GIM_Try, /*On fail goto*//*Label 4*/ GIMT_Encode4([[L492:[0-9]+]]), // Rule ID 0 //43// CHECK-NEXT:       GIM_CheckSimplePredicate, GIMT_Encode2(GICXXPred_Simple_IsRule0Enabled),44// CHECK-NEXT:       GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,45// CHECK-NEXT:       // MIs[0] a46// CHECK-NEXT:       // No operand predicates47// CHECK-NEXT:       GIM_CheckConstantInt8, /*MI*/0, /*Op*/1, 0,48// CHECK-NEXT:       // Combiner Rule #0: InstTest049// CHECK-NEXT:       GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(TargetOpcode::COPY),50// CHECK-NEXT:       GIR_RootToRootCopy, /*OpIdx*/0, // a51// CHECK-NEXT:       GIR_AddImm8, /*InsnID*/0, /*Imm*/0,52// CHECK-NEXT:       GIR_EraseRootFromParent_Done,53// CHECK-NEXT:     // Label 4: @[[L492]]54// CHECK-NEXT:     GIM_Reject,55// CHECK-NEXT:     // Label 1: @[[L493]]56// CHECK-NEXT:     GIM_Try, /*On fail goto*//*Label 5*/ GIMT_Encode4([[L538:[0-9]+]]), // Rule ID 2 //57// CHECK-NEXT:       GIM_CheckSimplePredicate, GIMT_Encode2(GICXXPred_Simple_IsRule2Enabled),58// CHECK-NEXT:       GIM_RootCheckType, /*Op*/1, /*Type*/GILLT_s32,59// CHECK-NEXT:       // MIs[0] a60// CHECK-NEXT:       // No operand predicates61// CHECK-NEXT:       GIM_CheckLiteralInt, /*MI*/0, /*Op*/1, GIMT_Encode8(0),62// CHECK-NEXT:       // Combiner Rule #2: CImmInstTest163// CHECK-NEXT:       GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(TargetOpcode::G_CONSTANT),64// CHECK-NEXT:       GIR_RootToRootCopy, /*OpIdx*/0, // a65// CHECK-NEXT:       GIR_AddCImm, /*InsnID*/0, /*Type*/GILLT_s32, /*Imm*/GIMT_Encode8(42),66// CHECK-NEXT:       GIR_EraseRootFromParent_Done,67// CHECK-NEXT:     // Label 5: @[[L538]]68// CHECK-NEXT:     GIM_Reject,69// CHECK-NEXT:     // Label 2: @{{[0-9]+}}70// CHECK-NEXT:     GIM_Try, /*On fail goto*//*Label 6*/ GIMT_Encode4([[L578:[0-9]+]]), // Rule ID 1 //71// CHECK-NEXT:       GIM_CheckSimplePredicate, GIMT_Encode2(GICXXPred_Simple_IsRule1Enabled),72// CHECK-NEXT:       // MIs[0] a73// CHECK-NEXT:       // No operand predicates74// CHECK-NEXT:       // MIs[0] Operand 175// CHECK-NEXT:       GIM_CheckConstantInt8, /*MI*/0, /*Op*/1, 0,76// CHECK-NEXT:       GIR_MakeTempReg, /*TempRegID*/0, /*TypeID*/GILLT_s32,77// CHECK-NEXT:       GIR_BuildConstant, /*TempRegID*/0, /*Val*/GIMT_Encode8(0),78// CHECK-NEXT:       // Combiner Rule #1: InstTest179// CHECK-NEXT:       GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(TargetOpcode::COPY),80// CHECK-NEXT:       GIR_RootToRootCopy, /*OpIdx*/0, // a81// CHECK-NEXT:       GIR_AddSimpleTempRegister, /*InsnID*/0, /*TempRegID*/0,82// CHECK-NEXT:       GIR_EraseRootFromParent_Done,83// CHECK-NEXT:     // Label 6: @[[L578]]84// CHECK-NEXT:     GIM_Reject,85// CHECK-NEXT:     // Label 3: @[[L579]]86// CHECK-NEXT:     GIM_Reject,87// CHECK-NEXT:     }; // Size: {{[0-9]+}} bytes88// CHECK-NEXT:   return MatchTable0;89// CHECK-NEXT: }90