ScopInfo: Rememeber the induction variable and its parent loop at the same thime.

llvm-svn: 130586
This commit is contained in:
Hongbin Zheng 2011-04-30 03:26:51 +00:00
parent 1d1eced025
commit 27f3afbc1a
2 changed files with 16 additions and 5 deletions

View File

@ -243,7 +243,7 @@ class ScopStmt {
/// @brief The loop induction variables surrounding the statement.
///
/// This information is only needed for final code generation.
std::vector<PHINode*> IVS;
std::vector<std::pair<PHINode*, Loop*> > IVS;
std::string BaseName;
@ -321,6 +321,12 @@ public:
/// @return The induction variable at a certain dimension.
const PHINode *getInductionVariableForDimension(unsigned Dimension) const;
/// @brief Get the loop for a dimension.
///
/// @param Dimension The dimension of the induction variable
/// @return The loop at a certain dimension.
const Loop *getLoopForDimension(unsigned Dimension) const;
/// @brief Return the SCEV for a loop dimension.
const SCEVAddRecExpr *getSCEVForDimension(unsigned Dimension) const;

View File

@ -525,7 +525,7 @@ void ScopStmt::buildIterationDomainFromLoops(TempScop &tempScop) {
Domain = isl_set_intersect(Domain, isl_set_from_basic_set(bset));
// Upper bound: IV <= NumberOfIterations.
const Loop *L = getSCEVForDimension(i)->getLoop();
const Loop *L = getLoopForDimension(i);
const SCEVAffFunc &UpperBound = tempScop.getLoopBound(L);
isl_set *UpperBoundSet = toUpperLoopBound(UpperBound, isl_dim_copy(dim), i);
Domain = isl_set_intersect(Domain, UpperBoundSet);
@ -575,7 +575,7 @@ ScopStmt::ScopStmt(Scop &parent, TempScop &tempScop,
for (unsigned i = 0, e = NestLoops.size(); i < e; ++i) {
PHINode *PN = NestLoops[i]->getCanonicalInductionVariable();
assert(PN && "Non canonical IV in Scop!");
IVS[i] = PN;
IVS[i] = std::make_pair(PN, NestLoops[i]);
}
raw_string_ostream OS(BaseName);
@ -677,12 +677,17 @@ const char *ScopStmt::getBaseName() const { return BaseName.c_str(); }
const PHINode *ScopStmt::getInductionVariableForDimension(unsigned Dimension)
const {
return IVS[Dimension];
return IVS[Dimension].first;
}
const Loop *ScopStmt::getLoopForDimension(unsigned Dimension) const {
return IVS[Dimension].second;
}
const SCEVAddRecExpr *ScopStmt::getSCEVForDimension(unsigned Dimension)
const {
PHINode *PN = IVS[Dimension];
PHINode *PN =
const_cast<PHINode*>(getInductionVariableForDimension(Dimension));
return cast<SCEVAddRecExpr>(getParent()->getSE()->getSCEV(PN));
}