LLVM: include/llvm/Support/Registry.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13#ifndef LLVM_SUPPORT_REGISTRY_H

14#define LLVM_SUPPORT_REGISTRY_H

15

21#include

22

23namespace llvm {

24

25

26 template

29 std::unique_ptr (*Ctor)();

30

31 public:

33 : Name(N), Desc(D), Ctor(C) {}

34

37 std::unique_ptr instantiate() const { return Ctor(); }

38 };

39

40

41

42

43 template

44 class Registry {

45 public:

48

49 class node;

50 class iterator;

51

52 private:

54

55 friend class node;

56

57

58

59

60

61 static inline node *Head = nullptr;

62 static inline node *Tail = nullptr;

63

64 public:

65

66

69 friend Registry;

70

73

74 public:

75 node(const entry &V) : Next(nullptr), Val(V) {}

76 };

77

78

79

80

81

82

83

84

86 if (Tail)

87 Tail->Next = N;

88 else

89 Head = N;

90 Tail = N;

91 }

92

93

94

97 const entry> {

98 const node *Cur;

99

100 public:

102

106 };

107

108

109

110 static iterator begin() { return iterator(Head); }

111 static iterator end() { return iterator(nullptr); }

112

116

117

118

119

120

121

122

123

124

125 template

129

130 static std::unique_ptr CtorFn() { return std::make_unique(); }

131

132 public:

134 : Entry(Name, Desc, CtorFn), Node(Entry) {

136 }

137 };

138 };

139

140}

141

142#ifdef _WIN32

143

144#define LLVM_INSTANTIATE_REGISTRY(REGISTRY_CLASS) \

145 namespace llvm { \

146 template class LLVM_ABI_EXPORT Registry<REGISTRY_CLASS::type>; \

147 }

148#else

149#define LLVM_INSTANTIATE_REGISTRY(REGISTRY_CLASS) \

150 namespace llvm { \

151 template class Registry<REGISTRY_CLASS::type>; \

152 }

153#endif

154

155#endif

static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")

Add(StringRef Name, StringRef Desc)

Definition Registry.h:133

const entry & operator*() const

Definition Registry.h:105

iterator & operator++()

Definition Registry.h:104

iterator(const node *N)

Definition Registry.h:101

bool operator==(const iterator &That) const

Definition Registry.h:103

Node in linked list of entries.

Definition Registry.h:67

friend class iterator

Definition Registry.h:68

node(const entry &V)

Definition Registry.h:75

static iterator end()

Definition Registry.h:111

static iterator_range< iterator > entries()

Definition Registry.h:113

static iterator begin()

Definition Registry.h:110

SimpleRegistryEntry< GCMetadataPrinter > entry

Definition Registry.h:47

GCMetadataPrinter type

Definition Registry.h:46

static void add_node(node *N)

Add a node to the Registry: this is the interface between the plugin and the executable.

Definition Registry.h:85

A simple registry entry which provides only a name, description, and no-argument constructor.

Definition Registry.h:27

SimpleRegistryEntry(StringRef N, StringRef D, std::unique_ptr< T >(*C)())

Definition Registry.h:32

StringRef getName() const

Definition Registry.h:35

StringRef getDesc() const

Definition Registry.h:36

std::unique_ptr< T > instantiate() const

Definition Registry.h:37

StringRef - Represent a constant reference to a string, i.e.

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.