13#ifndef LLVM_SUPPORT_REGISTRY_H
14#define LLVM_SUPPORT_REGISTRY_H
34 : Name(
N), Desc(
D), Ctor(
C) {}
38 std::unique_ptr<T>
instantiate(CtorParamTypes &&...Params)
const {
39 return Ctor(std::forward<CtorParamTypes>(Params)...);
43template <
typename T,
typename... CtorParamTypes>
class Registry;
46template <
typename T,
typename... CtorParamTypes>
116template <
typename T,
typename... CtorParamTypes>
class Registry {
119 "Trying to instantiate a wrong specialization 'Registry<Registry<...>>'");
139 friend Registry<
T, CtorParamTypes...>;
181 static iterator
end() {
return iterator(
nullptr); }
192 template <
typename V>
class Add {
196 static std::unique_ptr<T> CtorFn(CtorParamTypes &&...Params) {
197 static_assert(std::has_virtual_destructor_v<T>);
198 return std::make_unique<V>(std::forward<CtorParamTypes>(Params)...);
203 : Entry(Name,
Desc, CtorFn), Node(Entry) {
221#define LLVM_DECLARE_REGISTRY(REGISTRY_CLASS) \
222 namespace llvm::detail { \
224 struct RegistryLinkListDeclarationMarker<REGISTRY_CLASS> : std::true_type { \
227 LLVM_ABI_EXPORT RegistryLinkListStorage<REGISTRY_CLASS> & \
228 getRegistryLinkListInstance<REGISTRY_CLASS>(); \
238#define LLVM_DEFINE_REGISTRY(REGISTRY_CLASS) \
239 namespace llvm::detail { \
240 static_assert(RegistryLinkListDeclarationMarker<REGISTRY_CLASS>::value, \
241 "Missing matching registry delcaration of " #REGISTRY_CLASS \
242 ". Place `LLVM_DECLARE_REGISTRY(" #REGISTRY_CLASS \
243 ")` in a header."); \
245 LLVM_ABI_EXPORT RegistryLinkListStorage<REGISTRY_CLASS> & \
246 getRegistryLinkListInstance<REGISTRY_CLASS>() { \
247 static RegistryLinkListStorage<REGISTRY_CLASS> Instance; \
252#define LLVM_DETAIL_INSTANTIATE_REGISTRY_1(ABITAG, REGISTRY_CLASS) \
253 LLVM_DECLARE_REGISTRY(REGISTRY_CLASS) \
254 LLVM_DEFINE_REGISTRY(REGISTRY_CLASS) \
256 template class ABITAG Registry<REGISTRY_CLASS::type>; \
257 static_assert(!REGISTRY_CLASS::HasCtorParamTypes, \
258 "LLVM_INSTANTIATE_REGISTRY can't be used with extra " \
259 "constructor parameter types. Use " \
260 "LLVM_DECLARE/DEFINE_REGISTRY istead."); \
266#define LLVM_INSTANTIATE_REGISTRY(REGISTRY_CLASS) \
267 LLVM_DETAIL_INSTANTIATE_REGISTRY_1(LLVM_ABI_EXPORT, REGISTRY_CLASS)
269#define LLVM_INSTANTIATE_REGISTRY(REGISTRY_CLASS) \
270 LLVM_DETAIL_INSTANTIATE_REGISTRY_1(, REGISTRY_CLASS)
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Add(StringRef Name, StringRef Desc)
const entry & operator*() const
bool operator==(const iterator &That) const
Node in linked list of entries.
A global registry used in conjunction with static constructors to make pluggable components (like tar...
SimpleRegistryEntry< GCMetadataPrinter, CtorParamTypes... > entry
static constexpr bool HasCtorParamTypes
static iterator_range< iterator > entries()
static void add_node(node *N)
Add a node to the Registry: this is the interface between the plugin and the executable.
A simple registry entry which provides only a name, description, and an CtorParamTypes&& variadic par...
StringRef getName() const
std::unique_ptr< T > instantiate(CtorParamTypes &&...Params) const
StringRef getDesc() const
SimpleRegistryEntry(StringRef N, StringRef D, FactoryFnRef C)
StringRef - Represent a constant reference to a string, i.e.
An efficient, type-erasing, non-owning reference to a callable.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
A range adaptor for a pair of iterators.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
@ Tail
Attemps to make calls as fast as possible while guaranteeing that tail call optimization can always b...
@ C
The default llvm calling convention, compatible with C.
RegistryLinkListStorage< R > & getRegistryLinkListInstance()
The accessor to the endpoint.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
MachinePassRegistry< typename RegisterRegAllocBase< T >::FunctionPassCtor > RegisterRegAllocBase< T >::Registry
RegisterRegAlloc's global Registry tracks allocator registration.
Utility to guard against missing declarations or mismatched use of LLVM_DECLARE_REGISTRY and LLVM_INS...
The endpoint to the instance to hold registered components by a linked list.