[polly] r249606 - Move the ValueMapT declaration out of BlockGenerator

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 7 13:15:56 PDT 2015


Author: jdoerfert
Date: Wed Oct  7 15:15:56 2015
New Revision: 249606

URL: http://llvm.org/viewvc/llvm-project?rev=249606&view=rev
Log:
Move the ValueMapT declaration out of BlockGenerator

  Value maps are created and used in many places and it is not always
  possible to include CodeGen/Blockgenerators.h. To this end, ValueMapT
  now lives in the ScopHelper.h which does not have any dependences itself.

  This patch also replaces uses of different other value map types with
  the 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/CodeGen/LoopGenerators.h
    polly/trunk/include/polly/Support/ScopHelper.h
    polly/trunk/lib/CodeGen/IslNodeBuilder.cpp
    polly/trunk/lib/CodeGen/LoopGenerators.cpp

Modified: polly/trunk/include/polly/CodeGen/BlockGenerators.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/BlockGenerators.h?rev=249606&r1=249605&r2=249606&view=diff
==============================================================================
--- polly/trunk/include/polly/CodeGen/BlockGenerators.h (original)
+++ polly/trunk/include/polly/CodeGen/BlockGenerators.h Wed Oct  7 15:15:56 2015
@@ -60,6 +60,8 @@ bool isIgnoredIntrinsic(const llvm::Valu
 /// @brief Generate a new basic block for a polyhedral statement.
 class BlockGenerator {
 public:
+  typedef llvm::SmallVector<ValueMapT, 8> VectorValueMapT;
+
   /// @brief Map types to resolve scalar dependences.
   ///
   ///@{
@@ -67,10 +69,6 @@ public:
   /// @see The ScalarMap and PHIOpMap member.
   using ScalarAllocaMapTy = DenseMap<AssertingVH<Value>, AssertingVH<Value>>;
 
-  typedef llvm::DenseMap<AssertingVH<llvm::Value>, AssertingVH<llvm::Value>>
-      ValueMapT;
-  typedef llvm::SmallVector<ValueMapT, 8> VectorValueMapT;
-
   /// @brief Simple vector of instructions to store escape users.
   using EscapeUserVectorTy = SmallVector<Instruction *, 4>;
 

Modified: polly/trunk/include/polly/CodeGen/IslExprBuilder.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/IslExprBuilder.h?rev=249606&r1=249605&r2=249606&view=diff
==============================================================================
--- polly/trunk/include/polly/CodeGen/IslExprBuilder.h (original)
+++ polly/trunk/include/polly/CodeGen/IslExprBuilder.h Wed Oct  7 15:15:56 2015
@@ -12,8 +12,9 @@
 #ifndef POLLY_ISL_EXPR_BUILDER_H
 #define POLLY_ISL_EXPR_BUILDER_H
 
-#include "polly/CodeGen/BlockGenerators.h"
 #include "polly/CodeGen/IRBuilder.h"
+#include "polly/Support/ScopHelper.h"
+
 #include "llvm/ADT/MapVector.h"
 #include "isl/ast.h"
 
@@ -82,7 +83,6 @@ class IslExprBuilder {
 public:
   /// @brief A map from isl_ids to llvm::Values.
   typedef llvm::MapVector<isl_id *, llvm::AssertingVH<llvm::Value>> IDToValueTy;
-  typedef BlockGenerator::ValueMapT ValueToValueMap;
 
   /// @brief Construct an IslExprBuilder.
   ///
@@ -95,7 +95,7 @@ public:
   ///                  specifies the LLVM-IR Values that correspond to these
   ///                  parameters and variables.
   IslExprBuilder(Scop &S, PollyIRBuilder &Builder, IDToValueTy &IDToValue,
-                 ValueToValueMap &GlobalMap, const llvm::DataLayout &DL,
+                 ValueMapT &GlobalMap, const llvm::DataLayout &DL,
                  llvm::ScalarEvolution &SE, llvm::DominatorTree &DT,
                  llvm::LoopInfo &LI)
       : S(S), Builder(Builder), IDToValue(IDToValue), GlobalMap(GlobalMap),
@@ -130,7 +130,7 @@ private:
 
   PollyIRBuilder &Builder;
   IDToValueTy &IDToValue;
-  ValueToValueMap &GlobalMap;
+  ValueMapT &GlobalMap;
 
   const llvm::DataLayout &DL;
   llvm::ScalarEvolution &SE;

Modified: polly/trunk/include/polly/CodeGen/IslNodeBuilder.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/IslNodeBuilder.h?rev=249606&r1=249605&r2=249606&view=diff
==============================================================================
--- polly/trunk/include/polly/CodeGen/IslNodeBuilder.h (original)
+++ polly/trunk/include/polly/CodeGen/IslNodeBuilder.h Wed Oct  7 15:15:56 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::BlockGenerator::ValueMapT ValueMap;
+  ValueMapT ValueMap;
 
   /// @brief Materialize code for @p Id if it was not done before.
   void materializeValue(__isl_take isl_id *Id);
@@ -191,7 +191,7 @@ protected:
   /// pass down certain values.
   ///
   /// @param NewValues A map that maps certain llvm::Values to new llvm::Values.
-  void updateValues(ParallelLoopGenerator::ValueToValueMapTy &NewValues);
+  void updateValues(ValueMapT &NewValues);
 
   /// @brief Generate code for a marker now.
   ///

Modified: polly/trunk/include/polly/CodeGen/LoopGenerators.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/LoopGenerators.h?rev=249606&r1=249605&r2=249606&view=diff
==============================================================================
--- polly/trunk/include/polly/CodeGen/LoopGenerators.h (original)
+++ polly/trunk/include/polly/CodeGen/LoopGenerators.h Wed Oct  7 15:15:56 2015
@@ -15,6 +15,8 @@
 #define POLLY_LOOP_GENERATORS_H
 
 #include "polly/CodeGen/IRBuilder.h"
+#include "polly/Support/ScopHelper.h"
+
 #include "llvm/ADT/SetVector.h"
 #include "llvm/IR/ValueMap.h"
 
@@ -96,9 +98,6 @@ Value *createLoop(Value *LowerBound, Val
 ///   }
 class ParallelLoopGenerator {
 public:
-  using ValueToValueMapTy =
-      llvm::DenseMap<AssertingVH<Value>, AssertingVH<Value>>;
-
   /// @brief Create a parallel loop generator for the current function.
   ParallelLoopGenerator(PollyIRBuilder &Builder, Pass *P, LoopInfo &LI,
                         DominatorTree &DT, const DataLayout &DL)
@@ -123,7 +122,7 @@ public:
   ///
   /// @return The newly created induction variable for this loop.
   Value *createParallelLoop(Value *LB, Value *UB, Value *Stride,
-                            SetVector<Value *> &Values, ValueToValueMapTy &VMap,
+                            SetVector<Value *> &Values, ValueMapT &VMap,
                             BasicBlock::iterator *LoopBody);
 
 private:
@@ -190,7 +189,7 @@ private:
   /// @param VMap   A map to associate every element of @p Values with the
   ///               new llvm value loaded from the @p Struct.
   void extractValuesFromStruct(SetVector<Value *> Values, Type *Ty,
-                               Value *Struct, ValueToValueMapTy &VMap);
+                               Value *Struct, ValueMapT &VMap);
 
   /// @brief Create the definition of the parallel subfunction.
   Function *createSubFnDefinition();
@@ -207,7 +206,7 @@ private:
   ///
   /// @return The newly created induction variable.
   Value *createSubFn(Value *Stride, AllocaInst *Struct,
-                     SetVector<Value *> UsedValues, ValueToValueMapTy &VMap,
+                     SetVector<Value *> UsedValues, ValueMapT &VMap,
                      Function **SubFn);
 };
 } // end namespace polly

Modified: polly/trunk/include/polly/Support/ScopHelper.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/Support/ScopHelper.h?rev=249606&r1=249605&r2=249606&view=diff
==============================================================================
--- polly/trunk/include/polly/Support/ScopHelper.h (original)
+++ polly/trunk/include/polly/Support/ScopHelper.h Wed Oct  7 15:15:56 2015
@@ -15,6 +15,7 @@
 #define POLLY_SUPPORT_IRHELPER_H
 
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/IR/ValueHandle.h"
 #include "llvm/Analysis/AliasAnalysis.h"
 
 namespace llvm {
@@ -40,6 +41,10 @@ class ScalarEvolution;
 namespace polly {
 class Scop;
 
+/// @brief Type to remap values.
+using ValueMapT = llvm::DenseMap<llvm::AssertingVH<llvm::Value>,
+                                 llvm::AssertingVH<llvm::Value>>;
+
 /// Temporary Hack for extended regiontree.
 ///
 /// @brief Cast the region to loop.

Modified: polly/trunk/lib/CodeGen/IslNodeBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslNodeBuilder.cpp?rev=249606&r1=249605&r2=249606&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslNodeBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/IslNodeBuilder.cpp Wed Oct  7 15:15:56 2015
@@ -175,7 +175,7 @@ struct SubtreeReferences {
   LoopInfo &LI;
   ScalarEvolution &SE;
   Region &R;
-  polly::BlockGenerator::ValueMapT &GlobalMap;
+  ValueMapT &GlobalMap;
   SetVector<Value *> &Values;
   SetVector<const SCEV *> &SCEVs;
   BlockGenerator &BlockGen;
@@ -311,8 +311,7 @@ void IslNodeBuilder::getReferencesInSubt
   });
 }
 
-void IslNodeBuilder::updateValues(
-    ParallelLoopGenerator::ValueToValueMapTy &NewValues) {
+void IslNodeBuilder::updateValues(ValueMapT &NewValues) {
   SmallPtrSet<Value *, 5> Inserted;
 
   for (const auto &I : IDToValue) {
@@ -592,7 +591,7 @@ void IslNodeBuilder::createForParallel(_
     SubtreeValues.insert(V);
   }
 
-  ParallelLoopGenerator::ValueToValueMapTy NewValues;
+  ValueMapT NewValues;
   ParallelLoopGenerator ParallelLoopGen(Builder, P, LI, DT, DL);
 
   IV = ParallelLoopGen.createParallelLoop(ValueLB, ValueUB, ValueInc,
@@ -607,7 +606,7 @@ void IslNodeBuilder::createForParallel(_
   updateValues(NewValues);
   IDToValue[IteratorID] = IV;
 
-  ParallelLoopGenerator::ValueToValueMapTy NewValuesReverse;
+  ValueMapT NewValuesReverse;
 
   for (auto P : NewValues)
     NewValuesReverse[P.second] = P.first;

Modified: polly/trunk/lib/CodeGen/LoopGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/LoopGenerators.cpp?rev=249606&r1=249605&r2=249606&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/LoopGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/LoopGenerators.cpp Wed Oct  7 15:15:56 2015
@@ -146,7 +146,7 @@ Value *polly::createLoop(Value *LB, Valu
 
 Value *ParallelLoopGenerator::createParallelLoop(
     Value *LB, Value *UB, Value *Stride, SetVector<Value *> &UsedValues,
-    ValueToValueMapTy &Map, BasicBlock::iterator *LoopBody) {
+    ValueMapT &Map, BasicBlock::iterator *LoopBody) {
   Function *SubFn;
 
   AllocaInst *Struct = storeValuesIntoStruct(UsedValues);
@@ -305,8 +305,7 @@ ParallelLoopGenerator::storeValuesIntoSt
 }
 
 void ParallelLoopGenerator::extractValuesFromStruct(
-    SetVector<Value *> OldValues, Type *Ty, Value *Struct,
-    ValueToValueMapTy &Map) {
+    SetVector<Value *> OldValues, Type *Ty, Value *Struct, ValueMapT &Map) {
   for (unsigned i = 0; i < OldValues.size(); i++) {
     Value *Address = Builder.CreateStructGEP(Ty, Struct, i);
     Value *NewValue = Builder.CreateLoad(Address);
@@ -317,8 +316,7 @@ void ParallelLoopGenerator::extractValue
 
 Value *ParallelLoopGenerator::createSubFn(Value *Stride, AllocaInst *StructData,
                                           SetVector<Value *> Data,
-                                          ValueToValueMapTy &Map,
-                                          Function **SubFnPtr) {
+                                          ValueMapT &Map, Function **SubFnPtr) {
   BasicBlock *PrevBB, *HeaderBB, *ExitBB, *CheckNextBB, *PreHeaderBB, *AfterBB;
   Value *LBPtr, *UBPtr, *UserContext, *Ret1, *HasNextSchedule, *LB, *UB, *IV;
   Function *SubFn = createSubFnDefinition();




More information about the llvm-commits mailing list