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)...);
46template <
typename T,
typename... CtorParamTypes>
class Registry {
63 static inline node *Head =
nullptr;
64 static inline node *Tail =
nullptr;
71 friend Registry<
T, CtorParamTypes...>;
115 static iterator
begin() {
return iterator(Head); }
116 static iterator
end() {
return iterator(
nullptr); }
127 template <
typename V>
class Add {
131 static std::unique_ptr<T> CtorFn(CtorParamTypes &&...Params) {
132 return std::make_unique<V>(std::forward<CtorParamTypes>(Params)...);
137 : Entry(Name,
Desc, CtorFn), Node(Entry) {
147#define LLVM_INSTANTIATE_REGISTRY(REGISTRY_CLASS) \
149 template class LLVM_ABI_EXPORT Registry<REGISTRY_CLASS::type>; \
152#define LLVM_INSTANTIATE_REGISTRY(REGISTRY_CLASS) \
154 template class Registry<REGISTRY_CLASS::type>; \
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.
SimpleRegistryEntry< GCMetadataPrinter, CtorParamTypes... > entry
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.