[llvm-commits] [polly] r144083 - in /polly/trunk: include/polly/ScopInfo.h lib/Analysis/ScopInfo.cpp

Tobias Grosser grosser at fim.uni-passau.de
Tue Nov 8 07:41:03 PST 2011


Author: grosser
Date: Tue Nov  8 09:41:03 2011
New Revision: 144083

URL: http://llvm.org/viewvc/llvm-project?rev=144083&view=rev
Log:
Use a map to store the dimension of the the parameters

Modified:
    polly/trunk/include/polly/ScopInfo.h
    polly/trunk/lib/Analysis/ScopInfo.cpp

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=144083&r1=144082&r2=144083&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Tue Nov  8 09:41:03 2011
@@ -38,6 +38,7 @@
   class Type;
 }
 
+struct isl_ctx;
 struct isl_map;
 struct isl_basic_map;
 struct isl_id;
@@ -400,6 +401,13 @@
   typedef SmallVector<const SCEV*, 8> ParamVecType;
   ParamVecType Parameters;
 
+  /// The isl_ids that are used to represent the parameters
+  typedef std::map<const SCEV*, int> ParamIdType;
+  ParamIdType ParameterIds;
+
+  // Isl context.
+  isl_ctx *IslCtx;
+
   /// Constraints on parameters.
   isl_set *Context;
 

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=144083&r1=144082&r2=144083&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Tue Nov  8 09:41:03 2011
@@ -846,21 +846,14 @@
 
 //===----------------------------------------------------------------------===//
 /// Scop class implement
-isl_id *Scop::getIdForParam(const SCEV *Parameter) const {
-  int i = 0;
+__isl_give isl_id *Scop::getIdForParam(const SCEV *Parameter) const {
+  ParamIdType::const_iterator IdIter = ParameterIds.find(Parameter);
 
-  for (const_param_iterator PI = param_begin(), PE = param_end(); PI != PE;
-       ++PI) {
-    if (Parameter == *PI) {
-      std::string ParameterName = "p" + convertInt(i);
-      isl_id *id = isl_id_alloc(getIslCtx(), ParameterName.c_str(),
-                                (void *) Parameter);
-      return id;
-    }
-    i++;
-  }
+  if (IdIter == ParameterIds.end())
+    return NULL;
 
-  return NULL;
+  std::string ParameterName = "p" + convertInt(IdIter->second);
+  return isl_id_alloc(getIslCtx(), ParameterName.c_str(), (void *) Parameter);
 }
 
 void Scop::buildContext(isl_ctx *IslCtx, ParamSetType *ParamSet) {
@@ -871,9 +864,8 @@
        PI != PE; ++PI) {
     const SCEV *Parameter = *PI;
     Parameters.push_back(Parameter);
-    std::string ParameterName = "p" + convertInt(i);
-    isl_id *id = isl_id_alloc(IslCtx, ParameterName.c_str(),
-                              (void *) Parameter);
+    ParameterIds.insert(std::pair<const SCEV*, int>(Parameter, i));
+    isl_id *id = getIdForParam(Parameter);
     Space = isl_space_set_dim_id(Space, isl_dim_param, i, id);
     i++;
   }
@@ -887,6 +879,7 @@
            isl_ctx *Context)
            : SE(&ScalarEvolution), R(tempScop.getMaxRegion()),
            MaxLoopDepth(tempScop.getMaxLoopDepth()) {
+  IslCtx = Context;
   buildContext(Context, &tempScop.getParamSet());
 
   SmallVector<Loop*, 8> NestLoops;
@@ -966,7 +959,7 @@
 
 void Scop::dump() const { print(dbgs()); }
 
-isl_ctx *Scop::getIslCtx() const { return isl_set_get_ctx(Context); }
+isl_ctx *Scop::getIslCtx() const { return IslCtx; }
 
 ScalarEvolution *Scop::getSE() const { return SE; }
 





More information about the llvm-commits mailing list