LLVM: include/llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_EXECUTIONENGINE_ORC_SHARED_MEMORYFLAGS_H

15#define LLVM_EXECUTIONENGINE_ORC_SHARED_MEMORYFLAGS_H

16

22

23namespace llvm {

24namespace orc {

25

26

34

35

41

42

43

45 std::underlying_type_tsys::Memory::ProtectionFlags PF = 0;

53}

54

55

56

67

68

69

70

71

72

73

74

76

77

79

80

81

82

84

85

86

87

89};

90

91

93 switch (MLP) {

95 OS << "standard";

96 break;

98 OS << "finalize";

99 break;

101 OS << "noalloc";

102 break;

103 }

104 return OS;

105}

106

107

108

109

112

113 using underlying_type = uint8_t;

114 static constexpr unsigned BitsForProt = 3;

115 static constexpr unsigned BitsForLifetimePolicy = 2;

116 static constexpr unsigned MaxIdentifiers =

117 1U << (BitsForProt + BitsForLifetimePolicy);

118

119public:

120 static constexpr unsigned NumGroups = MaxIdentifiers;

121

122

123

125

126

127

129

130

132 : Id(static_cast<underlying_type>(MP) |

133 (static_cast<underlying_type>(MLP) << BitsForProt)) {}

134

135

137 return static_cast<MemProt>(Id & ((1U << BitsForProt) - 1));

138 }

139

140

142 return static_cast<MemLifetime>(Id >> BitsForProt);

143 }

144

146 return LHS.Id == RHS.Id;

147 }

148

150 return !(LHS == RHS);

151 }

152

154 return LHS.Id < RHS.Id;

155 }

156

157private:

158 AllocGroup(underlying_type RawId) : Id(RawId) {}

159 underlying_type Id = 0;

160};

161

162

163

164

166private:

167 using ElemT = std::pair<AllocGroup, T>;

169

170 static bool compareKey(const ElemT &E, const AllocGroup &G) {

171 return E.first < G;

172 }

173

174public:

176

179 : Elems(Inits) {

181 }

182

187 return (I == end() || I->first == G) ? I : end();

188 }

189

190 bool empty() const { return Elems.empty(); }

191 size_t size() const { return Elems.size(); }

192

195 if (I == Elems.end() || I->first != G)

196 I = Elems.insert(I, std::make_pair(G, T()));

197 return I->second;

198 }

199

200private:

201 VectorTy Elems;

202};

203

204

207}

208

209}

210

217 using UT = std::underlying_type_torc::MemProt;

219 }

223};

224

239

240}

241

242#endif

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

This file defines DenseMapInfo traits for DenseMap.

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

size_t size() const

Definition MemoryFlags.h:191

bool empty() const

Definition MemoryFlags.h:190

iterator find(AllocGroup G)

Definition MemoryFlags.h:185

iterator end()

Definition MemoryFlags.h:184

T & operator[](AllocGroup G)

Definition MemoryFlags.h:193

iterator begin()

Definition MemoryFlags.h:183

AllocGroupSmallMap(std::initializer_list< std::pair< AllocGroup, T > > Inits)

Definition MemoryFlags.h:178

AllocGroupSmallMap()=default

typename VectorTy::iterator iterator

Definition MemoryFlags.h:175

A pair of memory protections and allocation policies.

Definition MemoryFlags.h:110

static constexpr unsigned NumGroups

Definition MemoryFlags.h:120

MemProt getMemProt() const

Returns the MemProt for this group.

Definition MemoryFlags.h:136

friend bool operator==(const AllocGroup &LHS, const AllocGroup &RHS)

Definition MemoryFlags.h:145

AllocGroup(MemProt MP)

Create an AllocGroup from a MemProt only – uses MemLifetime::Standard.

Definition MemoryFlags.h:128

AllocGroup()=default

Create a default AllocGroup.

MemLifetime getMemLifetime() const

Returns the MemLifetime for this group.

Definition MemoryFlags.h:141

friend bool operator<(const AllocGroup &LHS, const AllocGroup &RHS)

Definition MemoryFlags.h:153

AllocGroup(MemProt MP, MemLifetime MLP)

Create an AllocGroup from a MemProt and a MemLifetime.

Definition MemoryFlags.h:131

friend bool operator!=(const AllocGroup &LHS, const AllocGroup &RHS)

Definition MemoryFlags.h:149

This class implements an extremely fast bulk output stream that can only output to a stream.

MemProt

Describes Read/Write/Exec permissions for memory.

Definition MemoryFlags.h:27

@ Write

Definition MemoryFlags.h:30

@ None

Definition MemoryFlags.h:28

@ Read

Definition MemoryFlags.h:29

@ Exec

Definition MemoryFlags.h:31

MemProt fromSysMemoryProtectionFlags(sys::Memory::ProtectionFlags PF)

Convert a sys::Memory::ProtectionFlags value to a corresponding MemProt value.

Definition MemoryFlags.h:57

LLVM_ABI raw_ostream & operator<<(raw_ostream &OS, const SymbolNameSet &Symbols)

Render a SymbolNameSet.

MemLifetime

Describes a memory lifetime policy for memory to be allocated by a JITLinkMemoryManager.

Definition MemoryFlags.h:75

@ NoAlloc

NoAlloc memory should not be allocated by the JITLinkMemoryManager at all.

Definition MemoryFlags.h:88

@ Standard

Standard memory should be allocated by the allocator and then deallocated when the deallocate method ...

Definition MemoryFlags.h:78

@ Finalize

Finalize memory should be allocated by the allocator, and then be overwritten and deallocated after a...

Definition MemoryFlags.h:83

sys::Memory::ProtectionFlags toSysMemoryProtectionFlags(MemProt MP)

Convert a MemProt value to a corresponding sys::Memory::ProtectionFlags value.

Definition MemoryFlags.h:44

This is an optimization pass for GlobalISel generic memory operations.

void sort(IteratorTy Start, IteratorTy End)

@ LLVM_MARK_AS_BITMASK_ENUM

auto lower_bound(R &&Range, T &&Value)

Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...

static bool isEqual(const orc::AllocGroup &LHS, const orc::AllocGroup &RHS)

Definition MemoryFlags.h:235

static orc::AllocGroup getEmptyKey()

Definition MemoryFlags.h:226

static orc::AllocGroup getTombstoneKey()

Definition MemoryFlags.h:229

static unsigned getHashValue(const orc::AllocGroup &Val)

Definition MemoryFlags.h:232

static orc::MemProt getEmptyKey()

Definition MemoryFlags.h:212

static bool isEqual(const orc::MemProt &LHS, const orc::MemProt &RHS)

Definition MemoryFlags.h:220

static orc::MemProt getTombstoneKey()

Definition MemoryFlags.h:213

static unsigned getHashValue(const orc::MemProt &Val)

Definition MemoryFlags.h:216

An information struct used to provide DenseMap with the various necessary components for a given valu...

Function object to check whether the first component of a container supported by std::get (like std::...