Skip to content

[NFC][TableGen] Migrate LLVM Attribute Emitter to const RecordKeeper #107698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2024
Merged
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
13 changes: 4 additions & 9 deletions llvm/utils/TableGen/Attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ namespace {

class Attributes {
public:
Attributes(RecordKeeper &R) : Records(R) {}
Attributes(const RecordKeeper &R) : Records(R) {}
void run(raw_ostream &OS);

private:
void emitTargetIndependentNames(raw_ostream &OS);
void emitFnAttrCompatCheck(raw_ostream &OS, bool IsStringAttr);
void emitAttributeProperties(raw_ostream &OF);

RecordKeeper &Records;
const RecordKeeper &Records;
};

} // End anonymous namespace.
Expand Down Expand Up @@ -85,10 +85,7 @@ void Attributes::emitFnAttrCompatCheck(raw_ostream &OS, bool IsStringAttr) {
<< " const Function &Callee) {\n";
OS << " bool Ret = true;\n\n";

std::vector<Record *> CompatRules =
Records.getAllDerivedDefinitions("CompatRule");

for (auto *Rule : CompatRules) {
for (const Record *Rule : Records.getAllDerivedDefinitions("CompatRule")) {
StringRef FuncName = Rule->getValueAsString("CompatFunc");
OS << " Ret &= " << FuncName << "(Caller, Callee";
StringRef AttrName = Rule->getValueAsString("AttrName");
Expand All @@ -101,12 +98,10 @@ void Attributes::emitFnAttrCompatCheck(raw_ostream &OS, bool IsStringAttr) {
OS << " return Ret;\n";
OS << "}\n\n";

std::vector<Record *> MergeRules =
Records.getAllDerivedDefinitions("MergeRule");
OS << "static inline void mergeFnAttrs(Function &Caller,\n"
<< " const Function &Callee) {\n";

for (auto *Rule : MergeRules) {
for (const Record *Rule : Records.getAllDerivedDefinitions("MergeRule")) {
StringRef FuncName = Rule->getValueAsString("MergeFunc");
OS << " " << FuncName << "(Caller, Callee);\n";
}
Expand Down
Loading