From 55519dad62216bbb3f23ef1366b0f7643162c502 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Fri, 30 Sep 2016 16:10:19 +0000 Subject: [PATCH] [Support] Add (Nonowning-)IslPtr::dump(). NFC. 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 | 15 +++++++++++++++ polly/lib/Support/GICHelper.cpp | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/polly/include/polly/Support/GICHelper.h b/polly/include/polly/Support/GICHelper.h index 53c13e04e3f1..2574974d53fc 100644 --- a/polly/include/polly/Support/GICHelper.h +++ b/polly/include/polly/Support/GICHelper.h @@ -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 static IslPtr 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::dump() + void dump() const; }; template diff --git a/polly/lib/Support/GICHelper.cpp b/polly/lib/Support/GICHelper.cpp index 055d743e2c0b..58c3ba564db1 100644 --- a/polly/lib/Support/GICHelper.cpp +++ b/polly/lib/Support/GICHelper.cpp @@ -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::dump() const { \ + isl_##TYPE##_dump(Obj); \ + } \ + template <> void polly::NonowningIslPtr::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 UMap, const std::function Map)> &F) { isl_union_map_foreach_map(