1*9dfe4e7cSTobias Grosser //===------ PPCGCodeGeneration.cpp - Polly Accelerator Code Generation. ---===// 2*9dfe4e7cSTobias Grosser // 3*9dfe4e7cSTobias Grosser // The LLVM Compiler Infrastructure 4*9dfe4e7cSTobias Grosser // 5*9dfe4e7cSTobias Grosser // This file is distributed under the University of Illinois Open Source 6*9dfe4e7cSTobias Grosser // License. See LICENSE.TXT for details. 7*9dfe4e7cSTobias Grosser // 8*9dfe4e7cSTobias Grosser //===----------------------------------------------------------------------===// 9*9dfe4e7cSTobias Grosser // 10*9dfe4e7cSTobias Grosser // Take a scop created by ScopInfo and map it to GPU code using the ppcg 11*9dfe4e7cSTobias Grosser // GPU mapping strategy. 12*9dfe4e7cSTobias Grosser // 13*9dfe4e7cSTobias Grosser //===----------------------------------------------------------------------===// 14*9dfe4e7cSTobias Grosser 15*9dfe4e7cSTobias Grosser #include "polly/CodeGen/IslNodeBuilder.h" 16*9dfe4e7cSTobias Grosser #include "polly/DependenceInfo.h" 17*9dfe4e7cSTobias Grosser #include "polly/LinkAllPasses.h" 18*9dfe4e7cSTobias Grosser #include "polly/ScopInfo.h" 19*9dfe4e7cSTobias Grosser #include "llvm/Analysis/AliasAnalysis.h" 20*9dfe4e7cSTobias Grosser #include "llvm/Analysis/BasicAliasAnalysis.h" 21*9dfe4e7cSTobias Grosser #include "llvm/Analysis/GlobalsModRef.h" 22*9dfe4e7cSTobias Grosser #include "llvm/Analysis/PostDominators.h" 23*9dfe4e7cSTobias Grosser #include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h" 24*9dfe4e7cSTobias Grosser 25*9dfe4e7cSTobias Grosser #include "llvm/Support/Debug.h" 26*9dfe4e7cSTobias Grosser 27*9dfe4e7cSTobias Grosser using namespace polly; 28*9dfe4e7cSTobias Grosser using namespace llvm; 29*9dfe4e7cSTobias Grosser 30*9dfe4e7cSTobias Grosser #define DEBUG_TYPE "polly-codegen-ppcg" 31*9dfe4e7cSTobias Grosser 32*9dfe4e7cSTobias Grosser namespace { 33*9dfe4e7cSTobias Grosser class PPCGCodeGeneration : public ScopPass { 34*9dfe4e7cSTobias Grosser public: 35*9dfe4e7cSTobias Grosser static char ID; 36*9dfe4e7cSTobias Grosser 37*9dfe4e7cSTobias Grosser PPCGCodeGeneration() : ScopPass(ID) {} 38*9dfe4e7cSTobias Grosser 39*9dfe4e7cSTobias Grosser bool runOnScop(Scop &S) override { return true; } 40*9dfe4e7cSTobias Grosser 41*9dfe4e7cSTobias Grosser void printScop(raw_ostream &, Scop &) const override {} 42*9dfe4e7cSTobias Grosser 43*9dfe4e7cSTobias Grosser void getAnalysisUsage(AnalysisUsage &AU) const override { 44*9dfe4e7cSTobias Grosser AU.addRequired<DominatorTreeWrapperPass>(); 45*9dfe4e7cSTobias Grosser AU.addRequired<RegionInfoPass>(); 46*9dfe4e7cSTobias Grosser AU.addRequired<ScalarEvolutionWrapperPass>(); 47*9dfe4e7cSTobias Grosser AU.addRequired<ScopDetection>(); 48*9dfe4e7cSTobias Grosser AU.addRequired<ScopInfoRegionPass>(); 49*9dfe4e7cSTobias Grosser AU.addRequired<LoopInfoWrapperPass>(); 50*9dfe4e7cSTobias Grosser 51*9dfe4e7cSTobias Grosser AU.addPreserved<AAResultsWrapperPass>(); 52*9dfe4e7cSTobias Grosser AU.addPreserved<BasicAAWrapperPass>(); 53*9dfe4e7cSTobias Grosser AU.addPreserved<LoopInfoWrapperPass>(); 54*9dfe4e7cSTobias Grosser AU.addPreserved<DominatorTreeWrapperPass>(); 55*9dfe4e7cSTobias Grosser AU.addPreserved<GlobalsAAWrapperPass>(); 56*9dfe4e7cSTobias Grosser AU.addPreserved<PostDominatorTreeWrapperPass>(); 57*9dfe4e7cSTobias Grosser AU.addPreserved<ScopDetection>(); 58*9dfe4e7cSTobias Grosser AU.addPreserved<ScalarEvolutionWrapperPass>(); 59*9dfe4e7cSTobias Grosser AU.addPreserved<SCEVAAWrapperPass>(); 60*9dfe4e7cSTobias Grosser 61*9dfe4e7cSTobias Grosser // FIXME: We do not yet add regions for the newly generated code to the 62*9dfe4e7cSTobias Grosser // region tree. 63*9dfe4e7cSTobias Grosser AU.addPreserved<RegionInfoPass>(); 64*9dfe4e7cSTobias Grosser AU.addPreserved<ScopInfoRegionPass>(); 65*9dfe4e7cSTobias Grosser } 66*9dfe4e7cSTobias Grosser }; 67*9dfe4e7cSTobias Grosser } 68*9dfe4e7cSTobias Grosser 69*9dfe4e7cSTobias Grosser char PPCGCodeGeneration::ID = 1; 70*9dfe4e7cSTobias Grosser 71*9dfe4e7cSTobias Grosser Pass *polly::createPPCGCodeGenerationPass() { return new PPCGCodeGeneration(); } 72*9dfe4e7cSTobias Grosser 73*9dfe4e7cSTobias Grosser INITIALIZE_PASS_BEGIN(PPCGCodeGeneration, "polly-codegen-ppcg", 74*9dfe4e7cSTobias Grosser "Polly - Apply PPCG translation to SCOP", false, false) 75*9dfe4e7cSTobias Grosser INITIALIZE_PASS_DEPENDENCY(DependenceInfo); 76*9dfe4e7cSTobias Grosser INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass); 77*9dfe4e7cSTobias Grosser INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass); 78*9dfe4e7cSTobias Grosser INITIALIZE_PASS_DEPENDENCY(RegionInfoPass); 79*9dfe4e7cSTobias Grosser INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass); 80*9dfe4e7cSTobias Grosser INITIALIZE_PASS_DEPENDENCY(ScopDetection); 81*9dfe4e7cSTobias Grosser INITIALIZE_PASS_END(PPCGCodeGeneration, "polly-codegen-ppcg", 82*9dfe4e7cSTobias Grosser "Polly - Apply PPCG translation to SCOP", false, false) 83