summaryrefslogtreecommitdiffstats
path: root/llvm/utils/TableGen/InfoByHwMode.cpp
diff options
context:
space:
mode:
authorKrzysztof Parzyszek <kparzysz@codeaurora.org>2017-09-22 16:06:35 +0000
committerKrzysztof Parzyszek <kparzysz@codeaurora.org>2017-09-22 16:06:35 +0000
commitd55727e8739decc5d79346cd337446d9191f3639 (patch)
treee91bbf1fa5561759580129a44b49786261a0ad76 /llvm/utils/TableGen/InfoByHwMode.cpp
parent1341ac2ced33ef42c755b5c8379585699cab44bf (diff)
downloadbcm5719-llvm-d55727e8739decc5d79346cd337446d9191f3639.tar.gz
bcm5719-llvm-d55727e8739decc5d79346cd337446d9191f3639.zip
[TableGen] Replace InfoByHwMode::getAsString with writeToStream
Also add operator<< for use with raw_ostream to InfoByHwMode and its derived classes. llvm-svn: 313989
Diffstat (limited to 'llvm/utils/TableGen/InfoByHwMode.cpp')
-rw-r--r--llvm/utils/TableGen/InfoByHwMode.cpp62
1 files changed, 35 insertions, 27 deletions
diff --git a/llvm/utils/TableGen/InfoByHwMode.cpp b/llvm/utils/TableGen/InfoByHwMode.cpp
index aee0dd6fa6a..d4de490feeb 100644
--- a/llvm/utils/TableGen/InfoByHwMode.cpp
+++ b/llvm/utils/TableGen/InfoByHwMode.cpp
@@ -76,34 +76,31 @@ StringRef ValueTypeByHwMode::getMVTName(MVT T) {
return N;
}
-std::string ValueTypeByHwMode::getAsString() const {
- if (isSimple())
- return getMVTName(getSimple());
+void ValueTypeByHwMode::writeToStream(raw_ostream &OS) const {
+ if (isSimple()) {
+ OS << getMVTName(getSimple());
+ return;
+ }
std::vector<const PairType*> Pairs;
for (const auto &P : Map)
Pairs.push_back(&P);
std::sort(Pairs.begin(), Pairs.end(), deref<std::less<PairType>>());
- std::stringstream str;
- str << '{';
+ OS << '{';
for (unsigned i = 0, e = Pairs.size(); i != e; ++i) {
const PairType *P = Pairs[i];
- str << '(' << getModeName(P->first)
- << ':' << getMVTName(P->second).str() << ')';
+ OS << '(' << getModeName(P->first)
+ << ':' << getMVTName(P->second).str() << ')';
if (i != e-1)
- str << ',';
+ OS << ',';
}
- str << '}';
- return str.str();
+ OS << '}';
}
LLVM_DUMP_METHOD
void ValueTypeByHwMode::dump() const {
- dbgs() << "size=" << Map.size() << '\n';
- for (const auto &P : Map)
- dbgs() << " " << P.first << " -> "
- << llvm::getEnumName(P.second.SimpleTy) << '\n';
+ dbgs() << *this << '\n';
}
ValueTypeByHwMode llvm::getValueTypeByHwMode(Record *Rec,
@@ -136,11 +133,9 @@ bool RegSizeInfo::isSubClassOf(const RegSizeInfo &I) const {
SpillSize <= I.SpillSize;
}
-std::string RegSizeInfo::getAsString() const {
- std::stringstream str;
- str << "[R=" << RegSize << ",S=" << SpillSize
- << ",A=" << SpillAlignment << ']';
- return str.str();
+void RegSizeInfo::writeToStream(raw_ostream &OS) const {
+ OS << "[R=" << RegSize << ",S=" << SpillSize
+ << ",A=" << SpillAlignment << ']';
}
RegSizeInfoByHwMode::RegSizeInfoByHwMode(Record *R,
@@ -177,22 +172,35 @@ bool RegSizeInfoByHwMode::hasStricterSpillThan(const RegSizeInfoByHwMode &I)
std::tie(B0.SpillSize, B0.SpillAlignment);
}
-std::string RegSizeInfoByHwMode::getAsString() const {
+void RegSizeInfoByHwMode::writeToStream(raw_ostream &OS) const {
typedef typename decltype(Map)::value_type PairType;
std::vector<const PairType*> Pairs;
for (const auto &P : Map)
Pairs.push_back(&P);
std::sort(Pairs.begin(), Pairs.end(), deref<std::less<PairType>>());
- std::stringstream str;
- str << '{';
+ OS << '{';
for (unsigned i = 0, e = Pairs.size(); i != e; ++i) {
const PairType *P = Pairs[i];
- str << '(' << getModeName(P->first)
- << ':' << P->second.getAsString() << ')';
+ OS << '(' << getModeName(P->first) << ':' << P->second << ')';
if (i != e-1)
- str << ',';
+ OS << ',';
}
- str << '}';
- return str.str();
+ OS << '}';
}
+
+raw_ostream &operator<<(raw_ostream &OS, const ValueTypeByHwMode &T) {
+ T.writeToStream(OS);
+ return OS;
+}
+
+raw_ostream &operator<<(raw_ostream &OS, const RegSizeInfo &T) {
+ T.writeToStream(OS);
+ return OS;
+}
+
+raw_ostream &operator<<(raw_ostream &OS, const RegSizeInfoByHwMode &T) {
+ T.writeToStream(OS);
+ return OS;
+}
+
OpenPOWER on IntegriCloud