LLVM: include/llvm/Transforms/Utils/LoopConstrainer.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_TRANSFORMS_UTILS_LOOP_CONSTRAINER_H

10#define LLVM_TRANSFORMS_UTILS_LOOP_CONSTRAINER_H

11

14#include

15

16namespace llvm {

17

19class BranchInst;

20class DominatorTree;

21class IntegerType;

22class Loop;

23class LoopInfo;

24class PHINode;

25class ScalarEvolution;

26class SCEV;

28

29

30

31

32

33

35 const char *Tag = "";

36

39

40

41

44 unsigned LatchBrExitIdx = std::numeric_limits::max();

45

46

47

48

49

50

51

52

53

54

62

64

67 Result.Tag = Tag;

68 Result.Header = cast(Map(Header));

69 Result.Latch = cast(Map(Latch));

70 Result.LatchBr = cast(Map(LatchBr));

71 Result.LatchExit = cast(Map(LatchExit));

80 return Result;

81 }

82

83 static std::optional

85};

86

87

88

89

90

91

92

93

94

96public:

97

98

99

100

101

102

103

107 };

108

109private:

110

111 struct ClonedLoop {

112

113 std::vector<BasicBlock *> Blocks;

114

115

117

118

120 };

121

122

123

124 struct RewrittenRangeInfo {

127 std::vector<PHINode *> PHIValuesAtPseudoExit;

128 PHINode *IndVarEnd = nullptr;

129

130 RewrittenRangeInfo() = default;

131 };

132

133

134

135

136

137 void cloneLoop(ClonedLoop &CLResult, const char *Tag) const;

138

139

140

141 Loop *createClonedLoopStructure(Loop *Original, Loop *Parent,

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165 RewrittenRangeInfo

166 changeIterationSpaceEnd(const LoopStructure &LS, BasicBlock *Preheader,

167 Value *ExitLoopAt,

168 BasicBlock *ContinuationBlock) const;

169

170

171

172 BasicBlock *createPreheader(const LoopStructure &LS, BasicBlock *OldPreheader,

173 const char *Tag) const;

174

175

176

177

178

179 void rewriteIncomingValuesForPHIs(

180 LoopStructure &LS, BasicBlock *ContinuationBlockAndPreheader,

181 const LoopConstrainer::RewrittenRangeInfo &RRI) const;

182

183

184

185

186

187 void addToParentLoopIfNeeded(ArrayRef<BasicBlock *> BBs);

188

189

190 Function &F;

191 LLVMContext &Ctx;

192 ScalarEvolution &SE;

193 DominatorTree &DT;

194 LoopInfo &LI;

195 function_ref<void(Loop *, bool)> LPMAddNewLoop;

196

197

198 Loop &OriginalLoop;

199

200 BasicBlock *OriginalPreheader = nullptr;

201

202

203

204 BasicBlock *MainLoopPreheader = nullptr;

205

206

207 Type *RangeTy;

208

209

210

211 LoopStructure MainLoopStructure;

212

213 SubRanges SR;

214

215public:

216 LoopConstrainer(Loop &L, LoopInfo &LI,

217 function_ref<void(Loop *, bool)> LPMAddNewLoop,

218 const LoopStructure &LS, ScalarEvolution &SE,

219 DominatorTree &DT, Type *T, SubRanges SR);

220

221

222 bool run();

223};

224}

225

226#endif

DenseMap< Block *, BlockRelaxAux > Blocks

LLVM Basic Block Representation.

Conditional or Unconditional Branch instruction.

Class to represent integer types.

This class is used to constrain loops to run within a given iteration space.

Represents a single loop in the control flow graph.

The main scalar evolution driver.

LLVM Value Representation.

@ BasicBlock

Various leaf nodes.

This is an optimization pass for GlobalISel generic memory operations.

ValueMap< const Value *, WeakTrackingVH > ValueToValueMapTy

std::optional< const SCEV * > LowLimit

std::optional< const SCEV * > HighLimit

LoopStructure map(M Map) const

IntegerType * ExitCountTy

static std::optional< LoopStructure > parseLoopStructure(ScalarEvolution &, Loop &, bool, const char *&)