diff options
author | Tobias Grosser <grosser@fim.uni-passau.de> | 2013-03-23 01:05:07 +0000 |
---|---|---|
committer | Tobias Grosser <grosser@fim.uni-passau.de> | 2013-03-23 01:05:07 +0000 |
commit | 4d96c8d7140b95ac2608422b59c9749a0c5b6981 (patch) | |
tree | b6f1c007d7b8b49c3806d7cb979d75bd2930dc4f /polly/lib | |
parent | 0db04b47780dcbfe74e58c2f41fa9432ce3369cc (diff) | |
download | bcm5719-llvm-4d96c8d7140b95ac2608422b59c9749a0c5b6981.tar.gz bcm5719-llvm-4d96c8d7140b95ac2608422b59c9749a0c5b6981.zip |
clang-format: Many more files
After this commit, polly is clang-format clean. This can be tested with
'ninja polly-check-format'. Updates to clang-format may change this, but the
differences will hopefully be both small and general improvements to the
formatting.
We currently have some not very nice formatting for a couple of items, DEBUG()
stmts for example. I believe the benefit of being clang-format clean outweights
the not perfect layout of this code.
llvm-svn: 177796
Diffstat (limited to 'polly/lib')
25 files changed, 610 insertions, 720 deletions
diff --git a/polly/lib/Analysis/Dependences.cpp b/polly/lib/Analysis/Dependences.cpp index 01c9027f0ba..ab720eb0f72 100644 --- a/polly/lib/Analysis/Dependences.cpp +++ b/polly/lib/Analysis/Dependences.cpp @@ -286,12 +286,10 @@ void Dependences::getAnalysisUsage(AnalysisUsage &AU) const { char Dependences::ID = 0; +Pass *polly::createDependencesPass() { return new Dependences(); } + INITIALIZE_PASS_BEGIN(Dependences, "polly-dependences", - "Polly - Calculate dependences", false, false) -INITIALIZE_PASS_DEPENDENCY(ScopInfo) + "Polly - Calculate dependences", false, false); +INITIALIZE_PASS_DEPENDENCY(ScopInfo); INITIALIZE_PASS_END(Dependences, "polly-dependences", "Polly - Calculate dependences", false, false) - -Pass *polly::createDependencesPass() { - return new Dependences(); -} diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp index e5704c6fc20..f695b6a7c78 100644 --- a/polly/lib/Analysis/ScopDetection.cpp +++ b/polly/lib/Analysis/ScopDetection.cpp @@ -175,7 +175,8 @@ bool ScopDetection::isValidCFG(BasicBlock &BB, // Only Constant and ICmpInst are allowed as condition. if (!(isa<Constant>(Condition) || isa<ICmpInst>(Condition))) - INVALID(AffFunc, "Condition in BB '" + BB.getName() + "' neither " + INVALID(AffFunc, "Condition in BB '" + BB.getName() + + "' neither " "constant nor an icmp instruction"); // Allow perfectly nested conditions. @@ -201,7 +202,8 @@ bool ScopDetection::isValidCFG(BasicBlock &BB, if (!isAffineExpr(&Context.CurRegion, LHS, *SE) || !isAffineExpr(&Context.CurRegion, RHS, *SE)) INVALID(AffFunc, "Non affine branch in BB '" << BB.getName() - << "' with LHS: " << *LHS << " and RHS: " << *RHS); + << "' with LHS: " << *LHS + << " and RHS: " << *RHS); } // Allow loop exit conditions. @@ -404,8 +406,9 @@ bool ScopDetection::isValidLoop(Loop *L, DetectionContext &Context) const { // Is the loop count affine? const SCEV *LoopCount = SE->getBackedgeTakenCount(L); if (!isAffineExpr(&Context.CurRegion, LoopCount, *SE)) - INVALID(LoopBound, "Non affine loop bound '" << *LoopCount << "' in loop: " - << L->getHeader()->getName()); + INVALID(LoopBound, + "Non affine loop bound '" + << *LoopCount << "' in loop: " << L->getHeader()->getName()); return true; } @@ -450,12 +453,9 @@ Region *ScopDetection::expandRegion(Region &R) { } } - DEBUG( - if (LastValidRegion) - dbgs() << "\tto " << LastValidRegion->getNameStr() << "\n"; - else - dbgs() << "\tExpanding " << R.getNameStr() << " failed\n"; - ); + DEBUG(if (LastValidRegion) + dbgs() << "\tto " << LastValidRegion->getNameStr() << "\n"; + else dbgs() << "\tExpanding " << R.getNameStr() << " failed\n";); return LastValidRegion; } @@ -543,8 +543,7 @@ bool ScopDetection::isValidRegion(DetectionContext &Context) const { // The toplevel region is no valid region. if (!R.getParent()) { - DEBUG(dbgs() << "Top level region is invalid"; - dbgs() << "\n"); + DEBUG(dbgs() << "Top level region is invalid"; dbgs() << "\n"); return false; } @@ -668,7 +667,7 @@ void ScopDetection::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); } -void ScopDetection::print(raw_ostream &OS, const Module *)const { +void ScopDetection::print(raw_ostream &OS, const Module *) const { for (RegionSet::const_iterator I = ValidRegions.begin(), E = ValidRegions.end(); I != E; ++I) @@ -685,18 +684,16 @@ void ScopDetection::releaseMemory() { char ScopDetection::ID = 0; +Pass *polly::createScopDetectionPass() { return new ScopDetection(); } + INITIALIZE_PASS_BEGIN(ScopDetection, "polly-detect", "Polly - Detect static control parts (SCoPs)", false, - false) -INITIALIZE_AG_DEPENDENCY(AliasAnalysis) -INITIALIZE_PASS_DEPENDENCY(DominatorTree) -INITIALIZE_PASS_DEPENDENCY(LoopInfo) -INITIALIZE_PASS_DEPENDENCY(PostDominatorTree) -INITIALIZE_PASS_DEPENDENCY(RegionInfo) -INITIALIZE_PASS_DEPENDENCY(ScalarEvolution) + false); +INITIALIZE_AG_DEPENDENCY(AliasAnalysis); +INITIALIZE_PASS_DEPENDENCY(DominatorTree); +INITIALIZE_PASS_DEPENDENCY(LoopInfo); +INITIALIZE_PASS_DEPENDENCY(PostDominatorTree); +INITIALIZE_PASS_DEPENDENCY(RegionInfo); +INITIALIZE_PASS_DEPENDENCY(ScalarEvolution); INITIALIZE_PASS_END(ScopDetection, "polly-detect", "Polly - Detect static control parts (SCoPs)", false, false) - -Pass *polly::createScopDetectionPass() { - return new ScopDetection(); -} diff --git a/polly/lib/Analysis/ScopGraphPrinter.cpp b/polly/lib/Analysis/ScopGraphPrinter.cpp index 6c2a7372376..a86fc59b51f 100644 --- a/polly/lib/Analysis/ScopGraphPrinter.cpp +++ b/polly/lib/Analysis/ScopGraphPrinter.cpp @@ -25,25 +25,23 @@ using namespace polly; using namespace llvm; namespace llvm { - template <> struct GraphTraits<ScopDetection*> - : public GraphTraits<RegionInfo*> { +template <> +struct GraphTraits<ScopDetection *> : public GraphTraits<RegionInfo *> { - static NodeType *getEntryNode(ScopDetection *SD) { - return GraphTraits<RegionInfo*>::getEntryNode(SD->getRI()); - } - static nodes_iterator nodes_begin(ScopDetection *SD) { - return nodes_iterator::begin(getEntryNode(SD)); - } - static nodes_iterator nodes_end(ScopDetection *SD) { - return nodes_iterator::end(getEntryNode(SD)); - } - }; + static NodeType *getEntryNode(ScopDetection *SD) { + return GraphTraits<RegionInfo *>::getEntryNode(SD->getRI()); + } + static nodes_iterator nodes_begin(ScopDetection *SD) { + return nodes_iterator::begin(getEntryNode(SD)); + } + static nodes_iterator nodes_end(ScopDetection *SD) { + return nodes_iterator::end(getEntryNode(SD)); + } +}; -template<> -struct DOTGraphTraits<RegionNode*> : public DefaultDOTGraphTraits { +template <> struct DOTGraphTraits<RegionNode *> : public DefaultDOTGraphTraits { - DOTGraphTraits (bool isSimple=false) - : DefaultDOTGraphTraits(isSimple) {} + DOTGraphTraits(bool isSimple = false) : DefaultDOTGraphTraits(isSimple) {} std::string getNodeLabel(RegionNode *Node, RegionNode *Graph) { @@ -51,27 +49,26 @@ struct DOTGraphTraits<RegionNode*> : public DefaultDOTGraphTraits { BasicBlock *BB = Node->getNodeAs<BasicBlock>(); if (isSimple()) - return DOTGraphTraits<const Function*> - ::getSimpleNodeLabel(BB, BB->getParent()); + return DOTGraphTraits<const Function *>::getSimpleNodeLabel( + BB, BB->getParent()); else - return DOTGraphTraits<const Function*> - ::getCompleteNodeLabel(BB, BB->getParent()); + return DOTGraphTraits<const Function *>::getCompleteNodeLabel( + BB, BB->getParent()); } return "Not implemented"; } }; -template<> -struct DOTGraphTraits<ScopDetection*> : public DOTGraphTraits<RegionNode*> { - DOTGraphTraits (bool isSimple=false) - : DOTGraphTraits<RegionNode*>(isSimple) {} - static std::string getGraphName(ScopDetection *SD) { - return "Scop Graph"; - } +template <> +struct DOTGraphTraits<ScopDetection *> : public DOTGraphTraits<RegionNode *> { + DOTGraphTraits(bool isSimple = false) + : DOTGraphTraits<RegionNode *>(isSimple) {} + static std::string getGraphName(ScopDetection *SD) { return "Scop Graph"; } std::string getEdgeAttributes(RegionNode *srcNode, - GraphTraits<RegionInfo*>::ChildIteratorType CI, ScopDetection *SD) { + GraphTraits<RegionInfo *>::ChildIteratorType CI, + ScopDetection *SD) { RegionNode *destNode = *CI; @@ -98,15 +95,15 @@ struct DOTGraphTraits<ScopDetection*> : public DOTGraphTraits<RegionNode*> { } std::string getNodeLabel(RegionNode *Node, ScopDetection *SD) { - return DOTGraphTraits<RegionNode*> - ::getNodeLabel(Node, SD->getRI()->getTopLevelRegion()); + return DOTGraphTraits<RegionNode *>::getNodeLabel( + Node, SD->getRI()->getTopLevelRegion()); } static std::string escapeString(std::string String) { std::string Escaped; - for (std::string::iterator SI = String.begin(), SE = String.end(); - SI != SE; ++SI) { + for (std::string::iterator SI = String.begin(), SE = String.end(); SI != SE; + ++SI) { if (*SI == '"') Escaped += '\\'; @@ -120,8 +117,8 @@ struct DOTGraphTraits<ScopDetection*> : public DOTGraphTraits<RegionNode*> { // and adds a different background color for each group. static void printRegionCluster(const ScopDetection *SD, const Region *R, raw_ostream &O, unsigned depth = 0) { - O.indent(2 * depth) << "subgraph cluster_" << static_cast<const void*>(R) - << " {\n"; + O.indent(2 * depth) << "subgraph cluster_" << static_cast<const void *>(R) + << " {\n"; std::string ErrorMessage = SD->regionIsInvalidBecause(R); ErrorMessage = escapeString(ErrorMessage); O.indent(2 * (depth + 1)) << "label = \"" << ErrorMessage << "\";\n"; @@ -140,8 +137,7 @@ struct DOTGraphTraits<ScopDetection*> : public DOTGraphTraits<RegionNode*> { if (color == 3) color = 6; - O.indent(2 * (depth + 1)) << "color = " - << color << "\n"; + O.indent(2 * (depth + 1)) << "color = " << color << "\n"; } for (Region::const_iterator RI = R->begin(), RE = R->end(); RI != RE; ++RI) @@ -150,57 +146,53 @@ struct DOTGraphTraits<ScopDetection*> : public DOTGraphTraits<RegionNode*> { RegionInfo *RI = R->getRegionInfo(); for (Region::const_block_iterator BI = R->block_begin(), - BE = R->block_end(); BI != BE; ++BI) + BE = R->block_end(); + BI != BE; ++BI) if (RI->getRegionFor(*BI) == R) - O.indent(2 * (depth + 1)) << "Node" - << static_cast<const void*>(RI->getTopLevelRegion()->getBBNode(*BI)) - << ";\n"; + O.indent(2 * (depth + 1)) + << "Node" << static_cast<const void *>( + RI->getTopLevelRegion()->getBBNode(*BI)) << ";\n"; O.indent(2 * depth) << "}\n"; } static void addCustomGraphFeatures(const ScopDetection *SD, - GraphWriter<ScopDetection*> &GW) { + GraphWriter<ScopDetection *> &GW) { raw_ostream &O = GW.getOStream(); O << "\tcolorscheme = \"paired12\"\n"; printRegionCluster(SD, SD->getRI()->getTopLevelRegion(), O, 4); } }; -} //end namespace llvm +} //end namespace llvm -struct ScopViewer - : public DOTGraphTraitsViewer<ScopDetection, false> { +struct ScopViewer : public DOTGraphTraitsViewer<ScopDetection, false> { static char ID; - ScopViewer() : DOTGraphTraitsViewer<ScopDetection, false>("scops", ID){} + ScopViewer() : DOTGraphTraitsViewer<ScopDetection, false>("scops", ID) {} }; char ScopViewer::ID = 0; -struct ScopOnlyViewer - : public DOTGraphTraitsViewer<ScopDetection, true> { +struct ScopOnlyViewer : public DOTGraphTraitsViewer<ScopDetection, true> { static char ID; ScopOnlyViewer() - : DOTGraphTraitsViewer<ScopDetection, true>("scopsonly", ID){} + : DOTGraphTraitsViewer<ScopDetection, true>("scopsonly", ID) {} }; char ScopOnlyViewer::ID = 0; -struct ScopPrinter - : public DOTGraphTraitsPrinter<ScopDetection, false> { +struct ScopPrinter : public DOTGraphTraitsPrinter<ScopDetection, false> { static char ID; - ScopPrinter() : - DOTGraphTraitsPrinter<ScopDetection, false>("scops", ID) {} + ScopPrinter() : DOTGraphTraitsPrinter<ScopDetection, false>("scops", ID) {} }; char ScopPrinter::ID = 0; -struct ScopOnlyPrinter - : public DOTGraphTraitsPrinter<ScopDetection, true> { +struct ScopOnlyPrinter : public DOTGraphTraitsPrinter<ScopDetection, true> { static char ID; - ScopOnlyPrinter() : - DOTGraphTraitsPrinter<ScopDetection, true>("scopsonly", ID) {} + ScopOnlyPrinter() + : DOTGraphTraitsPrinter<ScopDetection, true>("scopsonly", ID) {} }; char ScopOnlyPrinter::ID = 0; static RegisterPass<ScopViewer> -X("view-scops","Polly - View Scops of function"); +X("view-scops", "Polly - View Scops of function"); static RegisterPass<ScopOnlyViewer> Y("view-scops-only", @@ -213,18 +205,10 @@ static RegisterPass<ScopOnlyPrinter> N("dot-scops-only", "Polly - Print Scops of function (with no function bodies)"); -Pass *polly::createDOTViewerPass() { - return new ScopViewer(); -} +Pass *polly::createDOTViewerPass() { return new ScopViewer(); } -Pass *polly::createDOTOnlyViewerPass() { - return new ScopOnlyViewer(); -} +Pass *polly::createDOTOnlyViewerPass() { return new ScopOnlyViewer(); } -Pass *polly::createDOTPrinterPass() { - return new ScopPrinter(); -} +Pass *polly::createDOTPrinterPass() { return new ScopPrinter(); } -Pass *polly::createDOTOnlyPrinterPass() { - return new ScopOnlyPrinter(); -} +Pass *polly::createDOTOnlyPrinterPass() { return new ScopOnlyPrinter(); } diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index eb66047ac75..2c44d872354 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -95,8 +95,7 @@ public: SCEVAffinator(const ScopStmt *Stmt) : Ctx(Stmt->getIslCtx()), NbLoopSpaces(Stmt->getNumIterators()), - S(Stmt->getParent()) { - } + S(Stmt->getParent()) {} __isl_give isl_pw_aff *visitConstant(const SCEVConstant *Constant) { ConstantInt *Value = Constant->getValue(); @@ -588,7 +587,7 @@ ScopStmt::buildDomain(TempScop &tempScop, const Region &CurRegion) { ScopStmt::ScopStmt(Scop &parent, TempScop &tempScop, const Region &CurRegion, BasicBlock &bb, SmallVectorImpl<Loop *> &Nest, SmallVectorImpl<unsigned> &Scatter) - : Parent(parent), BB(&bb), IVS(Nest.size()), NestLoops(Nest.size()) { + : Parent(parent), BB(&bb), IVS(Nest.size()), NestLoops(Nest.size()) { // Setup the induction variables. for (unsigned i = 0, e = Nest.size(); i < e; ++i) { if (!SCEVCodegen) { @@ -980,17 +979,15 @@ bool ScopInfo::runOnRegion(Region *R, RGPassManager &RGM) { char ScopInfo::ID = 0; +Pass *polly::createScopInfoPass() { return new ScopInfo(); } + INITIALIZE_PASS_BEGIN(ScopInfo, "polly-scops", "Polly - Create polyhedral description of Scops", false, - false) -INITIALIZE_PASS_DEPENDENCY(LoopInfo) -INITIALIZE_PASS_DEPENDENCY(RegionInfo) -INITIALIZE_PASS_DEPENDENCY(ScalarEvolution) -INITIALIZE_PASS_DEPENDENCY(TempScopInfo) + false); +INITIALIZE_PASS_DEPENDENCY(LoopInfo); +INITIALIZE_PASS_DEPENDENCY(RegionInfo); +INITIALIZE_PASS_DEPENDENCY(ScalarEvolution); +INITIALIZE_PASS_DEPENDENCY(TempScopInfo); INITIALIZE_PASS_END(ScopInfo, "polly-scops", "Polly - Create polyhedral description of Scops", false, false) - -Pass *polly::createScopInfoPass() { - return new ScopInfo(); -} diff --git a/polly/lib/Analysis/TempScopInfo.cpp b/polly/lib/Analysis/TempScopInfo.cpp index c0a9ebb8717..a3a3dd2343e 100644 --- a/polly/lib/Analysis/TempScopInfo.cpp +++ b/polly/lib/Analysis/TempScopInfo.cpp @@ -73,8 +73,7 @@ void TempScop::print(raw_ostream &OS, ScalarEvolution *SE, LoopInfo *LI) const { void TempScop::printDetail(llvm::raw_ostream &OS, ScalarEvolution *SE, LoopInfo *LI, const Region *CurR, - unsigned ind) const { -} + unsigned ind) const {} void TempScopInfo::buildAccessFunctions(Region &R, BasicBlock &BB) { AccFuncSetType Functions; @@ -106,7 +105,8 @@ void TempScopInfo::buildAccessFunctions(Region &R, BasicBlock &BB) { Functions.push_back( std::make_pair(IRAccess(Type, BasePointer->getValue(), AccessFunction, - Size, IsAffine), &Inst)); + Size, IsAffine), + &Inst)); } } @@ -164,7 +164,7 @@ void TempScopInfo::buildAffineCondition(Value &V, bool inverted, assert(ICmp && "Only ICmpInst of constant as condition supported!"); const SCEV *LHS = SE->getSCEV(ICmp->getOperand(0)), - *RHS = SE->getSCEV(ICmp->getOperand(1)); + *RHS = SE->getSCEV(ICmp->getOperand(1)); ICmpInst::Predicate Pred = ICmp->getPredicate(); @@ -245,7 +245,7 @@ TempScop *TempScopInfo::getTempScop(const Region *R) const { return at == TempScops.end() ? 0 : at->second; } -void TempScopInfo::print(raw_ostream &OS, const Module *)const { +void TempScopInfo::print(raw_ostream &OS, const Module *) const { for (TempScopMapType::const_iterator I = TempScops.begin(), E = TempScops.end(); I != E; ++I) @@ -295,20 +295,18 @@ void TempScopInfo::clear() { // TempScop information extraction pass implement char TempScopInfo::ID = 0; +Pass *polly::createTempScopInfoPass() { return new TempScopInfo(); } + INITIALIZE_PASS_BEGIN(TempScopInfo, "polly-analyze-ir", "Polly - Analyse the LLVM-IR in the detected regions", - false, false) -INITIALIZE_AG_DEPENDENCY(AliasAnalysis) -INITIALIZE_PASS_DEPENDENCY(DominatorTree) -INITIALIZE_PASS_DEPENDENCY(LoopInfo) -INITIALIZE_PASS_DEPENDENCY(PostDominatorTree) -INITIALIZE_PASS_DEPENDENCY(RegionInfo) -INITIALIZE_PASS_DEPENDENCY(ScalarEvolution) -INITIALIZE_PASS_DEPENDENCY(DataLayout) + false, false); +INITIALIZE_AG_DEPENDENCY(AliasAnalysis); +INITIALIZE_PASS_DEPENDENCY(DominatorTree); +INITIALIZE_PASS_DEPENDENCY(LoopInfo); +INITIALIZE_PASS_DEPENDENCY(PostDominatorTree); +INITIALIZE_PASS_DEPENDENCY(RegionInfo); +INITIALIZE_PASS_DEPENDENCY(ScalarEvolution); +INITIALIZE_PASS_DEPENDENCY(DataLayout); INITIALIZE_PASS_END(TempScopInfo, "polly-analyze-ir", "Polly - Analyse the LLVM-IR in the detected regions", false, false) - -Pass *polly::createTempScopInfoPass() { - return new TempScopInfo(); -} diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp index 94c0ac6274e..bfd70641cb9 100644 --- a/polly/lib/CodeGen/BlockGenerators.cpp +++ b/polly/lib/CodeGen/BlockGenerators.cpp @@ -37,10 +37,9 @@ Aligned("enable-polly-aligned", cl::desc("Assumed aligned memory accesses."), cl::Hidden, cl::value_desc("OpenMP code generation enabled if true"), cl::init(false), cl::ZeroOrMore); -static cl::opt<bool, true> -SCEVCodegenF("polly-codegen-scev", cl::desc("Use SCEV based code generation."), - cl::Hidden, cl::location(SCEVCodegen), cl::init(false), - cl::ZeroOrMore); +static cl::opt<bool, true> SCEVCodegenF( + "polly-codegen-scev", cl::desc("Use SCEV based code generation."), + cl::Hidden, cl::location(SCEVCodegen), cl::init(false), cl::ZeroOrMore); bool polly::SCEVCodegen; @@ -62,7 +61,6 @@ bool polly::canSynthesize(const Instruction *I, const llvm::LoopInfo *LI, return L && I == L->getCanonicalInductionVariable(); } - // Helper class to generate memory location. namespace { class IslGenerator { @@ -181,7 +179,7 @@ Value *BlockGenerator::getNewValue(const Value *Old, ValueMapT &BBMap, Value *New = GlobalMap[Old]; if (Old->getType()->getScalarSizeInBits() < - New->getType()->getScalarSizeInBits()) + New->getType()->getScalarSizeInBits()) New = Builder.CreateTruncOrBitCast(New, Old->getType()); return New; @@ -312,8 +310,7 @@ Value *BlockGenerator::generateLocationAccessed( return NewPointer; } -Loop * -BlockGenerator::getLoopForInst(const llvm::Instruction *Inst) { +Loop *BlockGenerator::getLoopForInst(const llvm::Instruction *Inst) { return P->getAnalysis<LoopInfo>().getLoopFor(Inst->getParent()); } @@ -390,9 +387,9 @@ VectorBlockGenerator::VectorBlockGenerator( assert(Schedule && "No statement domain provided"); } -Value *VectorBlockGenerator::getVectorValue( - const Value *Old, ValueMapT &VectorMap, VectorValueMapT &ScalarMaps, - Loop *L) { +Value * +VectorBlockGenerator::getVectorValue(const Value *Old, ValueMapT &VectorMap, + VectorValueMapT &ScalarMaps, Loop *L) { if (VectorMap.count(Old)) return VectorMap[Old]; diff --git a/polly/lib/CodeGen/Cloog.cpp b/polly/lib/CodeGen/Cloog.cpp index 9925d47d721..5a091a041a7 100644 --- a/polly/lib/CodeGen/Cloog.cpp +++ b/polly/lib/CodeGen/Cloog.cpp @@ -330,7 +330,7 @@ bool CloogInfo::runOnScop(Scop &S) { C = new Cloog(&S); Function *F = S.getRegion().getEntry()->getParent(); - (void)F; + (void) F; DEBUG(dbgs() << ":: " << F->getName()); DEBUG(dbgs() << " : " << S.getRegion().getNameStr() << "\n"); diff --git a/polly/lib/CodeGen/CodeGeneration.cpp b/polly/lib/CodeGen/CodeGeneration.cpp index ffe6f389a4b..e3e5621693e 100644 --- a/polly/lib/CodeGen/CodeGeneration.cpp +++ b/polly/lib/CodeGen/CodeGeneration.cpp @@ -193,7 +193,7 @@ Value *ClastExpCodeGen::codegen(const clast_reduction *r, Type *Ty) { } ClastExpCodeGen::ClastExpCodeGen(IRBuilder<> &B, CharMapT &IVMap) - : Builder(B), IVS(IVMap) {} + : Builder(B), IVS(IVMap) {} Value *ClastExpCodeGen::codegen(const clast_expr *e, Type *Ty) { switch (e->type) { @@ -366,10 +366,9 @@ void ClastStmtCodeGen::codegen(const clast_assignment *a) { ClastVars[a->LHS] = V; } -void ClastStmtCodeGen::codegen(const clast_assignment *A, ScopStmt *Stmt, - unsigned Dim, int VectorDim, - std::vector<ValueMapT> *VectorVMap, - std::vector<LoopToScevMapT> *VLTS) { +void ClastStmtCodeGen::codegen( + const clast_assignment *A, ScopStmt *Stmt, unsigned Dim, int VectorDim, + std::vector<ValueMapT> *VectorVMap, std::vector<LoopToScevMapT> *VLTS) { Value *RHS; assert(!A->LHS && "Statement assignments do not have left hand side"); @@ -970,8 +969,7 @@ void ClastStmtCodeGen::codegen(const clast_root *r) { } ClastStmtCodeGen::ClastStmtCodeGen(Scop *scop, IRBuilder<> &B, Pass *P) - : S(scop), P(P), Builder(B), ExpGen(Builder, ClastVars) { -} + : S(scop), P(P), Builder(B), ExpGen(Builder, ClastVars) {} namespace { class CodeGeneration : public ScopPass { @@ -1040,9 +1038,7 @@ public: char CodeGeneration::ID = 1; -Pass *polly::createCodeGenerationPass() { - return new CodeGeneration(); -} +Pass *polly::createCodeGenerationPass() { return new CodeGeneration(); } INITIALIZE_PASS_BEGIN(CodeGeneration, "polly-codegen", "Polly - Create LLVM-IR from SCoPs", false, false); @@ -1054,6 +1050,6 @@ INITIALIZE_PASS_DEPENDENCY(ScalarEvolution); INITIALIZE_PASS_DEPENDENCY(ScopDetection); INITIALIZE_PASS_DEPENDENCY(DataLayout); INITIALIZE_PASS_END(CodeGeneration, "polly-codegen", - "Polly - Create LLVM-IR from SCoPs", false, false) + "Polly - Create LLVM-IR from SCoPs", false, false) #endif // CLOOG_FOUND diff --git a/polly/lib/CodeGen/IslAst.cpp b/polly/lib/CodeGen/IslAst.cpp index 04e02f6700c..4f68b89b2ac 100644 --- a/polly/lib/CodeGen/IslAst.cpp +++ b/polly/lib/CodeGen/IslAst.cpp @@ -326,13 +326,12 @@ IslAst::IslAst(Scop *Scop, Dependences &D) : S(Scop) { isl_union_map *Schedule = getSchedule(); Function *F = Scop->getRegion().getEntry()->getParent(); - (void)F; + (void) F; DEBUG(dbgs() << ":: isl ast :: " << F->getName() << " :: " << Scop->getRegion().getNameStr() << "\n"); - DEBUG(dbgs() << S->getContextStr() << "\n"; - isl_union_map_dump(Schedule)); + DEBUG(dbgs() << S->getContextStr() << "\n"; isl_union_map_dump(Schedule)); if (DetectParallel || PollyVectorizerChoice != VECTORIZER_NONE) { BuildInfo.Deps = &D; @@ -433,9 +432,9 @@ char IslAstInfo::ID = 0; Pass *polly::createIslAstInfoPass() { return new IslAstInfo(); } INITIALIZE_PASS_BEGIN(IslAstInfo, "polly-ast", - "Generate an AST of the SCoP (isl)", false, false); + "Polly - Generate an AST of the SCoP (isl)", false, + false); INITIALIZE_PASS_DEPENDENCY(ScopInfo); INITIALIZE_PASS_DEPENDENCY(Dependences); INITIALIZE_PASS_END(IslAstInfo, "polly-ast", - "Generate an AST from the SCoP (isl)", false, false) - + "Polly - Generate an AST from the SCoP (isl)", false, false) diff --git a/polly/lib/CodeGen/IslCodeGeneration.cpp b/polly/lib/CodeGen/IslCodeGeneration.cpp index 20738a9b32b..6db09258a62 100644 --- a/polly/lib/CodeGen/IslCodeGeneration.cpp +++ b/polly/lib/CodeGen/IslCodeGeneration.cpp @@ -126,7 +126,7 @@ void RuntimeDebugBuilder::createStrPrinter(std::string String) { void RuntimeDebugBuilder::createIntPrinter(Value *V) { IntegerType *Ty = dyn_cast<IntegerType>(V->getType()); - (void)Ty; + (void) Ty; assert(Ty && Ty->getBitWidth() == 64 && "Cannot insert printer for this type."); @@ -1080,4 +1080,3 @@ INITIALIZE_PASS_DEPENDENCY(ScalarEvolution); INITIALIZE_PASS_DEPENDENCY(ScopDetection); INITIALIZE_PASS_END(IslCodeGeneration, "polly-codegen-isl", "Polly - Create LLVM-IR from SCoPs", false, false) - diff --git a/polly/lib/CodePreparation.cpp b/polly/lib/CodePreparation.cpp index da9cd01b2d7..4ec0cc9651d 100644 --- a/polly/lib/CodePreparation.cpp +++ b/polly/lib/CodePreparation.cpp @@ -183,4 +183,3 @@ INITIALIZE_PASS_BEGIN(CodePreparation, "polly-prepare", INITIALIZE_PASS_DEPENDENCY(LoopInfo); INITIALIZE_PASS_END(CodePreparation, "polly-prepare", "Polly - Prepare code for polly", false, false) - diff --git a/polly/lib/DeadCodeElimination.cpp b/polly/lib/DeadCodeElimination.cpp index 0ea83e0d260..9e2a4d67a98 100644 --- a/polly/lib/DeadCodeElimination.cpp +++ b/polly/lib/DeadCodeElimination.cpp @@ -71,4 +71,3 @@ INITIALIZE_PASS_DEPENDENCY(Dependences); INITIALIZE_PASS_DEPENDENCY(ScopInfo); INITIALIZE_PASS_END(DeadCodeElim, "polly-dce", "Polly - Remove dead iterations", false, false) - diff --git a/polly/lib/Exchange/JSONExporter.cpp b/polly/lib/Exchange/JSONExporter.cpp index 1e50b1870b1..402798805b3 100644 --- a/polly/lib/Exchange/JSONExporter.cpp +++ b/polly/lib/Exchange/JSONExporter.cpp @@ -39,20 +39,18 @@ using namespace llvm; using namespace polly; -STATISTIC(NewAccessMapFound, "Number of updated access functions"); +STATISTIC(NewAccessMapFound, "Number of updated access functions"); namespace { -static cl::opt<std::string> -ImportDir("polly-import-jscop-dir", - cl::desc("The directory to import the .jscop files from."), - cl::Hidden, cl::value_desc("Directory path"), cl::ValueRequired, - cl::init(".")); - -static cl::opt<std::string> -ImportPostfix("polly-import-jscop-postfix", - cl::desc("Postfix to append to the import .jsop files."), - cl::Hidden, cl::value_desc("File postfix"), cl::ValueRequired, - cl::init("")); +static cl::opt<std::string> ImportDir( + "polly-import-jscop-dir", + cl::desc("The directory to import the .jscop files from."), cl::Hidden, + cl::value_desc("Directory path"), cl::ValueRequired, cl::init(".")); + +static cl::opt<std::string> ImportPostfix( + "polly-import-jscop-postfix", + cl::desc("Postfix to append to the import .jsop files."), cl::Hidden, + cl::value_desc("File postfix"), cl::ValueRequired, cl::init("")); struct JSONExporter : public ScopPass { static char ID; @@ -82,15 +80,12 @@ struct JSONImporter : public ScopPass { char JSONExporter::ID = 0; std::string JSONExporter::getFileName(Scop *S) const { - std::string FunctionName = - S->getRegion().getEntry()->getParent()->getName(); + std::string FunctionName = S->getRegion().getEntry()->getParent()->getName(); std::string FileName = FunctionName + "___" + S->getNameStr() + ".jscop"; return FileName; } -void JSONExporter::printScop(raw_ostream &OS) const { - S->print(OS); -} +void JSONExporter::printScop(raw_ostream &OS) const { S->print(OS); } Json::Value JSONExporter::getJSON(Scop &scop) const { Json::Value root; @@ -110,7 +105,8 @@ Json::Value JSONExporter::getJSON(Scop &scop) const { statement["accesses"]; for (ScopStmt::memacc_iterator MI = Stmt->memacc_begin(), - ME = Stmt->memacc_end(); MI != ME; ++MI) { + ME = Stmt->memacc_end(); + MI != ME; ++MI) { Json::Value access; access["kind"] = (*MI)->isRead() ? "read" : "write"; @@ -141,7 +137,7 @@ bool JSONExporter::runOnScop(Scop &scop) { std::string FunctionName = R.getEntry()->getParent()->getName(); errs() << "Writing JScop '" << R.getNameStr() << "' in function '" - << FunctionName << "' to '" << FileName << "'.\n"; + << FunctionName << "' to '" << FileName << "'.\n"; if (ErrInfo.empty()) { F.os() << fileContent; @@ -164,22 +160,11 @@ void JSONExporter::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<ScopInfo>(); } -INITIALIZE_PASS_BEGIN(JSONExporter, "polly-export-jscop", - "Polly - Export Scops as JSON" - " (Writes a .jscop file for each Scop)", false, false) -INITIALIZE_PASS_DEPENDENCY(Dependences) -INITIALIZE_PASS_END(JSONExporter, "polly-export-jscop", - "Polly - Export Scops as JSON" - " (Writes a .jscop file for each Scop)", false, false) - -Pass *polly::createJSONExporterPass() { - return new JSONExporter(); -} +Pass *polly::createJSONExporterPass() { return new JSONExporter(); } char JSONImporter::ID = 0; std::string JSONImporter::getFileName(Scop *S) const { - std::string FunctionName = - S->getRegion().getEntry()->getParent()->getName(); + std::string FunctionName = S->getRegion().getEntry()->getParent()->getName(); std::string FileName = FunctionName + "___" + S->getNameStr() + ".jscop"; if (ImportPostfix != "") @@ -191,7 +176,8 @@ std::string JSONImporter::getFileName(Scop *S) const { void JSONImporter::printScop(raw_ostream &OS) const { S->print(OS); for (std::vector<std::string>::const_iterator I = newAccessStrings.begin(), - E = newAccessStrings.end(); I != E; I++) + E = newAccessStrings.end(); + I != E; I++) OS << "New access function '" << *I << "'detected in JSCOP file\n"; } @@ -206,7 +192,7 @@ bool JSONImporter::runOnScop(Scop &scop) { std::string FunctionName = R.getEntry()->getParent()->getName(); errs() << "Reading JScop '" << R.getNameStr() << "' in function '" - << FunctionName << "' from '" << FileName << "'.\n"; + << FunctionName << "' from '" << FileName << "'.\n"; OwningPtr<MemoryBuffer> result; error_code ec = MemoryBuffer::getFile(FileName, result); @@ -226,8 +212,8 @@ bool JSONImporter::runOnScop(Scop &scop) { } isl_set *OldContext = S->getContext(); - isl_set *NewContext = isl_set_read_from_str(S->getIslCtx(), - jscop["context"].asCString()); + isl_set *NewContext = + isl_set_read_from_str(S->getIslCtx(), jscop["context"].asCString()); for (unsigned i = 0; i < isl_set_dim(OldContext, isl_dim_param); i++) { isl_id *id = isl_set_get_dim_id(OldContext, isl_dim_param, i); @@ -275,15 +261,16 @@ bool JSONImporter::runOnScop(Scop &scop) { int memoryAccessIdx = 0; for (ScopStmt::memacc_iterator MI = Stmt->memacc_begin(), - ME = Stmt->memacc_end(); MI != ME; ++MI) { - Json::Value accesses = jscop["statements"][statementIdx] - ["accesses"][memoryAccessIdx]["relation"]; - isl_map *newAccessMap = isl_map_read_from_str(S->getIslCtx(), - accesses.asCString()); + ME = Stmt->memacc_end(); + MI != ME; ++MI) { + Json::Value accesses = jscop["statements"][statementIdx]["accesses"][ + memoryAccessIdx]["relation"]; + isl_map *newAccessMap = + isl_map_read_from_str(S->getIslCtx(), accesses.asCString()); isl_map *currentAccessMap = (*MI)->getAccessRelation(); if (isl_map_dim(newAccessMap, isl_dim_param) != - isl_map_dim(currentAccessMap, isl_dim_param)) { + isl_map_dim(currentAccessMap, isl_dim_param)) { errs() << "JScop file changes the number of parameter dimensions\n"; isl_map_free(currentAccessMap); isl_map_free(newAccessMap); @@ -339,15 +326,27 @@ void JSONImporter::getAnalysisUsage(AnalysisUsage &AU) const { ScopPass::getAnalysisUsage(AU); AU.addRequired<Dependences>(); } +Pass *polly::createJSONImporterPass() { return new JSONImporter(); } + +INITIALIZE_PASS_BEGIN(JSONExporter, "polly-export-jscop", + "Polly - Export Scops as JSON" + " (Writes a .jscop file for each Scop)", + false, false); +INITIALIZE_PASS_DEPENDENCY(Dependences); +INITIALIZE_PASS_END(JSONExporter, "polly-export-jscop", + "Polly - Export Scops as JSON" + " (Writes a .jscop file for each Scop)", + false, false) + + // typedef to make clang-format introduce a linebreak + typedef int clangformatdef; INITIALIZE_PASS_BEGIN(JSONImporter, "polly-import-jscop", "Polly - Import Scops from JSON" - " (Reads a .jscop file for each Scop)", false, false) -INITIALIZE_PASS_DEPENDENCY(Dependences) + " (Reads a .jscop file for each Scop)", + false, false); +INITIALIZE_PASS_DEPENDENCY(Dependences); INITIALIZE_PASS_END(JSONImporter, "polly-import-jscop", "Polly - Import Scops from JSON" - " (Reads a .jscop file for each Scop)", false, false) - -Pass *polly::createJSONImporterPass() { - return new JSONImporter(); -} + " (Reads a .jscop file for each Scop)", + false, false) diff --git a/polly/lib/Exchange/OpenScopExporter.cpp b/polly/lib/Exchange/OpenScopExporter.cpp index 39b4a2aa44a..0b4a41eb058 100644 --- a/polly/lib/Exchange/OpenScopExporter.cpp +++ b/polly/lib/Exchange/OpenScopExporter.cpp @@ -58,7 +58,7 @@ class OpenScop { Scop *PollyScop; openscop_scop_p openscop; - std::map<const Value*, int> ArrayMap; + std::map<const Value *, int> ArrayMap; void initializeArrays(); void initializeParameters(); @@ -94,7 +94,7 @@ OpenScop::OpenScop(Scop *S) : PollyScop(S) { void OpenScop::initializeParameters() { openscop->nb_parameters = PollyScop->getNumParams(); - openscop->parameters = new char*[openscop->nb_parameters]; + openscop->parameters = new char *[openscop->nb_parameters]; for (int i = 0; i < openscop->nb_parameters; ++i) { openscop->parameters[i] = new char[20]; @@ -108,7 +108,8 @@ void OpenScop::initializeArrays() { for (Scop::iterator SI = PollyScop->begin(), SE = PollyScop->end(); SI != SE; ++SI) for (ScopStmt::memacc_iterator MI = (*SI)->memacc_begin(), - ME = (*SI)->memacc_end(); MI != ME; ++MI) { + ME = (*SI)->memacc_end(); + MI != ME; ++MI) { const Value *BaseAddr = (*MI)->getBaseAddr(); if (ArrayMap.find(BaseAddr) == ArrayMap.end()) { ArrayMap.insert(std::make_pair(BaseAddr, nb_arrays)); @@ -117,11 +118,12 @@ void OpenScop::initializeArrays() { } openscop->nb_arrays = nb_arrays; - openscop->arrays = new char*[nb_arrays]; + openscop->arrays = new char *[nb_arrays]; for (int i = 0; i < nb_arrays; ++i) - for (std::map<const Value*, int>::iterator VI = ArrayMap.begin(), - VE = ArrayMap.end(); VI != VE; ++VI) + for (std::map<const Value *, int>::iterator VI = ArrayMap.begin(), + VE = ArrayMap.end(); + VI != VE; ++VI) if ((*VI).second == i) { const Value *V = (*VI).first; std::string name = V->getName(); @@ -132,7 +134,7 @@ void OpenScop::initializeArrays() { void OpenScop::initializeScattering() { openscop->nb_scattdims = PollyScop->getScatterDim(); - openscop->scattdims = new char*[openscop->nb_scattdims]; + openscop->scattdims = new char *[openscop->nb_scattdims]; for (int i = 0; i < openscop->nb_scattdims; ++i) { openscop->scattdims[i] = new char[20]; @@ -151,15 +153,14 @@ openscop_statement_p OpenScop::initializeStatement(ScopStmt *stmt) { isl_set_free(domain); isl_map_free(Scattering); - // Statement name const char *entryName = stmt->getBaseName(); - Stmt->body = (char*)malloc(sizeof(char) * (strlen(entryName) + 1)); + Stmt->body = (char *)malloc(sizeof(char) * (strlen(entryName) + 1)); strcpy(Stmt->body, entryName); // Iterator names Stmt->nb_iterators = isl_set_n_dim(stmt->getDomain()); - Stmt->iterators = new char*[Stmt->nb_iterators]; + Stmt->iterators = new char *[Stmt->nb_iterators]; for (int i = 0; i < Stmt->nb_iterators; ++i) { Stmt->iterators[i] = new char[20]; @@ -213,9 +214,7 @@ void OpenScop::freeStatement(openscop_statement_p stmt) { openscop_statement_free(stmt); } -void OpenScop::print(FILE *F) { - openscop_scop_print_dot_scop(F, openscop); -} +void OpenScop::print(FILE *F) { openscop_scop_print_dot_scop(F, openscop); } /// Add an isl constraint to an OpenScop matrix. /// @@ -286,8 +285,8 @@ openscop_matrix_p OpenScop::domainToMatrix(isl_set *PS) { // Create a canonical copy of this set. isl_set *set = isl_set_copy(PS); - set = isl_set_compute_divs (set); - set = isl_set_align_divs (set); + set = isl_set_compute_divs(set); + set = isl_set_align_divs(set); // Initialize the matrix. unsigned NbRows, NbColumns; @@ -318,7 +317,7 @@ int OpenScop::scatteringToMatrix_constraint(isl_constraint *c, void *user) { assert(!nb_div && "Existentially quantified variables not yet supported"); openscop_vector_p vec = - openscop_vector_malloc(nb_params + nb_in + nb_out + 2); + openscop_vector_malloc(nb_params + nb_in + nb_out + 2); // Assign type if (isl_constraint_is_equality(c)) @@ -380,14 +379,14 @@ openscop_matrix_p OpenScop::scatteringToMatrix(isl_map *pmap) { // Create a canonical copy of this set. isl_map *map = isl_map_copy(pmap); - map = isl_map_compute_divs (map); - map = isl_map_align_divs (map); + map = isl_map_compute_divs(map); + map = isl_map_align_divs(map); // Initialize the matrix. unsigned NbRows, NbColumns; NbRows = 0; - NbColumns = isl_map_n_in(pmap) + isl_map_n_out(pmap) + isl_map_n_param(pmap) - + 2; + NbColumns = + isl_map_n_in(pmap) + isl_map_n_out(pmap) + isl_map_n_param(pmap) + 2; openscop_matrix_p matrix = openscop_matrix_malloc(NbRows, NbColumns); // Copy the content into the matrix. @@ -411,8 +410,7 @@ int OpenScop::accessToMatrix_constraint(isl_constraint *c, void *user) { assert(!nb_div && "Existentially quantified variables not yet supported"); - openscop_vector_p vec = - openscop_vector_malloc(nb_params + nb_in + 2); + openscop_vector_p vec = openscop_vector_malloc(nb_params + nb_in + 2); isl_int v; isl_int_init(v); @@ -420,13 +418,14 @@ int OpenScop::accessToMatrix_constraint(isl_constraint *c, void *user) { // The access dimension has to be one. isl_constraint_get_coefficient(c, isl_space_out, 0, &v); assert(isl_int_is_one(v)); - bool inverse = true ; + bool inverse = true; // Assign variables for (int i = 0; i < nb_in; ++i) { isl_constraint_get_coefficient(c, isl_space_in, i, &v); - if (inverse) isl_int_neg(v,v); + if (inverse) + isl_int_neg(v, v); isl_int_set(vec->p[i + 1], v); } @@ -435,7 +434,8 @@ int OpenScop::accessToMatrix_constraint(isl_constraint *c, void *user) { for (int i = 0; i < nb_params; ++i) { isl_constraint_get_coefficient(c, isl_space_param, i, &v); - if (inverse) isl_int_neg(v,v); + if (inverse) + isl_int_neg(v, v); isl_int_set(vec->p[nb_in + i + 1], v); } @@ -443,7 +443,8 @@ int OpenScop::accessToMatrix_constraint(isl_constraint *c, void *user) { // Assign constant isl_constraint_get_constant(c, &v); - if (inverse) isl_int_neg(v,v); + if (inverse) + isl_int_neg(v, v); isl_int_set(vec->p[nb_in + nb_params + 1], v); @@ -452,7 +453,6 @@ int OpenScop::accessToMatrix_constraint(isl_constraint *c, void *user) { return 0; } - /// Add an isl basic map to a OpenScop matrix_list /// /// @param bmap The basic map to add @@ -487,8 +487,8 @@ openscop_matrix_p OpenScop::createAccessMatrix(ScopStmt *S, bool isRead) { &accessToMatrix_basic_map, m); // Set the index of the memory access base element. - std::map<const Value*, int>::iterator BA = - ArrayMap.find((*MI)->getBaseAddr()); + std::map<const Value *, int>::iterator BA = + ArrayMap.find((*MI)->getBaseAddr()); isl_int_set_si(m->p[m->NbRows - 1][0], (*BA).second + 1); } @@ -536,15 +536,12 @@ OpenScop::~OpenScop() { } std::string ScopExporter::getFileName(Scop *S) const { - std::string FunctionName = - S->getRegion().getEntry()->getParent()->getName(); + std::string FunctionName = S->getRegion().getEntry()->getParent()->getName(); std::string FileName = FunctionName + "___" + S->getNameStr() + ".scop"; return FileName; } -void ScopExporter::printScop(raw_ostream &OS) const { - S->print(OS); -} +void ScopExporter::printScop(raw_ostream &OS) const { S->print(OS); } bool ScopExporter::runOnScop(Scop &scop) { S = &scop; @@ -565,7 +562,7 @@ bool ScopExporter::runOnScop(Scop &scop) { std::string FunctionName = R.getEntry()->getParent()->getName(); errs() << "Writing Scop '" << R.getNameStr() << "' in function '" - << FunctionName << "' to '" << FileName << "'.\n"; + << FunctionName << "' to '" << FileName << "'.\n"; return false; } @@ -574,14 +571,10 @@ void ScopExporter::getAnalysisUsage(AnalysisUsage &AU) const { ScopPass::getAnalysisUsage(AU); } -static RegisterPass<ScopExporter> A("polly-export", - "Polly - Export Scops with OpenScop library" - " (Writes a .scop file for each Scop)" - ); +static RegisterPass<ScopExporter> +A("polly-export", "Polly - Export Scops with OpenScop library" + " (Writes a .scop file for each Scop)"); -Pass *polly::createScopExporterPass() { - return new ScopExporter(); -} +Pass *polly::createScopExporterPass() { return new ScopExporter(); } #endif - diff --git a/polly/lib/Exchange/OpenScopImporter.cpp b/polly/lib/Exchange/OpenScopImporter.cpp index c04cb8dc91d..4f6a7d8de55 100644 --- a/polly/lib/Exchange/OpenScopImporter.cpp +++ b/polly/lib/Exchange/OpenScopImporter.cpp @@ -34,29 +34,27 @@ using namespace llvm; using namespace polly; namespace { - static cl::opt<std::string> - ImportDir("polly-import-dir", - cl::desc("The directory to import the .scop files from."), - cl::Hidden, cl::value_desc("Directory path"), cl::ValueRequired, - cl::init(".")); - static cl::opt<std::string> - ImportPostfix("polly-import-postfix", - cl::desc("Postfix to append to the import .scop files."), - cl::Hidden, cl::value_desc("File postfix"), cl::ValueRequired, - cl::init("")); - - struct ScopImporter : public ScopPass { - static char ID; - Scop *S; - Dependences *D; - explicit ScopImporter() : ScopPass(ID) {} - bool updateScattering(Scop *S, openscop_scop_p OScop); - - std::string getFileName(Scop *S) const; - virtual bool runOnScop(Scop &S); - virtual void printScop(raw_ostream &OS) const; - void getAnalysisUsage(AnalysisUsage &AU) const; - }; +static cl::opt<std::string> +ImportDir("polly-import-dir", + cl::desc("The directory to import the .scop files from."), cl::Hidden, + cl::value_desc("Directory path"), cl::ValueRequired, cl::init(".")); +static cl::opt<std::string> ImportPostfix( + "polly-import-postfix", + cl::desc("Postfix to append to the import .scop files."), cl::Hidden, + cl::value_desc("File postfix"), cl::ValueRequired, cl::init("")); + +struct ScopImporter : public ScopPass { + static char ID; + Scop *S; + Dependences *D; + explicit ScopImporter() : ScopPass(ID) {} + bool updateScattering(Scop *S, openscop_scop_p OScop); + + std::string getFileName(Scop *S) const; + virtual bool runOnScop(Scop &S); + virtual void printScop(raw_ostream &OS) const; + void getAnalysisUsage(AnalysisUsage &AU) const; +}; } char ScopImporter::ID = 0; @@ -88,7 +86,8 @@ isl_constraint *constraintFromMatrixRow(isl_int *row, isl_space *Space) { isl_constraint_set_coefficient(c, isl_space_in, j, row[current_column++]); for (unsigned j = 0; j < NbParam; ++j) - isl_constraint_set_coefficient(c, isl_space_param, j, row[current_column++]); + isl_constraint_set_coefficient(c, isl_space_param, j, + row[current_column++]); isl_constraint_set_constant(c, row[current_column]); @@ -181,7 +180,7 @@ bool ScopImporter::updateScattering(Scop *S, openscop_scop_p OScop) { if (!D->isValidScattering(NewScattering)) { errs() << "OpenScop file contains a scattering that changes the " - << "dependences. Use -disable-polly-legality to continue anyways\n"; + << "dependences. Use -disable-polly-legality to continue anyways\n"; return false; } @@ -195,15 +194,12 @@ bool ScopImporter::updateScattering(Scop *S, openscop_scop_p OScop) { return true; } std::string ScopImporter::getFileName(Scop *S) const { - std::string FunctionName = - S->getRegion().getEntry()->getParent()->getName(); + std::string FunctionName = S->getRegion().getEntry()->getParent()->getName(); std::string FileName = FunctionName + "___" + S->getNameStr() + ".scop"; return FileName; } -void ScopImporter::printScop(raw_ostream &OS) const { - S->print(OS); -} +void ScopImporter::printScop(raw_ostream &OS) const { S->print(OS); } bool ScopImporter::runOnScop(Scop &scop) { S = &scop; @@ -224,12 +220,13 @@ bool ScopImporter::runOnScop(Scop &scop) { std::string FunctionName = R.getEntry()->getParent()->getName(); errs() << "Reading Scop '" << R.getNameStr() << "' in function '" - << FunctionName << "' from '" << FileName << "'.\n"; + << FunctionName << "' from '" << FileName << "'.\n"; bool UpdateSuccessfull = updateScattering(S, openscop); if (!UpdateSuccessfull) { - errs() << "Update failed" << "\n"; + errs() << "Update failed" + << "\n"; } return false; @@ -240,13 +237,10 @@ void ScopImporter::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<Dependences>(); } -static RegisterPass<ScopImporter> A("polly-import", - "Polly - Import Scops with OpenScop library" - " (Reads a .scop file for each Scop)" - ); +static RegisterPass<ScopImporter> +A("polly-import", "Polly - Import Scops with OpenScop library" + " (Reads a .scop file for each Scop)"); -Pass *polly::createScopImporterPass() { - return new ScopImporter(); -} +Pass *polly::createScopImporterPass() { return new ScopImporter(); } #endif diff --git a/polly/lib/Exchange/ScopLib.cpp b/polly/lib/Exchange/ScopLib.cpp index 72809a216d1..483f6ba8ebb 100644 --- a/polly/lib/Exchange/ScopLib.cpp +++ b/polly/lib/Exchange/ScopLib.cpp @@ -46,10 +46,11 @@ ScopLib::ScopLib(Scop *S, FILE *F, Dependences *dep) : PollyScop(S), D(dep) { void ScopLib::initializeParameters() { scoplib->nb_parameters = PollyScop->getNumParams(); - scoplib->parameters = (char**) malloc(sizeof(char*) * scoplib->nb_parameters); + scoplib->parameters = + (char **)malloc(sizeof(char *) * scoplib->nb_parameters); for (int i = 0; i < scoplib->nb_parameters; ++i) { - scoplib->parameters[i] = (char *) malloc(sizeof(char*) * 20); + scoplib->parameters[i] = (char *)malloc(sizeof(char *) * 20); sprintf(scoplib->parameters[i], "p_%d", i); } } @@ -60,7 +61,8 @@ void ScopLib::initializeArrays() { for (Scop::iterator SI = PollyScop->begin(), SE = PollyScop->end(); SI != SE; ++SI) for (ScopStmt::memacc_iterator MI = (*SI)->memacc_begin(), - ME = (*SI)->memacc_end(); MI != ME; ++MI) { + ME = (*SI)->memacc_end(); + MI != ME; ++MI) { const Value *BaseAddr = (*MI)->getBaseAddr(); if (ArrayMap.find(BaseAddr) == ArrayMap.end()) { ArrayMap.insert(std::make_pair(BaseAddr, nb_arrays)); @@ -69,21 +71,21 @@ void ScopLib::initializeArrays() { } scoplib->nb_arrays = nb_arrays; - scoplib->arrays = (char**)malloc(sizeof(char*) * nb_arrays); + scoplib->arrays = (char **)malloc(sizeof(char *) * nb_arrays); for (int i = 0; i < nb_arrays; ++i) - for (std::map<const Value*, int>::iterator VI = ArrayMap.begin(), - VE = ArrayMap.end(); VI != VE; ++VI) + for (std::map<const Value *, int>::iterator VI = ArrayMap.begin(), + VE = ArrayMap.end(); + VI != VE; ++VI) if ((*VI).second == i) { const Value *V = (*VI).first; std::string name = V->getName(); - scoplib->arrays[i] = (char*) malloc(sizeof(char*) * (name.size() + 1)); + scoplib->arrays[i] = (char *)malloc(sizeof(char *) * (name.size() + 1)); strcpy(scoplib->arrays[i], name.c_str()); } } -void ScopLib::initializeScattering() { -} +void ScopLib::initializeScattering() {} scoplib_statement_p ScopLib::initializeStatement(ScopStmt *stmt) { scoplib_statement_p Stmt = scoplib_statement_malloc(); @@ -98,15 +100,15 @@ scoplib_statement_p ScopLib::initializeStatement(ScopStmt *stmt) { raw_string_ostream OS(entryName); WriteAsOperand(OS, stmt->getBasicBlock(), false); entryName = OS.str(); - Stmt->body = (char*)malloc(sizeof(char) * (entryName.size() + 1)); + Stmt->body = (char *)malloc(sizeof(char) * (entryName.size() + 1)); strcpy(Stmt->body, entryName.c_str()); // Iterator names Stmt->nb_iterators = stmt->getNumIterators(); - Stmt->iterators = (char**) malloc(sizeof(char*) * Stmt->nb_iterators); + Stmt->iterators = (char **)malloc(sizeof(char *) * Stmt->nb_iterators); for (int i = 0; i < Stmt->nb_iterators; ++i) { - Stmt->iterators[i] = (char*) malloc(sizeof(char*) * 20); + Stmt->iterators[i] = (char *)malloc(sizeof(char *) * 20); sprintf(Stmt->iterators[i], "i_%d", i); } @@ -161,9 +163,7 @@ void ScopLib::freeStatement(scoplib_statement_p stmt) { scoplib_statement_free(stmt); } -void ScopLib::print(FILE *F) { - scoplib_scop_print_dot_scop(F, scoplib); -} +void ScopLib::print(FILE *F) { scoplib_scop_print_dot_scop(F, scoplib); } /// Add an isl constraint to an ScopLib matrix. /// @@ -180,7 +180,6 @@ int ScopLib::domainToMatrix_constraint(isl_constraint *c, void *user) { scoplib_vector_p vec = scoplib_vector_malloc(nb_params + nb_vars + 2); - // Assign type if (isl_constraint_is_equality(c)) scoplib_vector_tag_equality(vec); @@ -237,8 +236,8 @@ int ScopLib::domainToMatrix_basic_set(isl_basic_set *bset, void *user) { /// @param PS The set to be translated /// @return A ScopLib Matrix scoplib_matrix_p ScopLib::domainToMatrix(__isl_take isl_set *set) { - set = isl_set_compute_divs (set); - set = isl_set_align_divs (set); + set = isl_set_compute_divs(set); + set = isl_set_align_divs(set); // Initialize the matrix. unsigned NbRows, NbColumns; @@ -267,8 +266,7 @@ int ScopLib::scatteringToMatrix_constraint(isl_constraint *c, void *user) { assert(!nb_div && "Existentially quantified variables not yet supported"); - scoplib_vector_p vec = - scoplib_vector_malloc(nb_params + nb_in + 2); + scoplib_vector_p vec = scoplib_vector_malloc(nb_params + nb_in + 2); // Assign type if (isl_constraint_is_equality(c)) @@ -295,8 +293,7 @@ int ScopLib::scatteringToMatrix_constraint(isl_constraint *c, void *user) { isl_constraint_get_constant(c, &v); isl_int_set(vec->p[nb_in + nb_params + 1], v); - scoplib_vector_p null = - scoplib_vector_malloc(nb_params + nb_in + 2); + scoplib_vector_p null = scoplib_vector_malloc(nb_params + nb_in + 2); vec = scoplib_vector_sub(null, vec); scoplib_matrix_insert_vector(m, vec, 0); @@ -329,8 +326,8 @@ int ScopLib::scatteringToMatrix_basic_map(isl_basic_map *bmap, void *user) { /// @param map The map to be translated /// @return A ScopLib Matrix scoplib_matrix_p ScopLib::scatteringToMatrix(__isl_take isl_map *map) { - map = isl_map_compute_divs (map); - map = isl_map_align_divs (map); + map = isl_map_compute_divs(map); + map = isl_map_align_divs(map); // Initialize the matrix. unsigned NbRows, NbColumns; @@ -342,10 +339,10 @@ scoplib_matrix_p ScopLib::scatteringToMatrix(__isl_take isl_map *map) { isl_map_foreach_basic_map(map, &scatteringToMatrix_basic_map, matrix); // Only keep the relevant rows. - scoplib_matrix_p reduced = scoplib_matrix_ncopy(matrix, - isl_map_n_in(map) * 2 + 1); + scoplib_matrix_p reduced = + scoplib_matrix_ncopy(matrix, isl_map_n_in(map) * 2 + 1); - scoplib_matrix_free (matrix); + scoplib_matrix_free(matrix); isl_map_free(map); return reduced; @@ -364,23 +361,23 @@ int ScopLib::accessToMatrix_constraint(isl_constraint *c, void *user) { assert(!nb_div && "Existentially quantified variables not yet supported"); - scoplib_vector_p vec = - scoplib_vector_malloc(nb_params + nb_in + 2); + scoplib_vector_p vec = scoplib_vector_malloc(nb_params + nb_in + 2); isl_int v; isl_int_init(v); // The access dimension has to be one. isl_constraint_get_coefficient(c, isl_dim_out, 0, &v); - assert((isl_int_is_one(v) || isl_int_is_negone(v)) - && "Access relations not supported in scoplib"); + assert((isl_int_is_one(v) || isl_int_is_negone(v)) && + "Access relations not supported in scoplib"); bool inverse = isl_int_is_one(v); // Assign variables for (int i = 0; i < nb_in; ++i) { isl_constraint_get_coefficient(c, isl_dim_in, i, &v); - if (inverse) isl_int_neg(v,v); + if (inverse) + isl_int_neg(v, v); isl_int_set(vec->p[i + 1], v); } @@ -389,7 +386,8 @@ int ScopLib::accessToMatrix_constraint(isl_constraint *c, void *user) { for (int i = 0; i < nb_params; ++i) { isl_constraint_get_coefficient(c, isl_dim_param, i, &v); - if (inverse) isl_int_neg(v,v); + if (inverse) + isl_int_neg(v, v); isl_int_set(vec->p[nb_in + i + 1], v); } @@ -397,7 +395,8 @@ int ScopLib::accessToMatrix_constraint(isl_constraint *c, void *user) { // Assign constant isl_constraint_get_constant(c, &v); - if (inverse) isl_int_neg(v,v); + if (inverse) + isl_int_neg(v, v); isl_int_set(vec->p[nb_in + nb_params + 1], v); @@ -409,7 +408,6 @@ int ScopLib::accessToMatrix_constraint(isl_constraint *c, void *user) { return 0; } - /// Add an isl basic map to a ScopLib matrix_list /// /// @param bmap The basic map to add @@ -442,13 +440,12 @@ scoplib_matrix_p ScopLib::createAccessMatrix(ScopStmt *S, bool isRead) { if ((*MI)->isRead() == isRead) { // Extract the access function. isl_map *AccessRelation = (*MI)->getAccessRelation(); - isl_map_foreach_basic_map(AccessRelation, - &accessToMatrix_basic_map, m); + isl_map_foreach_basic_map(AccessRelation, &accessToMatrix_basic_map, m); isl_map_free(AccessRelation); // Set the index of the memory access base element. - std::map<const Value*, int>::iterator BA = - ArrayMap.find((*MI)->getBaseAddr()); + std::map<const Value *, int>::iterator BA = + ArrayMap.find((*MI)->getBaseAddr()); isl_int_set_si(m->p[m->NbRows - 1][0], (*BA).second + 1); } @@ -495,8 +492,8 @@ ScopLib::~ScopLib() { /// @param Space An isl space object, describing how to spilt the dimensions. /// /// @return An isl constraint representing this integer array. -isl_constraint *constraintFromMatrixRow(isl_int *row, - __isl_take isl_space *Space) { +isl_constraint * +constraintFromMatrixRow(isl_int *row, __isl_take isl_space *Space) { isl_constraint *c; unsigned NbIn = isl_space_dim(Space, isl_dim_in); @@ -566,8 +563,8 @@ isl_map *mapFromMatrix(scoplib_matrix_p m, __isl_take isl_space *Space, /// @param Space An isl space object, describing how to spilt the dimensions. /// /// @return An isl constraint representing this integer array. -isl_constraint *constraintFromMatrixRowFull(isl_int *row, - __isl_take isl_space *Space) { +isl_constraint * +constraintFromMatrixRowFull(isl_int *row, __isl_take isl_space *Space) { isl_constraint *c; unsigned NbOut = isl_space_dim(Space, isl_dim_out); @@ -624,8 +621,8 @@ isl_map *mapFromMatrix(scoplib_matrix_p m, __isl_take isl_space *Space) { /// @param PollyStmt The statement to create the scattering for. /// /// @return An isl_map describing the scattering. -isl_map *scatteringForStmt(scoplib_matrix_p m, ScopStmt *PollyStmt, - int scatteringDims) { +isl_map * +scatteringForStmt(scoplib_matrix_p m, ScopStmt *PollyStmt, int scatteringDims) { unsigned NbParam = PollyStmt->getNumParams(); unsigned NbIterators = PollyStmt->getNumIterators(); @@ -644,8 +641,7 @@ isl_map *scatteringForStmt(scoplib_matrix_p m, ScopStmt *PollyStmt, // We need to copy the isl_ids for the parameter dimensions to the new // map. Without doing this the current map would have different // ids then the new one, even though both are named identically. - for (unsigned i = 0; i < isl_space_dim(Space, isl_dim_param); - i++) { + for (unsigned i = 0; i < isl_space_dim(Space, isl_dim_param); i++) { isl_id *id = isl_space_get_dim_id(ParamSpace, isl_dim_param, i); Space = isl_space_set_dim_id(Space, isl_dim_param, i, id); } @@ -697,8 +693,8 @@ StatementToIslMapTy *readScattering(Scop *S, scoplib_scop_p OScop) { int numScatteringDims = -1; ScopStmt *pollyStmt = *S->begin(); - if (stmt->schedule->NbColumns - == 2 + pollyStmt->getNumParams() + pollyStmt->getNumIterators()) { + if (stmt->schedule->NbColumns == + 2 + pollyStmt->getNumParams() + pollyStmt->getNumIterators()) { numScatteringDims = maxScattering(stmt); } @@ -709,8 +705,8 @@ StatementToIslMapTy *readScattering(Scop *S, scoplib_scop_p OScop) { return NULL; } - NewScattering[*SI] = scatteringForStmt(stmt->schedule, *SI, - numScatteringDims); + NewScattering[*SI] = + scatteringForStmt(stmt->schedule, *SI, numScatteringDims); stmt = stmt->next; } @@ -737,7 +733,7 @@ bool ScopLib::updateScattering() { if (!D->isValidScattering(NewScattering)) { freeStmtToIslMap(NewScattering); errs() << "OpenScop file contains a scattering that changes the " - << "dependences. Use -disable-polly-legality to continue anyways\n"; + << "dependences. Use -disable-polly-legality to continue anyways\n"; return false; } diff --git a/polly/lib/Exchange/ScopLibExporter.cpp b/polly/lib/Exchange/ScopLibExporter.cpp index 583240d51cb..4c7a85e1d5e 100644 --- a/polly/lib/Exchange/ScopLibExporter.cpp +++ b/polly/lib/Exchange/ScopLibExporter.cpp @@ -30,31 +30,29 @@ using namespace llvm; using namespace polly; namespace { - static cl::opt<std::string> - ExportDir("polly-export-scoplib-dir", - cl::desc("The directory to export the .scoplib files to."), - cl::Hidden, cl::value_desc("Directory path"), cl::ValueRequired, - cl::init(".")); +static cl::opt<std::string> ExportDir( + "polly-export-scoplib-dir", + cl::desc("The directory to export the .scoplib files to."), cl::Hidden, + cl::value_desc("Directory path"), cl::ValueRequired, cl::init(".")); - class ScopLibExporter : public ScopPass { - Scop *S; +class ScopLibExporter : public ScopPass { + Scop *S; - std::string getFileName(Scop *S) const; - public: - static char ID; - explicit ScopLibExporter() : ScopPass(ID) {} + std::string getFileName(Scop *S) const; +public: + static char ID; + explicit ScopLibExporter() : ScopPass(ID) {} - virtual bool runOnScop(Scop &scop); - void getAnalysisUsage(AnalysisUsage &AU) const; - }; + virtual bool runOnScop(Scop &scop); + void getAnalysisUsage(AnalysisUsage &AU) const; +}; } char ScopLibExporter::ID = 0; std::string ScopLibExporter::getFileName(Scop *S) const { - std::string FunctionName = - S->getRegion().getEntry()->getParent()->getName(); + std::string FunctionName = S->getRegion().getEntry()->getParent()->getName(); std::string FileName = FunctionName + "___" + S->getNameStr() + ".scoplib"; return FileName; } @@ -78,7 +76,7 @@ bool ScopLibExporter::runOnScop(Scop &scop) { std::string FunctionName = R->getEntry()->getParent()->getName(); errs() << "Writing Scop '" << R->getNameStr() << "' in function '" - << FunctionName << "' to '" << FileName << "'.\n"; + << FunctionName << "' to '" << FileName << "'.\n"; return false; } @@ -87,13 +85,10 @@ void ScopLibExporter::getAnalysisUsage(AnalysisUsage &AU) const { ScopPass::getAnalysisUsage(AU); } -static RegisterPass<ScopLibExporter> A("polly-export-scoplib", - "Polly - Export Scops with ScopLib library" - " (Writes a .scoplib file for each Scop)" - ); +static RegisterPass<ScopLibExporter> +A("polly-export-scoplib", "Polly - Export Scops with ScopLib library" + " (Writes a .scoplib file for each Scop)"); -Pass *polly::createScopLibExporterPass() { - return new ScopLibExporter(); -} +Pass *polly::createScopLibExporterPass() { return new ScopLibExporter(); } #endif diff --git a/polly/lib/Exchange/ScopLibImporter.cpp b/polly/lib/Exchange/ScopLibImporter.cpp index bf90857f893..4a106d16589 100644 --- a/polly/lib/Exchange/ScopLibImporter.cpp +++ b/polly/lib/Exchange/ScopLibImporter.cpp @@ -32,37 +32,34 @@ using namespace llvm; using namespace polly; namespace { - static cl::opt<std::string> - ImportDir("polly-import-scoplib-dir", - cl::desc("The directory to import the .scoplib files from."), - cl::Hidden, cl::value_desc("Directory path"), cl::ValueRequired, - cl::init(".")); - static cl::opt<std::string> - ImportPostfix("polly-import-scoplib-postfix", - cl::desc("Postfix to append to the import .scoplib files."), - cl::Hidden, cl::value_desc("File postfix"), cl::ValueRequired, - cl::init("")); - - struct ScopLibImporter : public RegionPass { - static char ID; - Scop *S; - Dependences *D; - explicit ScopLibImporter() : RegionPass(ID) {} - - bool updateScattering(Scop *S, scoplib_scop_p OScop); - std::string getFileName(Scop *S) const; - virtual bool runOnRegion(Region *R, RGPassManager &RGM); - virtual void print(raw_ostream &OS, const Module *) const; - void getAnalysisUsage(AnalysisUsage &AU) const; - }; +static cl::opt<std::string> ImportDir( + "polly-import-scoplib-dir", + cl::desc("The directory to import the .scoplib files from."), cl::Hidden, + cl::value_desc("Directory path"), cl::ValueRequired, cl::init(".")); +static cl::opt<std::string> ImportPostfix( + "polly-import-scoplib-postfix", + cl::desc("Postfix to append to the import .scoplib files."), cl::Hidden, + cl::value_desc("File postfix"), cl::ValueRequired, cl::init("")); + +struct ScopLibImporter : public RegionPass { + static char ID; + Scop *S; + Dependences *D; + explicit ScopLibImporter() : RegionPass(ID) {} + + bool updateScattering(Scop *S, scoplib_scop_p OScop); + std::string getFileName(Scop *S) const; + virtual bool runOnRegion(Region *R, RGPassManager &RGM); + virtual void print(raw_ostream &OS, const Module *) const; + void getAnalysisUsage(AnalysisUsage &AU) const; +}; } char ScopLibImporter::ID = 0; namespace { std::string ScopLibImporter::getFileName(Scop *S) const { - std::string FunctionName = - S->getRegion().getEntry()->getParent()->getName(); + std::string FunctionName = S->getRegion().getEntry()->getParent()->getName(); std::string FileName = FunctionName + "___" + S->getNameStr() + ".scoplib"; return FileName; } @@ -87,14 +84,15 @@ bool ScopLibImporter::runOnRegion(Region *R, RGPassManager &RGM) { std::string FunctionName = R->getEntry()->getParent()->getName(); errs() << "Reading Scop '" << R->getNameStr() << "' in function '" - << FunctionName << "' from '" << FileName << "'.\n"; + << FunctionName << "' from '" << FileName << "'.\n"; ScopLib scoplib(S, F, D); bool UpdateSuccessfull = scoplib.updateScattering(); fclose(F); if (!UpdateSuccessfull) { - errs() << "Update failed" << "\n"; + errs() << "Update failed" + << "\n"; } return false; @@ -108,13 +106,10 @@ void ScopLibImporter::getAnalysisUsage(AnalysisUsage &AU) const { } -static RegisterPass<ScopLibImporter> A("polly-import-scoplib", - "Polly - Import Scops with ScopLib library" - " (Reads a .scoplib file for each Scop)" - ); +static RegisterPass<ScopLibImporter> +A("polly-import-scoplib", "Polly - Import Scops with ScopLib library" + " (Reads a .scoplib file for each Scop)"); -Pass *polly::createScopLibImporterPass() { - return new ScopLibImporter(); -} +Pass *polly::createScopLibImporterPass() { return new ScopLibImporter(); } #endif diff --git a/polly/lib/MayAliasSet.cpp b/polly/lib/MayAliasSet.cpp index 2e6939e9950..9f66835612c 100644 --- a/polly/lib/MayAliasSet.cpp +++ b/polly/lib/MayAliasSet.cpp @@ -29,7 +29,7 @@ using namespace polly; void MayAliasSet::print(raw_ostream &OS) const { OS << "Must alias {"; - + for (const_iterator I = mustalias_begin(), E = mustalias_end(); I != E; ++I) { WriteAsOperand(OS, *I, false); OS << ", "; @@ -39,9 +39,6 @@ void MayAliasSet::print(raw_ostream &OS) const { OS << '}'; } -void MayAliasSet::dump() const { - print(dbgs()); -} +void MayAliasSet::dump() const { print(dbgs()); } -void MayAliasSetInfo::buildMayAliasSets(TempScop &Scop, AliasAnalysis &AA) { -} +void MayAliasSetInfo::buildMayAliasSets(TempScop &Scop, AliasAnalysis &AA) {} diff --git a/polly/lib/Pluto.cpp b/polly/lib/Pluto.cpp index 0ed1c1b4eaa..2c2004ff20c 100644 --- a/polly/lib/Pluto.cpp +++ b/polly/lib/Pluto.cpp @@ -27,51 +27,45 @@ #include "pluto/libpluto.h" #include "isl/map.h" - using namespace llvm; using namespace polly; -static cl::opt<bool> -EnableTiling("polly-pluto-tile", - cl::desc("Enable tiling"), - cl::Hidden, cl::init(false)); +static cl::opt<bool> EnableTiling("polly-pluto-tile", cl::desc("Enable tiling"), + cl::Hidden, cl::init(false)); namespace { /// Convert an int into a string. -static std::string convertInt(int number) -{ +static std::string convertInt(int number) { if (number == 0) return "0"; std::string temp = ""; std::string returnvalue = ""; - while (number > 0) - { + while (number > 0) { temp += number % 10 + 48; number /= 10; } for (unsigned i = 0; i < temp.length(); i++) - returnvalue+=temp[temp.length() - i - 1]; + returnvalue += temp[temp.length() - i - 1]; return returnvalue; } +class PlutoOptimizer : public ScopPass { - class PlutoOptimizer : public ScopPass { - - public: - static char ID; - explicit PlutoOptimizer() : ScopPass(ID) {} +public: + static char ID; + explicit PlutoOptimizer() : ScopPass(ID) {} - virtual bool runOnScop(Scop &S); - void printScop(llvm::raw_ostream &OS) const; - void getAnalysisUsage(AnalysisUsage &AU) const; - static void extendScattering(Scop &S, unsigned NewDimensions); - }; + virtual bool runOnScop(Scop &S); + void printScop(llvm::raw_ostream &OS) const; + void getAnalysisUsage(AnalysisUsage &AU) const; + static void extendScattering(Scop &S, unsigned NewDimensions); +}; } char PlutoOptimizer::ID = 0; static int getSingleMap(__isl_take isl_map *map, void *user) { - isl_map **singleMap = (isl_map **) user; + isl_map **singleMap = (isl_map **)user; *singleMap = map; return 0; @@ -93,7 +87,6 @@ void PlutoOptimizer::extendScattering(Scop &S, unsigned NewDimensions) { for (unsigned i = OldDimensions; i < NewDimensions; i++) Map = isl_map_fix_si(Map, isl_dim_out, i, 0); - Map = isl_map_align_params(Map, S.getParamSpace()); New = isl_map_apply_range(Stmt->getScattering(), Map); Stmt->setScattering(New); @@ -107,8 +100,8 @@ bool PlutoOptimizer::runOnScop(Scop &S) { Dependences *D = &getAnalysis<Dependences>(); - int DependencesKinds = Dependences::TYPE_RAW | Dependences::TYPE_WAR - | Dependences::TYPE_WAW; + int DependencesKinds = + Dependences::TYPE_RAW | Dependences::TYPE_WAR | Dependences::TYPE_WAW; Deps = D->getDependences(DependencesKinds); Domain = S.getDomains(); @@ -119,7 +112,7 @@ bool PlutoOptimizer::runOnScop(Scop &S) { ScopStmt *Stmt = *SI; std::string Name = "S_" + convertInt(counter); isl_map *Identity = isl_map_identity(isl_space_map_from_domain_and_range( - Stmt->getDomainSpace(), Stmt->getDomainSpace())); + Stmt->getDomainSpace(), Stmt->getDomainSpace())); Identity = isl_map_set_tuple_name(Identity, isl_dim_out, Name.c_str()); ToPlutoNames = isl_union_map_add_map(ToPlutoNames, Identity); counter++; @@ -133,10 +126,8 @@ bool PlutoOptimizer::runOnScop(Scop &S) { Options->fuse = 0; Options->tile = EnableTiling; - DEBUG( - dbgs() << "Domain: " << stringFromIslObj(Domain) << "\n"; - dbgs() << "Dependences: " << stringFromIslObj(Deps) << "\n"; - ); + DEBUG(dbgs() << "Domain: " << stringFromIslObj(Domain) << "\n"; + dbgs() << "Dependences: " << stringFromIslObj(Deps) << "\n";); Schedule = pluto_schedule(Domain, Deps, Options); pluto_options_free(Options); @@ -146,15 +137,15 @@ bool PlutoOptimizer::runOnScop(Scop &S) { if (!Schedule) return false; - Schedule = isl_union_map_apply_domain(Schedule, - isl_union_map_reverse(ToPlutoNames)); + Schedule = + isl_union_map_apply_domain(Schedule, isl_union_map_reverse(ToPlutoNames)); for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) { ScopStmt *Stmt = *SI; isl_set *Domain = Stmt->getDomain(); isl_union_map *StmtBand; StmtBand = isl_union_map_intersect_domain(isl_union_map_copy(Schedule), - isl_union_set_from_set(Domain)); + isl_union_set_from_set(Domain)); isl_map *StmtSchedule; isl_union_map_foreach_map(StmtBand, getSingleMap, &StmtSchedule); Stmt->setScattering(StmtSchedule); @@ -172,23 +163,21 @@ bool PlutoOptimizer::runOnScop(Scop &S) { return false; } -void PlutoOptimizer::printScop(raw_ostream &OS) const { -} +void PlutoOptimizer::printScop(raw_ostream &OS) const {} void PlutoOptimizer::getAnalysisUsage(AnalysisUsage &AU) const { ScopPass::getAnalysisUsage(AU); AU.addRequired<Dependences>(); } +Pass *polly::createPlutoOptimizerPass() { return new PlutoOptimizer(); } + INITIALIZE_PASS_BEGIN(PlutoOptimizer, "polly-opt-pluto", - "Polly - Optimize schedule of SCoP (Pluto)", false, false) -INITIALIZE_PASS_DEPENDENCY(Dependences) -INITIALIZE_PASS_DEPENDENCY(ScopInfo) + "Polly - Optimize schedule of SCoP (Pluto)", false, + false); +INITIALIZE_PASS_DEPENDENCY(Dependences); +INITIALIZE_PASS_DEPENDENCY(ScopInfo); INITIALIZE_PASS_END(PlutoOptimizer, "polly-opt-pluto", - "Polly - Optimize schedule of SCoP (Pluto)", false, false) - -Pass* polly::createPlutoOptimizerPass() { - return new PlutoOptimizer(); -} + "Polly - Optimize schedule of SCoP (Pluto)", false, false) #endif // PLUTO_FOUND diff --git a/polly/lib/Pocc.cpp b/polly/lib/Pocc.cpp index df8702a2c87..4a57f239e05 100644 --- a/polly/lib/Pocc.cpp +++ b/polly/lib/Pocc.cpp @@ -39,35 +39,32 @@ #include "isl/map.h" #include "isl/constraint.h" - using namespace llvm; using namespace polly; static cl::opt<std::string> -PlutoFuse("pluto-fuse", - cl::desc(""), cl::Hidden, - cl::value_desc("Set fuse mode of Pluto"), - cl::init("maxfuse")); +PlutoFuse("pluto-fuse", cl::desc(""), cl::Hidden, + cl::value_desc("Set fuse mode of Pluto"), cl::init("maxfuse")); namespace { - class Pocc : public ScopPass { - sys::Path plutoStderr; - sys::Path plutoStdout; - std::vector<const char*> arguments; +class Pocc : public ScopPass { + sys::Path plutoStderr; + sys::Path plutoStdout; + std::vector<const char *> arguments; - public: - static char ID; - explicit Pocc() : ScopPass(ID) {} +public: + static char ID; + explicit Pocc() : ScopPass(ID) {} - std::string getFileName(Region *R) const; - virtual bool runOnScop(Scop &S); - void printScop(llvm::raw_ostream &OS) const; - void getAnalysisUsage(AnalysisUsage &AU) const; + std::string getFileName(Region *R) const; + virtual bool runOnScop(Scop &S); + void printScop(llvm::raw_ostream &OS) const; + void getAnalysisUsage(AnalysisUsage &AU) const; - private: - bool runTransform(Scop &S); - }; +private: + bool runTransform(Scop &S); +}; } @@ -127,13 +124,13 @@ bool Pocc::runTransform(Scop &S) { plutoStderr = tempDir; plutoStderr.appendComponent("pluto.stderr"); - std::vector<sys::Path*> redirect; + std::vector<sys::Path *> redirect; redirect.push_back(0); redirect.push_back(&plutoStdout); redirect.push_back(&plutoStderr); program.ExecuteAndWait(pocc, &arguments[0], 0, - (sys::Path const **) &redirect[0]); + (sys::Path const **)&redirect[0]); // Read the created scop file sys::Path newScopFile = tempDir; @@ -145,8 +142,9 @@ bool Pocc::runTransform(Scop &S) { if (!newScoplib.updateScattering()) { errs() << "Failure when calculating the optimization with " "the following command: "; - for (std::vector<const char*>::const_iterator AI = arguments.begin(), - AE = arguments.end(); AI != AE; ++AI) + for (std::vector<const char *>::const_iterator AI = arguments.begin(), + AE = arguments.end(); + AI != AE; ++AI) if (*AI) errs() << " " << *AI; errs() << "\n"; @@ -246,8 +244,9 @@ void Pocc::printScop(raw_ostream &OS) const { OS << "Command line: "; - for (std::vector<const char*>::const_iterator AI = arguments.begin(), - AE = arguments.end(); AI != AE; ++AI) + for (std::vector<const char *>::const_iterator AI = arguments.begin(), + AE = arguments.end(); + AI != AE; ++AI) if (*AI) OS << " " << *AI; @@ -273,14 +272,12 @@ void Pocc::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<Dependences>(); } +Pass *polly::createPoccPass() { return new Pocc(); } + INITIALIZE_PASS_BEGIN(Pocc, "polly-opt-pocc", - "Polly - Optimize the scop using pocc", false, false) -INITIALIZE_PASS_DEPENDENCY(Dependences) -INITIALIZE_PASS_DEPENDENCY(ScopInfo) + "Polly - Optimize the scop using pocc", false, false); +INITIALIZE_PASS_DEPENDENCY(Dependences); +INITIALIZE_PASS_DEPENDENCY(ScopInfo); INITIALIZE_PASS_END(Pocc, "polly-opt-pocc", "Polly - Optimize the scop using pocc", false, false) - -Pass* polly::createPoccPass() { - return new Pocc(); -} #endif /* SCOPLIB_FOUND */ diff --git a/polly/lib/RegionSimplify.cpp b/polly/lib/RegionSimplify.cpp index 8d897b1698e..abf8aee588e 100644 --- a/polly/lib/RegionSimplify.cpp +++ b/polly/lib/RegionSimplify.cpp @@ -33,7 +33,7 @@ STATISTIC(NumEntries, "The # of created entry edges"); STATISTIC(NumExits, "The # of created exit edges"); namespace { -class RegionSimplify: public RegionPass { +class RegionSimplify : public RegionPass { // Remember the modified region. Region *r; void createSingleEntryEdge(Region *R); @@ -51,21 +51,13 @@ public: char RegionSimplify::ID = 0; -INITIALIZE_PASS_BEGIN(RegionSimplify, "polly-region-simplify", - "Transform refined regions into simple regions", false, - false) -INITIALIZE_PASS_DEPENDENCY(RegionInfo) -INITIALIZE_PASS_END(RegionSimplify, "polly-region-simplify", - "Transform refined regions into simple regions", false, - false) namespace polly { - Pass *createRegionSimplifyPass() { - return new RegionSimplify(); - } +Pass *createRegionSimplifyPass() { return new RegionSimplify(); } } void RegionSimplify::print(raw_ostream &O, const Module *M) const { - if (r == 0) return; + if (r == 0) + return; BasicBlock *enteringBlock = r->getEnteringBlock(); BasicBlock *exitingBlock = r->getExitingBlock(); @@ -92,19 +84,19 @@ void RegionSimplify::getAnalysisUsage(AnalysisUsage &AU) const { // Function SplitBlockPredecessors currently updates/preserves AliasAnalysis, /// DominatorTree, LoopInfo, and LCCSA but no other analyses. //AU.addPreserved<AliasAnalysis>(); Break SCEV-AA - AU.addPreserved<DominatorTree> (); + AU.addPreserved<DominatorTree>(); AU.addPreserved<LoopInfo>(); AU.addPreservedID(LCSSAID); - AU.addPreserved<RegionInfo> (); - AU.addRequired<RegionInfo> (); + AU.addPreserved<RegionInfo>(); + AU.addRequired<RegionInfo>(); } // createSingleEntryEdge - Split the entry basic block of the given // region after the last PHINode to form a single entry edge. void RegionSimplify::createSingleEntryEdge(Region *R) { BasicBlock *oldEntry = R->getEntry(); - SmallVector<BasicBlock*, 4> Preds; + SmallVector<BasicBlock *, 4> Preds; for (pred_iterator PI = pred_begin(oldEntry), PE = pred_end(oldEntry); PI != PE; ++PI) if (!R->contains(*PI)) @@ -112,10 +104,10 @@ void RegionSimplify::createSingleEntryEdge(Region *R) { assert(Preds.size() && "This region has already a single entry edge"); - BasicBlock *newEntry = SplitBlockPredecessors(oldEntry, Preds, - ".single_entry", this); + BasicBlock *newEntry = + SplitBlockPredecessors(oldEntry, Preds, ".single_entry", this); - RegionInfo *RI = &getAnalysis<RegionInfo> (); + RegionInfo *RI = &getAnalysis<RegionInfo>(); // We do not update entry node for children of this region. // This make it easier to extract children regions because they do not share // the entry node with their parents. @@ -123,7 +115,7 @@ void RegionSimplify::createSingleEntryEdge(Region *R) { Region *r = R->getParent(); // Put the new entry to R's parent. - RI->setRegionFor(newEntry,r); + RI->setRegionFor(newEntry, r); while (r->getEntry() == oldEntry && !r->isTopLevelRegion()) { r->replaceEntry(newEntry); @@ -137,11 +129,11 @@ void RegionSimplify::createSingleEntryEdge(Region *R) { std::vector<Region *> RQ; RQ.push_back(r); - while (!RQ.empty()){ + while (!RQ.empty()) { r = RQ.back(); RQ.pop_back(); - for (Region::const_iterator RI = r->begin(), RE = r->end(); RI!=RE; ++RI) + for (Region::const_iterator RI = r->begin(), RE = r->end(); RI != RE; ++RI) RQ.push_back(*RI); if (r->getExit() == oldEntry && !R->contains(r)) @@ -155,37 +147,37 @@ void RegionSimplify::createSingleEntryEdge(Region *R) { void RegionSimplify::createSingleExitEdge(Region *R) { BasicBlock *oldExit = R->getExit(); - SmallVector<BasicBlock*, 4> Preds; - for (pred_iterator PI = pred_begin(oldExit), PE = pred_end(oldExit); - PI != PE; ++PI) + SmallVector<BasicBlock *, 4> Preds; + for (pred_iterator PI = pred_begin(oldExit), PE = pred_end(oldExit); PI != PE; + ++PI) if (R->contains(*PI)) Preds.push_back(*PI); DEBUG(dbgs() << "Going to create single exit for:\n"); DEBUG(R->print(dbgs(), true, 0, Region::PrintRN)); - BasicBlock *newExit = SplitBlockPredecessors(oldExit, Preds, - ".single_exit", this); + BasicBlock *newExit = + SplitBlockPredecessors(oldExit, Preds, ".single_exit", this); RegionInfo *RI = &getAnalysis<RegionInfo>(); // We do not need to update entry nodes because this split happens inside // this region and it affects only this region and all of its children. // The new split node belongs to this region - RI->setRegionFor(newExit,R); + RI->setRegionFor(newExit, R); DEBUG(dbgs() << "Adding new exiting block: " << newExit->getName() << '\n'); // all children of this region whose exit is oldExit is changed to newExit std::vector<Region *> RQ; - for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; ++RI) + for (Region::const_iterator RI = R->begin(), RE = R->end(); RI != RE; ++RI) RQ.push_back(*RI); - while (!RQ.empty()){ + while (!RQ.empty()) { R = RQ.back(); RQ.pop_back(); if (R->getExit() != oldExit) continue; - for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; ++RI) + for (Region::const_iterator RI = R->begin(), RE = R->end(); RI != RE; ++RI) RQ.push_back(*RI); R->replaceExit(newExit); @@ -203,8 +195,8 @@ bool RegionSimplify::runOnRegion(Region *R, RGPassManager &RGM) { if (!R->isTopLevelRegion()) { // split entry node if the region has multiple entry edges - if (!(R->getEnteringBlock()) - && (pred_begin(R->getEntry()) != pred_end(R->getEntry()))) { + if (!(R->getEnteringBlock()) && + (pred_begin(R->getEntry()) != pred_end(R->getEntry()))) { createSingleEntryEdge(R); r = R; ++NumEntries; @@ -220,3 +212,11 @@ bool RegionSimplify::runOnRegion(Region *R, RGPassManager &RGM) { return r != 0; } + +INITIALIZE_PASS_BEGIN(RegionSimplify, "polly-region-simplify", + "Transform refined regions into simple regions", false, + false); +INITIALIZE_PASS_DEPENDENCY(RegionInfo); +INITIALIZE_PASS_END(RegionSimplify, "polly-region-simplify", + "Transform refined regions into simple regions", false, + false) diff --git a/polly/lib/ScheduleOptimizer.cpp b/polly/lib/ScheduleOptimizer.cpp index 266ec907d06..10639771765 100644 --- a/polly/lib/ScheduleOptimizer.cpp +++ b/polly/lib/ScheduleOptimizer.cpp @@ -39,13 +39,10 @@ using namespace llvm; using namespace polly; -namespace polly { - bool DisablePollyTiling; -} -static cl::opt<bool, true> -DisableTiling("polly-no-tiling", - cl::desc("Disable tiling in the scheduler"), cl::Hidden, - cl::location(polly::DisablePollyTiling), cl::init(false)); +namespace polly { bool DisablePollyTiling; } +static cl::opt<bool, true> DisableTiling( + "polly-no-tiling", cl::desc("Disable tiling in the scheduler"), cl::Hidden, + cl::location(polly::DisablePollyTiling), cl::init(false)); static cl::opt<std::string> OptimizeDeps("polly-opt-optimize-only", @@ -54,8 +51,8 @@ OptimizeDeps("polly-opt-optimize-only", static cl::opt<std::string> SimplifyDeps("polly-opt-simplify-deps", - cl::desc("Dependences should be simplified (yes/no)"), - cl::Hidden, cl::init("yes")); + cl::desc("Dependences should be simplified (yes/no)"), cl::Hidden, + cl::init("yes")); static cl::opt<int> MaxConstantTerm("polly-opt-max-constant-term", @@ -67,140 +64,133 @@ MaxCoefficient("polly-opt-max-coefficient", cl::desc("The maximal coefficient allowed (-1 is unlimited)"), cl::Hidden, cl::init(20)); -static cl::opt<std::string> -FusionStrategy("polly-opt-fusion", - cl::desc("The fusion strategy to choose (min/max)"), - cl::Hidden, cl::init("min")); +static cl::opt<std::string> FusionStrategy( + "polly-opt-fusion", cl::desc("The fusion strategy to choose (min/max)"), + cl::Hidden, cl::init("min")); -static cl::opt<std::string> -MaximizeBandDepth("polly-opt-maximize-bands", - cl::desc("Maximize the band depth (yes/no)"), - cl::Hidden, cl::init("yes")); +static cl::opt<std::string> MaximizeBandDepth( + "polly-opt-maximize-bands", cl::desc("Maximize the band depth (yes/no)"), + cl::Hidden, cl::init("yes")); namespace { - class IslScheduleOptimizer : public ScopPass { - - public: - static char ID; - explicit IslScheduleOptimizer() : ScopPass(ID) { - LastSchedule = NULL; - } - - ~IslScheduleOptimizer() { - isl_schedule_free(LastSchedule); - } - - virtual bool runOnScop(Scop &S); - void printScop(llvm::raw_ostream &OS) const; - void getAnalysisUsage(AnalysisUsage &AU) const; - - private: - isl_schedule *LastSchedule; - - static void extendScattering(Scop &S, unsigned NewDimensions); - - /// @brief Create a map that describes a n-dimensonal tiling. - /// - /// getTileMap creates a map from a n-dimensional scattering space into an - /// 2*n-dimensional scattering space. The map describes a rectangular - /// tiling. - /// - /// Example: - /// scheduleDimensions = 2, parameterDimensions = 1, tileSize = 32 - /// - /// tileMap := [p0] -> {[s0, s1] -> [t0, t1, s0, s1]: - /// t0 % 32 = 0 and t0 <= s0 < t0 + 32 and - /// t1 % 32 = 0 and t1 <= s1 < t1 + 32} - /// - /// Before tiling: - /// - /// for (i = 0; i < N; i++) - /// for (j = 0; j < M; j++) - /// S(i,j) - /// - /// After tiling: - /// - /// for (t_i = 0; t_i < N; i+=32) - /// for (t_j = 0; t_j < M; j+=32) - /// for (i = t_i; i < min(t_i + 32, N); i++) | Unknown that N % 32 = 0 - /// for (j = t_j; j < t_j + 32; j++) | Known that M % 32 = 0 - /// S(i,j) - /// - static isl_basic_map *getTileMap(isl_ctx *ctx, int scheduleDimensions, - isl_space *SpaceModel, int tileSize = 32); - - /// @brief Get the schedule for this band. - /// - /// Polly applies transformations like tiling on top of the isl calculated - /// value. This can influence the number of scheduling dimension. The - /// number of schedule dimensions is returned in the parameter 'Dimension'. - static isl_union_map *getScheduleForBand(isl_band *Band, int *Dimensions); - - /// @brief Create a map that pre-vectorizes one scheduling dimension. - /// - /// getPrevectorMap creates a map that maps each input dimension to the same - /// output dimension, except for the dimension DimToVectorize. - /// DimToVectorize is strip mined by 'VectorWidth' and the newly created - /// point loop of DimToVectorize is moved to the innermost level. - /// - /// Example (DimToVectorize=0, ScheduleDimensions=2, VectorWidth=4): - /// - /// | Before transformation - /// | - /// | A[i,j] -> [i,j] - /// | - /// | for (i = 0; i < 128; i++) - /// | for (j = 0; j < 128; j++) - /// | A(i,j); - /// - /// Prevector map: - /// [i,j] -> [it,j,ip] : it % 4 = 0 and it <= ip <= it + 3 and i = ip - /// - /// | After transformation: - /// | - /// | A[i,j] -> [it,j,ip] : it % 4 = 0 and it <= ip <= it + 3 and i = ip - /// | - /// | for (it = 0; it < 128; it+=4) - /// | for (j = 0; j < 128; j++) - /// | for (ip = max(0,it); ip < min(128, it + 3); ip++) - /// | A(ip,j); - /// - /// The goal of this transformation is to create a trivially vectorizable - /// loop. This means a parallel loop at the innermost level that has a - /// constant number of iterations corresponding to the target vector width. - /// - /// This transformation creates a loop at the innermost level. The loop has - /// a constant number of iterations, if the number of loop iterations at - /// DimToVectorize can be divided by VectorWidth. The default VectorWidth is - /// currently constant and not yet target specific. This function does not - /// reason about parallelism. - static isl_map *getPrevectorMap(isl_ctx *ctx, int DimToVectorize, - int ScheduleDimensions, - int VectorWidth = 4); - - /// @brief Get the scheduling map for a list of bands. - /// - /// Walk recursively the forest of bands to combine the schedules of the - /// individual bands to the overall schedule. In case tiling is requested, - /// the individual bands are tiled. - static isl_union_map *getScheduleForBandList(isl_band_list *BandList); - - static isl_union_map *getScheduleMap(isl_schedule *Schedule); - - bool doFinalization() { - isl_schedule_free(LastSchedule); - LastSchedule = NULL; - return true; - } - }; +class IslScheduleOptimizer : public ScopPass { + +public: + static char ID; + explicit IslScheduleOptimizer() : ScopPass(ID) { LastSchedule = NULL; } + + ~IslScheduleOptimizer() { isl_schedule_free(LastSchedule); } + + virtual bool runOnScop(Scop &S); + void printScop(llvm::raw_ostream &OS) const; + void getAnalysisUsage(AnalysisUsage &AU) const; + +private: + isl_schedule *LastSchedule; + + static void extendScattering(Scop &S, unsigned NewDimensions); + + /// @brief Create a map that describes a n-dimensonal tiling. + /// + /// getTileMap creates a map from a n-dimensional scattering space into an + /// 2*n-dimensional scattering space. The map describes a rectangular + /// tiling. + /// + /// Example: + /// scheduleDimensions = 2, parameterDimensions = 1, tileSize = 32 + /// + /// tileMap := [p0] -> {[s0, s1] -> [t0, t1, s0, s1]: + /// t0 % 32 = 0 and t0 <= s0 < t0 + 32 and + /// t1 % 32 = 0 and t1 <= s1 < t1 + 32} + /// + /// Before tiling: + /// + /// for (i = 0; i < N; i++) + /// for (j = 0; j < M; j++) + /// S(i,j) + /// + /// After tiling: + /// + /// for (t_i = 0; t_i < N; i+=32) + /// for (t_j = 0; t_j < M; j+=32) + /// for (i = t_i; i < min(t_i + 32, N); i++) | Unknown that N % 32 = 0 + /// for (j = t_j; j < t_j + 32; j++) | Known that M % 32 = 0 + /// S(i,j) + /// + static isl_basic_map *getTileMap(isl_ctx *ctx, int scheduleDimensions, + isl_space *SpaceModel, int tileSize = 32); + + /// @brief Get the schedule for this band. + /// + /// Polly applies transformations like tiling on top of the isl calculated + /// value. This can influence the number of scheduling dimension. The + /// number of schedule dimensions is returned in the parameter 'Dimension'. + static isl_union_map *getScheduleForBand(isl_band *Band, int *Dimensions); + + /// @brief Create a map that pre-vectorizes one scheduling dimension. + /// + /// getPrevectorMap creates a map that maps each input dimension to the same + /// output dimension, except for the dimension DimToVectorize. + /// DimToVectorize is strip mined by 'VectorWidth' and the newly created + /// point loop of DimToVectorize is moved to the innermost level. + /// + /// Example (DimToVectorize=0, ScheduleDimensions=2, VectorWidth=4): + /// + /// | Before transformation + /// | + /// | A[i,j] -> [i,j] + /// | + /// | for (i = 0; i < 128; i++) + /// | for (j = 0; j < 128; j++) + /// | A(i,j); + /// + /// Prevector map: + /// [i,j] -> [it,j,ip] : it % 4 = 0 and it <= ip <= it + 3 and i = ip + /// + /// | After transformation: + /// | + /// | A[i,j] -> [it,j,ip] : it % 4 = 0 and it <= ip <= it + 3 and i = ip + /// | + /// | for (it = 0; it < 128; it+=4) + /// | for (j = 0; j < 128; j++) + /// | for (ip = max(0,it); ip < min(128, it + 3); ip++) + /// | A(ip,j); + /// + /// The goal of this transformation is to create a trivially vectorizable + /// loop. This means a parallel loop at the innermost level that has a + /// constant number of iterations corresponding to the target vector width. + /// + /// This transformation creates a loop at the innermost level. The loop has + /// a constant number of iterations, if the number of loop iterations at + /// DimToVectorize can be divided by VectorWidth. The default VectorWidth is + /// currently constant and not yet target specific. This function does not + /// reason about parallelism. + static isl_map *getPrevectorMap(isl_ctx *ctx, int DimToVectorize, + int ScheduleDimensions, int VectorWidth = 4); + + /// @brief Get the scheduling map for a list of bands. + /// + /// Walk recursively the forest of bands to combine the schedules of the + /// individual bands to the overall schedule. In case tiling is requested, + /// the individual bands are tiled. + static isl_union_map *getScheduleForBandList(isl_band_list *BandList); + + static isl_union_map *getScheduleMap(isl_schedule *Schedule); + + bool doFinalization() { + isl_schedule_free(LastSchedule); + LastSchedule = NULL; + return true; + } +}; } char IslScheduleOptimizer::ID = 0; static int getSingleMap(__isl_take isl_map *map, void *user) { - isl_map **singleMap = (isl_map **) user; + isl_map **singleMap = (isl_map **)user; *singleMap = map; return 0; @@ -222,17 +212,14 @@ void IslScheduleOptimizer::extendScattering(Scop &S, unsigned NewDimensions) { for (unsigned i = OldDimensions; i < NewDimensions; i++) Map = isl_map_fix_si(Map, isl_dim_out, i, 0); - Map = isl_map_align_params(Map, S.getParamSpace()); New = isl_map_apply_range(Stmt->getScattering(), Map); Stmt->setScattering(New); } } -isl_basic_map *IslScheduleOptimizer::getTileMap(isl_ctx *ctx, - int scheduleDimensions, - isl_space *SpaceModel, - int tileSize) { +isl_basic_map *IslScheduleOptimizer::getTileMap( + isl_ctx *ctx, int scheduleDimensions, isl_space *SpaceModel, int tileSize) { // We construct // // tileMap := [p0] -> {[s0, s1] -> [t0, t1, p0, p1, a0, a1]: @@ -240,8 +227,8 @@ isl_basic_map *IslScheduleOptimizer::getTileMap(isl_ctx *ctx, // s1 = a1 * 32 and s1 = p1 and t1 <= p1 < t1 + 32} // // and project out the auxilary dimensions a0 and a1. - isl_space *Space = isl_space_alloc(ctx, 0, scheduleDimensions, - scheduleDimensions * 3); + isl_space *Space = + isl_space_alloc(ctx, 0, scheduleDimensions, scheduleDimensions * 3); isl_basic_map *tileMap = isl_basic_map_universe(isl_space_copy(Space)); isl_local_space *LocalSpace = isl_local_space_from_space(Space); @@ -285,15 +272,14 @@ isl_basic_map *IslScheduleOptimizer::getTileMap(isl_ctx *ctx, // The auxilary dimensions are transformed into existentially quantified ones. // This reduces the number of visible scattering dimensions and allows Cloog // to produces better code. - tileMap = isl_basic_map_project_out(tileMap, isl_dim_out, - 2 * scheduleDimensions, - scheduleDimensions); + tileMap = isl_basic_map_project_out( + tileMap, isl_dim_out, 2 * scheduleDimensions, scheduleDimensions); isl_local_space_free(LocalSpace); return tileMap; } -isl_union_map *IslScheduleOptimizer::getScheduleForBand(isl_band *Band, - int *Dimensions) { +isl_union_map * +IslScheduleOptimizer::getScheduleForBand(isl_band *Band, int *Dimensions) { isl_union_map *PartialSchedule; isl_ctx *ctx; isl_space *Space; @@ -321,10 +307,8 @@ isl_union_map *IslScheduleOptimizer::getScheduleForBand(isl_band *Band, return isl_union_map_apply_range(PartialSchedule, TileUMap); } -isl_map *IslScheduleOptimizer::getPrevectorMap(isl_ctx *ctx, - int DimToVectorize, - int ScheduleDimensions, - int VectorWidth) { +isl_map *IslScheduleOptimizer::getPrevectorMap( + isl_ctx *ctx, int DimToVectorize, int ScheduleDimensions, int VectorWidth) { isl_space *Space; isl_local_space *LocalSpace, *LocalSpaceRange; isl_set *Modulo; @@ -335,7 +319,7 @@ isl_map *IslScheduleOptimizer::getPrevectorMap(isl_ctx *ctx, int TileDimension; /* it */ isl_int VectorWidthMP; - assert (0 <= DimToVectorize && DimToVectorize < ScheduleDimensions); + assert(0 <= DimToVectorize && DimToVectorize < ScheduleDimensions); Space = isl_space_alloc(ctx, 0, ScheduleDimensions, ScheduleDimensions + 1); TilingMap = isl_map_universe(isl_space_copy(Space)); @@ -385,8 +369,8 @@ isl_map *IslScheduleOptimizer::getPrevectorMap(isl_ctx *ctx, return TilingMap; } -isl_union_map *IslScheduleOptimizer::getScheduleForBandList( - isl_band_list *BandList) { +isl_union_map * +IslScheduleOptimizer::getScheduleForBandList(isl_band_list *BandList) { int NumBands; isl_union_map *Schedule; isl_ctx *ctx; @@ -411,24 +395,24 @@ isl_union_map *IslScheduleOptimizer::getScheduleForBandList( Children = isl_band_get_children(Band); SuffixSchedule = getScheduleForBandList(Children); - PartialSchedule = isl_union_map_flat_range_product(PartialSchedule, - SuffixSchedule); + PartialSchedule = + isl_union_map_flat_range_product(PartialSchedule, SuffixSchedule); isl_band_list_free(Children); } else if (PollyVectorizerChoice != VECTORIZER_NONE) { - for (int j = 0; j < isl_band_n_member(Band); j++) { - if (isl_band_member_is_zero_distance(Band, j)) { + for (int j = 0; j < isl_band_n_member(Band); j++) { + if (isl_band_member_is_zero_distance(Band, j)) { isl_map *TileMap; isl_union_map *TileUMap; - TileMap = getPrevectorMap(ctx, ScheduleDimensions - j - 1, + TileMap = getPrevectorMap(ctx, ScheduleDimensions - j - 1, ScheduleDimensions); - TileUMap = isl_union_map_from_map(TileMap); - TileUMap = isl_union_map_align_params(TileUMap, - isl_space_copy(Space)); - PartialSchedule = isl_union_map_apply_range(PartialSchedule, - TileUMap); - break; - } + TileUMap = isl_union_map_from_map(TileMap); + TileUMap = + isl_union_map_align_params(TileUMap, isl_space_copy(Space)); + PartialSchedule = + isl_union_map_apply_range(PartialSchedule, TileUMap); + break; + } } } @@ -455,20 +439,20 @@ bool IslScheduleOptimizer::runOnScop(Scop &S) { LastSchedule = NULL; // Build input data. - int ValidityKinds = Dependences::TYPE_RAW | Dependences::TYPE_WAR - | Dependences::TYPE_WAW; + int ValidityKinds = + Dependences::TYPE_RAW | Dependences::TYPE_WAR | Dependences::TYPE_WAW; int ProximityKinds; if (OptimizeDeps == "all") - ProximityKinds = Dependences::TYPE_RAW | Dependences::TYPE_WAR - | Dependences::TYPE_WAW; + ProximityKinds = + Dependences::TYPE_RAW | Dependences::TYPE_WAR | Dependences::TYPE_WAW; else if (OptimizeDeps == "raw") ProximityKinds = Dependences::TYPE_RAW; else { errs() << "Do not know how to optimize for '" << OptimizeDeps << "'" - << " Falling back to optimizing all dependences.\n"; - ProximityKinds = Dependences::TYPE_RAW | Dependences::TYPE_WAR - | Dependences::TYPE_WAW; + << " Falling back to optimizing all dependences.\n"; + ProximityKinds = + Dependences::TYPE_RAW | Dependences::TYPE_WAR | Dependences::TYPE_WAW; } isl_union_set *Domain = S.getDomains(); @@ -489,8 +473,8 @@ bool IslScheduleOptimizer::runOnScop(Scop &S) { if (SimplifyDeps == "yes") { Validity = isl_union_map_gist_domain(Validity, isl_union_set_copy(Domain)); Validity = isl_union_map_gist_range(Validity, isl_union_set_copy(Domain)); - Proximity = isl_union_map_gist_domain(Proximity, - isl_union_set_copy(Domain)); + Proximity = + isl_union_map_gist_domain(Proximity, isl_union_set_copy(Domain)); Proximity = isl_union_map_gist_range(Proximity, isl_union_set_copy(Domain)); } else if (SimplifyDeps != "no") { errs() << "warning: Option -polly-opt-simplify-deps should either be 'yes' " @@ -535,7 +519,7 @@ bool IslScheduleOptimizer::runOnScop(Scop &S) { isl_options_set_on_error(S.getIslCtx(), ISL_ON_ERROR_CONTINUE); isl_schedule *Schedule; - Schedule = isl_union_set_compute_schedule(Domain, Validity, Proximity); + Schedule = isl_union_set_compute_schedule(Domain, Validity, Proximity); isl_options_set_on_error(S.getIslCtx(), ISL_ON_ERROR_ABORT); // In cases the scheduler is not able to optimize the code, we just do not @@ -543,8 +527,7 @@ bool IslScheduleOptimizer::runOnScop(Scop &S) { if (!Schedule) return false; - DEBUG(dbgs() << "Schedule := "; isl_schedule_dump(Schedule); - dbgs() << ";\n"); + DEBUG(dbgs() << "Schedule := "; isl_schedule_dump(Schedule); dbgs() << ";\n"); isl_union_map *ScheduleMap = getScheduleMap(Schedule); @@ -553,7 +536,7 @@ bool IslScheduleOptimizer::runOnScop(Scop &S) { isl_set *Domain = Stmt->getDomain(); isl_union_map *StmtBand; StmtBand = isl_union_map_intersect_domain(isl_union_map_copy(ScheduleMap), - isl_union_set_from_set(Domain)); + isl_union_set_from_set(Domain)); isl_map *StmtSchedule; isl_union_map_foreach_map(StmtBand, getSingleMap, &StmtSchedule); Stmt->setScattering(StmtSchedule); @@ -596,13 +579,13 @@ void IslScheduleOptimizer::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<Dependences>(); } -INITIALIZE_PASS_BEGIN(IslScheduleOptimizer, "polly-opt-isl", - "Polly - Optimize schedule of SCoP", false, false) -INITIALIZE_PASS_DEPENDENCY(Dependences) -INITIALIZE_PASS_DEPENDENCY(ScopInfo) -INITIALIZE_PASS_END(IslScheduleOptimizer, "polly-opt-isl", - "Polly - Optimize schedule of SCoP", false, false) - -Pass* polly::createIslScheduleOptimizerPass() { +Pass *polly::createIslScheduleOptimizerPass() { return new IslScheduleOptimizer(); } + +INITIALIZE_PASS_BEGIN(IslScheduleOptimizer, "polly-opt-isl", + "Polly - Optimize schedule of SCoP", false, false); +INITIALIZE_PASS_DEPENDENCY(Dependences); +INITIALIZE_PASS_DEPENDENCY(ScopInfo); +INITIALIZE_PASS_END(IslScheduleOptimizer, "polly-opt-isl", + "Polly - Optimize schedule of SCoP", false, false) diff --git a/polly/lib/Support/GICHelper.cpp b/polly/lib/Support/GICHelper.cpp index 3959cd014a5..d01c4eeeb43 100644 --- a/polly/lib/Support/GICHelper.cpp +++ b/polly/lib/Support/GICHelper.cpp @@ -121,4 +121,3 @@ std::string polly::stringFromIslObj(__isl_keep isl_pw_aff *pwaff) { return stringFromIslObjInternal(pwaff, isl_pw_aff_get_ctx, isl_printer_print_pw_aff); } - diff --git a/polly/lib/Support/SCEVValidator.cpp b/polly/lib/Support/SCEVValidator.cpp index ffaf3dcddc6..d5b4a34ae13 100644 --- a/polly/lib/Support/SCEVValidator.cpp +++ b/polly/lib/Support/SCEVValidator.cpp @@ -437,30 +437,22 @@ private: }; namespace polly { - bool hasScalarDepsInsideRegion(const SCEV *Expr, const Region *R) { - return SCEVInRegionDependences::hasDependences(Expr, R); - } +bool hasScalarDepsInsideRegion(const SCEV *Expr, const Region *R) { + return SCEVInRegionDependences::hasDependences(Expr, R); +} - bool isAffineExpr(const Region *R, const SCEV *Expr, ScalarEvolution &SE, - const Value *BaseAddress) { - if (isa<SCEVCouldNotCompute>(Expr)) +bool isAffineExpr(const Region *R, const SCEV *Expr, ScalarEvolution &SE, + const Value *BaseAddress) { + if (isa<SCEVCouldNotCompute>(Expr)) return false; SCEVValidator Validator(R, SE, BaseAddress); - DEBUG( - dbgs() << "\n"; - dbgs() << "Expr: " << *Expr << "\n"; - dbgs() << "Region: " << R->getNameStr() << "\n"; - dbgs() << " -> " - ); + DEBUG(dbgs() << "\n"; dbgs() << "Expr: " << *Expr << "\n"; + dbgs() << "Region: " << R->getNameStr() << "\n"; dbgs() << " -> "); ValidatorResult Result = Validator.visit(Expr); - DEBUG( - if (Result.isValid()) - dbgs() << "VALID\n"; - dbgs() << "\n"; - ); + DEBUG(if (Result.isValid()) dbgs() << "VALID\n"; dbgs() << "\n";); return Result.isValid(); } @@ -477,5 +469,3 @@ getParamsInAffineExpr(const Region *R, const SCEV *Expr, ScalarEvolution &SE, return Result.getParameters(); } } - - |