[clang] Patch series to reapply #118734 and substantially improve it (PR #120534)
Chandler Carruth via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 22 03:10:23 PST 2024
================
@@ -68,23 +70,144 @@ enum ID {
FirstTSBuiltin
};
+// The info used to represent each builtin.
struct Info {
- llvm::StringLiteral Name;
- const char *Type, *Attributes;
- const char *Features;
+ // Rather than store pointers to the string literals describing these four
+ // aspects of builtins, we store offsets into a common string table.
+ struct StrOffsets {
+ llvm::StringTable::Offset Name;
+ llvm::StringTable::Offset Type;
+ llvm::StringTable::Offset Attributes;
+ llvm::StringTable::Offset Features;
+ } Offsets;
+
HeaderDesc Header;
LanguageID Langs;
};
+// A constexpr function to construct an infos array from X-macros.
+//
+// The input array uses the same data structure, but the offsets are actually
+// _lengths_ when input. This is all we can compute from the X-macro approach to
+// builtins. This function will convert these lengths into actual offsets to a
+// string table built up through sequentially appending strings with the given
+// lengths.
+template <size_t N>
+static constexpr std::array<Info, N> MakeInfos(std::array<Info, N> Infos) {
+ // Translate lengths to offsets. We start past the initial empty string at
+ // offset zero.
+ unsigned Offset = 1;
+ for (auto &I : Infos) {
----------------
chandlerc wrote:
Sure, switched.
https://github.com/llvm/llvm-project/pull/120534
More information about the cfe-commits
mailing list