[llvm] 7365b1c - [TableGen] Eliminate use of `convertInitializerTo` in SearchableTable (#109206)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 20 07:58:11 PDT 2024
Author: Rahul Joshi
Date: 2024-09-20T07:58:06-07:00
New Revision: 7365b1c7bb670d83b66e97628ccfc070c1abed94
URL: https://github.com/llvm/llvm-project/commit/7365b1c7bb670d83b66e97628ccfc070c1abed94
DIFF: https://github.com/llvm/llvm-project/commit/7365b1c7bb670d83b66e97628ccfc070c1abed94.diff
LOG: [TableGen] Eliminate use of `convertInitializerTo` in SearchableTable (#109206)
Eliminate use of `convertInitializerTo` as that needs a non-const
RecordKeeper (which we want to make const).
Added:
Modified:
llvm/utils/TableGen/SearchableTableEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/SearchableTableEmitter.cpp b/llvm/utils/TableGen/SearchableTableEmitter.cpp
index 37534fe4ca6afe..b5bf621b057383 100644
--- a/llvm/utils/TableGen/SearchableTableEmitter.cpp
+++ b/llvm/utils/TableGen/SearchableTableEmitter.cpp
@@ -31,17 +31,19 @@ using namespace llvm;
#define DEBUG_TYPE "searchable-table-emitter"
-namespace {
-
-int64_t getAsInt(Init *B) {
- return cast<IntInit>(
- B->convertInitializerTo(IntRecTy::get(B->getRecordKeeper())))
- ->getValue();
+static int64_t getAsInt(const Init *B) {
+ if (const BitsInit *BI = dyn_cast<BitsInit>(B))
+ return *BI->convertInitializerToInt();
+ if (const IntInit *II = dyn_cast<IntInit>(B))
+ return II->getValue();
+ llvm_unreachable("Unexpected initializer");
}
-int64_t getInt(Record *R, StringRef Field) {
+
+static int64_t getInt(const Record *R, StringRef Field) {
return getAsInt(R->getValueInit(Field));
}
+namespace {
struct GenericEnum {
using Entry = std::pair<StringRef, int64_t>;
More information about the llvm-commits
mailing list