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>
53template <
typename T,
typename... CtorParamTypes>
class Registry {
56 "Trying to instantiate a wrong specialization 'Registry<Registry<...>>'");
75 static inline node *Head =
nullptr;
76 static inline node *Tail =
nullptr;
83 friend Registry<
T, CtorParamTypes...>;
127 static iterator
begin() {
return iterator(Head); }
128 static iterator
end() {
return iterator(
nullptr); }
139 template <
typename V>
class Add {
143 static std::unique_ptr<T> CtorFn(CtorParamTypes &&...Params) {
144 return std::make_unique<V>(std::forward<CtorParamTypes>(Params)...);
149 : Entry(Name,
Desc, CtorFn), Node(Entry) {
159#define LLVM_INSTANTIATE_REGISTRY(REGISTRY_CLASS) \
161 template class LLVM_ABI_EXPORT Registry<REGISTRY_CLASS::type>; \
162 static_assert(!REGISTRY_CLASS::HasCtorParamTypes, \
163 "LLVM_INSTANTIATE_REGISTRY can't be used with extra " \
164 "constructor parameter types"); \
167#define LLVM_INSTANTIATE_REGISTRY(REGISTRY_CLASS) \
169 template class Registry<REGISTRY_CLASS::type>; \
170 static_assert(!REGISTRY_CLASS::HasCtorParamTypes, \
171 "LLVM_INSTANTIATE_REGISTRY can't be used with extra " \
172 "constructor parameter types"); \
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.
@ C
The default llvm calling convention, compatible with C.
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.