[Support] Add (Nonowning-)IslPtr::dump(). NFC.
authorMichael Kruse <llvm@meinersbur.de>
Fri, 30 Sep 2016 16:10:19 +0000 (16:10 +0000)
committerMichael Kruse <llvm@meinersbur.de>
Fri, 30 Sep 2016 16:10:19 +0000 (16:10 +0000)
The dump() methods can be called from a debugger instead of e.g.

    isl_*_dump(Var.Obj)

where Var is a variable of type IslPtr/NonowningIslPtr. To ensure that the
existence of the function pointers do not depdend on whether the methods are
used somwhere, they are declared with external linkage.

llvm-svn: 282870

polly/include/polly/Support/GICHelper.h
polly/lib/Support/GICHelper.cpp

index 53c13e0..2574974 100644 (file)
@@ -291,6 +291,16 @@ public:
 
   isl_ctx *getCtx() const { return Traits::get_ctx(Obj); }
   std::string toStr() const { return Traits::to_str(Obj); }
+
+  /// Print a string representation of this ISL object to stderr.
+  ///
+  /// This function is meant to be called from a debugger and therefore must
+  /// not be declared inline: The debugger needs a valid function pointer to
+  /// call, even if the method is not used.
+  ///
+  /// Note that the string representation of isl_*_dump is different than the
+  /// one for isl_printer/isl_*_to_str().
+  void dump() const;
 };
 
 template <typename T> static IslPtr<T> give(__isl_take T *Obj) {
@@ -338,6 +348,11 @@ public:
 
   isl_ctx *getCtx() const { return Traits::get_ctx(Obj); }
   std::string toStr() const { return Traits::to_str(Obj); }
+
+  /// Print a string representation of this ISL object to stderr.
+  ///
+  /// @see IslPtr<T>::dump()
+  void dump() const;
 };
 
 template <typename T>
index 055d743..58c3ba5 100644 (file)
@@ -199,6 +199,28 @@ std::string polly::getIslCompatibleName(const std::string &Prefix,
   return getIslCompatibleName(Prefix, ValStr, Suffix);
 }
 
+#define DEFINE_ISLPTR(TYPE)                                                    \
+  template <> void polly::IslPtr<isl_##TYPE>::dump() const {                   \
+    isl_##TYPE##_dump(Obj);                                                    \
+  }                                                                            \
+  template <> void polly::NonowningIslPtr<isl_##TYPE>::dump() const {          \
+    isl_##TYPE##_dump(Obj);                                                    \
+  }
+
+DEFINE_ISLPTR(val)
+DEFINE_ISLPTR(space)
+DEFINE_ISLPTR(basic_map)
+DEFINE_ISLPTR(map)
+DEFINE_ISLPTR(union_map)
+DEFINE_ISLPTR(basic_set)
+DEFINE_ISLPTR(set)
+DEFINE_ISLPTR(union_set)
+DEFINE_ISLPTR(aff)
+DEFINE_ISLPTR(pw_aff)
+// DEFINE_ISLPTR(union_pw_aff) /* There is no isl_union_pw_aff_dump() */
+DEFINE_ISLPTR(multi_union_pw_aff)
+DEFINE_ISLPTR(union_pw_multi_aff)
+
 void polly::foreachElt(NonowningIslPtr<isl_union_map> UMap,
                        const std::function<void(IslPtr<isl_map> Map)> &F) {
   isl_union_map_foreach_map(