summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Grosser <grosser@fim.uni-passau.de>2011-10-07 08:46:57 +0000
committerTobias Grosser <grosser@fim.uni-passau.de>2011-10-07 08:46:57 +0000
commite19661e0ca5ac59545554d283bb62a75d6700ce4 (patch)
tree3e7fdbc6962b3d5664f919f3022ad609e0ed8b4c
parentc52af4648416425d816d08221ec88db1113866cb (diff)
downloadbcm5719-llvm-e19661e0ca5ac59545554d283bb62a75d6700ce4.tar.gz
bcm5719-llvm-e19661e0ca5ac59545554d283bb62a75d6700ce4.zip
ScopInfo: Some cleanups
- Use __isl_give and __isl_take - Convert variables to start with Uppercase letter - Only assign the 'domain' after it is fully constructed - Only name it after it is fully constructed llvm-svn: 141361
-rwxr-xr-xpolly/include/polly/ScopInfo.h13
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp92
2 files changed, 61 insertions, 44 deletions
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h
index fd2e63848f6..c282e9709b6 100755
--- a/polly/include/polly/ScopInfo.h
+++ b/polly/include/polly/ScopInfo.h
@@ -255,10 +255,15 @@ class ScopStmt {
/// Build the statment.
//@{
- isl_set *toConditionSet(const Comparison &Cmp, isl_space *space) const;
- void addConditionsToDomain(TempScop &tempScop, const Region &CurRegion);
- void buildIterationDomainFromLoops(TempScop &tempScop);
- void buildIterationDomain(TempScop &tempScop, const Region &CurRegion);
+ __isl_give isl_set *buildConditionSet(const Comparison &Cmp,
+ __isl_take isl_space *Space) const;
+ __isl_give isl_set *addConditionsToDomain(__isl_take isl_set *Domain,
+ TempScop &tempScop,
+ const Region &CurRegion) const;
+ __isl_give isl_set *addLoopBoundsToDomain(__isl_take isl_set *Domain,
+ TempScop &tempScop) const;
+ __isl_give isl_set *buildDomain(TempScop &tempScop,
+ const Region &CurRegion) const;
void buildScattering(SmallVectorImpl<unsigned> &Scatter);
void buildAccesses(TempScop &tempScop, const Region &CurRegion);
//@}
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index 5d898fc0d65..99d08d716c3 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -590,33 +590,35 @@ void ScopStmt::buildAccesses(TempScop &tempScop, const Region &CurRegion) {
}
}
-isl_set *ScopStmt::toConditionSet(const Comparison &Comp,
- isl_space *space) const {
+__isl_give isl_set *ScopStmt::buildConditionSet(const Comparison &Comp,
+ __isl_take isl_space *Space)
+ const {
+
isl_pw_aff *LHS = SCEVAffinator::getPwAff(this, Comp.getLHS()->OriginalSCEV,
0);
isl_pw_aff *RHS = SCEVAffinator::getPwAff(this, Comp.getRHS()->OriginalSCEV,
0);
- isl_set *set;
+ isl_set *Set;
switch (Comp.getPred()) {
case ICmpInst::ICMP_EQ:
- set = isl_pw_aff_eq_set(LHS, RHS);
+ Set = isl_pw_aff_eq_set(LHS, RHS);
break;
case ICmpInst::ICMP_NE:
- set = isl_pw_aff_ne_set(LHS, RHS);
+ Set = isl_pw_aff_ne_set(LHS, RHS);
break;
case ICmpInst::ICMP_SLT:
- set = isl_pw_aff_lt_set(LHS, RHS);
+ Set = isl_pw_aff_lt_set(LHS, RHS);
break;
case ICmpInst::ICMP_SLE:
- set = isl_pw_aff_le_set(LHS, RHS);
+ Set = isl_pw_aff_le_set(LHS, RHS);
break;
case ICmpInst::ICMP_SGT:
- set = isl_pw_aff_gt_set(LHS, RHS);
+ Set = isl_pw_aff_gt_set(LHS, RHS);
break;
case ICmpInst::ICMP_SGE:
- set = isl_pw_aff_ge_set(LHS, RHS);
+ Set = isl_pw_aff_ge_set(LHS, RHS);
break;
case ICmpInst::ICMP_ULT:
case ICmpInst::ICMP_UGT:
@@ -627,17 +629,16 @@ isl_set *ScopStmt::toConditionSet(const Comparison &Comp,
llvm_unreachable("Non integer predicate not supported");
}
- set = isl_set_set_tuple_name(set, isl_space_get_tuple_name(space, isl_dim_set));
-
- return set;
+ return Set;
}
-void ScopStmt::buildIterationDomainFromLoops(TempScop &tempScop) {
- isl_space *Space = isl_space_set_alloc(getIslCtx(), 0, getNumIterators());
+__isl_give isl_set *ScopStmt::addLoopBoundsToDomain(__isl_take isl_set *Domain,
+ TempScop &tempScop) const {
+ isl_space *Space;
+ isl_local_space *LocalSpace;
- Domain = isl_set_universe(isl_space_copy(Space));
- Domain = isl_set_align_params(Domain, Parent.getParamSpace());
- isl_local_space *LocalSpace = isl_local_space_from_space(Space);
+ Space = isl_set_get_space(Domain);
+ LocalSpace = isl_local_space_from_space(Space);
for (int i = 0, e = getNumIterators(); i != e; ++i) {
isl_aff *Zero = isl_aff_zero_on_domain(isl_local_space_copy(LocalSpace));
@@ -656,40 +657,51 @@ void ScopStmt::buildIterationDomainFromLoops(TempScop &tempScop) {
Domain = isl_set_intersect(Domain, UpperBoundSet);
}
- Domain = isl_set_set_tuple_name(Domain, getBaseName());
isl_local_space_free(LocalSpace);
+ return Domain;
}
-void ScopStmt::addConditionsToDomain(TempScop &tempScop,
- const Region &CurRegion) {
+__isl_give isl_set *ScopStmt::addConditionsToDomain(__isl_take isl_set *Domain,
+ TempScop &tempScop,
+ const Region &CurRegion)
+ const {
isl_space *Space = isl_set_get_space(Domain);
- const Region *TopR = tempScop.getMaxRegion().getParent(),
- *CurR = &CurRegion;
- const BasicBlock *CurEntry = BB;
+ const Region *TopRegion = tempScop.getMaxRegion().getParent(),
+ *CurrentRegion = &CurRegion;
+ const BasicBlock *BranchingBB = BB;
- // Build BB condition constrains, by traveling up the region tree.
do {
- assert(CurR && "We exceed the top region?");
- // Skip when multiple regions share the same entry.
- if (CurEntry != CurR->getEntry()) {
- if (const BBCond *Cnd = tempScop.getBBCond(CurEntry))
- for (BBCond::const_iterator I = Cnd->begin(), E = Cnd->end();
- I != E; ++I) {
- isl_set *c = toConditionSet(*I, Space);
- Domain = isl_set_intersect(Domain, c);
+ if (BranchingBB != CurrentRegion->getEntry()) {
+ if (const BBCond *Condition = tempScop.getBBCond(BranchingBB))
+ for (BBCond::const_iterator CI = Condition->begin(),
+ CE = Condition->end(); CI != CE; ++CI) {
+ isl_set *ConditionSet = buildConditionSet(*CI, Space);
+ Domain = isl_set_intersect(Domain, ConditionSet);
}
}
- CurEntry = CurR->getEntry();
- CurR = CurR->getParent();
- } while (TopR != CurR);
+ BranchingBB = CurrentRegion->getEntry();
+ CurrentRegion = CurrentRegion->getParent();
+ } while (TopRegion != CurrentRegion);
isl_space_free(Space);
+
+ return Domain;
}
-void ScopStmt::buildIterationDomain(TempScop &tempScop, const Region &CurRegion)
-{
- buildIterationDomainFromLoops(tempScop);
- addConditionsToDomain(tempScop, CurRegion);
+__isl_give isl_set *ScopStmt::buildDomain(TempScop &tempScop,
+ const Region &CurRegion) const {
+ isl_space *Space;
+ isl_set *Domain;
+
+ Space = isl_space_set_alloc(getIslCtx(), 0, getNumIterators());
+
+ Domain = isl_set_universe(Space);
+ Domain = isl_set_align_params(Domain, Parent.getParamSpace());
+ Domain = addLoopBoundsToDomain(Domain, tempScop);
+ Domain = addConditionsToDomain(Domain, tempScop, CurRegion);
+ Domain = isl_set_set_tuple_name(Domain, getBaseName());
+
+ return Domain;
}
ScopStmt::ScopStmt(Scop &parent, TempScop &tempScop,
@@ -711,7 +723,7 @@ ScopStmt::ScopStmt(Scop &parent, TempScop &tempScop,
makeIslCompatible(BaseName);
BaseName = "Stmt_" + BaseName;
- buildIterationDomain(tempScop, CurRegion);
+ Domain = buildDomain(tempScop, CurRegion);
buildScattering(Scatter);
buildAccesses(tempScop, CurRegion);
}
OpenPOWER on IntegriCloud