Skip to content

Commit e19661e

Browse files
committed
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
1 parent c52af46 commit e19661e

File tree

2 files changed

+61
-44
lines changed

2 files changed

+61
-44
lines changed

polly/include/polly/ScopInfo.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,15 @@ class ScopStmt {
255255

256256
/// Build the statment.
257257
//@{
258-
isl_set *toConditionSet(const Comparison &Cmp, isl_space *space) const;
259-
void addConditionsToDomain(TempScop &tempScop, const Region &CurRegion);
260-
void buildIterationDomainFromLoops(TempScop &tempScop);
261-
void buildIterationDomain(TempScop &tempScop, const Region &CurRegion);
258+
__isl_give isl_set *buildConditionSet(const Comparison &Cmp,
259+
__isl_take isl_space *Space) const;
260+
__isl_give isl_set *addConditionsToDomain(__isl_take isl_set *Domain,
261+
TempScop &tempScop,
262+
const Region &CurRegion) const;
263+
__isl_give isl_set *addLoopBoundsToDomain(__isl_take isl_set *Domain,
264+
TempScop &tempScop) const;
265+
__isl_give isl_set *buildDomain(TempScop &tempScop,
266+
const Region &CurRegion) const;
262267
void buildScattering(SmallVectorImpl<unsigned> &Scatter);
263268
void buildAccesses(TempScop &tempScop, const Region &CurRegion);
264269
//@}

polly/lib/Analysis/ScopInfo.cpp

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -590,33 +590,35 @@ void ScopStmt::buildAccesses(TempScop &tempScop, const Region &CurRegion) {
590590
}
591591
}
592592

593-
isl_set *ScopStmt::toConditionSet(const Comparison &Comp,
594-
isl_space *space) const {
593+
__isl_give isl_set *ScopStmt::buildConditionSet(const Comparison &Comp,
594+
__isl_take isl_space *Space)
595+
const {
596+
595597
isl_pw_aff *LHS = SCEVAffinator::getPwAff(this, Comp.getLHS()->OriginalSCEV,
596598
0);
597599
isl_pw_aff *RHS = SCEVAffinator::getPwAff(this, Comp.getRHS()->OriginalSCEV,
598600
0);
599601

600-
isl_set *set;
602+
isl_set *Set;
601603

602604
switch (Comp.getPred()) {
603605
case ICmpInst::ICMP_EQ:
604-
set = isl_pw_aff_eq_set(LHS, RHS);
606+
Set = isl_pw_aff_eq_set(LHS, RHS);
605607
break;
606608
case ICmpInst::ICMP_NE:
607-
set = isl_pw_aff_ne_set(LHS, RHS);
609+
Set = isl_pw_aff_ne_set(LHS, RHS);
608610
break;
609611
case ICmpInst::ICMP_SLT:
610-
set = isl_pw_aff_lt_set(LHS, RHS);
612+
Set = isl_pw_aff_lt_set(LHS, RHS);
611613
break;
612614
case ICmpInst::ICMP_SLE:
613-
set = isl_pw_aff_le_set(LHS, RHS);
615+
Set = isl_pw_aff_le_set(LHS, RHS);
614616
break;
615617
case ICmpInst::ICMP_SGT:
616-
set = isl_pw_aff_gt_set(LHS, RHS);
618+
Set = isl_pw_aff_gt_set(LHS, RHS);
617619
break;
618620
case ICmpInst::ICMP_SGE:
619-
set = isl_pw_aff_ge_set(LHS, RHS);
621+
Set = isl_pw_aff_ge_set(LHS, RHS);
620622
break;
621623
case ICmpInst::ICMP_ULT:
622624
case ICmpInst::ICMP_UGT:
@@ -627,17 +629,16 @@ isl_set *ScopStmt::toConditionSet(const Comparison &Comp,
627629
llvm_unreachable("Non integer predicate not supported");
628630
}
629631

630-
set = isl_set_set_tuple_name(set, isl_space_get_tuple_name(space, isl_dim_set));
631-
632-
return set;
632+
return Set;
633633
}
634634

635-
void ScopStmt::buildIterationDomainFromLoops(TempScop &tempScop) {
636-
isl_space *Space = isl_space_set_alloc(getIslCtx(), 0, getNumIterators());
635+
__isl_give isl_set *ScopStmt::addLoopBoundsToDomain(__isl_take isl_set *Domain,
636+
TempScop &tempScop) const {
637+
isl_space *Space;
638+
isl_local_space *LocalSpace;
637639

638-
Domain = isl_set_universe(isl_space_copy(Space));
639-
Domain = isl_set_align_params(Domain, Parent.getParamSpace());
640-
isl_local_space *LocalSpace = isl_local_space_from_space(Space);
640+
Space = isl_set_get_space(Domain);
641+
LocalSpace = isl_local_space_from_space(Space);
641642

642643
for (int i = 0, e = getNumIterators(); i != e; ++i) {
643644
isl_aff *Zero = isl_aff_zero_on_domain(isl_local_space_copy(LocalSpace));
@@ -656,40 +657,51 @@ void ScopStmt::buildIterationDomainFromLoops(TempScop &tempScop) {
656657
Domain = isl_set_intersect(Domain, UpperBoundSet);
657658
}
658659

659-
Domain = isl_set_set_tuple_name(Domain, getBaseName());
660660
isl_local_space_free(LocalSpace);
661+
return Domain;
661662
}
662663

663-
void ScopStmt::addConditionsToDomain(TempScop &tempScop,
664-
const Region &CurRegion) {
664+
__isl_give isl_set *ScopStmt::addConditionsToDomain(__isl_take isl_set *Domain,
665+
TempScop &tempScop,
666+
const Region &CurRegion)
667+
const {
665668
isl_space *Space = isl_set_get_space(Domain);
666-
const Region *TopR = tempScop.getMaxRegion().getParent(),
667-
*CurR = &CurRegion;
668-
const BasicBlock *CurEntry = BB;
669+
const Region *TopRegion = tempScop.getMaxRegion().getParent(),
670+
*CurrentRegion = &CurRegion;
671+
const BasicBlock *BranchingBB = BB;
669672

670-
// Build BB condition constrains, by traveling up the region tree.
671673
do {
672-
assert(CurR && "We exceed the top region?");
673-
// Skip when multiple regions share the same entry.
674-
if (CurEntry != CurR->getEntry()) {
675-
if (const BBCond *Cnd = tempScop.getBBCond(CurEntry))
676-
for (BBCond::const_iterator I = Cnd->begin(), E = Cnd->end();
677-
I != E; ++I) {
678-
isl_set *c = toConditionSet(*I, Space);
679-
Domain = isl_set_intersect(Domain, c);
674+
if (BranchingBB != CurrentRegion->getEntry()) {
675+
if (const BBCond *Condition = tempScop.getBBCond(BranchingBB))
676+
for (BBCond::const_iterator CI = Condition->begin(),
677+
CE = Condition->end(); CI != CE; ++CI) {
678+
isl_set *ConditionSet = buildConditionSet(*CI, Space);
679+
Domain = isl_set_intersect(Domain, ConditionSet);
680680
}
681681
}
682-
CurEntry = CurR->getEntry();
683-
CurR = CurR->getParent();
684-
} while (TopR != CurR);
682+
BranchingBB = CurrentRegion->getEntry();
683+
CurrentRegion = CurrentRegion->getParent();
684+
} while (TopRegion != CurrentRegion);
685685

686686
isl_space_free(Space);
687+
688+
return Domain;
687689
}
688690

689-
void ScopStmt::buildIterationDomain(TempScop &tempScop, const Region &CurRegion)
690-
{
691-
buildIterationDomainFromLoops(tempScop);
692-
addConditionsToDomain(tempScop, CurRegion);
691+
__isl_give isl_set *ScopStmt::buildDomain(TempScop &tempScop,
692+
const Region &CurRegion) const {
693+
isl_space *Space;
694+
isl_set *Domain;
695+
696+
Space = isl_space_set_alloc(getIslCtx(), 0, getNumIterators());
697+
698+
Domain = isl_set_universe(Space);
699+
Domain = isl_set_align_params(Domain, Parent.getParamSpace());
700+
Domain = addLoopBoundsToDomain(Domain, tempScop);
701+
Domain = addConditionsToDomain(Domain, tempScop, CurRegion);
702+
Domain = isl_set_set_tuple_name(Domain, getBaseName());
703+
704+
return Domain;
693705
}
694706

695707
ScopStmt::ScopStmt(Scop &parent, TempScop &tempScop,
@@ -711,7 +723,7 @@ ScopStmt::ScopStmt(Scop &parent, TempScop &tempScop,
711723
makeIslCompatible(BaseName);
712724
BaseName = "Stmt_" + BaseName;
713725

714-
buildIterationDomain(tempScop, CurRegion);
726+
Domain = buildDomain(tempScop, CurRegion);
715727
buildScattering(Scatter);
716728
buildAccesses(tempScop, CurRegion);
717729
}

0 commit comments

Comments
 (0)