diff options
| author | Tobias Grosser <tobias@grosser.es> | 2015-08-28 08:23:35 +0000 |
|---|---|---|
| committer | Tobias Grosser <tobias@grosser.es> | 2015-08-28 08:23:35 +0000 |
| commit | b79a67df786fa00ec4aeb0bf908889ce90ae591f (patch) | |
| tree | a28ecefdc0245ed4a594e03c07c755fd7322986f /polly/lib/CodeGen/BlockGenerators.cpp | |
| parent | f42d508360542fb3915ffff7d15b511cda871bd9 (diff) | |
BlockGenerator: Make scalar memory locations accessible
For external users, the memory locations into which we generate scalar values
may be of interest. This change introduces two functions that allow to obtain
(or create) the AllocInsts for a given BasePointer.
We use this change to simplify the code in BlockGenerators.
llvm-svn: 246285
Diffstat (limited to 'polly/lib/CodeGen/BlockGenerators.cpp')
| -rw-r--r-- | polly/lib/CodeGen/BlockGenerators.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp index 1b5e7ccd63d3..9e2112ba45c3 100644 --- a/polly/lib/CodeGen/BlockGenerators.cpp +++ b/polly/lib/CodeGen/BlockGenerators.cpp @@ -362,6 +362,14 @@ AllocaInst *BlockGenerator::getOrCreateAlloca(Value *ScalarBase, return Addr; } +AllocaInst *BlockGenerator::getOrCreateScalarAlloca(Value *ScalarBase) { + return getOrCreateAlloca(ScalarBase, ScalarMap, ".s2a"); +} + +AllocaInst *BlockGenerator::getOrCreatePHIAlloca(Value *ScalarBase) { + return getOrCreateAlloca(ScalarBase, PHIOpMap, ".phiops"); +} + void BlockGenerator::handleOutsideUsers(const Region &R, Instruction *Inst, Value *InstCopy) { // If there are escape users we get the alloca for this instruction and put @@ -422,9 +430,9 @@ void BlockGenerator::generateScalarLoads(ScopStmt &Stmt, auto Base = MA.getBaseAddr(); if (MA.getScopArrayInfo()->isPHI()) - Address = getOrCreateAlloca(Base, PHIOpMap, ".phiops"); + Address = getOrCreatePHIAlloca(Base); else - Address = getOrCreateAlloca(Base, ScalarMap, ".s2a"); + Address = getOrCreateScalarAlloca(Base); BBMap[Base] = Builder.CreateLoad(Address, Address->getName() + ".reload"); } @@ -487,9 +495,9 @@ void BlockGenerator::generateScalarStores(ScopStmt &Stmt, BasicBlock *BB, AllocaInst *Address = nullptr; if (MA->getScopArrayInfo()->isPHI()) - Address = getOrCreateAlloca(Base, PHIOpMap, ".phiops"); + Address = getOrCreatePHIAlloca(Base); else - Address = getOrCreateAlloca(Base, ScalarMap, ".s2a"); + Address = getOrCreateScalarAlloca(Base); Val = getNewScalarValue(Val, R, ScalarMap, BBMap, GlobalMap); Builder.CreateStore(Val, Address); @@ -1122,9 +1130,9 @@ void RegionGenerator::generateScalarStores(ScopStmt &Stmt, BasicBlock *BB, AllocaInst *ScalarAddr = nullptr; if (MA->getScopArrayInfo()->isPHI()) - ScalarAddr = getOrCreateAlloca(ScalarBase, PHIOpMap, ".phiops"); + ScalarAddr = getOrCreatePHIAlloca(ScalarBase); else - ScalarAddr = getOrCreateAlloca(ScalarBase, ScalarMap, ".s2a"); + ScalarAddr = getOrCreateScalarAlloca(ScalarBase); Val = getNewScalarValue(Val, R, ScalarMap, BBMap, GlobalMap); Builder.CreateStore(Val, ScalarAddr); @@ -1161,8 +1169,7 @@ void RegionGenerator::addOperandToPHI(ScopStmt &Stmt, const PHINode *PHI, if (PHICopy->getBasicBlockIndex(BBCopy) >= 0) return; - AllocaInst *PHIOpAddr = - getOrCreateAlloca(const_cast<PHINode *>(PHI), PHIOpMap, ".phiops"); + AllocaInst *PHIOpAddr = getOrCreatePHIAlloca(const_cast<PHINode *>(PHI)); OpCopy = new LoadInst(PHIOpAddr, PHIOpAddr->getName() + ".reload", BlockMap[IncomingBB]->getTerminator()); } |
