[llvm] r313983 - [TableGen] Return StringRef from ValueTypeByHwMode::getMVTName
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 22 06:32:26 PDT 2017
Author: rksimon
Date: Fri Sep 22 06:32:26 2017
New Revision: 313983
URL: http://llvm.org/viewvc/llvm-project?rev=313983&view=rev
Log:
[TableGen] Return StringRef from ValueTypeByHwMode::getMVTName
Avoid unnecessary std::string creations during TypeSetByHwMode::writeToStream.
Found during investigations into PR28222
Differential Revision: https://reviews.llvm.org/D38174
Modified:
llvm/trunk/utils/TableGen/InfoByHwMode.cpp
llvm/trunk/utils/TableGen/InfoByHwMode.h
Modified: llvm/trunk/utils/TableGen/InfoByHwMode.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/InfoByHwMode.cpp?rev=313983&r1=313982&r2=313983&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/InfoByHwMode.cpp (original)
+++ llvm/trunk/utils/TableGen/InfoByHwMode.cpp Fri Sep 22 06:32:26 2017
@@ -70,10 +70,9 @@ MVT &ValueTypeByHwMode::getOrCreateTypeF
return Map.insert(std::make_pair(Mode, Type)).first->second;
}
-std::string ValueTypeByHwMode::getMVTName(MVT T) {
- std::string N = llvm::getEnumName(T.SimpleTy);
- if (N.substr(0,5) == "MVT::")
- N = N.substr(5);
+StringRef ValueTypeByHwMode::getMVTName(MVT T) {
+ StringRef N = llvm::getEnumName(T.SimpleTy);
+ N.consume_front("MVT::");
return N;
}
@@ -91,7 +90,7 @@ std::string ValueTypeByHwMode::getAsStri
for (unsigned i = 0, e = Pairs.size(); i != e; ++i) {
const PairType *P = Pairs[i];
str << '(' << getModeName(P->first)
- << ':' << getMVTName(P->second) << ')';
+ << ':' << getMVTName(P->second).str() << ')';
if (i != e-1)
str << ',';
}
Modified: llvm/trunk/utils/TableGen/InfoByHwMode.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/InfoByHwMode.h?rev=313983&r1=313982&r2=313983&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/InfoByHwMode.h (original)
+++ llvm/trunk/utils/TableGen/InfoByHwMode.h Fri Sep 22 06:32:26 2017
@@ -129,7 +129,7 @@ struct ValueTypeByHwMode : public InfoBy
MVT getType(unsigned Mode) const { return get(Mode); }
MVT &getOrCreateTypeForMode(unsigned Mode, MVT Type);
- static std::string getMVTName(MVT T);
+ static StringRef getMVTName(MVT T);
std::string getAsString() const;
void dump() const;
};
More information about the llvm-commits
mailing list