LLVM: include/llvm/Analysis/LoopNestAnalysis.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_ANALYSIS_LOOPNESTANALYSIS_H

15#define LLVM_ANALYSIS_LOOPNESTANALYSIS_H

16

21

22namespace llvm {

23

25

27

28

30public:

32

33

35

37

38

40

41

42

43

44

45

46

47

48

49

50

51

54

55

56

58 const Loop &InnerLoop,

60

61

62

63

64

65

66

67

68

69

71

72

73

74

75

78 bool CheckUniquePred = false);

79

80

82

83

84

85

87 if (Loops.size() == 1)

88 return Loops.back();

89

90

91

92

94 auto SecondLastLoopIter = ++Loops.rbegin();

95 return (LastLoop->getLoopDepth() == (*SecondLastLoopIter)->getLoopDepth())

96 ? nullptr

97 : LastLoop;

98 }

99

100

102 assert(Index < Loops.size() && "Index is out of bounds");

103 return Loops[Index];

104 }

105

106

113

114

116

117

119

120

123 Depth <= Loops.back()->getLoopDepth() && "Invalid depth");

127 if (L->getLoopDepth() == Depth)

128 Result.push_back(L);

129 else if (L->getLoopDepth() > Depth)

130 break;

131 }

132 return Result;

133 }

134

135

136

137

138

139

140

141

142

143

144

146

147

148

149

150

151

152

153

154

155

157 int NestDepth =

158 Loops.back()->getLoopDepth() - Loops.front()->getLoopDepth() + 1;

159 assert(NestDepth > 0 && "Expecting NestDepth to be at least 1");

160 return NestDepth;

161 }

162

163

165

166

168 return all_of(Loops, [](const Loop *L) { return L->isLoopSimplifyForm(); });

169 }

170

171

173 return all_of(Loops, [](const Loop *L) { return L->isRotatedForm(); });

174 }

175

176

178 return Loops.front()->getHeader()->getParent();

179 }

180

182

183protected:

184 const unsigned MaxPerfectDepth;

186

187private:

188 enum LoopNestEnum {

189 PerfectLoopNest,

190 ImperfectLoopNest,

191 InvalidLoopStructure,

192 OuterLoopLowerBoundUnknown

193 };

194 static LoopNestEnum analyzeLoopNestForPerfectNest(const Loop &OuterLoop,

195 const Loop &InnerLoop,

197};

198

200

201

202

212

213

216

217public:

219

223

225};

226

227}

228

229#endif

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

This header provides classes for managing per-loop analyses.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

LLVM Basic Block Representation.

This class provides an interface for updating the loop pass manager based on mutations to the loop ne...

unsigned getLoopDepth() const

Return the nesting level of this loop.

This analysis provides information for a loop nest.

Definition LoopNestAnalysis.h:203

LoopNest Result

Definition LoopNestAnalysis.h:208

LLVM_ABI Result run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR)

LoopNestPrinterPass(raw_ostream &OS)

Definition LoopNestAnalysis.h:218

static bool isRequired()

Definition LoopNestAnalysis.h:224

LLVM_ABI PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &U)

This class represents a loop nest and can be used to query its properties.

Definition LoopNestAnalysis.h:29

StringRef getName() const

Definition LoopNestAnalysis.h:181

static const BasicBlock & skipEmptyBlockUntil(const BasicBlock *From, const BasicBlock *End, bool CheckUniquePred=false)

Recursivelly traverse all empty 'single successor' basic blocks of From (if there are any).

ArrayRef< Loop * > getLoops() const

Get the loops in the nest.

Definition LoopNestAnalysis.h:118

unsigned getNestDepth() const

Return the loop nest depth (i.e.

Definition LoopNestAnalysis.h:156

LoopVectorTy Loops

Definition LoopNestAnalysis.h:185

static bool arePerfectlyNested(const Loop &OuterLoop, const Loop &InnerLoop, ScalarEvolution &SE)

Return true if the given loops OuterLoop and InnerLoop are perfectly nested with respect to each othe...

static InstrVectorTy getInterveningInstructions(const Loop &OuterLoop, const Loop &InnerLoop, ScalarEvolution &SE)

Return a vector of instructions that prevent the LoopNest given by loops OuterLoop and InnerLoop from...

const unsigned MaxPerfectDepth

Definition LoopNestAnalysis.h:184

LoopVectorTy getLoopsAtDepth(unsigned Depth) const

Get the loops in the nest at the given Depth.

Definition LoopNestAnalysis.h:121

static std::unique_ptr< LoopNest > getLoopNest(Loop &Root, ScalarEvolution &SE)

Construct a LoopNest object.

SmallVector< const Instruction * > InstrVectorTy

Definition LoopNestAnalysis.h:31

LoopNest(Loop &Root, ScalarEvolution &SE)

Construct a loop nest rooted by loop Root.

Loop * getLoop(unsigned Index) const

Return the loop at the given Index.

Definition LoopNestAnalysis.h:101

bool areAllLoopsRotatedForm() const

Return true if all loops in the loop nest are in rotated form.

Definition LoopNestAnalysis.h:172

unsigned getMaxPerfectDepth() const

Return the maximum perfect nesting depth.

Definition LoopNestAnalysis.h:164

Function * getParent() const

Return the function to which the loop-nest belongs.

Definition LoopNestAnalysis.h:177

static unsigned getMaxPerfectDepth(const Loop &Root, ScalarEvolution &SE)

Return the maximum nesting depth of the loop nest rooted by loop Root.

unsigned getLoopIndex(const Loop &L) const

Get the loop index of the given loop L.

Definition LoopNestAnalysis.h:107

Loop & getOutermostLoop() const

Return the outermost loop in the loop nest.

Definition LoopNestAnalysis.h:81

bool areAllLoopsSimplifyForm() const

Return true if all loops in the loop nest are in simplify form.

Definition LoopNestAnalysis.h:167

size_t getNumLoops() const

Return the number of loops in the nest.

Definition LoopNestAnalysis.h:115

Loop * getInnermostLoop() const

Return the innermost loop in the loop nest if the nest has only one innermost loop,...

Definition LoopNestAnalysis.h:86

Represents a single loop in the control flow graph.

A set of analyses that are preserved following a run of a transformation pass.

The main scalar evolution driver.

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

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

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

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

This is an optimization pass for GlobalISel generic memory operations.

bool all_of(R &&range, UnaryPredicate P)

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

AnalysisManager< Loop, LoopStandardAnalysisResults & > LoopAnalysisManager

The loop analysis manager.

SmallVector< Loop *, 8 > LoopVectorTy

raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)

A CRTP mix-in that provides informational APIs needed for analysis passes.

A special type used by analysis passes to provide an address that identifies that particular analysis...

The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...

A CRTP mix-in to automatically provide informational APIs needed for passes.