From 3a7e812c6683a4a5508882e3bfd96728ed8fce7e Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Thu, 19 Feb 2015 18:09:39 +0000 Subject: [PATCH] [NFC] Generalize getIslCompatibleName interface. llvm-svn: 229877 --- polly/include/polly/Support/GICHelper.h | 9 +++++++-- polly/lib/Support/GICHelper.cpp | 16 +++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/polly/include/polly/Support/GICHelper.h b/polly/include/polly/Support/GICHelper.h index c5fb4a1..a83588d 100644 --- a/polly/include/polly/Support/GICHelper.h +++ b/polly/include/polly/Support/GICHelper.h @@ -72,8 +72,13 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &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); +std::string getIslCompatibleName(const std::string &Prefix, + const llvm::Value *Val, + const std::string &Suffix); + +std::string getIslCompatibleName(const std::string &Prefix, + const std::string &Middle, + const std::string &Suffix); } // end namespace polly diff --git a/polly/lib/Support/GICHelper.cpp b/polly/lib/Support/GICHelper.cpp index 0b7abc2..581d2e2 100644 --- a/polly/lib/Support/GICHelper.cpp +++ b/polly/lib/Support/GICHelper.cpp @@ -136,15 +136,21 @@ static void makeIslCompatible(std::string &str) { replace(str, "\"", "_"); } -std::string polly::getIslCompatibleName(std::string Prefix, const Value *Val, - std::string Suffix) { +std::string polly::getIslCompatibleName(const std::string &Prefix, + const std::string &Middle, + const std::string &Suffix) { + std::string S = Prefix + Middle + Suffix; + makeIslCompatible(S); + return S; +} + +std::string polly::getIslCompatibleName(const std::string &Prefix, const Value *Val, + const 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; + return getIslCompatibleName(Prefix, ValStr, Suffix); } -- 2.7.4