[polly] r213907 - Make getIslCompatibleName globaly available

Johannes Doerfert jdoerfert at codeaurora.org
Thu Jul 24 16:48:02 PDT 2014


Author: jdoerfert
Date: Thu Jul 24 18:48:02 2014
New Revision: 213907

URL: http://llvm.org/viewvc/llvm-project?rev=213907&view=rev
Log:
Make getIslCompatibleName globaly available

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

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=213907&r1=213906&r2=213907&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Thu Jul 24 18:48:02 2014
@@ -106,7 +106,6 @@ private:
   const Value *BaseAddr;
   std::string BaseName;
   isl_basic_map *createBasicAccessMap(ScopStmt *Statement);
-  void setBaseName();
   ScopStmt *Statement;
 
   /// @brief Reduction type for reduction like accesses, RT_NONE otherwise

Modified: polly/trunk/include/polly/Support/GICHelper.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/Support/GICHelper.h?rev=213907&r1=213906&r2=213907&view=diff
==============================================================================
--- polly/trunk/include/polly/Support/GICHelper.h (original)
+++ polly/trunk/include/polly/Support/GICHelper.h Thu Jul 24 18:48:02 2014
@@ -18,6 +18,8 @@
 #include "isl/ctx.h"
 #include "llvm/Support/raw_ostream.h"
 
+#include <string>
+
 struct isl_map;
 struct isl_union_map;
 struct isl_set;
@@ -29,6 +31,10 @@ struct isl_aff;
 struct isl_pw_aff;
 struct isl_val;
 
+namespace llvm {
+class Value;
+}
+
 namespace polly {
 __isl_give isl_val *isl_valFromAPInt(isl_ctx *Ctx, const llvm::APInt Int,
                                      bool IsSigned);
@@ -58,6 +64,11 @@ inline llvm::raw_ostream &operator<<(llv
   OS << polly::stringFromIslObj(Map);
   return OS;
 }
+
+/// @brief Return @p Prefix + @p Val->getName() + @p Suffix but Isl compatible.
+std::string getIslCompatibleName(std::string Prefix, const llvm::Value *Val,
+                                 std::string Suffix);
+
 } // end namespace polly
 
 #endif

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=213907&r1=213906&r2=213907&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Thu Jul 24 18:48:02 2014
@@ -309,30 +309,6 @@ MemoryAccess::~MemoryAccess() {
   isl_map_free(newAccessRelation);
 }
 
-static void replace(std::string &str, const std::string &find,
-                    const std::string &replace) {
-  size_t pos = 0;
-  while ((pos = str.find(find, pos)) != std::string::npos) {
-    str.replace(pos, find.length(), replace);
-    pos += replace.length();
-  }
-}
-
-static void makeIslCompatible(std::string &str) {
-  str.erase(0, 1);
-  replace(str, ".", "_");
-  replace(str, "\"", "_");
-}
-
-void MemoryAccess::setBaseName() {
-  raw_string_ostream OS(BaseName);
-  getBaseAddr()->printAsOperand(OS, false);
-  BaseName = OS.str();
-
-  makeIslCompatible(BaseName);
-  BaseName = "MemRef_" + BaseName;
-}
-
 isl_map *MemoryAccess::getAccessRelation() const {
   return isl_map_copy(AccessRelation);
 }
@@ -424,7 +400,7 @@ MemoryAccess::MemoryAccess(const IRAcces
     : Statement(Statement), Inst(AccInst), newAccessRelation(nullptr) {
 
   BaseAddr = Access.getBase();
-  setBaseName();
+  BaseName = getIslCompatibleName("MemRef_", getBaseAddr(), "");
 
   if (!Access.isAffine()) {
     // We overapproximate non-affine accesses with a possible access to the
@@ -809,12 +785,7 @@ ScopStmt::ScopStmt(Scop &parent, TempSco
     NestLoops[i] = Nest[i];
   }
 
-  raw_string_ostream OS(BaseName);
-  bb.printAsOperand(OS, false);
-  BaseName = OS.str();
-
-  makeIslCompatible(BaseName);
-  BaseName = "Stmt_" + BaseName;
+  BaseName = getIslCompatibleName("Stmt_", &bb, "");
 
   Domain = buildDomain(tempScop, CurRegion);
   buildScattering(Scatter);

Modified: polly/trunk/lib/Support/GICHelper.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/GICHelper.cpp?rev=213907&r1=213906&r2=213907&view=diff
==============================================================================
--- polly/trunk/lib/Support/GICHelper.cpp (original)
+++ polly/trunk/lib/Support/GICHelper.cpp Thu Jul 24 18:48:02 2014
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 #include "polly/Support/GICHelper.h"
+#include "llvm/IR/Value.h"
 #include "isl/aff.h"
 #include "isl/map.h"
 #include "isl/schedule.h"
@@ -124,3 +125,30 @@ std::string polly::stringFromIslObj(__is
   return stringFromIslObjInternal(pwaff, isl_pw_aff_get_ctx,
                                   isl_printer_print_pw_aff);
 }
+
+static void replace(std::string &str, const std::string &find,
+                    const std::string &replace) {
+  size_t pos = 0;
+  while ((pos = str.find(find, pos)) != std::string::npos) {
+    str.replace(pos, find.length(), replace);
+    pos += replace.length();
+  }
+}
+
+static void makeIslCompatible(std::string &str) {
+  replace(str, ".", "_");
+  replace(str, "\"", "_");
+}
+
+std::string polly::getIslCompatibleName(std::string Prefix, const Value *Val,
+                                        std::string Suffix) {
+  std::string ValStr;
+  raw_string_ostream OS(ValStr);
+  Val->printAsOperand(OS, false);
+  ValStr = OS.str();
+  // Remove the leading %
+  ValStr.erase(0, 1);
+  ValStr = Prefix + ValStr + Suffix;
+  makeIslCompatible(ValStr);
+  return ValStr;
+}





More information about the llvm-commits mailing list