aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/Builtins.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2024-12-17 19:21:27 +0000
committerChandler Carruth <chandlerc@gmail.com>2025-02-04 18:04:58 +0000
commit212ecb9d5caaa7cc721edd981f36384ddfccfa5d (patch)
treeea504bf9ccc8ed9ab082610568c3d23fc77b19fe /clang/lib/Basic/Builtins.cpp
parent64ea3f5a4720105d166b034d5a34d92475579e64 (diff)
downloadllvm-212ecb9d5caaa7cc721edd981f36384ddfccfa5d.zip
llvm-212ecb9d5caaa7cc721edd981f36384ddfccfa5d.tar.gz
llvm-212ecb9d5caaa7cc721edd981f36384ddfccfa5d.tar.bz2
[StrTable] Teach main builtin TableGen to use direct enums, strings, and info
This moves the main builtins and several targets to use nice generated string tables and info structures rather than X-macros. Even without obvious prefixes factored out, the resulting tables are significantly smaller and much cheaper to compile with out all the X-macro overhead. This leaves the X-macros in place for atomic builtins which have a wide range of uses that don't seem reasonable to fold into TableGen. As future work, these should move to their own file (whether as X-macros or just generated patterns) so the AST headers don't have to include all the data for other builtins.
Diffstat (limited to 'clang/lib/Basic/Builtins.cpp')
-rw-r--r--clang/lib/Basic/Builtins.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/clang/lib/Basic/Builtins.cpp b/clang/lib/Basic/Builtins.cpp
index e5b0ff5..e7829a4 100644
--- a/clang/lib/Basic/Builtins.cpp
+++ b/clang/lib/Basic/Builtins.cpp
@@ -29,23 +29,19 @@ const char *HeaderDesc::getName() const {
llvm_unreachable("Unknown HeaderDesc::HeaderID enum");
}
-static constexpr llvm::StringTable BuiltinStrings =
- CLANG_BUILTIN_STR_TABLE_START
- // We inject a non-builtin string into the table.
- CLANG_BUILTIN_STR_TABLE("not a builtin function", "", "")
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
+static constexpr unsigned NumBuiltins = Builtin::FirstTSBuiltin;
+
+#define GET_BUILTIN_STR_TABLE
#include "clang/Basic/Builtins.inc"
- ;
-static_assert(BuiltinStrings.size() < 100'000);
-
-static constexpr auto BuiltinInfos =
- Builtin::MakeInfos<Builtin::FirstTSBuiltin>(
- {CLANG_BUILTIN_ENTRY("not a builtin function", "", "")
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define LANGBUILTIN CLANG_LANGBUILTIN_ENTRY
-#define LIBBUILTIN CLANG_LIBBUILTIN_ENTRY
+#undef GET_BUILTIN_STR_TABLE
+
+static constexpr Builtin::Info BuiltinInfos[] = {
+ Builtin::Info{}, // No-builtin info entry.
+#define GET_BUILTIN_INFOS
#include "clang/Basic/Builtins.inc"
- });
+#undef GET_BUILTIN_INFOS
+};
+static_assert(std::size(BuiltinInfos) == NumBuiltins);
std::pair<const Builtin::InfosShard &, const Builtin::Info &>
Builtin::Context::getShardAndInfo(unsigned ID) const {