aboutsummaryrefslogtreecommitdiff
path: root/polly/include
diff options
context:
space:
mode:
authorDominik Adamski <adamski.dominik@gmail.com>2019-07-17 21:42:39 +0000
committerDominik Adamski <adamski.dominik@gmail.com>2019-07-17 21:42:39 +0000
commitd0ac007f9a93d577f3e829812444bdae8b26269d (patch)
tree8d925e977781b7ea9f8833a7b6cc5e74a3e4058d /polly/include
parent9c7f4264d352316cd4213f78c63c43d830b95752 (diff)
downloadllvm-project-d0ac007f9a93d577f3e829812444bdae8b26269d.tar.gz
[NFC][ScopBuilder] Move buildSchedule and its callees to ScopBuilder or ScopHelper
Scope of changes: 1. Moved buildSchedule functions to ScopBuilder. 2. Moved combineInSequence function to ScopBuilder. 3. Moved mapToDimension function to ScopBuilder. 4. Moved LoopStackTy to ScopBuilder. 5. Moved getLoopSurroundingScop to ScopHelper. 6. Moved getNumBlocksInLoop to ScopHelper. 7. Moved getNumBlocksInRegionNode to ScopHelper. 8. Moved getRegionNodeLoop to ScopHelper. Differential Revision: https://reviews.llvm.org/D64223 llvm-svn: 366377
Diffstat (limited to 'polly/include')
-rw-r--r--polly/include/polly/ScopBuilder.h56
-rw-r--r--polly/include/polly/ScopInfo.h60
-rw-r--r--polly/include/polly/Support/ScopHelper.h22
3 files changed, 78 insertions, 60 deletions
diff --git a/polly/include/polly/ScopBuilder.h b/polly/include/polly/ScopBuilder.h
index a6c8c0eb893b..415190b5dfda 100644
--- a/polly/include/polly/ScopBuilder.h
+++ b/polly/include/polly/ScopBuilder.h
@@ -584,6 +584,62 @@ class ScopBuilder {
/// have been hoisted as loop invariant.
void canonicalizeDynamicBasePtrs();
+ /// Construct the schedule of this SCoP.
+ void buildSchedule();
+
+ /// A loop stack element to keep track of per-loop information during
+ /// schedule construction.
+ using LoopStackElementTy = struct LoopStackElement {
+ // The loop for which we keep information.
+ Loop *L;
+
+ // The (possibly incomplete) schedule for this loop.
+ isl::schedule Schedule;
+
+ // The number of basic blocks in the current loop, for which a schedule has
+ // already been constructed.
+ unsigned NumBlocksProcessed;
+
+ LoopStackElement(Loop *L, isl::schedule S, unsigned NumBlocksProcessed)
+ : L(L), Schedule(S), NumBlocksProcessed(NumBlocksProcessed) {}
+ };
+
+ /// The loop stack used for schedule construction.
+ ///
+ /// The loop stack keeps track of schedule information for a set of nested
+ /// loops as well as an (optional) 'nullptr' loop that models the outermost
+ /// schedule dimension. The loops in a loop stack always have a parent-child
+ /// relation where the loop at position n is the parent of the loop at
+ /// position n + 1.
+ using LoopStackTy = SmallVector<LoopStackElementTy, 4>;
+
+ /// Construct schedule information for a given Region and add the
+ /// derived information to @p LoopStack.
+ ///
+ /// Given a Region we derive schedule information for all RegionNodes
+ /// contained in this region ensuring that the assigned execution times
+ /// correctly model the existing control flow relations.
+ ///
+ /// @param R The region which to process.
+ /// @param LoopStack A stack of loops that are currently under
+ /// construction.
+ void buildSchedule(Region *R, LoopStackTy &LoopStack);
+
+ /// Build Schedule for the region node @p RN and add the derived
+ /// information to @p LoopStack.
+ ///
+ /// In case @p RN is a BasicBlock or a non-affine Region, we construct the
+ /// schedule for this @p RN and also finalize loop schedules in case the
+ /// current @p RN completes the loop.
+ ///
+ /// In case @p RN is a not-non-affine Region, we delegate the construction to
+ /// buildSchedule(Region *R, ...).
+ ///
+ /// @param RN The RegionNode region traversed.
+ /// @param LoopStack A stack of loops that are currently under
+ /// construction.
+ void buildSchedule(RegionNode *RN, LoopStackTy &LoopStack);
+
public:
explicit ScopBuilder(Region *R, AssumptionCache &AC, AliasAnalysis &AA,
const DataLayout &DL, DominatorTree &DT, LoopInfo &LI,
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h
index 0e523bc9dee3..9405d8c26c61 100644
--- a/polly/include/polly/ScopInfo.h
+++ b/polly/include/polly/ScopInfo.h
@@ -2109,66 +2109,6 @@ private:
/// have a corresponding domain in the domain map (or it is empty).
void removeStmtNotInDomainMap();
- /// Construct the schedule of this SCoP.
- ///
- /// @param LI The LoopInfo for the current function.
- void buildSchedule(LoopInfo &LI);
-
- /// A loop stack element to keep track of per-loop information during
- /// schedule construction.
- using LoopStackElementTy = struct LoopStackElement {
- // The loop for which we keep information.
- Loop *L;
-
- // The (possibly incomplete) schedule for this loop.
- isl::schedule Schedule;
-
- // The number of basic blocks in the current loop, for which a schedule has
- // already been constructed.
- unsigned NumBlocksProcessed;
-
- LoopStackElement(Loop *L, isl::schedule S, unsigned NumBlocksProcessed)
- : L(L), Schedule(S), NumBlocksProcessed(NumBlocksProcessed) {}
- };
-
- /// The loop stack used for schedule construction.
- ///
- /// The loop stack keeps track of schedule information for a set of nested
- /// loops as well as an (optional) 'nullptr' loop that models the outermost
- /// schedule dimension. The loops in a loop stack always have a parent-child
- /// relation where the loop at position n is the parent of the loop at
- /// position n + 1.
- using LoopStackTy = SmallVector<LoopStackElementTy, 4>;
-
- /// Construct schedule information for a given Region and add the
- /// derived information to @p LoopStack.
- ///
- /// Given a Region we derive schedule information for all RegionNodes
- /// contained in this region ensuring that the assigned execution times
- /// correctly model the existing control flow relations.
- ///
- /// @param R The region which to process.
- /// @param LoopStack A stack of loops that are currently under
- /// construction.
- /// @param LI The LoopInfo for the current function.
- void buildSchedule(Region *R, LoopStackTy &LoopStack, LoopInfo &LI);
-
- /// Build Schedule for the region node @p RN and add the derived
- /// information to @p LoopStack.
- ///
- /// In case @p RN is a BasicBlock or a non-affine Region, we construct the
- /// schedule for this @p RN and also finalize loop schedules in case the
- /// current @p RN completes the loop.
- ///
- /// In case @p RN is a not-non-affine Region, we delegate the construction to
- /// buildSchedule(Region *R, ...).
- ///
- /// @param RN The RegionNode region traversed.
- /// @param LoopStack A stack of loops that are currently under
- /// construction.
- /// @param LI The LoopInfo for the current function.
- void buildSchedule(RegionNode *RN, LoopStackTy &LoopStack, LoopInfo &LI);
-
/// Collect all memory access relations of a given type.
///
/// @param Predicate A predicate function that returns true if an access is
diff --git a/polly/include/polly/Support/ScopHelper.h b/polly/include/polly/Support/ScopHelper.h
index 02c669a1f3e2..8d794e0bf786 100644
--- a/polly/include/polly/Support/ScopHelper.h
+++ b/polly/include/polly/Support/ScopHelper.h
@@ -27,6 +27,7 @@ class Region;
class Pass;
class DominatorTree;
class RegionInfo;
+class RegionNode;
} // namespace llvm
namespace polly {
@@ -379,6 +380,27 @@ bool isErrorBlock(llvm::BasicBlock &BB, const llvm::Region &R,
/// @return The condition of @p TI and nullptr if none could be extracted.
llvm::Value *getConditionFromTerminator(llvm::Instruction *TI);
+/// Get the smallest loop that contains @p S but is not in @p S.
+llvm::Loop *getLoopSurroundingScop(Scop &S, llvm::LoopInfo &LI);
+
+/// Get the number of blocks in @p L.
+///
+/// The number of blocks in a loop are the number of basic blocks actually
+/// belonging to the loop, as well as all single basic blocks that the loop
+/// exits to and which terminate in an unreachable instruction. We do not
+/// allow such basic blocks in the exit of a scop, hence they belong to the
+/// scop and represent run-time conditions which we want to model and
+/// subsequently speculate away.
+///
+/// @see getRegionNodeLoop for additional details.
+unsigned getNumBlocksInLoop(llvm::Loop *L);
+
+/// Get the number of blocks in @p RN.
+unsigned getNumBlocksInRegionNode(llvm::RegionNode *RN);
+
+/// Return the smallest loop surrounding @p RN.
+llvm::Loop *getRegionNodeLoop(llvm::RegionNode *RN, llvm::LoopInfo &LI);
+
/// Check if @p LInst can be hoisted in @p R.
///
/// @param LInst The load to check.