[polly] r249264 - Consolidate the different ValueMapTypes we are using
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 4 03:18:33 PDT 2015
Author: grosser
Date: Sun Oct 4 05:18:32 2015
New Revision: 249264
URL: http://llvm.org/viewvc/llvm-project?rev=249264&view=rev
Log:
Consolidate the different ValueMapTypes we are using
There have been various places where llvm::DenseMap<const llvm::Value *,
llvm::Value *> types have been defined, but all types have been expected to be
identical. We make this more clear by consolidating the different types and use
BlockGenerator::ValueMapT wherever there is a need for types to match
BlockGenerator::ValueMapT.
Modified:
polly/trunk/include/polly/CodeGen/BlockGenerators.h
polly/trunk/include/polly/CodeGen/IslExprBuilder.h
polly/trunk/include/polly/CodeGen/IslNodeBuilder.h
polly/trunk/include/polly/Support/ScopHelper.h
polly/trunk/lib/CodeGen/BlockGenerators.cpp
polly/trunk/lib/CodeGen/IslExprBuilder.cpp
polly/trunk/lib/CodeGen/IslNodeBuilder.cpp
polly/trunk/lib/Support/ScopHelper.cpp
Modified: polly/trunk/include/polly/CodeGen/BlockGenerators.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/BlockGenerators.h?rev=249264&r1=249263&r2=249264&view=diff
==============================================================================
--- polly/trunk/include/polly/CodeGen/BlockGenerators.h (original)
+++ polly/trunk/include/polly/CodeGen/BlockGenerators.h Sun Oct 4 05:18:32 2015
@@ -67,6 +67,9 @@ public:
/// @see The ScalarMap and PHIOpMap member.
using ScalarAllocaMapTy = DenseMap<AssertingVH<Value>, AssertingVH<Value>>;
+ typedef llvm::DenseMap<const llvm::Value *, llvm::Value *> ValueMapT;
+ typedef llvm::SmallVector<ValueMapT, 8> VectorValueMapT;
+
/// @brief Simple vector of instructions to store escape users.
using EscapeUserVectorTy = SmallVector<Instruction *, 4>;
@@ -98,8 +101,7 @@ public:
BlockGenerator(PollyIRBuilder &Builder, LoopInfo &LI, ScalarEvolution &SE,
DominatorTree &DT, ScalarAllocaMapTy &ScalarMap,
ScalarAllocaMapTy &PHIOpMap, EscapeUsersAllocaMapTy &EscapeMap,
- ValueToValueMap &GlobalMap,
- IslExprBuilder *ExprBuilder = nullptr);
+ ValueMapT &GlobalMap, IslExprBuilder *ExprBuilder = nullptr);
/// @brief Copy the basic block.
///
@@ -310,7 +312,7 @@ protected:
/// @brief A map from llvm::Values referenced in the old code to a new set of
/// llvm::Values, which is used to replace these old values during
/// code generation.
- ValueToValueMap &GlobalMap;
+ ValueMapT &GlobalMap;
/// @brief Split @p BB to create a new one we can use to clone @p BB in.
BasicBlock *splitBB(BasicBlock *BB);
Modified: polly/trunk/include/polly/CodeGen/IslExprBuilder.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/IslExprBuilder.h?rev=249264&r1=249263&r2=249264&view=diff
==============================================================================
--- polly/trunk/include/polly/CodeGen/IslExprBuilder.h (original)
+++ polly/trunk/include/polly/CodeGen/IslExprBuilder.h Sun Oct 4 05:18:32 2015
@@ -12,6 +12,7 @@
#ifndef POLLY_ISL_EXPR_BUILDER_H
#define POLLY_ISL_EXPR_BUILDER_H
+#include "polly/CodeGen/BlockGenerators.h"
#include "polly/CodeGen/IRBuilder.h"
#include "llvm/ADT/MapVector.h"
#include "isl/ast.h"
@@ -81,7 +82,7 @@ class IslExprBuilder {
public:
/// @brief A map from isl_ids to llvm::Values.
typedef llvm::MapVector<isl_id *, llvm::AssertingVH<llvm::Value>> IDToValueTy;
- typedef llvm::DenseMap<const llvm::Value *, llvm::Value *> ValueToValueMap;
+ typedef BlockGenerator::ValueMapT ValueToValueMap;
/// @brief Construct an IslExprBuilder.
///
Modified: polly/trunk/include/polly/CodeGen/IslNodeBuilder.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/IslNodeBuilder.h?rev=249264&r1=249263&r2=249264&view=diff
==============================================================================
--- polly/trunk/include/polly/CodeGen/IslNodeBuilder.h (original)
+++ polly/trunk/include/polly/CodeGen/IslNodeBuilder.h Sun Oct 4 05:18:32 2015
@@ -115,7 +115,7 @@ protected:
///
/// When generating new code for a ScopStmt this map is used to map certain
/// llvm::Values to new llvm::Values.
- polly::ValueMapT ValueMap;
+ polly::BlockGenerator::ValueMapT ValueMap;
/// @brief Materialize code for @p Id if it was not done before.
void materializeValue(__isl_take isl_id *Id);
Modified: polly/trunk/include/polly/Support/ScopHelper.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/Support/ScopHelper.h?rev=249264&r1=249263&r2=249264&view=diff
==============================================================================
--- polly/trunk/include/polly/Support/ScopHelper.h (original)
+++ polly/trunk/include/polly/Support/ScopHelper.h Sun Oct 4 05:18:32 2015
@@ -39,8 +39,6 @@ class ScalarEvolution;
namespace polly {
class Scop;
-typedef llvm::DenseMap<const llvm::Value *, llvm::Value *> ValueMapT;
-typedef llvm::SmallVector<ValueMapT, 8> VectorValueMapT;
/// Temporary Hack for extended regiontree.
///
@@ -102,10 +100,11 @@ void splitEntryBlockForAlloca(llvm::Basi
/// @param E The expression for which code is actually generated.
/// @param Ty The type of the resulting code.
/// @param IP The insertion point for the new code.
-llvm::Value *expandCodeFor(Scop &S, llvm::ScalarEvolution &SE,
- const llvm::DataLayout &DL, const char *Name,
- const llvm::SCEV *E, llvm::Type *Ty,
- llvm::Instruction *IP, ValueMapT *VMap = nullptr);
+llvm::Value *expandCodeFor(
+ Scop &S, llvm::ScalarEvolution &SE, const llvm::DataLayout &DL,
+ const char *Name, const llvm::SCEV *E, llvm::Type *Ty,
+ llvm::Instruction *IP,
+ llvm::DenseMap<const llvm::Value *, llvm::Value *> *VMap = nullptr);
/// @brief Check if the block is a error block.
///
Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=249264&r1=249263&r2=249264&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Sun Oct 4 05:18:32 2015
@@ -93,7 +93,7 @@ BlockGenerator::BlockGenerator(PollyIRBu
ScalarAllocaMapTy &ScalarMap,
ScalarAllocaMapTy &PHIOpMap,
EscapeUsersAllocaMapTy &EscapeMap,
- ValueToValueMap &GlobalMap,
+ ValueMapT &GlobalMap,
IslExprBuilder *ExprBuilder)
: Builder(B), LI(LI), SE(SE), ExprBuilder(ExprBuilder), DT(DT),
EntryBB(nullptr), PHIOpMap(PHIOpMap), ScalarMap(ScalarMap),
@@ -107,7 +107,7 @@ Value *BlockGenerator::trySynthesizeNewV
if (const SCEV *Scev = SE.getSCEVAtScope(const_cast<Value *>(Old), L)) {
if (!isa<SCEVCouldNotCompute>(Scev)) {
const SCEV *NewScev = apply(Scev, LTS, SE);
- ValueToValueMap VTV;
+ llvm::ValueToValueMap VTV;
VTV.insert(BBMap.begin(), BBMap.end());
VTV.insert(GlobalMap.begin(), GlobalMap.end());
Modified: polly/trunk/lib/CodeGen/IslExprBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslExprBuilder.cpp?rev=249264&r1=249263&r2=249264&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslExprBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/IslExprBuilder.cpp Sun Oct 4 05:18:32 2015
@@ -153,7 +153,8 @@ Value *IslExprBuilder::createAccessAddre
const SCEV *DimSCEV = SAI->getDimensionSize(u - 1);
- DimSCEV = SCEVParameterRewriter::rewrite(DimSCEV, SE, GlobalMap);
+ llvm::ValueToValueMap Map(GlobalMap.begin(), GlobalMap.end());
+ DimSCEV = SCEVParameterRewriter::rewrite(DimSCEV, SE, Map);
Value *DimSize =
expandCodeFor(S, SE, DL, "polly", DimSCEV, DimSCEV->getType(),
Builder.GetInsertPoint());
Modified: polly/trunk/lib/CodeGen/IslNodeBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslNodeBuilder.cpp?rev=249264&r1=249263&r2=249264&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslNodeBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/IslNodeBuilder.cpp Sun Oct 4 05:18:32 2015
@@ -175,7 +175,7 @@ struct SubtreeReferences {
LoopInfo &LI;
ScalarEvolution &SE;
Region &R;
- ValueMapT &GlobalMap;
+ polly::BlockGenerator::ValueMapT &GlobalMap;
SetVector<Value *> &Values;
SetVector<const SCEV *> &SCEVs;
BlockGenerator &BlockGen;
@@ -601,7 +601,7 @@ void IslNodeBuilder::createForParallel(_
Builder.SetInsertPoint(LoopBody);
// Save the current values.
- ValueMapT ValueMapCopy = ValueMap;
+ auto ValueMapCopy = ValueMap;
IslExprBuilder::IDToValueTy IDToValueCopy = IDToValue;
updateValues(NewValues);
Modified: polly/trunk/lib/Support/ScopHelper.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/ScopHelper.cpp?rev=249264&r1=249263&r2=249264&view=diff
==============================================================================
--- polly/trunk/lib/Support/ScopHelper.cpp (original)
+++ polly/trunk/lib/Support/ScopHelper.cpp Sun Oct 4 05:18:32 2015
@@ -240,6 +240,8 @@ void polly::splitEntryBlockForAlloca(Bas
struct ScopExpander : SCEVVisitor<ScopExpander, const SCEV *> {
friend struct SCEVVisitor<ScopExpander, const SCEV *>;
+ typedef llvm::DenseMap<const llvm::Value *, llvm::Value *> ValueMapT;
+
explicit ScopExpander(const Region &R, ScalarEvolution &SE,
const DataLayout &DL, const char *Name, ValueMapT *VMap)
: Expander(SCEVExpander(SE, DL, Name)), SE(SE), Name(Name), R(R),
@@ -340,9 +342,10 @@ private:
///}
};
-Value *polly::expandCodeFor(Scop &S, ScalarEvolution &SE, const DataLayout &DL,
- const char *Name, const SCEV *E, Type *Ty,
- Instruction *IP, ValueMapT *VMap) {
+Value *
+polly::expandCodeFor(Scop &S, ScalarEvolution &SE, const DataLayout &DL,
+ const char *Name, const SCEV *E, Type *Ty, Instruction *IP,
+ llvm::DenseMap<const llvm::Value *, llvm::Value *> *VMap) {
ScopExpander Expander(S.getRegion(), SE, DL, Name, VMap);
return Expander.expandCodeFor(E, Ty, IP);
}
More information about the llvm-commits
mailing list