#include "polly/CodeGen/BlockGenerators.h"
#include "polly/CodeGen/IslExprBuilder.h"
#include "polly/CodeGen/RuntimeDebugBuilder.h"
#include "polly/Options.h"
#include "polly/ScopInfo.h"
#include "polly/Support/ISLTools.h"
#include "polly/Support/ScopHelper.h"
#include "polly/Support/VirtualInstruction.h"
#include "llvm/Analysis/DomTreeUpdater.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/RegionInfo.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Local.h"
#include "isl/ast.h"
#include <deque>
usingnamespacellvm;
usingnamespacepolly;
static cl::opt<bool> Aligned("enable-polly-aligned",
cl::desc("Assumed aligned memory accesses."),
cl::Hidden, cl::cat(PollyCategory));
bool PollyDebugPrinting;
static cl::opt<bool, true> DebugPrintingX(
"polly-codegen-add-debug-printing",
cl::desc("Add printf calls that show the values loaded/stored."),
cl::location(PollyDebugPrinting), cl::Hidden, cl::cat(PollyCategory));
static cl::opt<bool> TraceStmts(
"polly-codegen-trace-stmts",
cl::desc("Add printf calls that print the statement being executed"),
cl::Hidden, cl::cat(PollyCategory));
static cl::opt<bool> TraceScalars(
"polly-codegen-trace-scalars",
cl::desc("Add printf calls that print the values of all scalar values "
"used in a statement. Requires -polly-codegen-trace-stmts."),
cl::Hidden, cl::cat(PollyCategory));
BlockGenerator::BlockGenerator(
PollyIRBuilder &B, LoopInfo &LI, ScalarEvolution &SE, DominatorTree &DT,
AllocaMapTy &ScalarMap, EscapeUsersAllocaMapTy &EscapeMap,
ValueMapT &GlobalMap, IslExprBuilder *ExprBuilder, BasicBlock *StartBlock)
: … { … }
Value *BlockGenerator::trySynthesizeNewValue(ScopStmt &Stmt, Value *Old,
ValueMapT &BBMap,
LoopToScevMapT <S,
Loop *L) const { … }
Value *BlockGenerator::getNewValue(ScopStmt &Stmt, Value *Old, ValueMapT &BBMap,
LoopToScevMapT <S, Loop *L) const { … }
void BlockGenerator::copyInstScalar(ScopStmt &Stmt, Instruction *Inst,
ValueMapT &BBMap, LoopToScevMapT <S) { … }
Value *
BlockGenerator::generateLocationAccessed(ScopStmt &Stmt, MemAccInst Inst,
ValueMapT &BBMap, LoopToScevMapT <S,
isl_id_to_ast_expr *NewAccesses) { … }
Value *BlockGenerator::generateLocationAccessed(
ScopStmt &Stmt, Loop *L, Value *Pointer, ValueMapT &BBMap,
LoopToScevMapT <S, isl_id_to_ast_expr *NewAccesses, __isl_take isl_id *Id,
Type *ExpectedType) { … }
Value *
BlockGenerator::getImplicitAddress(MemoryAccess &Access, Loop *L,
LoopToScevMapT <S, ValueMapT &BBMap,
__isl_keep isl_id_to_ast_expr *NewAccesses) { … }
Loop *BlockGenerator::getLoopForStmt(const ScopStmt &Stmt) const { … }
Value *BlockGenerator::generateArrayLoad(ScopStmt &Stmt, LoadInst *Load,
ValueMapT &BBMap, LoopToScevMapT <S,
isl_id_to_ast_expr *NewAccesses) { … }
void BlockGenerator::generateArrayStore(ScopStmt &Stmt, StoreInst *Store,
ValueMapT &BBMap, LoopToScevMapT <S,
isl_id_to_ast_expr *NewAccesses) { … }
bool BlockGenerator::canSyntheziseInStmt(ScopStmt &Stmt, Instruction *Inst) { … }
void BlockGenerator::copyInstruction(ScopStmt &Stmt, Instruction *Inst,
ValueMapT &BBMap, LoopToScevMapT <S,
isl_id_to_ast_expr *NewAccesses) { … }
void BlockGenerator::removeDeadInstructions(BasicBlock *BB, ValueMapT &BBMap) { … }
void BlockGenerator::copyStmt(ScopStmt &Stmt, LoopToScevMapT <S,
__isl_keep isl_id_to_ast_expr *NewAccesses) { … }
BasicBlock *BlockGenerator::splitBB(BasicBlock *BB) { … }
BasicBlock *BlockGenerator::copyBB(ScopStmt &Stmt, BasicBlock *BB,
ValueMapT &BBMap, LoopToScevMapT <S,
isl_id_to_ast_expr *NewAccesses) { … }
void BlockGenerator::switchGeneratedFunc(Function *GenFn, DominatorTree *GenDT,
LoopInfo *GenLI,
ScalarEvolution *GenSE) { … }
void BlockGenerator::copyBB(ScopStmt &Stmt, BasicBlock *BB, BasicBlock *CopyBB,
ValueMapT &BBMap, LoopToScevMapT <S,
isl_id_to_ast_expr *NewAccesses) { … }
Value *BlockGenerator::getOrCreateAlloca(const MemoryAccess &Access) { … }
Value *BlockGenerator::getOrCreateAlloca(const ScopArrayInfo *Array) { … }
void BlockGenerator::handleOutsideUsers(const Scop &S, ScopArrayInfo *Array) { … }
void BlockGenerator::generateScalarLoads(
ScopStmt &Stmt, LoopToScevMapT <S, ValueMapT &BBMap,
__isl_keep isl_id_to_ast_expr *NewAccesses) { … }
Value *BlockGenerator::buildContainsCondition(ScopStmt &Stmt,
const isl::set &Subdomain) { … }
void BlockGenerator::generateConditionalExecution(
ScopStmt &Stmt, const isl::set &Subdomain, StringRef Subject,
const std::function<void()> &GenThenFunc) { … }
static std::string getInstName(Value *Val) { … }
void BlockGenerator::generateBeginStmtTrace(ScopStmt &Stmt, LoopToScevMapT <S,
ValueMapT &BBMap) { … }
void BlockGenerator::generateScalarStores(
ScopStmt &Stmt, LoopToScevMapT <S, ValueMapT &BBMap,
__isl_keep isl_id_to_ast_expr *NewAccesses) { … }
void BlockGenerator::createScalarInitialization(Scop &S) { … }
void BlockGenerator::createScalarFinalization(Scop &S) { … }
void BlockGenerator::findOutsideUsers(Scop &S) { … }
void BlockGenerator::createExitPHINodeMerges(Scop &S) { … }
void BlockGenerator::invalidateScalarEvolution(Scop &S) { … }
void BlockGenerator::finalizeSCoP(Scop &S) { … }
BasicBlock *RegionGenerator::repairDominance(BasicBlock *BB,
BasicBlock *BBCopy) { … }
static bool isDominatingSubregionExit(const DominatorTree &DT, Region *R,
BasicBlock *BB) { … }
static BasicBlock *findExitDominator(DominatorTree &DT, Region *R) { … }
void RegionGenerator::copyStmt(ScopStmt &Stmt, LoopToScevMapT <S,
__isl_keep isl_id_to_ast_expr *IdToAstExp) { … }
PHINode *RegionGenerator::buildExitPHI(MemoryAccess *MA, LoopToScevMapT <S,
ValueMapT &BBMap, Loop *L) { … }
Value *RegionGenerator::getExitScalar(MemoryAccess *MA, LoopToScevMapT <S,
ValueMapT &BBMap) { … }
void RegionGenerator::generateScalarStores(
ScopStmt &Stmt, LoopToScevMapT <S, ValueMapT &BBMap,
__isl_keep isl_id_to_ast_expr *NewAccesses) { … }
void RegionGenerator::addOperandToPHI(ScopStmt &Stmt, PHINode *PHI,
PHINode *PHICopy, BasicBlock *IncomingBB,
LoopToScevMapT <S) { … }
void RegionGenerator::copyPHIInstruction(ScopStmt &Stmt, PHINode *PHI,
ValueMapT &BBMap,
LoopToScevMapT <S) { … }