LLVM 23.0.0git
Registry.h File Reference

Go to the source code of this file.

Classes

class  llvm::SimpleRegistryEntry< T, CtorParamTypes >
 A simple registry entry which provides only a name, description, and an CtorParamTypes&& variadic parameterized constructor. More...
struct  llvm::detail::IsRegistryType< R >
struct  llvm::detail::IsRegistryType< Registry< T, CtorParamTypes... > >
struct  llvm::detail::RegistryLinkListStorage< R >
 The endpoint to the instance to hold registered components by a linked list. More...
struct  llvm::detail::RegistryLinkListDeclarationMarker< R >
 Utility to guard against missing declarations or mismatched use of LLVM_DECLARE_REGISTRY and LLVM_INSTANTIATE_REGISTRY. More...
class  llvm::Registry< T, CtorParamTypes >
 A global registry used in conjunction with static constructors to make pluggable components (like targets or garbage collectors) "just work" when linked with an executable. More...
class  llvm::Registry< T, CtorParamTypes >::node
 Node in linked list of entries. More...
class  llvm::Registry< T, CtorParamTypes >::iterator
 Iterators for registry entries. More...
class  llvm::Registry< T, CtorParamTypes >::Add< V >
 A static registration template. More...

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
namespace  llvm::detail
 A self-contained host- and target-independent arbitrary-precision floating-point software implementation.

Macros

#define LLVM_DECLARE_REGISTRY(REGISTRY_CLASS)
 Helper macro to declare registry class.
#define LLVM_DEFINE_REGISTRY(REGISTRY_CLASS)
 Helper macro to define registry class.
#define LLVM_DETAIL_INSTANTIATE_REGISTRY_1(ABITAG, REGISTRY_CLASS)
#define LLVM_INSTANTIATE_REGISTRY(REGISTRY_CLASS)
 Old style helper macro to instantiate registry class.
#define LLVM_DECLARE_REGISTRY_EX(EXPORT_ABI, REGISTRY_CLASS)
 Variants of the registration macros that take an explicit export annotation (EXPORT_ABI) in place of the hard-coded LLVM_ABI_EXPORT.
#define LLVM_DEFINE_REGISTRY_EX(EXPORT_ABI, REGISTRY_CLASS)
#define LLVM_INSTANTIATE_REGISTRY_EX(EXPORT_ABI, REGISTRY_CLASS)

Functions

template<typename R>
RegistryLinkListStorage< R > & llvm::detail::getRegistryLinkListInstance ()
 The accessor to the endpoint.

Macro Definition Documentation

◆ LLVM_DECLARE_REGISTRY

#define LLVM_DECLARE_REGISTRY ( REGISTRY_CLASS)
Value:
namespace llvm::detail { \
template <> \
struct RegistryLinkListDeclarationMarker<REGISTRY_CLASS> : std::true_type { \
}; \
template <> \
LLVM_ABI_EXPORT RegistryLinkListStorage<REGISTRY_CLASS> & \
getRegistryLinkListInstance<REGISTRY_CLASS>(); \
}
#define LLVM_ABI_EXPORT
Definition Compiler.h:218
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
Definition ADL.h:123

Helper macro to declare registry class.

The LLVM_ABI_EXPORT (i.e. __delcpsec(dllexport) on Win32) attached to the declaration is mandatory since MSVC disallows adding dllexport after the first non-exported specialization declaration, and it is generally safe. All of link.exe, ld.bfd, and lld-link will attempt to import undefined symbols (including template specializations) from DLLs, even if the symbol is declared with dllexport, just like non-imported symbols. The dllimport attribute is not eligible here, since the specialization may or may not be defined in the same object, a static library, or an import library.

Definition at line 221 of file Registry.h.

◆ LLVM_DECLARE_REGISTRY_EX

#define LLVM_DECLARE_REGISTRY_EX ( EXPORT_ABI,
REGISTRY_CLASS )
Value:
namespace llvm::detail { \
template <> \
struct RegistryLinkListDeclarationMarker<REGISTRY_CLASS> : std::true_type { \
}; \
template <> \
EXPORT_ABI RegistryLinkListStorage<REGISTRY_CLASS> & \
getRegistryLinkListInstance<REGISTRY_CLASS>(); \
}

Variants of the registration macros that take an explicit export annotation (EXPORT_ABI) in place of the hard-coded LLVM_ABI_EXPORT.

Use these when a registry is owned by a component that is NOT part of the LLVM dylib. For example, a clang library that is statically linked (CLANG_LINK_CLANG_DYLIB OFF). With LLVM_ABI_EXPORT the getRegistryLinkListInstance accessor is unconditionally dllexported; when such a static component is embedded in a DLL that should only export its own API surface (e.g. libclang.dll), the accessor leaks into that DLL's export table and then collides on the link line of any tool that also links the static component directly.

EXPORT_ABI must export-or-be-empty, NEVER dllimport, for the same reason LLVM_ABI_EXPORT is used here rather than LLVM_ABI: the definition may be in the same object, a static library, or an import library. CLANG_ABI_EXPORT satisfies this (it is empty under CLANG_BUILD_STATIC).

Definition at line 287 of file Registry.h.

◆ LLVM_DEFINE_REGISTRY

#define LLVM_DEFINE_REGISTRY ( REGISTRY_CLASS)
Value:
namespace llvm::detail { \
static_assert(RegistryLinkListDeclarationMarker<REGISTRY_CLASS>::value, \
"Missing matching registry delcaration of " #REGISTRY_CLASS \
". Place `LLVM_DECLARE_REGISTRY(" #REGISTRY_CLASS \
")` in a header."); \
template <> \
LLVM_ABI_EXPORT RegistryLinkListStorage<REGISTRY_CLASS> & \
getRegistryLinkListInstance<REGISTRY_CLASS>() { \
static RegistryLinkListStorage<REGISTRY_CLASS> Instance; \
return Instance; \
} \
}

Helper macro to define registry class.

Technically, these macros don't instantiate Registry despite the name. They handle underlying storage that used by Registry indirectly, enforcing proper declarations/definitions by compilers or linkers. If you forget to place LLVM_DEFINE_REGISTRY, your linker will complain about a missing getRegistryLinkListInstance definiton.

Definition at line 238 of file Registry.h.

◆ LLVM_DEFINE_REGISTRY_EX

#define LLVM_DEFINE_REGISTRY_EX ( EXPORT_ABI,
REGISTRY_CLASS )
Value:
namespace llvm::detail { \
static_assert(RegistryLinkListDeclarationMarker<REGISTRY_CLASS>::value, \
"Missing matching registry declaration of " #REGISTRY_CLASS \
". Place `LLVM_DECLARE_REGISTRY(" #REGISTRY_CLASS \
")` in a header."); \
template <> \
EXPORT_ABI RegistryLinkListStorage<REGISTRY_CLASS> & \
getRegistryLinkListInstance<REGISTRY_CLASS>() { \
static RegistryLinkListStorage<REGISTRY_CLASS> Instance; \
return Instance; \
} \
}

Definition at line 297 of file Registry.h.

◆ LLVM_DETAIL_INSTANTIATE_REGISTRY_1

#define LLVM_DETAIL_INSTANTIATE_REGISTRY_1 ( ABITAG,
REGISTRY_CLASS )
Value:
LLVM_DECLARE_REGISTRY(REGISTRY_CLASS) \
LLVM_DEFINE_REGISTRY(REGISTRY_CLASS) \
namespace llvm { \
template class ABITAG Registry<REGISTRY_CLASS::type>; \
static_assert(!REGISTRY_CLASS::HasCtorParamTypes, \
"LLVM_INSTANTIATE_REGISTRY can't be used with extra " \
"constructor parameter types. Use " \
"LLVM_DECLARE/DEFINE_REGISTRY istead."); \
}
#define LLVM_DECLARE_REGISTRY(REGISTRY_CLASS)
Helper macro to declare registry class.
Definition Registry.h:221
This is an optimization pass for GlobalISel generic memory operations.

Definition at line 252 of file Registry.h.

◆ LLVM_INSTANTIATE_REGISTRY

#define LLVM_INSTANTIATE_REGISTRY ( REGISTRY_CLASS)
Value:
#define LLVM_DETAIL_INSTANTIATE_REGISTRY_1(ABITAG, REGISTRY_CLASS)
Definition Registry.h:252

Old style helper macro to instantiate registry class.

Definition at line 269 of file Registry.h.

◆ LLVM_INSTANTIATE_REGISTRY_EX

#define LLVM_INSTANTIATE_REGISTRY_EX ( EXPORT_ABI,
REGISTRY_CLASS )
Value:
LLVM_DECLARE_REGISTRY_EX(EXPORT_ABI, REGISTRY_CLASS) \
LLVM_DEFINE_REGISTRY_EX(EXPORT_ABI, REGISTRY_CLASS) \
namespace llvm { \
template class EXPORT_ABI Registry<REGISTRY_CLASS::type>; \
static_assert(!REGISTRY_CLASS::HasCtorParamTypes, \
"LLVM_INSTANTIATE_REGISTRY can't be used with extra " \
"constructor parameter types. Use " \
"LLVM_DECLARE/DEFINE_REGISTRY istead."); \
}
#define LLVM_DECLARE_REGISTRY_EX(EXPORT_ABI, REGISTRY_CLASS)
Variants of the registration macros that take an explicit export annotation (EXPORT_ABI) in place of ...
Definition Registry.h:287

Definition at line 311 of file Registry.h.