[PATCH] D38174: [TableGen] Return StringRef from ValueTypeByHwMode::getMVTName
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 22 06:26:02 PDT 2017
The types are printed as comments in <Target>GenDAGISel.inc.
Also, it's very useful for debugging.
Replacing getAsString with writeToStream is fine. On that note, having
an operator<< that can be invoked in a sequence with other <<'s would be
great (it could be a wrapper around writeToStream).
-Krzysztof
On 9/22/2017 7:29 AM, Zachary Turner wrote:
> Who calls getAsString? I just noticed it's using a std::stringstream
> again, which has terrible performance. One of the biggest improvements i
> made originally was converting stringstream operations to llvm streams.
>
> Is it possible to change this function to not return a std::string but
> to instead accept a llvm::raw_ostream&?
> On Fri, Sep 22, 2017 at 5:22 AM Simon Pilgrim via Phabricator
> <reviews at reviews.llvm.org <mailto:reviews at reviews.llvm.org>> wrote:
>
> RKSimon created this revision.
>
> Avoid unnecessary std::string creations during
> TypeSetByHwMode::writeToStream.
>
> Found during investigations into PR28222
>
>
> Repository:
> rL LLVM
>
> https://reviews.llvm.org/D38174
>
> Files:
> utils/TableGen/InfoByHwMode.cpp
> utils/TableGen/InfoByHwMode.h
>
>
> Index: utils/TableGen/InfoByHwMode.h
> ===================================================================
> --- utils/TableGen/InfoByHwMode.h
> +++ utils/TableGen/InfoByHwMode.h
> @@ -129,7 +129,7 @@
> 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;
> };
> Index: utils/TableGen/InfoByHwMode.cpp
> ===================================================================
> --- utils/TableGen/InfoByHwMode.cpp
> +++ utils/TableGen/InfoByHwMode.cpp
> @@ -70,10 +70,9 @@
> 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 @@
> 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 << ',';
> }
>
>
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
More information about the llvm-commits
mailing list