[llvm-branch-commits] [clang] 333befd - Revert "Switch builtin strings to use string tables (#118734)"
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Dec 11 15:59:38 PST 2024
Author: Chandler Carruth
Date: 2024-12-11T15:59:35-08:00
New Revision: 333befd054fb5da81f1349c8eba7255aa4e3ec12
URL: https://github.com/llvm/llvm-project/commit/333befd054fb5da81f1349c8eba7255aa4e3ec12
DIFF: https://github.com/llvm/llvm-project/commit/333befd054fb5da81f1349c8eba7255aa4e3ec12.diff
LOG: Revert "Switch builtin strings to use string tables (#118734)"
This reverts commit be2df95e9281985b61270bb6420ea0eeeffbbe59.
Added:
Modified:
clang/include/clang/Basic/Builtins.h
clang/include/clang/Basic/BuiltinsPPC.def
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/Builtins.cpp
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/AArch64.h
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/ARC.h
clang/lib/Basic/Targets/ARM.cpp
clang/lib/Basic/Targets/ARM.h
clang/lib/Basic/Targets/AVR.h
clang/lib/Basic/Targets/BPF.cpp
clang/lib/Basic/Targets/BPF.h
clang/lib/Basic/Targets/CSKY.cpp
clang/lib/Basic/Targets/CSKY.h
clang/lib/Basic/Targets/DirectX.h
clang/lib/Basic/Targets/Hexagon.cpp
clang/lib/Basic/Targets/Hexagon.h
clang/lib/Basic/Targets/Lanai.h
clang/lib/Basic/Targets/LoongArch.cpp
clang/lib/Basic/Targets/LoongArch.h
clang/lib/Basic/Targets/M68k.cpp
clang/lib/Basic/Targets/M68k.h
clang/lib/Basic/Targets/MSP430.h
clang/lib/Basic/Targets/Mips.cpp
clang/lib/Basic/Targets/Mips.h
clang/lib/Basic/Targets/NVPTX.cpp
clang/lib/Basic/Targets/NVPTX.h
clang/lib/Basic/Targets/PNaCl.h
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Basic/Targets/RISCV.h
clang/lib/Basic/Targets/SPIR.cpp
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/Sparc.h
clang/lib/Basic/Targets/SystemZ.cpp
clang/lib/Basic/Targets/SystemZ.h
clang/lib/Basic/Targets/TCE.h
clang/lib/Basic/Targets/VE.cpp
clang/lib/Basic/Targets/VE.h
clang/lib/Basic/Targets/WebAssembly.cpp
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Basic/Targets/X86.cpp
clang/lib/Basic/Targets/X86.h
clang/lib/Basic/Targets/XCore.cpp
clang/lib/Basic/Targets/XCore.h
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/Builtins.h b/clang/include/clang/Basic/Builtins.h
index a9bb6efe850cc6..89f65682ae5b41 100644
--- a/clang/include/clang/Basic/Builtins.h
+++ b/clang/include/clang/Basic/Builtins.h
@@ -55,7 +55,6 @@ struct HeaderDesc {
#undef HEADER
} ID;
- constexpr HeaderDesc() : ID() {}
constexpr HeaderDesc(HeaderID ID) : ID(ID) {}
const char *getName() const;
@@ -69,140 +68,14 @@ enum ID {
FirstTSBuiltin
};
-// The info used to represent each builtin.
struct Info {
- // Rather than store pointers to the string literals describing these four
- // aspects of builtins, we store offsets into a common string table.
- struct StrOffsets {
- int Name;
- int Type;
- int Attributes;
- int Features;
- } Offsets;
-
+ llvm::StringLiteral Name;
+ const char *Type, *Attributes;
+ const char *Features;
HeaderDesc Header;
LanguageID Langs;
};
-// The storage for `N` builtins. This contains a single pointer to the string
-// table used for these builtins and an array of metadata for each builtin.
-template <size_t N> struct Storage {
- const char *StringTable;
-
- std::array<Info, N> Infos;
-
- // A constexpr function to construct the storage for a a given string table in
- // the first argument and an array in the second argument. This is *only*
- // expected to be used at compile time, we should mark it `consteval` when
- // available.
- //
- // The `Infos` array is particularly special. This function expects an array
- // of `Info` structs, where the string offsets of each entry refer to the
- // *sizes* of those strings rather than their offsets, and for the target
- // string to be in the provided string table at an offset the sum of all
- // previous string sizes. This function walks the `Infos` array computing the
- // running sum and replacing the sizes with the actual offsets in the string
- // table that should be used. This arrangement is designed to make it easy to
- // expand `.def` and `.inc` files with X-macros to construct both the string
- // table and the `Info` structs in the arguments to this function.
- static constexpr Storage<N> Make(const char *Strings,
- std::array<Info, N> Infos) {
- // Translate lengths to offsets.
- int Offset = 0;
- for (auto &I : Infos) {
- Info::StrOffsets NewOffsets = {};
- NewOffsets.Name = Offset;
- Offset += I.Offsets.Name;
- NewOffsets.Type = Offset;
- Offset += I.Offsets.Type;
- NewOffsets.Attributes = Offset;
- Offset += I.Offsets.Attributes;
- NewOffsets.Features = Offset;
- Offset += I.Offsets.Features;
- I.Offsets = NewOffsets;
- }
- return {Strings, Infos};
- }
-};
-
-// A detail macro used below to emit a string literal that, after string literal
-// concatenation, ends up triggering the `-Woverlength-strings` warning. While
-// the warning is useful in general to catch accidentally excessive strings,
-// here we are creating them intentionally.
-//
-// This relies on a subtle aspect of `_Pragma`: that the *diagnostic* ones don't
-// turn into actual tokens that would disrupt string literal concatenation.
-#ifdef __clang__
-#define CLANG_BUILTIN_DETAIL_STR_TABLE(S) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Woverlength-strings\"") \
- S _Pragma("clang diagnostic pop")
-#else
-#define CLANG_BUILTIN_DETAIL_STR_TABLE(S) S
-#endif
-
-// A macro that can be used with `Builtins.def` and similar files as an X-macro
-// to add the string arguments to a builtin string table. This is typically the
-// target for the `BUILTIN`, `LANGBUILTIN`, or `LIBBUILTIN` macros in those
-// files.
-#define CLANG_BUILTIN_STR_TABLE(ID, TYPE, ATTRS) \
- CLANG_BUILTIN_DETAIL_STR_TABLE(#ID "\0" TYPE "\0" ATTRS "\0" /*FEATURE*/ "\0")
-
-// A macro that can be used with target builtin `.def` and `.inc` files as an
-// X-macro to add the string arguments to a builtin string table. this is
-// typically the target for the `TARGET_BUILTIN` macro.
-#define CLANG_TARGET_BUILTIN_STR_TABLE(ID, TYPE, ATTRS, FEATURE) \
- CLANG_BUILTIN_DETAIL_STR_TABLE(#ID "\0" TYPE "\0" ATTRS "\0" FEATURE "\0")
-
-// A macro that can be used with target builtin `.def` and `.inc` files as an
-// X-macro to add the string arguments to a builtin string table. this is
-// typically the target for the `TARGET_HEADER_BUILTIN` macro. We can't delegate
-// to `TARGET_BUILTIN` because the `FEATURE` string changes position.
-#define CLANG_TARGET_HEADER_BUILTIN_STR_TABLE(ID, TYPE, ATTRS, HEADER, LANGS, \
- FEATURE) \
- CLANG_BUILTIN_DETAIL_STR_TABLE(#ID "\0" TYPE "\0" ATTRS "\0" FEATURE "\0")
-
-// A detail macro used internally to compute the desired string table
-// `StrOffsets` struct for arguments to `Storage::Make`.
-#define CLANG_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS) \
- Builtin::Info::StrOffsets { \
- sizeof(#ID), sizeof(TYPE), sizeof(ATTRS), sizeof("") \
- }
-
-// A detail macro used internally to compute the desired string table
-// `StrOffsets` struct for arguments to `Storage::Make`.
-#define CLANG_TARGET_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS, FEATURE) \
- Builtin::Info::StrOffsets { \
- sizeof(#ID), sizeof(TYPE), sizeof(ATTRS), sizeof(FEATURE) \
- }
-
-// A set of macros that can be used with builtin `.def' files as an X-macro to
-// create an `Info` struct for a particular builtin. It both computes the
-// `StrOffsets` value for the string table (the lengths here, translated to
-// offsets by the Storage::Make function), and the other metadata for each
-// builtin.
-//
-// There is a corresponding macro for each of `BUILTIN`, `LANGBUILTIN`,
-// `LIBBUILTIN`, `TARGET_BUILTIN`, and `TARGET_HEADER_BUILTIN`.
-#define CLANG_BUILTIN_ENTRY(ID, TYPE, ATTRS) \
- Builtin::Info{CLANG_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS), \
- HeaderDesc::NO_HEADER, ALL_LANGUAGES},
-#define CLANG_LANGBUILTIN_ENTRY(ID, TYPE, ATTRS, LANG) \
- Builtin::Info{CLANG_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS), \
- HeaderDesc::NO_HEADER, LANG},
-#define CLANG_LIBBUILTIN_ENTRY(ID, TYPE, ATTRS, HEADER, LANG) \
- Builtin::Info{CLANG_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS), \
- HeaderDesc::HEADER, LANG},
-#define CLANG_TARGET_BUILTIN_ENTRY(ID, TYPE, ATTRS, FEATURE) \
- Builtin::Info{ \
- CLANG_TARGET_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS, FEATURE), \
- HeaderDesc::NO_HEADER, ALL_LANGUAGES},
-#define CLANG_TARGET_HEADER_BUILTIN_ENTRY(ID, TYPE, ATTRS, HEADER, LANG, \
- FEATURE) \
- Builtin::Info{ \
- CLANG_TARGET_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS, FEATURE), \
- HeaderDesc::HEADER, LANG},
-
/// Holds information about both target-independent and
/// target-specific builtins, allowing easy queries by clients.
///
@@ -210,11 +83,8 @@ template <size_t N> struct Storage {
/// AuxTSRecords. Their IDs are shifted up by TSRecords.size() and need to
/// be translated back with getAuxBuiltinID() before use.
class Context {
- const char *TSStrTable = nullptr;
- const char *AuxTSStrTable = nullptr;
-
- llvm::ArrayRef<Info> TSInfos;
- llvm::ArrayRef<Info> AuxTSInfos;
+ llvm::ArrayRef<Info> TSRecords;
+ llvm::ArrayRef<Info> AuxTSRecords;
public:
Context() = default;
@@ -230,13 +100,12 @@ class Context {
/// Return the identifier name for the specified builtin,
/// e.g. "__builtin_abs".
- llvm::StringRef getName(unsigned ID) const;
+ llvm::StringRef getName(unsigned ID) const { return getRecord(ID).Name; }
/// Get the type descriptor string for the specified builtin.
- const char *getTypeString(unsigned ID) const;
-
- /// Get the attributes descriptor string for the specified builtin.
- const char *getAttributesString(unsigned ID) const;
+ const char *getTypeString(unsigned ID) const {
+ return getRecord(ID).Type;
+ }
/// Return true if this function is a target-specific builtin.
bool isTSBuiltin(unsigned ID) const {
@@ -245,40 +114,40 @@ class Context {
/// Return true if this function has no side effects.
bool isPure(unsigned ID) const {
- return strchr(getAttributesString(ID), 'U') != nullptr;
+ return strchr(getRecord(ID).Attributes, 'U') != nullptr;
}
/// Return true if this function has no side effects and doesn't
/// read memory.
bool isConst(unsigned ID) const {
- return strchr(getAttributesString(ID), 'c') != nullptr;
+ return strchr(getRecord(ID).Attributes, 'c') != nullptr;
}
/// Return true if we know this builtin never throws an exception.
bool isNoThrow(unsigned ID) const {
- return strchr(getAttributesString(ID), 'n') != nullptr;
+ return strchr(getRecord(ID).Attributes, 'n') != nullptr;
}
/// Return true if we know this builtin never returns.
bool isNoReturn(unsigned ID) const {
- return strchr(getAttributesString(ID), 'r') != nullptr;
+ return strchr(getRecord(ID).Attributes, 'r') != nullptr;
}
/// Return true if we know this builtin can return twice.
bool isReturnsTwice(unsigned ID) const {
- return strchr(getAttributesString(ID), 'j') != nullptr;
+ return strchr(getRecord(ID).Attributes, 'j') != nullptr;
}
/// Returns true if this builtin does not perform the side-effects
/// of its arguments.
bool isUnevaluated(unsigned ID) const {
- return strchr(getAttributesString(ID), 'u') != nullptr;
+ return strchr(getRecord(ID).Attributes, 'u') != nullptr;
}
/// Return true if this is a builtin for a libc/libm function,
/// with a "__builtin_" prefix (e.g. __builtin_abs).
bool isLibFunction(unsigned ID) const {
- return strchr(getAttributesString(ID), 'F') != nullptr;
+ return strchr(getRecord(ID).Attributes, 'F') != nullptr;
}
/// Determines whether this builtin is a predefined libc/libm
@@ -289,21 +158,21 @@ class Context {
/// they do not, but they are recognized as builtins once we see
/// a declaration.
bool isPredefinedLibFunction(unsigned ID) const {
- return strchr(getAttributesString(ID), 'f') != nullptr;
+ return strchr(getRecord(ID).Attributes, 'f') != nullptr;
}
/// Returns true if this builtin requires appropriate header in other
/// compilers. In Clang it will work even without including it, but we can emit
/// a warning about missing header.
bool isHeaderDependentFunction(unsigned ID) const {
- return strchr(getAttributesString(ID), 'h') != nullptr;
+ return strchr(getRecord(ID).Attributes, 'h') != nullptr;
}
/// Determines whether this builtin is a predefined compiler-rt/libgcc
/// function, such as "__clear_cache", where we know the signature a
/// priori.
bool isPredefinedRuntimeFunction(unsigned ID) const {
- return strchr(getAttributesString(ID), 'i') != nullptr;
+ return strchr(getRecord(ID).Attributes, 'i') != nullptr;
}
/// Determines whether this builtin is a C++ standard library function
@@ -311,7 +180,7 @@ class Context {
/// specialization, where the signature is determined by the standard library
/// declaration.
bool isInStdNamespace(unsigned ID) const {
- return strchr(getAttributesString(ID), 'z') != nullptr;
+ return strchr(getRecord(ID).Attributes, 'z') != nullptr;
}
/// Determines whether this builtin can have its address taken with no
@@ -325,33 +194,33 @@ class Context {
/// Determines whether this builtin has custom typechecking.
bool hasCustomTypechecking(unsigned ID) const {
- return strchr(getAttributesString(ID), 't') != nullptr;
+ return strchr(getRecord(ID).Attributes, 't') != nullptr;
}
/// Determines whether a declaration of this builtin should be recognized
/// even if the type doesn't match the specified signature.
bool allowTypeMismatch(unsigned ID) const {
- return strchr(getAttributesString(ID), 'T') != nullptr ||
+ return strchr(getRecord(ID).Attributes, 'T') != nullptr ||
hasCustomTypechecking(ID);
}
/// Determines whether this builtin has a result or any arguments which
/// are pointer types.
bool hasPtrArgsOrResult(unsigned ID) const {
- return strchr(getTypeString(ID), '*') != nullptr;
+ return strchr(getRecord(ID).Type, '*') != nullptr;
}
/// Return true if this builtin has a result or any arguments which are
/// reference types.
bool hasReferenceArgsOrResult(unsigned ID) const {
- return strchr(getTypeString(ID), '&') != nullptr ||
- strchr(getTypeString(ID), 'A') != nullptr;
+ return strchr(getRecord(ID).Type, '&') != nullptr ||
+ strchr(getRecord(ID).Type, 'A') != nullptr;
}
/// If this is a library function that comes from a specific
/// header, retrieve that header name.
const char *getHeaderName(unsigned ID) const {
- return getInfo(ID).Header.getName();
+ return getRecord(ID).Header.getName();
}
/// Determine whether this builtin is like printf in its
@@ -376,25 +245,27 @@ class Context {
/// Such functions can be const when the MathErrno lang option and FP
/// exceptions are disabled.
bool isConstWithoutErrnoAndExceptions(unsigned ID) const {
- return strchr(getAttributesString(ID), 'e') != nullptr;
+ return strchr(getRecord(ID).Attributes, 'e') != nullptr;
}
bool isConstWithoutExceptions(unsigned ID) const {
- return strchr(getAttributesString(ID), 'g') != nullptr;
+ return strchr(getRecord(ID).Attributes, 'g') != nullptr;
}
- const char *getRequiredFeatures(unsigned ID) const;
+ const char *getRequiredFeatures(unsigned ID) const {
+ return getRecord(ID).Features;
+ }
unsigned getRequiredVectorWidth(unsigned ID) const;
/// Return true if builtin ID belongs to AuxTarget.
bool isAuxBuiltinID(unsigned ID) const {
- return ID >= (Builtin::FirstTSBuiltin + TSInfos.size());
+ return ID >= (Builtin::FirstTSBuiltin + TSRecords.size());
}
/// Return real builtin ID (i.e. ID it would have during compilation
/// for AuxTarget).
- unsigned getAuxBuiltinID(unsigned ID) const { return ID - TSInfos.size(); }
+ unsigned getAuxBuiltinID(unsigned ID) const { return ID - TSRecords.size(); }
/// Returns true if this is a libc/libm function without the '__builtin_'
/// prefix.
@@ -406,20 +277,16 @@ class Context {
/// Return true if this function can be constant evaluated by Clang frontend.
bool isConstantEvaluated(unsigned ID) const {
- return strchr(getAttributesString(ID), 'E') != nullptr;
+ return strchr(getRecord(ID).Attributes, 'E') != nullptr;
}
/// Returns true if this is an immediate (consteval) function
bool isImmediate(unsigned ID) const {
- return strchr(getAttributesString(ID), 'G') != nullptr;
+ return strchr(getRecord(ID).Attributes, 'G') != nullptr;
}
private:
- std::pair<const char *, const Info &> getStrTableAndInfo(unsigned ID) const;
-
- const Info &getInfo(unsigned ID) const {
- return getStrTableAndInfo(ID).second;
- }
+ const Info &getRecord(unsigned ID) const;
/// Helper function for isPrintfLike and isScanfLike.
bool isLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg,
diff --git a/clang/include/clang/Basic/BuiltinsPPC.def b/clang/include/clang/Basic/BuiltinsPPC.def
index bb7d54bbb793eb..161df386f00f03 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -1138,6 +1138,5 @@ UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2nn, "vW512*VVi15i15i3", true,
// FIXME: Obviously incomplete.
#undef BUILTIN
-#undef TARGET_BUILTIN
#undef CUSTOM_BUILTIN
#undef UNALIASED_CUSTOM_BUILTIN
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index 52a1ac9781395c..4420228793e95f 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -16,7 +16,6 @@
#include "clang/Basic/AddressSpaces.h"
#include "clang/Basic/BitmaskEnum.h"
-#include "clang/Basic/Builtins.h"
#include "clang/Basic/CFProtectionOptions.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/Basic/LLVM.h"
@@ -1010,11 +1009,11 @@ class TargetInfo : public TransferrableTargetInfo,
virtual void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const = 0;
- /// Return information about target-specific builtins for the current primary
- /// target, and info about which builtins are non-portable across the current
- /// set of primary and secondary targets.
- virtual std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const = 0;
+
+ /// Return information about target-specific builtins for
+ /// the current primary target, and info about which builtins are non-portable
+ /// across the current set of primary and secondary targets.
+ virtual ArrayRef<Builtin::Info> getTargetBuiltins() const = 0;
/// Returns target-specific min and max values VScale_Range.
virtual std::optional<std::pair<unsigned, unsigned>>
diff --git a/clang/lib/Basic/Builtins.cpp b/clang/lib/Basic/Builtins.cpp
index c991139b8d5ad7..25a601573698e7 100644
--- a/clang/lib/Basic/Builtins.cpp
+++ b/clang/lib/Basic/Builtins.cpp
@@ -29,93 +29,54 @@ const char *HeaderDesc::getName() const {
llvm_unreachable("Unknown HeaderDesc::HeaderID enum");
}
-static constexpr auto BuiltinStorage =
- Builtin::Storage<Builtin::FirstTSBuiltin>::Make(
- CLANG_BUILTIN_STR_TABLE("not a builtin function", "", "")
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
+static constexpr Builtin::Info BuiltinInfo[] = {
+ {"not a builtin function", nullptr, nullptr, nullptr, HeaderDesc::NO_HEADER,
+ ALL_LANGUAGES},
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define LANGBUILTIN(ID, TYPE, ATTRS, LANGS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, LANGS},
+#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER, LANGS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, LANGS},
#include "clang/Basic/Builtins.inc"
- ,
- {CLANG_BUILTIN_ENTRY("not a builtin function", "", "")
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define LANGBUILTIN CLANG_LANGBUILTIN_ENTRY
-#define LIBBUILTIN CLANG_LIBBUILTIN_ENTRY
-#include "clang/Basic/Builtins.inc"
- });
+};
-std::pair<const char *, const Builtin::Info &>
-Builtin::Context::getStrTableAndInfo(unsigned ID) const {
+const Builtin::Info &Builtin::Context::getRecord(unsigned ID) const {
if (ID < Builtin::FirstTSBuiltin)
- return {BuiltinStorage.StringTable, BuiltinStorage.Infos[ID]};
- assert(
- ((ID - Builtin::FirstTSBuiltin) < (TSInfos.size() + AuxTSInfos.size())) &&
- "Invalid builtin ID!");
+ return BuiltinInfo[ID];
+ assert(((ID - Builtin::FirstTSBuiltin) <
+ (TSRecords.size() + AuxTSRecords.size())) &&
+ "Invalid builtin ID!");
if (isAuxBuiltinID(ID))
- return {AuxTSStrTable,
- AuxTSInfos[getAuxBuiltinID(ID) - Builtin::FirstTSBuiltin]};
- return {TSStrTable, TSInfos[ID - Builtin::FirstTSBuiltin]};
-}
-
-static llvm::StringRef getStrFromTable(const char *StrTable, int Offset) {
- return &StrTable[Offset];
-}
-
-/// Return the identifier name for the specified builtin,
-/// e.g. "__builtin_abs".
-llvm::StringRef Builtin::Context::getName(unsigned ID) const {
- const auto &[StrTable, I] = getStrTableAndInfo(ID);
- return getStrFromTable(StrTable, I.Offsets.Name);
-}
-
-const char *Builtin::Context::getTypeString(unsigned ID) const {
- const auto &[StrTable, I] = getStrTableAndInfo(ID);
- return getStrFromTable(StrTable, I.Offsets.Type).data();
-}
-
-const char *Builtin::Context::getAttributesString(unsigned ID) const {
- const auto &[StrTable, I] = getStrTableAndInfo(ID);
- return getStrFromTable(StrTable, I.Offsets.Attributes).data();
-}
-
-const char *Builtin::Context::getRequiredFeatures(unsigned ID) const {
- const auto &[StrTable, I] = getStrTableAndInfo(ID);
- return getStrFromTable(StrTable, I.Offsets.Features).data();
+ return AuxTSRecords[getAuxBuiltinID(ID) - Builtin::FirstTSBuiltin];
+ return TSRecords[ID - Builtin::FirstTSBuiltin];
}
void Builtin::Context::InitializeTarget(const TargetInfo &Target,
const TargetInfo *AuxTarget) {
- assert(TSStrTable == nullptr && "Already initialized target?");
- assert(TSInfos.empty() && "Already initialized target?");
- std::tie(TSStrTable, TSInfos) = Target.getTargetBuiltinStorage();
- if (AuxTarget) {
- std::tie(AuxTSStrTable, AuxTSInfos) = AuxTarget->getTargetBuiltinStorage();
- }
+ assert(TSRecords.empty() && "Already initialized target?");
+ TSRecords = Target.getTargetBuiltins();
+ if (AuxTarget)
+ AuxTSRecords = AuxTarget->getTargetBuiltins();
}
bool Builtin::Context::isBuiltinFunc(llvm::StringRef FuncName) {
bool InStdNamespace = FuncName.consume_front("std-");
- const char *StrTable = BuiltinStorage.StringTable;
for (unsigned i = Builtin::NotBuiltin + 1; i != Builtin::FirstTSBuiltin;
++i) {
- const auto &I = BuiltinStorage.Infos[i];
- if (FuncName == getStrFromTable(StrTable, I.Offsets.Name) &&
- (bool)strchr(getStrFromTable(StrTable, I.Offsets.Attributes).data(),
- 'z') == InStdNamespace)
- return strchr(getStrFromTable(StrTable, I.Offsets.Attributes).data(),
- 'f') != nullptr;
+ if (FuncName == BuiltinInfo[i].Name &&
+ (bool)strchr(BuiltinInfo[i].Attributes, 'z') == InStdNamespace)
+ return strchr(BuiltinInfo[i].Attributes, 'f') != nullptr;
}
return false;
}
/// Is this builtin supported according to the given language options?
-static bool builtinIsSupported(const char *StrTable,
- const Builtin::Info &BuiltinInfo,
+static bool builtinIsSupported(const Builtin::Info &BuiltinInfo,
const LangOptions &LangOpts) {
- auto AttributesStr =
- getStrFromTable(StrTable, BuiltinInfo.Offsets.Attributes);
-
/* Builtins Unsupported */
- if (LangOpts.NoBuiltin && strchr(AttributesStr.data(), 'f') != nullptr)
+ if (LangOpts.NoBuiltin && strchr(BuiltinInfo.Attributes, 'f') != nullptr)
return false;
/* CorBuiltins Unsupported */
if (!LangOpts.Coroutines && (BuiltinInfo.Langs & COR_LANG))
@@ -162,7 +123,7 @@ static bool builtinIsSupported(const char *StrTable,
if (!LangOpts.CPlusPlus && BuiltinInfo.Langs == CXX_LANG)
return false;
/* consteval Unsupported */
- if (!LangOpts.CPlusPlus20 && strchr(AttributesStr.data(), 'G') != nullptr)
+ if (!LangOpts.CPlusPlus20 && strchr(BuiltinInfo.Attributes, 'G') != nullptr)
return false;
return true;
}
@@ -173,23 +134,20 @@ static bool builtinIsSupported(const char *StrTable,
void Builtin::Context::initializeBuiltins(IdentifierTable &Table,
const LangOptions& LangOpts) {
// Step #1: mark all target-independent builtins with their ID's.
- for (const auto &&[Index, I] :
- llvm::enumerate(llvm::ArrayRef(BuiltinStorage.Infos).drop_front()))
- if (builtinIsSupported(BuiltinStorage.StringTable, I, LangOpts)) {
- Table.get(getStrFromTable(BuiltinStorage.StringTable, I.Offsets.Name))
- .setBuiltinID(Index + 1);
+ for (unsigned i = Builtin::NotBuiltin+1; i != Builtin::FirstTSBuiltin; ++i)
+ if (builtinIsSupported(BuiltinInfo[i], LangOpts)) {
+ Table.get(BuiltinInfo[i].Name).setBuiltinID(i);
}
// Step #2: Register target-specific builtins.
- for (const auto &&[Index, I] : llvm::enumerate(TSInfos))
- if (builtinIsSupported(TSStrTable, I, LangOpts))
- Table.get(getStrFromTable(TSStrTable, I.Offsets.Name))
- .setBuiltinID(Index + Builtin::FirstTSBuiltin);
+ for (unsigned i = 0, e = TSRecords.size(); i != e; ++i)
+ if (builtinIsSupported(TSRecords[i], LangOpts))
+ Table.get(TSRecords[i].Name).setBuiltinID(i + Builtin::FirstTSBuiltin);
// Step #3: Register target-specific builtins for AuxTarget.
- for (const auto &&[Index, I] : llvm::enumerate(AuxTSInfos))
- Table.get(getStrFromTable(AuxTSStrTable, I.Offsets.Name))
- .setBuiltinID(Index + Builtin::FirstTSBuiltin + TSInfos.size());
+ for (unsigned i = 0, e = AuxTSRecords.size(); i != e; ++i)
+ Table.get(AuxTSRecords[i].Name)
+ .setBuiltinID(i + Builtin::FirstTSBuiltin + TSRecords.size());
// Step #4: Unregister any builtins specified by -fno-builtin-foo.
for (llvm::StringRef Name : LangOpts.NoBuiltinFuncs) {
@@ -206,7 +164,7 @@ void Builtin::Context::initializeBuiltins(IdentifierTable &Table,
}
unsigned Builtin::Context::getRequiredVectorWidth(unsigned ID) const {
- const char *WidthPos = ::strchr(getAttributesString(ID), 'V');
+ const char *WidthPos = ::strchr(getRecord(ID).Attributes, 'V');
if (!WidthPos)
return 0;
@@ -229,7 +187,7 @@ bool Builtin::Context::isLike(unsigned ID, unsigned &FormatIdx,
assert(::toupper(Fmt[0]) == Fmt[1] &&
"Format string is not in the form \"xX\"");
- const char *Like = ::strpbrk(getAttributesString(ID), Fmt);
+ const char *Like = ::strpbrk(getRecord(ID).Attributes, Fmt);
if (!Like)
return false;
@@ -256,7 +214,7 @@ bool Builtin::Context::isScanfLike(unsigned ID, unsigned &FormatIdx,
bool Builtin::Context::performsCallback(unsigned ID,
SmallVectorImpl<int> &Encoding) const {
- const char *CalleePos = ::strchr(getAttributesString(ID), 'C');
+ const char *CalleePos = ::strchr(getRecord(ID).Attributes, 'C');
if (!CalleePos)
return false;
diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp
index 858f83d090d7ad..53e102bbe44687 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -26,39 +26,35 @@
using namespace clang;
using namespace clang::targets;
-static constexpr int NumBuiltins =
- clang::AArch64::LastTSBuiltin - Builtin::FirstTSBuiltin;
-
-static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make(
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE
-#include "clang/Basic/BuiltinsNEON.def"
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE
-#include "clang/Basic/BuiltinsSVE.def"
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE
-#include "clang/Basic/BuiltinsSME.def"
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE
-#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_STR_TABLE
-#include "clang/Basic/BuiltinsAArch64.def"
- , {
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY
+static constexpr Builtin::Info BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsNEON.def"
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY
+
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsSVE.def"
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY
+
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsSME.def"
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY
-#define LANGBUILTIN CLANG_LANGBUILTIN_ENTRY
-#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_ENTRY
+
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define LANGBUILTIN(ID, TYPE, ATTRS, LANG) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, LANG},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::HEADER, LANGS},
#include "clang/Basic/BuiltinsAArch64.def"
- });
+};
void AArch64TargetInfo::setArchFeatures() {
if (*ArchInfo == llvm::AArch64::ARMV8R) {
@@ -701,9 +697,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
}
}
-std::pair<const char *, ArrayRef<Builtin::Info>>
-AArch64TargetInfo::getTargetBuiltinStorage() const {
- return {BuiltinStorage.StringTable, BuiltinStorage.Infos};
+ArrayRef<Builtin::Info> AArch64TargetInfo::getTargetBuiltins() const {
+ return llvm::ArrayRef(BuiltinInfo, clang::AArch64::LastTSBuiltin -
+ Builtin::FirstTSBuiltin);
}
std::optional<std::pair<unsigned, unsigned>>
diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h
index a3ce04e249e30d..68a8b1ebad8cde 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -180,8 +180,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override;
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override;
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override;
std::optional<std::pair<unsigned, unsigned>>
getVScaleRange(const LangOptions &LangOpts) const override;
diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp b/clang/lib/Basic/Targets/AMDGPU.cpp
index 21281e7201b020..99f8f2944e2796 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -88,18 +88,13 @@ const LangASMap AMDGPUTargetInfo::AMDGPUDefIsPrivMap = {
} // namespace targets
} // namespace clang
-static constexpr int NumBuiltins =
- clang::AMDGPU::LastTSBuiltin - Builtin::FirstTSBuiltin;
-
-static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make(
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE
-#include "clang/Basic/BuiltinsAMDGPU.def"
- , {
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY
+static constexpr Builtin::Info BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsAMDGPU.def"
- });
+};
const char *const AMDGPUTargetInfo::GCCRegNames[] = {
"v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8",
@@ -271,9 +266,9 @@ void AMDGPUTargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
!isAMDGCN(getTriple()));
}
-std::pair<const char *, ArrayRef<Builtin::Info>>
-AMDGPUTargetInfo::getTargetBuiltinStorage() const {
- return {BuiltinStorage.StringTable, BuiltinStorage.Infos};
+ArrayRef<Builtin::Info> AMDGPUTargetInfo::getTargetBuiltins() const {
+ return llvm::ArrayRef(BuiltinInfo,
+ clang::AMDGPU::LastTSBuiltin - Builtin::FirstTSBuiltin);
}
void AMDGPUTargetInfo::getTargetDefines(const LangOptions &Opts,
diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h
index 8068184a0d4117..ea4189cdea47da 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -257,8 +257,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
StringRef CPU,
const std::vector<std::string> &FeatureVec) const override;
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override;
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override;
bool useFP16ConversionIntrinsics() const override { return false; }
diff --git a/clang/lib/Basic/Targets/ARC.h b/clang/lib/Basic/Targets/ARC.h
index d84daf2e527ca0..7f3d0aa15ab81f 100644
--- a/clang/lib/Basic/Targets/ARC.h
+++ b/clang/lib/Basic/Targets/ARC.h
@@ -40,10 +40,7 @@ class LLVM_LIBRARY_VISIBILITY ARCTargetInfo : public TargetInfo {
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override;
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override {
- return {nullptr, {}};
- }
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override { return {}; }
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::VoidPtrBuiltinVaList;
diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index fb10bc8249e981..370444057b4298 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -1071,34 +1071,31 @@ void ARMTargetInfo::getTargetDefines(const LangOptions &Opts,
}
}
-static constexpr int NumBuiltins =
- clang::ARM::LastTSBuiltin - Builtin::FirstTSBuiltin;
-
-static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make(
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE
+static constexpr Builtin::Info BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsNEON.def"
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE
-#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_STR_TABLE
-#include "clang/Basic/BuiltinsARM.def"
- , {
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define LIBBUILTIN CLANG_LIBBUILTIN_ENTRY
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY
-#include "clang/Basic/BuiltinsNEON.def"
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define LANGBUILTIN CLANG_LANGBUILTIN_ENTRY
-#define LIBBUILTIN CLANG_LIBBUILTIN_ENTRY
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY
-#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_ENTRY
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define LANGBUILTIN(ID, TYPE, ATTRS, LANG) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, LANG},
+#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::HEADER, LANGS},
#include "clang/Basic/BuiltinsARM.def"
- });
+};
-std::pair<const char *, ArrayRef<Builtin::Info>>
-ARMTargetInfo::getTargetBuiltinStorage() const {
- return {BuiltinStorage.StringTable, BuiltinStorage.Infos};
+ArrayRef<Builtin::Info> ARMTargetInfo::getTargetBuiltins() const {
+ return llvm::ArrayRef(BuiltinInfo,
+ clang::ARM::LastTSBuiltin - Builtin::FirstTSBuiltin);
}
bool ARMTargetInfo::isCLZForZeroUndef() const { return false; }
diff --git a/clang/lib/Basic/Targets/ARM.h b/clang/lib/Basic/Targets/ARM.h
index 71f44f7248f68b..55ecb99d82d8fb 100644
--- a/clang/lib/Basic/Targets/ARM.h
+++ b/clang/lib/Basic/Targets/ARM.h
@@ -196,8 +196,7 @@ class LLVM_LIBRARY_VISIBILITY ARMTargetInfo : public TargetInfo {
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override;
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override;
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override;
bool isCLZForZeroUndef() const override;
BuiltinVaListKind getBuiltinVaListKind() const override;
diff --git a/clang/lib/Basic/Targets/AVR.h b/clang/lib/Basic/Targets/AVR.h
index f19dee3a88231c..df1f8d171efbaa 100644
--- a/clang/lib/Basic/Targets/AVR.h
+++ b/clang/lib/Basic/Targets/AVR.h
@@ -63,10 +63,7 @@ class LLVM_LIBRARY_VISIBILITY AVRTargetInfo : public TargetInfo {
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override;
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override {
- return {nullptr, {}};
- }
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override { return {}; }
bool allowsLargerPreferedTypeAlignment() const override { return false; }
diff --git a/clang/lib/Basic/Targets/BPF.cpp b/clang/lib/Basic/Targets/BPF.cpp
index b62e792590185a..f4684765b7ffb3 100644
--- a/clang/lib/Basic/Targets/BPF.cpp
+++ b/clang/lib/Basic/Targets/BPF.cpp
@@ -19,16 +19,11 @@
using namespace clang;
using namespace clang::targets;
-static constexpr int NumBuiltins =
- clang::BPF::LastTSBuiltin - Builtin::FirstTSBuiltin;
-
-static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make(
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#include "clang/Basic/BuiltinsBPF.inc"
- , {
-#define BUILTIN CLANG_BUILTIN_ENTRY
+static constexpr Builtin::Info BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsBPF.inc"
- });
+};
void BPFTargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
@@ -86,9 +81,9 @@ void BPFTargetInfo::fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {
Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
}
-std::pair<const char *, ArrayRef<Builtin::Info>>
-BPFTargetInfo::getTargetBuiltinStorage() const {
- return {BuiltinStorage.StringTable, BuiltinStorage.Infos};
+ArrayRef<Builtin::Info> BPFTargetInfo::getTargetBuiltins() const {
+ return llvm::ArrayRef(BuiltinInfo,
+ clang::BPF::LastTSBuiltin - Builtin::FirstTSBuiltin);
}
bool BPFTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
diff --git a/clang/lib/Basic/Targets/BPF.h b/clang/lib/Basic/Targets/BPF.h
index 8f5c0e31aa87cc..27a4b5f3149702 100644
--- a/clang/lib/Basic/Targets/BPF.h
+++ b/clang/lib/Basic/Targets/BPF.h
@@ -58,8 +58,7 @@ class LLVM_LIBRARY_VISIBILITY BPFTargetInfo : public TargetInfo {
bool handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) override;
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override;
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override;
std::string_view getClobbers() const override { return ""; }
diff --git a/clang/lib/Basic/Targets/CSKY.cpp b/clang/lib/Basic/Targets/CSKY.cpp
index e698508a2370c9..c8bf8b9234d243 100644
--- a/clang/lib/Basic/Targets/CSKY.cpp
+++ b/clang/lib/Basic/Targets/CSKY.cpp
@@ -139,6 +139,10 @@ bool CSKYTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
return true;
}
+ArrayRef<Builtin::Info> CSKYTargetInfo::getTargetBuiltins() const {
+ return ArrayRef<Builtin::Info>();
+}
+
ArrayRef<const char *> CSKYTargetInfo::getGCCRegNames() const {
static const char *const GCCRegNames[] = {
// Integer registers
diff --git a/clang/lib/Basic/Targets/CSKY.h b/clang/lib/Basic/Targets/CSKY.h
index 59c83340b8c311..94d4eeb9a1fff4 100644
--- a/clang/lib/Basic/Targets/CSKY.h
+++ b/clang/lib/Basic/Targets/CSKY.h
@@ -73,10 +73,7 @@ class LLVM_LIBRARY_VISIBILITY CSKYTargetInfo : public TargetInfo {
unsigned getMinGlobalAlign(uint64_t, bool HasNonWeakDef) const override;
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override {
- return {nullptr, {}};
- }
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override;
BuiltinVaListKind getBuiltinVaListKind() const override {
return VoidPtrBuiltinVaList;
diff --git a/clang/lib/Basic/Targets/DirectX.h b/clang/lib/Basic/Targets/DirectX.h
index 3e6e84b0d9e6fe..ab22d1281a4df7 100644
--- a/clang/lib/Basic/Targets/DirectX.h
+++ b/clang/lib/Basic/Targets/DirectX.h
@@ -72,10 +72,7 @@ class LLVM_LIBRARY_VISIBILITY DirectXTargetInfo : public TargetInfo {
return Feature == "directx";
}
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override {
- return {nullptr, {}};
- }
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override { return {}; }
std::string_view getClobbers() const override { return ""; }
diff --git a/clang/lib/Basic/Targets/Hexagon.cpp b/clang/lib/Basic/Targets/Hexagon.cpp
index 70059d68c562bd..0282ac812c306f 100644
--- a/clang/lib/Basic/Targets/Hexagon.cpp
+++ b/clang/lib/Basic/Targets/Hexagon.cpp
@@ -198,19 +198,15 @@ ArrayRef<TargetInfo::GCCRegAlias> HexagonTargetInfo::getGCCRegAliases() const {
return llvm::ArrayRef(GCCRegAliases);
}
-static constexpr int NumBuiltins =
- clang::Hexagon::LastTSBuiltin - Builtin::FirstTSBuiltin;
-
-static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make(
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE
-#include "clang/Basic/BuiltinsHexagon.def"
- , {
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define LIBBUILTIN CLANG_LIBBUILTIN_ENTRY
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY
+static constexpr Builtin::Info BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
+ {#ID, TYPE, ATTRS, nullptr, HEADER, ALL_LANGUAGES},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsHexagon.def"
- });
+};
bool HexagonTargetInfo::hasFeature(StringRef Feature) const {
std::string VS = "hvxv" + HVXVersion;
@@ -268,7 +264,7 @@ void HexagonTargetInfo::fillValidCPUList(
Values.push_back(Suffix.Name);
}
-std::pair<const char *, ArrayRef<Builtin::Info>>
-HexagonTargetInfo::getTargetBuiltinStorage() const {
- return {BuiltinStorage.StringTable, BuiltinStorage.Infos};
+ArrayRef<Builtin::Info> HexagonTargetInfo::getTargetBuiltins() const {
+ return llvm::ArrayRef(BuiltinInfo, clang::Hexagon::LastTSBuiltin -
+ Builtin::FirstTSBuiltin);
}
diff --git a/clang/lib/Basic/Targets/Hexagon.h b/clang/lib/Basic/Targets/Hexagon.h
index 2230735b8971b1..7f053ab7e48886 100644
--- a/clang/lib/Basic/Targets/Hexagon.h
+++ b/clang/lib/Basic/Targets/Hexagon.h
@@ -66,8 +66,7 @@ class LLVM_LIBRARY_VISIBILITY HexagonTargetInfo : public TargetInfo {
BoolWidth = BoolAlign = 8;
}
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override;
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override;
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &Info) const override {
diff --git a/clang/lib/Basic/Targets/Lanai.h b/clang/lib/Basic/Targets/Lanai.h
index f37b0fdb087318..f7e439c7c9e1cf 100644
--- a/clang/lib/Basic/Targets/Lanai.h
+++ b/clang/lib/Basic/Targets/Lanai.h
@@ -78,10 +78,7 @@ class LLVM_LIBRARY_VISIBILITY LanaiTargetInfo : public TargetInfo {
return TargetInfo::VoidPtrBuiltinVaList;
}
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override {
- return {nullptr, {}};
- }
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override { return {}; }
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const override {
diff --git a/clang/lib/Basic/Targets/LoongArch.cpp b/clang/lib/Basic/Targets/LoongArch.cpp
index 7c714000af42f1..d36186aa9c2fbf 100644
--- a/clang/lib/Basic/Targets/LoongArch.cpp
+++ b/clang/lib/Basic/Targets/LoongArch.cpp
@@ -270,18 +270,13 @@ void LoongArchTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
}
-static constexpr int NumBuiltins =
- clang::LoongArch::LastTSBuiltin - Builtin::FirstTSBuiltin;
-
-static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make(
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE
-#include "clang/Basic/BuiltinsLoongArch.def"
- , {
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY
+static constexpr Builtin::Info BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsLoongArch.def"
- });
+};
bool LoongArchTargetInfo::initFeatureMap(
llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU,
@@ -308,9 +303,9 @@ bool LoongArchTargetInfo::hasFeature(StringRef Feature) const {
.Default(false);
}
-std::pair<const char *, ArrayRef<Builtin::Info>>
-LoongArchTargetInfo::getTargetBuiltinStorage() const {
- return {BuiltinStorage.StringTable, BuiltinStorage.Infos};
+ArrayRef<Builtin::Info> LoongArchTargetInfo::getTargetBuiltins() const {
+ return llvm::ArrayRef(BuiltinInfo, clang::LoongArch::LastTSBuiltin -
+ Builtin::FirstTSBuiltin);
}
bool LoongArchTargetInfo::handleTargetFeatures(
diff --git a/clang/lib/Basic/Targets/LoongArch.h b/clang/lib/Basic/Targets/LoongArch.h
index 1bb82667cb512e..abaa05aa42d438 100644
--- a/clang/lib/Basic/Targets/LoongArch.h
+++ b/clang/lib/Basic/Targets/LoongArch.h
@@ -70,8 +70,7 @@ class LLVM_LIBRARY_VISIBILITY LoongArchTargetInfo : public TargetInfo {
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override;
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override;
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override;
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::VoidPtrBuiltinVaList;
diff --git a/clang/lib/Basic/Targets/M68k.cpp b/clang/lib/Basic/Targets/M68k.cpp
index 5670c6309e7171..b5b29fd8675630 100644
--- a/clang/lib/Basic/Targets/M68k.cpp
+++ b/clang/lib/Basic/Targets/M68k.cpp
@@ -115,10 +115,9 @@ void M68kTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__HAVE_68881__");
}
-std::pair<const char *, ArrayRef<Builtin::Info>>
-M68kTargetInfo::getTargetBuiltinStorage() const {
+ArrayRef<Builtin::Info> M68kTargetInfo::getTargetBuiltins() const {
// FIXME: Implement.
- return {nullptr, {}};
+ return {};
}
bool M68kTargetInfo::hasFeature(StringRef Feature) const {
diff --git a/clang/lib/Basic/Targets/M68k.h b/clang/lib/Basic/Targets/M68k.h
index c68b2ab132ea0e..b732add77e0340 100644
--- a/clang/lib/Basic/Targets/M68k.h
+++ b/clang/lib/Basic/Targets/M68k.h
@@ -44,8 +44,7 @@ class LLVM_LIBRARY_VISIBILITY M68kTargetInfo : public TargetInfo {
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override;
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override;
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override;
bool hasFeature(StringRef Feature) const override;
ArrayRef<const char *> getGCCRegNames() const override;
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
diff --git a/clang/lib/Basic/Targets/MSP430.h b/clang/lib/Basic/Targets/MSP430.h
index 462bcdfaa9b214..2266ada25c1dd6 100644
--- a/clang/lib/Basic/Targets/MSP430.h
+++ b/clang/lib/Basic/Targets/MSP430.h
@@ -50,10 +50,9 @@ class LLVM_LIBRARY_VISIBILITY MSP430TargetInfo : public TargetInfo {
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override;
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override {
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override {
// FIXME: Implement.
- return {nullptr, {}};
+ return {};
}
bool allowsLargerPreferedTypeAlignment() const override { return false; }
diff --git a/clang/lib/Basic/Targets/Mips.cpp b/clang/lib/Basic/Targets/Mips.cpp
index b4f137b2c19503..174bc9d2ab9967 100644
--- a/clang/lib/Basic/Targets/Mips.cpp
+++ b/clang/lib/Basic/Targets/Mips.cpp
@@ -20,17 +20,13 @@
using namespace clang;
using namespace clang::targets;
-static constexpr int NumBuiltins =
- clang::Mips::LastTSBuiltin - Builtin::FirstTSBuiltin;
-
-static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make(
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#include "clang/Basic/BuiltinsMips.def"
- , {
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define LIBBUILTIN CLANG_LIBBUILTIN_ENTRY
+static constexpr Builtin::Info BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsMips.def"
- });
+};
bool MipsTargetInfo::processorSupportsGPR64() const {
return llvm::StringSwitch<bool>(CPU)
@@ -227,9 +223,9 @@ bool MipsTargetInfo::hasFeature(StringRef Feature) const {
.Default(false);
}
-std::pair<const char *, ArrayRef<Builtin::Info>>
-MipsTargetInfo::getTargetBuiltinStorage() const {
- return {BuiltinStorage.StringTable, BuiltinStorage.Infos};
+ArrayRef<Builtin::Info> MipsTargetInfo::getTargetBuiltins() const {
+ return llvm::ArrayRef(BuiltinInfo,
+ clang::Mips::LastTSBuiltin - Builtin::FirstTSBuiltin);
}
unsigned MipsTargetInfo::getUnwindWordWidth() const {
diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h
index 2749b5d43a45df..8acaf56523b218 100644
--- a/clang/lib/Basic/Targets/Mips.h
+++ b/clang/lib/Basic/Targets/Mips.h
@@ -197,8 +197,7 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override;
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override;
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override;
bool hasFeature(StringRef Feature) const override;
diff --git a/clang/lib/Basic/Targets/NVPTX.cpp b/clang/lib/Basic/Targets/NVPTX.cpp
index 1d490d9f12992d..dbc3fec3657610 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -20,19 +20,15 @@
using namespace clang;
using namespace clang::targets;
-static constexpr int NumBuiltins =
- clang::NVPTX::LastTSBuiltin - Builtin::FirstTSBuiltin;
-
-static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make(
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE
-#include "clang/Basic/BuiltinsNVPTX.def"
- , {
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define LIBBUILTIN CLANG_LIBBUILTIN_ENTRY
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY
+static constexpr Builtin::Info BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsNVPTX.def"
- });
+};
const char *const NVPTXTargetInfo::GCCRegNames[] = {"r0"};
@@ -299,7 +295,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions &Opts,
}
}
-std::pair<const char *, ArrayRef<Builtin::Info>>
-NVPTXTargetInfo::getTargetBuiltinStorage() const {
- return {BuiltinStorage.StringTable, BuiltinStorage.Infos};
+ArrayRef<Builtin::Info> NVPTXTargetInfo::getTargetBuiltins() const {
+ return llvm::ArrayRef(BuiltinInfo,
+ clang::NVPTX::LastTSBuiltin - Builtin::FirstTSBuiltin);
}
diff --git a/clang/lib/Basic/Targets/NVPTX.h b/clang/lib/Basic/Targets/NVPTX.h
index 6520f441b41674..d81b89a7f24ac0 100644
--- a/clang/lib/Basic/Targets/NVPTX.h
+++ b/clang/lib/Basic/Targets/NVPTX.h
@@ -74,8 +74,7 @@ class LLVM_LIBRARY_VISIBILITY NVPTXTargetInfo : public TargetInfo {
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override;
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override;
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override;
bool useFP16ConversionIntrinsics() const override { return false; }
diff --git a/clang/lib/Basic/Targets/PNaCl.h b/clang/lib/Basic/Targets/PNaCl.h
index 20c0892fbf8c8c..7e0e10aa362d87 100644
--- a/clang/lib/Basic/Targets/PNaCl.h
+++ b/clang/lib/Basic/Targets/PNaCl.h
@@ -52,10 +52,7 @@ class LLVM_LIBRARY_VISIBILITY PNaClTargetInfo : public TargetInfo {
return Feature == "pnacl";
}
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override {
- return {nullptr, {}};
- }
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override { return {}; }
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::PNaClABIBuiltinVaList;
diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 6aa36839afa813..1448069173b5f4 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -19,19 +19,15 @@
using namespace clang;
using namespace clang::targets;
-static constexpr int NumBuiltins =
- clang::PPC::LastTSBuiltin - Builtin::FirstTSBuiltin;
-
-static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make(
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE
-#include "clang/Basic/BuiltinsPPC.def"
- , {
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY
-#define LIBBUILTIN CLANG_LIBBUILTIN_ENTRY
+static constexpr Builtin::Info BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsPPC.def"
- });
+};
/// handleTargetFeatures - Perform initialization based on the user
/// configured set of features.
@@ -931,9 +927,9 @@ void PPCTargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
MaxAtomicInlineWidth = 128;
}
-std::pair<const char *, ArrayRef<Builtin::Info>>
-PPCTargetInfo::getTargetBuiltinStorage() const {
- return {BuiltinStorage.StringTable, BuiltinStorage.Infos};
+ArrayRef<Builtin::Info> PPCTargetInfo::getTargetBuiltins() const {
+ return llvm::ArrayRef(BuiltinInfo,
+ clang::PPC::LastTSBuiltin - Builtin::FirstTSBuiltin);
}
bool PPCTargetInfo::validateCpuSupports(StringRef FeatureStr) const {
diff --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index b58375f6f37935..3cd0fcad172939 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -187,8 +187,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public TargetInfo {
StringRef getABI() const override { return ABI; }
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override;
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override;
bool isCLZForZeroUndef() const override { return false; }
diff --git a/clang/lib/Basic/Targets/RISCV.cpp b/clang/lib/Basic/Targets/RISCV.cpp
index 0add1dfdb2f572..a541dfedc9b8e1 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -240,28 +240,22 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
}
}
-static constexpr int NumBuiltins =
- clang::RISCV::LastTSBuiltin - Builtin::FirstTSBuiltin;
-
-static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make(
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE
-#include "clang/Basic/BuiltinsRISCVVector.def"
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE
-#include "clang/Basic/BuiltinsRISCV.inc"
- , {
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY
+static constexpr Builtin::Info BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsRISCVVector.def"
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsRISCV.inc"
- });
+};
-std::pair<const char *, ArrayRef<Builtin::Info>>
-RISCVTargetInfo::getTargetBuiltinStorage() const {
- return {BuiltinStorage.StringTable, BuiltinStorage.Infos};
+ArrayRef<Builtin::Info> RISCVTargetInfo::getTargetBuiltins() const {
+ return llvm::ArrayRef(BuiltinInfo,
+ clang::RISCV::LastTSBuiltin - Builtin::FirstTSBuiltin);
}
bool RISCVTargetInfo::initFeatureMap(
diff --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h
index a168952e6c6f54..68f10e74ba98c3 100644
--- a/clang/lib/Basic/Targets/RISCV.h
+++ b/clang/lib/Basic/Targets/RISCV.h
@@ -62,8 +62,7 @@ class RISCVTargetInfo : public TargetInfo {
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override;
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override;
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override;
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::VoidPtrBuiltinVaList;
diff --git a/clang/lib/Basic/Targets/SPIR.cpp b/clang/lib/Basic/Targets/SPIR.cpp
index b0e1fa35cca695..040303983594f8 100644
--- a/clang/lib/Basic/Targets/SPIR.cpp
+++ b/clang/lib/Basic/Targets/SPIR.cpp
@@ -81,9 +81,8 @@ SPIRV64AMDGCNTargetInfo::convertConstraint(const char *&Constraint) const {
return AMDGPUTI.convertConstraint(Constraint);
}
-std::pair<const char *, ArrayRef<Builtin::Info>>
-SPIRV64AMDGCNTargetInfo::getTargetBuiltinStorage() const {
- return AMDGPUTI.getTargetBuiltinStorage();
+ArrayRef<Builtin::Info> SPIRV64AMDGCNTargetInfo::getTargetBuiltins() const {
+ return AMDGPUTI.getTargetBuiltins();
}
void SPIRV64AMDGCNTargetInfo::getTargetDefines(const LangOptions &Opts,
diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
index f25c0cb93e6579..85e4bd920d8535 100644
--- a/clang/lib/Basic/Targets/SPIR.h
+++ b/clang/lib/Basic/Targets/SPIR.h
@@ -159,10 +159,7 @@ class LLVM_LIBRARY_VISIBILITY BaseSPIRTargetInfo : public TargetInfo {
// memcpy as per section 3 of the SPIR spec.
bool useFP16ConversionIntrinsics() const override { return false; }
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override {
- return {nullptr, {}};
- }
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override { return {}; }
std::string_view getClobbers() const override { return ""; }
@@ -411,8 +408,7 @@ class LLVM_LIBRARY_VISIBILITY SPIRV64AMDGCNTargetInfo final
std::string convertConstraint(const char *&Constraint) const override;
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override;
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override;
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override;
diff --git a/clang/lib/Basic/Targets/Sparc.h b/clang/lib/Basic/Targets/Sparc.h
index 480073fae35c59..9c529a5bc5e7fa 100644
--- a/clang/lib/Basic/Targets/Sparc.h
+++ b/clang/lib/Basic/Targets/Sparc.h
@@ -48,10 +48,9 @@ class LLVM_LIBRARY_VISIBILITY SparcTargetInfo : public TargetInfo {
bool hasFeature(StringRef Feature) const override;
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override {
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override {
// FIXME: Implement!
- return {nullptr, {}};
+ return {};
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::VoidPtrBuiltinVaList;
diff --git a/clang/lib/Basic/Targets/SystemZ.cpp b/clang/lib/Basic/Targets/SystemZ.cpp
index ffc55a80db9d9b..06f08db2eadd47 100644
--- a/clang/lib/Basic/Targets/SystemZ.cpp
+++ b/clang/lib/Basic/Targets/SystemZ.cpp
@@ -20,18 +20,13 @@
using namespace clang;
using namespace clang::targets;
-static constexpr int NumBuiltins =
- clang::SystemZ::LastTSBuiltin - Builtin::FirstTSBuiltin;
-
-static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make(
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE
-#include "clang/Basic/BuiltinsSystemZ.def"
- , {
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY
+static constexpr Builtin::Info BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsSystemZ.def"
- });
+};
const char *const SystemZTargetInfo::GCCRegNames[] = {
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
@@ -175,7 +170,7 @@ void SystemZTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__VEC__", "10304");
}
-std::pair<const char *, ArrayRef<Builtin::Info>>
-SystemZTargetInfo::getTargetBuiltinStorage() const {
- return {BuiltinStorage.StringTable, BuiltinStorage.Infos};
+ArrayRef<Builtin::Info> SystemZTargetInfo::getTargetBuiltins() const {
+ return llvm::ArrayRef(BuiltinInfo, clang::SystemZ::LastTSBuiltin -
+ Builtin::FirstTSBuiltin);
}
diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h
index 04e00bac644765..e6405f174f660f 100644
--- a/clang/lib/Basic/Targets/SystemZ.h
+++ b/clang/lib/Basic/Targets/SystemZ.h
@@ -99,8 +99,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override;
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override;
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override;
ArrayRef<const char *> getGCCRegNames() const override;
diff --git a/clang/lib/Basic/Targets/TCE.h b/clang/lib/Basic/Targets/TCE.h
index 52a2b13fe28057..d6280b02f07b25 100644
--- a/clang/lib/Basic/Targets/TCE.h
+++ b/clang/lib/Basic/Targets/TCE.h
@@ -95,10 +95,7 @@ class LLVM_LIBRARY_VISIBILITY TCETargetInfo : public TargetInfo {
bool hasFeature(StringRef Feature) const override { return Feature == "tce"; }
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override {
- return {nullptr, {}};
- }
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override { return {}; }
std::string_view getClobbers() const override { return ""; }
diff --git a/clang/lib/Basic/Targets/VE.cpp b/clang/lib/Basic/Targets/VE.cpp
index f54ddc00f6f68a..67cae8faf60522 100644
--- a/clang/lib/Basic/Targets/VE.cpp
+++ b/clang/lib/Basic/Targets/VE.cpp
@@ -18,16 +18,11 @@
using namespace clang;
using namespace clang::targets;
-static constexpr int NumBuiltins =
- clang::VE::LastTSBuiltin - Builtin::FirstTSBuiltin;
-
-static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make(
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#include "clang/Basic/BuiltinsVE.def"
- , {
-#define BUILTIN CLANG_BUILTIN_ENTRY
+static constexpr Builtin::Info BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsVE.def"
- });
+};
void VETargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
@@ -44,7 +39,7 @@ void VETargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
}
-std::pair<const char *, ArrayRef<Builtin::Info>>
-VETargetInfo::getTargetBuiltinStorage() const {
- return {BuiltinStorage.StringTable, BuiltinStorage.Infos};
+ArrayRef<Builtin::Info> VETargetInfo::getTargetBuiltins() const {
+ return llvm::ArrayRef(BuiltinInfo,
+ clang::VE::LastTSBuiltin - Builtin::FirstTSBuiltin);
}
diff --git a/clang/lib/Basic/Targets/VE.h b/clang/lib/Basic/Targets/VE.h
index d2b0cd6de4d51a..7e8fdf6096ef23 100644
--- a/clang/lib/Basic/Targets/VE.h
+++ b/clang/lib/Basic/Targets/VE.h
@@ -55,8 +55,7 @@ class LLVM_LIBRARY_VISIBILITY VETargetInfo : public TargetInfo {
bool hasSjLjLowering() const override { return true; }
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override;
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override;
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::VoidPtrBuiltinVaList;
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp b/clang/lib/Basic/Targets/WebAssembly.cpp
index 14f1ac20747f5a..7b0fd0c841ba23 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -20,19 +20,15 @@
using namespace clang;
using namespace clang::targets;
-static constexpr int NumBuiltins =
- clang::WebAssembly::LastTSBuiltin - Builtin::FirstTSBuiltin;
-
-static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make(
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE
-#include "clang/Basic/BuiltinsWebAssembly.def"
- , {
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY
-#define LIBBUILTIN CLANG_LIBBUILTIN_ENTRY
+static constexpr Builtin::Info BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsWebAssembly.def"
- });
+};
static constexpr llvm::StringLiteral ValidCPUNames[] = {
{"mvp"}, {"bleeding-edge"}, {"generic"}, {"lime1"}};
@@ -364,9 +360,9 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
return true;
}
-std::pair<const char *, ArrayRef<Builtin::Info>>
-WebAssemblyTargetInfo::getTargetBuiltinStorage() const {
- return {BuiltinStorage.StringTable, BuiltinStorage.Infos};
+ArrayRef<Builtin::Info> WebAssemblyTargetInfo::getTargetBuiltins() const {
+ return llvm::ArrayRef(BuiltinInfo, clang::WebAssembly::LastTSBuiltin -
+ Builtin::FirstTSBuiltin);
}
void WebAssemblyTargetInfo::adjust(DiagnosticsEngine &Diags,
diff --git a/clang/lib/Basic/Targets/WebAssembly.h b/clang/lib/Basic/Targets/WebAssembly.h
index 6ce2bb00e5f2a6..0a14da6a277b8e 100644
--- a/clang/lib/Basic/Targets/WebAssembly.h
+++ b/clang/lib/Basic/Targets/WebAssembly.h
@@ -120,8 +120,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssemblyTargetInfo : public TargetInfo {
bool setCPU(const std::string &Name) final { return isValidCPUName(Name); }
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const final;
+ ArrayRef<Builtin::Info> getTargetBuiltins() const final;
BuiltinVaListKind getBuiltinVaListKind() const final {
return VoidPtrBuiltinVaList;
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 0b071573aa1e0f..1b16888a0711b5 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -23,45 +23,31 @@
namespace clang {
namespace targets {
-// The x86-32 builtins are a subset and prefix of the x86-64 builtins.
-static constexpr int NumX86Builtins =
- X86::LastX86CommonBuiltin - Builtin::FirstTSBuiltin + 1;
-static constexpr int NumX86_64Builtins =
- X86::LastTSBuiltin - Builtin::FirstTSBuiltin;
-static_assert(NumX86Builtins < NumX86_64Builtins);
-
-static constexpr auto BuiltinStorage =
- Builtin::Storage<NumX86_64Builtins>::Make(
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE
-#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_STR_TABLE
+static constexpr Builtin::Info BuiltinInfoX86[] = {
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::HEADER, LANGS},
#include "clang/Basic/BuiltinsX86.def"
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE
-#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_STR_TABLE
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::HEADER, LANGS},
#include "clang/Basic/BuiltinsX86.inc"
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE
-#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_STR_TABLE
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \
+ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::HEADER, LANGS},
#include "clang/Basic/BuiltinsX86_64.def"
- , {
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY
-#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_ENTRY
-#include "clang/Basic/BuiltinsX86.def"
-
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY
-#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_ENTRY
-#include "clang/Basic/BuiltinsX86.inc"
-
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY
-#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_ENTRY
-#include "clang/Basic/BuiltinsX86_64.def"
- });
+};
static const char *const GCCRegNames[] = {
"ax", "dx", "cx", "bx", "si", "di", "bp", "sp",
@@ -1878,14 +1864,12 @@ ArrayRef<TargetInfo::AddlRegName> X86TargetInfo::getGCCAddlRegNames() const {
return llvm::ArrayRef(AddlRegNames);
}
-std::pair<const char *, ArrayRef<Builtin::Info>>
-X86_32TargetInfo::getTargetBuiltinStorage() const {
- // Only use the relevant prefix of the infos, the string table base is common.
- return {BuiltinStorage.StringTable,
- llvm::ArrayRef(BuiltinStorage.Infos).take_front(NumX86Builtins)};
+ArrayRef<Builtin::Info> X86_32TargetInfo::getTargetBuiltins() const {
+ return llvm::ArrayRef(BuiltinInfoX86, clang::X86::LastX86CommonBuiltin -
+ Builtin::FirstTSBuiltin + 1);
}
-std::pair<const char *, ArrayRef<Builtin::Info>>
-X86_64TargetInfo::getTargetBuiltinStorage() const {
- return {BuiltinStorage.StringTable, BuiltinStorage.Infos};
+ArrayRef<Builtin::Info> X86_64TargetInfo::getTargetBuiltins() const {
+ return llvm::ArrayRef(BuiltinInfoX86,
+ X86::LastTSBuiltin - Builtin::FirstTSBuiltin);
}
diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 385d9e87a4e378..3ed36c8fa724b5 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -508,8 +508,7 @@ class LLVM_LIBRARY_VISIBILITY X86_32TargetInfo : public X86TargetInfo {
MaxAtomicInlineWidth = 64;
}
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override;
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override;
bool hasBitIntType() const override { return true; }
size_t getMaxBitIntWidth() const override {
@@ -813,8 +812,7 @@ class LLVM_LIBRARY_VISIBILITY X86_64TargetInfo : public X86TargetInfo {
MaxAtomicInlineWidth = 128;
}
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override;
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override;
bool hasBitIntType() const override { return true; }
size_t getMaxBitIntWidth() const override {
diff --git a/clang/lib/Basic/Targets/XCore.cpp b/clang/lib/Basic/Targets/XCore.cpp
index 403d421d0c0670..fd377bbfb90e16 100644
--- a/clang/lib/Basic/Targets/XCore.cpp
+++ b/clang/lib/Basic/Targets/XCore.cpp
@@ -18,17 +18,13 @@
using namespace clang;
using namespace clang::targets;
-static constexpr int NumBuiltins =
- XCore::LastTSBuiltin - Builtin::FirstTSBuiltin;
-
-static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make(
-#define BUILTIN CLANG_BUILTIN_STR_TABLE
-#include "clang/Basic/BuiltinsXCore.def"
- , {
-#define BUILTIN CLANG_BUILTIN_ENTRY
-#define LIBBUILTIN CLANG_LIBBUILTIN_ENTRY
+static constexpr Builtin::Info BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
+ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsXCore.def"
- });
+};
void XCoreTargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
@@ -36,7 +32,7 @@ void XCoreTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__XS1B__");
}
-std::pair<const char *, ArrayRef<Builtin::Info>>
-XCoreTargetInfo::getTargetBuiltinStorage() const {
- return {BuiltinStorage.StringTable, BuiltinStorage.Infos};
+ArrayRef<Builtin::Info> XCoreTargetInfo::getTargetBuiltins() const {
+ return llvm::ArrayRef(BuiltinInfo,
+ clang::XCore::LastTSBuiltin - Builtin::FirstTSBuiltin);
}
diff --git a/clang/lib/Basic/Targets/XCore.h b/clang/lib/Basic/Targets/XCore.h
index 1082990d74b2b0..84fd59d1a71e49 100644
--- a/clang/lib/Basic/Targets/XCore.h
+++ b/clang/lib/Basic/Targets/XCore.h
@@ -43,8 +43,7 @@ class LLVM_LIBRARY_VISIBILITY XCoreTargetInfo : public TargetInfo {
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override;
- std::pair<const char *, ArrayRef<Builtin::Info>>
- getTargetBuiltinStorage() const override;
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override;
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::VoidPtrBuiltinVaList;
More information about the llvm-branch-commits
mailing list