STATISTIC(RichScopFound, "Number of Scops containing a loop");
/// Translate a SCEVExpression into an isl_pw_aff object.
-struct SCEVAffinator : public SCEVVisitor<SCEVAffinator, isl_pw_aff*> {
+struct SCEVAffinator : public SCEVVisitor<SCEVAffinator, isl_pw_aff *> {
private:
isl_ctx *Ctx;
int NbLoopSpaces;
Space = isl_space_set_dim_id(Space, isl_dim_param, 0, Id);
isl_set *Domain = isl_set_universe(isl_space_copy(Space));
- isl_aff *Affine = isl_aff_zero_on_domain(
- isl_local_space_from_space(Space));
+ isl_aff *Affine =
+ isl_aff_zero_on_domain(isl_local_space_from_space(Space));
Affine = isl_aff_add_coefficient_si(Affine, isl_dim_param, 0, 1);
return isl_pw_aff_alloc(Domain, Affine);
}
- return SCEVVisitor<SCEVAffinator, isl_pw_aff*>::visit(Scev);
+ return SCEVVisitor<SCEVAffinator, isl_pw_aff *>::visit(Scev);
}
- SCEVAffinator(const ScopStmt *Stmt) :
- Ctx(Stmt->getIslCtx()),
- NbLoopSpaces(Stmt->getNumIterators()),
- S(Stmt->getParent()) {}
+ SCEVAffinator(const ScopStmt *Stmt)
+ : Ctx(Stmt->getIslCtx()), NbLoopSpaces(Stmt->getNumIterators()),
+ S(Stmt->getParent()) {
+ }
__isl_give isl_pw_aff *visitConstant(const SCEVConstant *Constant) {
ConstantInt *Value = Constant->getValue();
int getLoopDepth(const Loop *L) {
Loop *outerLoop =
- S->getRegion().outermostLoopInRegion(const_cast<Loop*>(L));
+ S->getRegion().outermostLoopInRegion(const_cast<Loop *>(L));
assert(outerLoop && "Scop does not contain this loop");
return L->getLoopDepth() - outerLoop->getLoopDepth();
}
int loopDimension = getLoopDepth(Expr->getLoop());
isl_aff *LAff = isl_aff_set_coefficient_si(
- isl_aff_zero_on_domain (LocalSpace), isl_dim_in, loopDimension, 1);
+ isl_aff_zero_on_domain(LocalSpace), isl_dim_in, loopDimension, 1);
isl_pw_aff *LPwAff = isl_pw_aff_from_aff(LAff);
// TODO: Do we need to check for NSW and NUW?
Space = isl_space_align_params(Space, Statement->getDomainSpace());
return isl_basic_map_from_domain_and_range(
- isl_basic_set_universe(Statement->getDomainSpace()),
- isl_basic_set_universe(Space));
+ isl_basic_set_universe(Statement->getDomainSpace()),
+ isl_basic_set_universe(Space));
}
MemoryAccess::MemoryAccess(const IRAccess &Access, const Instruction *AccInst,
- ScopStmt *Statement) : Inst(AccInst) {
+ ScopStmt *Statement)
+ : Inst(AccInst) {
newAccessRelation = NULL;
Type = Access.isRead() ? Read : Write;
statement = Statement;
AccessRelation = isl_map_from_pw_aff(Affine);
isl_space *Space = Statement->getDomainSpace();
- AccessRelation = isl_map_set_tuple_id(AccessRelation, isl_dim_in,
- isl_space_get_tuple_id(Space, isl_dim_set));
+ AccessRelation = isl_map_set_tuple_id(
+ AccessRelation, isl_dim_in, isl_space_get_tuple_id(Space, isl_dim_set));
isl_space_free(Space);
AccessRelation = isl_map_set_tuple_name(AccessRelation, isl_dim_out,
getBaseName().c_str());
}
isl_set *MemoryAccess::getStride(__isl_take const isl_map *Schedule) const {
- isl_map *S = const_cast<isl_map*>(Schedule);
+ isl_map *S = const_cast<isl_map *>(Schedule);
isl_map *AccessRelation = getAccessRelation();
isl_space *Space = isl_space_range(isl_map_get_space(S));
isl_map *NextScatt = getEqualAndLarger(Space);
// Loop dimensions.
for (unsigned i = 0; i < NbIterators; ++i)
- Scattering = isl_map_equate(Scattering, isl_dim_out, 2 * i + 1, isl_dim_in,
- i);
+ Scattering =
+ isl_map_equate(Scattering, isl_dim_out, 2 * i + 1, isl_dim_in, i);
// Constant dimensions
for (unsigned i = 0; i < NbIterators + 1; ++i)
const AccFuncSetType *AccFuncs = tempScop.getAccessFunctions(BB);
for (AccFuncSetType::const_iterator I = AccFuncs->begin(),
- E = AccFuncs->end(); I != E; ++I) {
+ E = AccFuncs->end();
+ I != E; ++I) {
MemAccs.push_back(new MemoryAccess(I->first, I->second, this));
InstructionToAccess[I->second] = MemAccs.back();
}
for (int i = 0, e = getNumIterators(); i != e; ++i) {
isl_aff *Zero = isl_aff_zero_on_domain(isl_local_space_copy(LocalSpace));
- isl_pw_aff *IV = isl_pw_aff_from_aff(
- isl_aff_set_coefficient_si(Zero, isl_dim_in, i, 1));
+ isl_pw_aff *IV =
+ isl_pw_aff_from_aff(isl_aff_set_coefficient_si(Zero, isl_dim_in, i, 1));
// 0 <= IV.
isl_set *LowerBound = isl_pw_aff_nonneg_set(isl_pw_aff_copy(IV));
return Domain;
}
-__isl_give isl_set *ScopStmt::addConditionsToDomain(__isl_take isl_set *Domain,
- TempScop &tempScop,
- const Region &CurRegion) {
+__isl_give isl_set *ScopStmt::addConditionsToDomain(
+ __isl_take isl_set *Domain, TempScop &tempScop, const Region &CurRegion) {
const Region *TopRegion = tempScop.getMaxRegion().getParent(),
- *CurrentRegion = &CurRegion;
+ *CurrentRegion = &CurRegion;
const BasicBlock *BranchingBB = BB;
do {
if (BranchingBB != CurrentRegion->getEntry()) {
if (const BBCond *Condition = tempScop.getBBCond(BranchingBB))
for (BBCond::const_iterator CI = Condition->begin(),
- CE = Condition->end(); CI != CE; ++CI) {
+ CE = Condition->end();
+ CI != CE; ++CI) {
isl_set *ConditionSet = buildConditionSet(*CI);
Domain = isl_set_intersect(Domain, ConditionSet);
}
return Domain;
}
-__isl_give isl_set *ScopStmt::buildDomain(TempScop &tempScop,
- const Region &CurRegion) {
+__isl_give isl_set *
+ScopStmt::buildDomain(TempScop &tempScop, const Region &CurRegion) {
isl_space *Space;
isl_set *Domain;
isl_id *Id;
const char *ScopStmt::getBaseName() const { return BaseName.c_str(); }
-const PHINode *ScopStmt::getInductionVariableForDimension(
- unsigned Dimension) const {
+const PHINode *
+ScopStmt::getInductionVariableForDimension(unsigned Dimension) const {
return IVS[Dimension].first;
}
Context = NewContext;
}
-void Scop::addParams(std::vector<const SCEV*> NewParameters) {
- for (std::vector<const SCEV*>::iterator PI = NewParameters.begin(),
- PE = NewParameters.end(); PI != PE; ++PI) {
+void Scop::addParams(std::vector<const SCEV *> NewParameters) {
+ for (std::vector<const SCEV *>::iterator PI = NewParameters.begin(),
+ PE = NewParameters.end();
+ PI != PE; ++PI) {
const SCEV *Parameter = *PI;
if (ParameterIds.find(Parameter) != ParameterIds.end())
if (ParameterName == "" || ParameterName.substr(0, 2) == "p_")
ParameterName = "p_" + utostr_32(IdIter->second);
- return isl_id_alloc(getIslCtx(), ParameterName.c_str(), (void *) Parameter);
+ return isl_id_alloc(getIslCtx(), ParameterName.c_str(), (void *)Parameter);
}
void Scop::buildContext() {
const IntegerType *T;
Id = isl_set_get_dim_id(Context, isl_dim_param, i);
- Scev = (const SCEV*) isl_id_get_user(Id);
+ Scev = (const SCEV *)isl_id_get_user(Id);
T = dyn_cast<IntegerType>(Scev->getType());
isl_id_free(Id);
Scop::Scop(TempScop &tempScop, LoopInfo &LI, ScalarEvolution &ScalarEvolution,
isl_ctx *Context)
- : SE(&ScalarEvolution), R(tempScop.getMaxRegion()),
- MaxLoopDepth(tempScop.getMaxLoopDepth()) {
+ : SE(&ScalarEvolution), R(tempScop.getMaxRegion()),
+ MaxLoopDepth(tempScop.getMaxLoopDepth()) {
IslCtx = Context;
buildContext();
- SmallVector<Loop*, 8> NestLoops;
+ SmallVector<Loop *, 8> NestLoops;
SmallVector<unsigned, 8> Scatter;
Scatter.assign(MaxLoopDepth + 1, 0);
OS.indent(4) << getContextStr() << "\n";
for (ParamVecType::const_iterator PI = Parameters.begin(),
- PE = Parameters.end(); PI != PE; ++PI) {
+ PE = Parameters.end();
+ PI != PE; ++PI) {
const SCEV *Parameter = *PI;
int Dim = ParameterIds.find(Parameter)->second;
Domain = isl_union_set_from_set((*SI)->getDomain());
else
Domain = isl_union_set_union(Domain,
- isl_union_set_from_set((*SI)->getDomain()));
+ isl_union_set_from_set((*SI)->getDomain()));
return Domain;
}
assert(Scatter.size() > loopDepth && "Scatter not big enough!");
for (Region::const_element_iterator I = CurRegion.element_begin(),
- E = CurRegion.element_end(); I != E; ++I)
+ E = CurRegion.element_end();
+ I != E; ++I)
if (I->isSubRegion())
buildScop(tempScop, *(I->getNodeAs<Region>()), NestLoops, Scatter, LI);
else {
if (isTrivialBB(BB, tempScop))
continue;
- Stmts.push_back(new ScopStmt(*this, tempScop, CurRegion, *BB, NestLoops,
- Scatter));
+ Stmts.push_back(
+ new ScopStmt(*this, tempScop, CurRegion, *BB, NestLoops, Scatter));
// Increasing the Scattering function is OK for the moment, because
// we are using a depth first iterator and the program is well structured.