Tablegen would generate code to access TargetResourceIndices with processor ID. The TargetProcResourceIndexStart[] array is generated for each processor which has itineraries. The processor which doesn't has itineraries is excluded from the array. When a target has mixed processors, the processor ID may exceed the array size and cause the error. This patch is to generate a table mapping processor with itineraries to resource index, so that scheduler can get the correct resource index with processor ID.
40 lines
1.2 KiB
TableGen
40 lines
1.2 KiB
TableGen
// RUN: llvm-tblgen -gen-dfa-packetizer -I %p/../../include %s | FileCheck %s
|
|
|
|
include "llvm/Target/Target.td"
|
|
|
|
def TestTarget : Target;
|
|
|
|
def TestSchedModel : SchedMachineModel {
|
|
let CompleteModel = 0;
|
|
}
|
|
|
|
def TestProcessor1 : ProcessorModel<"testprocessor1", TestSchedModel, []>;
|
|
|
|
def FU0 : FuncUnit;
|
|
def FU1 : FuncUnit;
|
|
|
|
def OP0 : InstrItinClass;
|
|
def OP1 : InstrItinClass;
|
|
|
|
def Itin {
|
|
list<InstrItinData> ItinList = [
|
|
InstrItinData<OP0, [InstrStage<1, [FU0]>]>,
|
|
InstrItinData<OP1, [InstrStage<1, [FU1]>]>,
|
|
];
|
|
}
|
|
|
|
// CHECK: int TestTargetGetResourceIndex(unsigned ProcID) {
|
|
// CHECK-NEXT: static const unsigned TestTargetProcIdToProcResourceIdxTable[][2] = {
|
|
// CHECK-NEXT: { 2, 1 }, // TestItinerariesModel
|
|
// CHECK-NEXT: };
|
|
// CHECK-NEXT: auto It = llvm::lower_bound(TestTargetProcIdToProcResourceIdxTable, ProcID,
|
|
// CHECK-NEXT: [](const unsigned LHS[], unsigned Val) { return LHS[0] < Val; });
|
|
// CHECK-NEXT: assert(*It[0] == ProcID);
|
|
// CHECK-NEXT: return (*It)[1];
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK: unsigned Index = TestTargetGetResourceIndex(IID->SchedModel.ProcID);
|
|
|
|
def TestItineraries: ProcessorItineraries<[], [], Itin.ItinList>;
|
|
def TestProcessor2 : Processor<"testprocessor2", TestItineraries, []>;
|