[NFC] Generalize getIslCompatibleName interface.

llvm-svn: 229877
This commit is contained in:
Johannes Doerfert 2015-02-19 18:09:39 +00:00
parent 8bc34f4d96
commit 3a7e812c66
2 changed files with 18 additions and 7 deletions

View File

@ -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

View File

@ -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);
}