[llvm] [TableGen] Migrate LLVM Attribute Emitter to const RecordKeeper (PR #107698)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 7 05:45:26 PDT 2024
https://github.com/jurahul created https://github.com/llvm/llvm-project/pull/107698
None
>From 6934179ef9ffcd631abda54ae6962aa691255746 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Sat, 7 Sep 2024 05:44:07 -0700
Subject: [PATCH] [TableGen] Migrate LLVM Attribute Emitter to const
RecordKeeper
---
llvm/utils/TableGen/Attributes.cpp | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/llvm/utils/TableGen/Attributes.cpp b/llvm/utils/TableGen/Attributes.cpp
index c50316985ef098..8d16ff89aae0f2 100644
--- a/llvm/utils/TableGen/Attributes.cpp
+++ b/llvm/utils/TableGen/Attributes.cpp
@@ -17,7 +17,7 @@ namespace {
class Attributes {
public:
- Attributes(RecordKeeper &R) : Records(R) {}
+ Attributes(const RecordKeeper &R) : Records(R) {}
void run(raw_ostream &OS);
private:
@@ -25,7 +25,7 @@ class Attributes {
void emitFnAttrCompatCheck(raw_ostream &OS, bool IsStringAttr);
void emitAttributeProperties(raw_ostream &OF);
- RecordKeeper &Records;
+ const RecordKeeper &Records;
};
} // End anonymous namespace.
@@ -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");
@@ -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";
}
More information about the llvm-commits
mailing list