Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ static StringRef getExtensionName(const Record *R) {
}

static void printExtensionTable(raw_ostream &OS,
const std::vector<Record *> &Extensions,
ArrayRef<const Record *> Extensions,
bool Experimental) {
OS << "static const RISCVSupportedExtension Supported";
if (Experimental)
OS << "Experimental";
OS << "Extensions[] = {\n";

for (Record *R : Extensions) {
for (const Record *R : Extensions) {
if (R->getValueAsBit("Experimental") != Experimental)
continue;

Expand All @@ -44,11 +44,11 @@ static void printExtensionTable(raw_ostream &OS,
OS << "};\n\n";
}

static void emitRISCVExtensions(RecordKeeper &Records, raw_ostream &OS) {
static void emitRISCVExtensions(const RecordKeeper &Records, raw_ostream &OS) {
OS << "#ifdef GET_SUPPORTED_EXTENSIONS\n";
OS << "#undef GET_SUPPORTED_EXTENSIONS\n\n";

std::vector<Record *> Extensions =
std::vector<const Record *> Extensions =
Records.getAllDerivedDefinitionsIfDefined("RISCVExtension");
llvm::sort(Extensions, [](const Record *Rec1, const Record *Rec2) {
return getExtensionName(Rec1) < getExtensionName(Rec2);
Expand All @@ -66,7 +66,7 @@ static void emitRISCVExtensions(RecordKeeper &Records, raw_ostream &OS) {

if (!Extensions.empty()) {
OS << "\nstatic constexpr ImpliedExtsEntry ImpliedExts[] = {\n";
for (Record *Ext : Extensions) {
for (const Record *Ext : Extensions) {
auto ImpliesList = Ext->getValueAsListOfDefs("Implies");
if (ImpliesList.empty())
continue;
Expand Down Expand Up @@ -94,12 +94,12 @@ static void emitRISCVExtensions(RecordKeeper &Records, raw_ostream &OS) {
//
// This is almost the same as RISCVFeatures::parseFeatureBits, except that we
// get feature name from feature records instead of feature bits.
static void printMArch(raw_ostream &OS, const std::vector<Record *> &Features) {
static void printMArch(raw_ostream &OS, ArrayRef<const Record *> Features) {
RISCVISAUtils::OrderedExtensionMap Extensions;
unsigned XLen = 0;

// Convert features to FeatureVector.
for (auto *Feature : Features) {
for (const Record *Feature : Features) {
StringRef FeatureName = getExtensionName(Feature);
if (Feature->isSubClassOf("RISCVExtension")) {
unsigned Major = Feature->getValueAsInt("MajorVersion");
Expand All @@ -124,7 +124,7 @@ static void printMArch(raw_ostream &OS, const std::vector<Record *> &Features) {
}

static void printProfileTable(raw_ostream &OS,
const std::vector<Record *> &Profiles,
ArrayRef<const Record *> Profiles,
bool Experimental) {
OS << "static constexpr RISCVProfile Supported";
if (Experimental)
Expand All @@ -145,7 +145,7 @@ static void printProfileTable(raw_ostream &OS,
OS << "};\n\n";
}

static void emitRISCVProfiles(RecordKeeper &Records, raw_ostream &OS) {
static void emitRISCVProfiles(const RecordKeeper &Records, raw_ostream &OS) {
OS << "#ifdef GET_SUPPORTED_PROFILES\n";
OS << "#undef GET_SUPPORTED_PROFILES\n\n";

Expand All @@ -163,7 +163,7 @@ static void emitRISCVProfiles(RecordKeeper &Records, raw_ostream &OS) {
OS << "#endif // GET_SUPPORTED_PROFILES\n\n";
}

static void emitRISCVProcs(RecordKeeper &RK, raw_ostream &OS) {
static void emitRISCVProcs(const RecordKeeper &RK, raw_ostream &OS) {
OS << "#ifndef PROC\n"
<< "#define PROC(ENUM, NAME, DEFAULT_MARCH, FAST_SCALAR_UNALIGN"
<< ", FAST_VECTOR_UNALIGN)\n"
Expand Down Expand Up @@ -210,9 +210,8 @@ static void emitRISCVProcs(RecordKeeper &RK, raw_ostream &OS) {
OS << "\n#undef TUNE_PROC\n";
}

static void emitRISCVExtensionBitmask(RecordKeeper &RK, raw_ostream &OS) {

std::vector<Record *> Extensions =
static void emitRISCVExtensionBitmask(const RecordKeeper &RK, raw_ostream &OS) {
std::vector<const Record *> Extensions =
RK.getAllDerivedDefinitionsIfDefined("RISCVExtensionBitmask");
llvm::sort(Extensions, [](const Record *Rec1, const Record *Rec2) {
return getExtensionName(Rec1) < getExtensionName(Rec2);
Expand Down Expand Up @@ -245,7 +244,7 @@ static void emitRISCVExtensionBitmask(RecordKeeper &RK, raw_ostream &OS) {
OS << "#endif\n";
}

static void EmitRISCVTargetDef(RecordKeeper &RK, raw_ostream &OS) {
static void EmitRISCVTargetDef(const RecordKeeper &RK, raw_ostream &OS) {
emitRISCVExtensions(RK, OS);
emitRISCVProfiles(RK, OS);
emitRISCVProcs(RK, OS);
Expand Down
7 changes: 3 additions & 4 deletions llvm/utils/TableGen/VTEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ namespace {

class VTEmitter {
private:
RecordKeeper &Records;
const RecordKeeper &Records;

public:
VTEmitter(RecordKeeper &R) : Records(R) {}
VTEmitter(const RecordKeeper &R) : Records(R) {}

void run(raw_ostream &OS);
};
Expand Down Expand Up @@ -91,8 +91,7 @@ void VTEmitter::run(raw_ostream &OS) {
emitSourceFileHeader("ValueTypes Source Fragment", OS, Records);

std::vector<const Record *> VTsByNumber{512};
auto ValueTypes = Records.getAllDerivedDefinitions("ValueType");
for (auto *VT : ValueTypes) {
for (auto *VT : Records.getAllDerivedDefinitions("ValueType")) {
auto Number = VT->getValueAsInt("Value");
assert(0 <= Number && Number < (int)VTsByNumber.size() &&
"ValueType should be uint16_t");
Expand Down