LLVM: lib/CodeGen/InterferenceCache.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_LIB_CODEGEN_INTERFERENCECACHE_H

15#define LLVM_LIB_CODEGEN_INTERFERENCECACHE_H

16

22#include

23#include

24#include

25

26namespace llvm {

27

31

33

34

35 struct BlockInterference {

36 unsigned Tag = 0;

39

40 BlockInterference() = default;

41 };

42

43

44

45 class Entry {

46

48

49

50

51 unsigned Tag = 0;

52

53

54 unsigned RefCount = 0;

55

56

58

59

61

62

64

65

67

68

69

70

71 struct RegUnitInfo {

72

73

75

76

77 unsigned VirtTag;

78

79

81

82

84

86 VirtI.setMap(LIU.getMap());

87 }

88 };

89

90

91

93

94

96

97

98 void update(unsigned MBBNum);

99

100 public:

101 Entry() = default;

102

104 assert(!hasRefs() && "Cannot clear cache entry with references");

106 MF = mf;

107 Indexes = indexes;

108 LIS = lis;

109 }

110

111 MCRegister getPhysReg() const { return PhysReg; }

112

113 void addRef(int Delta) { RefCount += Delta; }

114

115 bool hasRefs() const { return RefCount > 0; }

116

118

119

121

122

125

126

127 BlockInterference *get(unsigned MBBNum) {

128 if (Blocks[MBBNum].Tag != Tag)

129 update(MBBNum);

130 return &Blocks[MBBNum];

131 }

132 };

133

134

135

136

137 enum { CacheEntries = 32 };

138

142

143

144

145 unsigned char* PhysRegEntries = nullptr;

146 size_t PhysRegEntriesCount = 0;

147

148

149 unsigned RoundRobin = 0;

150

151

152 Entry Entries[CacheEntries];

153

154

156

157public:

162 free(PhysRegEntries);

163 }

164

165 void reinitPhysRegEntries();

166

167

171

172

173

175

176

178 Entry *CacheEntry = nullptr;

179 const BlockInterference *Current = nullptr;

180 static const BlockInterference NoInterference;

181

182 void setEntry(Entry *E) {

183 Current = nullptr;

184

185

186 if (CacheEntry)

187 CacheEntry->addRef(-1);

188 CacheEntry = E;

189 if (CacheEntry)

190 CacheEntry->addRef(+1);

191 }

192

193 public:

194

196

198 setEntry(O.CacheEntry);

199 }

200

202 setEntry(O.CacheEntry);

203 return *this;

204 }

205

207

208

210

211

212 setEntry(nullptr);

214 setEntry(Cache.get(PhysReg));

215 }

216

217

219 Current = CacheEntry ? CacheEntry->get(MBBNum) : &NoInterference;

220 }

221

222

224 return Current->First.isValid();

225 }

226

227

228

230 return Current->First;

231 }

232

233

234

236 return Current->Last;

237 }

238 };

239};

240

241}

242

243#endif

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

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

#define LLVM_LIBRARY_VISIBILITY

This file defines the SmallVector class.

SlotIndex first()

first - Return the starting index of the first interfering range in the current block.

Definition InterferenceCache.h:229

SlotIndex last()

last - Return the ending index of the last interfering range in the current block.

Definition InterferenceCache.h:235

~Cursor()

Definition InterferenceCache.h:206

Cursor & operator=(const Cursor &O)

Definition InterferenceCache.h:201

Cursor(const Cursor &O)

Definition InterferenceCache.h:197

bool hasInterference()

hasInterference - Return true if the current block has any interference.

Definition InterferenceCache.h:223

void moveToBlock(unsigned MBBNum)

moveTo - Move cursor to basic block MBBNum.

Definition InterferenceCache.h:218

Cursor()=default

Cursor - Create a dangling cursor.

void setPhysReg(InterferenceCache &Cache, MCRegister PhysReg)

setPhysReg - Point this cursor to PhysReg's interference.

Definition InterferenceCache.h:209

InterferenceCache & operator=(const InterferenceCache &other)=delete

InterferenceCache(const InterferenceCache &other)=delete

InterferenceCache()=default

unsigned getMaxCursors() const

getMaxCursors - Return the maximum number of concurrent cursors that can be supported.

Definition InterferenceCache.h:174

~InterferenceCache()

Definition InterferenceCache.h:161

Union of live intervals that are strong candidates for coalescing into a single register (either phys...

LiveSegments::iterator SegmentIter

unsigned getTag() const

getTag - Return an opaque tag representing the current state of the union.

const Map & getMap() const

This class represents the liveness of a register, stack slot, etc.

Segments::iterator iterator

Wrapper class representing physical registers. Should be passed by value.

constexpr bool isValid() const

static constexpr unsigned NoRegister

SlotIndex - An opaque wrapper around machine indexes.

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

TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...

This is an optimization pass for GlobalISel generic memory operations.

@ First

Helpers to iterate all locations in the MemoryEffectsBase class.