Skip to content

Commit ed7c7ea

Browse files
committed
fixup! [RISCV] Add searchable table for tune information
Define RISCVTuneInfo by need and fail back to generic if no related RISCVTuneInfo existed
1 parent 711d868 commit ed7c7ea

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

llvm/lib/Target/RISCV/RISCVProcessors.td

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,34 @@ def getRISCVTuneInfo : SearchIndex {
2626
let Key = ["Name"];
2727
}
2828

29+
class GenericTuneInfo: RISCVTuneInfo;
30+
2931
class RISCVProcessorModel<string n,
3032
SchedMachineModel m,
3133
list<SubtargetFeature> f,
3234
list<SubtargetFeature> tunef = [],
3335
string default_march = "">
34-
: ProcessorModel<n, m, f, tunef>, RISCVTuneInfo {
36+
: ProcessorModel<n, m, f, tunef> {
3537
string DefaultMarch = default_march;
3638
}
3739

3840
class RISCVTuneProcessorModel<string n,
3941
SchedMachineModel m,
4042
list<SubtargetFeature> tunef = [],
4143
list<SubtargetFeature> f = []>
42-
: ProcessorModel<n, m, f,tunef>, RISCVTuneInfo;
44+
: ProcessorModel<n, m, f,tunef>;
4345

4446
def GENERIC_RV32 : RISCVProcessorModel<"generic-rv32",
4547
NoSchedModel,
46-
[Feature32Bit]>;
48+
[Feature32Bit]>,
49+
GenericTuneInfo;
4750
def GENERIC_RV64 : RISCVProcessorModel<"generic-rv64",
4851
NoSchedModel,
49-
[Feature64Bit]>;
52+
[Feature64Bit]>,
53+
GenericTuneInfo;
5054
// Support generic for compatibility with other targets. The triple will be used
5155
// to change to the appropriate rv32/rv64 version.
52-
def : ProcessorModel<"generic", NoSchedModel, []>;
56+
def : ProcessorModel<"generic", NoSchedModel, []>, GenericTuneInfo;
5357

5458
def ROCKET_RV32 : RISCVProcessorModel<"rocket-rv32",
5559
RocketModel,

llvm/lib/Target/RISCV/RISCVSubtarget.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,12 @@ RISCVSubtarget::initializeSubtargetDependencies(const Triple &TT, StringRef CPU,
7171
if (TuneCPU.empty())
7272
TuneCPU = CPU;
7373

74-
ParseSubtargetFeatures(CPU, TuneCPU, FS);
7574
TuneInfo = RISCVTuneInfoTable::getRISCVTuneInfo(TuneCPU);
75+
// If there is no TuneInfo for this CPU, we fail back to generic.
76+
if (!TuneInfo)
77+
TuneInfo = RISCVTuneInfoTable::getRISCVTuneInfo("generic");
78+
79+
ParseSubtargetFeatures(CPU, TuneCPU, FS);
7680
TargetABI = RISCVABI::computeTargetABI(TT, getFeatureBits(), ABIName);
7781
RISCVFeatures::validate(TT, getFeatureBits());
7882
return *this;

0 commit comments

Comments
 (0)