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

1

2

3

4

5

6

7

8

9

10

11

12

13#ifndef LLVM_SUPPORT_MEMORY_H

14#define LLVM_SUPPORT_MEMORY_H

15

18#include <system_error>

19#include

20

21namespace llvm {

22

23

25

26namespace sys {

27

28

29

30

31

32

34 public:

35 MemoryBlock() : Address(nullptr), AllocatedSize(0) {}

38 void *base() const { return Address; }

39

40

42

43 private:

44 void *Address;

45 size_t AllocatedSize;

46 unsigned Flags = 0;

48 };

49

50

51

52

53

55 public:

61

62

63

64

65

66

67

68

69

70

71

73 };

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

101 unsigned Flags, std::error_code &EC);

102

103

104

105

106

107

108

109

110

111

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128 LLVM_ABI static std::error_code

130

131

132

133

135 size_t Len);

136 };

137

138

140 public:

156 void *base() const { return M.base(); }

157

158

162 std::error_code EC;

163 if (M.base()) {

166 }

167 return EC;

168 }

169 private:

171 };

172

173#ifndef NDEBUG

174

176

177

179#endif

180 }

181 }

182

183#endif

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

This class encapsulates the notion of a memory block which has an address and a size.

Definition Memory.h:33

MemoryBlock()

Definition Memory.h:35

friend class Memory

Definition Memory.h:47

void * base() const

Definition Memory.h:38

MemoryBlock(void *addr, size_t allocatedSize)

Definition Memory.h:36

size_t allocatedSize() const

The size as it was allocated.

Definition Memory.h:41

This class provides various memory handling functions that manipulate MemoryBlock instances.

Definition Memory.h:54

static LLVM_ABI std::error_code protectMappedMemory(const MemoryBlock &Block, unsigned Flags)

This method sets the protection flags for a block of memory to the state specified by /p Flags.

ProtectionFlags

Definition Memory.h:56

@ MF_READ

Definition Memory.h:57

@ MF_RWE_MASK

Definition Memory.h:60

@ MF_HUGE_HINT

The MF_HUGE_HINT flag is used to indicate that the request for a memory block should be satisfied wit...

Definition Memory.h:72

@ MF_EXEC

Definition Memory.h:59

@ MF_WRITE

Definition Memory.h:58

static LLVM_ABI std::error_code releaseMappedMemory(MemoryBlock &Block)

This method releases a block of memory that was allocated with the allocateMappedMemory method.

static LLVM_ABI void InvalidateInstructionCache(const void *Addr, size_t Len)

InvalidateInstructionCache - Before the JIT can run a block of code that has been emitted it must inv...

static LLVM_ABI MemoryBlock allocateMappedMemory(size_t NumBytes, const MemoryBlock *const NearBlock, unsigned Flags, std::error_code &EC)

This method allocates a block of memory that is suitable for loading dynamically generated code (e....

MemoryBlock getMemoryBlock() const

Definition Memory.h:160

OwningMemoryBlock()=default

~OwningMemoryBlock()

Definition Memory.h:152

OwningMemoryBlock(OwningMemoryBlock &&Other)

Definition Memory.h:143

void * base() const

Definition Memory.h:156

size_t allocatedSize() const

The size as it was allocated.

Definition Memory.h:159

OwningMemoryBlock(MemoryBlock M)

Definition Memory.h:142

std::error_code release()

Definition Memory.h:161

OwningMemoryBlock & operator=(OwningMemoryBlock &&Other)

Definition Memory.h:147

raw_ostream & operator<<(raw_ostream &OS, const Memory::ProtectionFlags &PF)

Debugging output for Memory::ProtectionFlags.

This is an optimization pass for GlobalISel generic memory operations.

OutputIt move(R &&Range, OutputIt Out)

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

Implement std::hash so that hash_code can be used in STL containers.