}
void llvm::EmitRISCVTargetDef(const RecordKeeper &RK, raw_ostream &OS) {
- using MapTy = std::pair<const std::string, std::unique_ptr<llvm::Record>>;
- using RecordMap = std::map<std::string, std::unique_ptr<Record>, std::less<>>;
- const RecordMap &Map = RK.getDefs();
-
OS << "#ifndef PROC\n"
<< "#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH)\n"
<< "#endif\n\n";
OS << "PROC(INVALID, {\"invalid\"}, FK_INVALID, {\"\"})\n";
// Iterate on all definition records.
- for (const MapTy &Def : Map) {
- const Record &Rec = *(Def.second);
- if (Rec.isSubClassOf("RISCVProcessorModel")) {
- int XLen = getXLen(Rec);
- std::string MArch = Rec.getValueAsString("DefaultMarch").str();
-
- // Compute MArch from features if we don't specify it.
- if (MArch.empty())
- MArch = getMArch(XLen, Rec);
-
- OS << "PROC(" << Rec.getName() << ", "
- << "{\"" << Rec.getValueAsString("Name") << "\"},"
- << getEnumFeatures(XLen) << ", "
- << "{\"" << MArch << "\"})\n";
- }
+ for (const Record *Rec : RK.getAllDerivedDefinitions("RISCVProcessorModel")) {
+ int XLen = getXLen(*Rec);
+ std::string MArch = Rec->getValueAsString("DefaultMarch").str();
+
+ // Compute MArch from features if we don't specify it.
+ if (MArch.empty())
+ MArch = getMArch(XLen, *Rec);
+
+ OS << "PROC(" << Rec->getName() << ", "
+ << "{\"" << Rec->getValueAsString("Name") << "\"},"
+ << getEnumFeatures(XLen) << ", "
+ << "{\"" << MArch << "\"})\n";
}
OS << "\n#undef PROC\n";
OS << "\n";
<< "#define TUNE_PROC(ENUM, NAME)\n"
<< "#endif\n\n";
OS << "TUNE_PROC(GENERIC, \"generic\")\n";
- for (const MapTy &Def : Map) {
- const Record &Rec = *(Def.second);
- if (Rec.isSubClassOf("RISCVTuneProcessorModel"))
- OS << "TUNE_PROC(" << Rec.getName() << ", "
- << "\"" << Rec.getValueAsString("Name") << "\")\n";
+
+ for (const Record *Rec :
+ RK.getAllDerivedDefinitions("RISCVTuneProcessorModel")) {
+ OS << "TUNE_PROC(" << Rec->getName() << ", "
+ << "\"" << Rec->getValueAsString("Name") << "\")\n";
}
OS << "\n#undef TUNE_PROC\n";