aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorKrzysztof Parzyszek <kparzysz@codeaurora.org>2017-09-22 18:29:37 +0000
committerKrzysztof Parzyszek <kparzysz@codeaurora.org>2017-09-22 18:29:37 +0000
commitbbd7d72ffd76b502d80f8c12665d007537e49ca3 (patch)
tree940f977d0c11de715617139e6146faa40eb09fa9 /utils
parent55d3e2aced7d0c2adfc76eec4de4ef31d55777d3 (diff)
downloadllvm-bbd7d72ffd76b502d80f8c12665d007537e49ca3.tar.gz
[TableGen] Replace InfoByHwMode::getAsString with writeToStream
Also add operator<< for use with raw_ostream to InfoByHwMode and its derived classes. Recommitting r313989 with the fix for unresolved references: explicitly define the operator<< in namespace llvm. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314004 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/CodeGenDAGPatterns.cpp10
-rw-r--r--utils/TableGen/CodeGenDAGPatterns.h2
-rw-r--r--utils/TableGen/CodeGenRegisters.cpp2
-rw-r--r--utils/TableGen/InfoByHwMode.cpp63
-rw-r--r--utils/TableGen/InfoByHwMode.h12
5 files changed, 56 insertions, 33 deletions
diff --git a/utils/TableGen/CodeGenDAGPatterns.cpp b/utils/TableGen/CodeGenDAGPatterns.cpp
index ed2ea75e943..6321c96086e 100644
--- a/utils/TableGen/CodeGenDAGPatterns.cpp
+++ b/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -238,10 +238,16 @@ bool TypeSetByHwMode::operator==(const TypeSetByHwMode &VTS) const {
return true;
}
+namespace llvm {
+ raw_ostream &operator<<(raw_ostream &OS, const TypeSetByHwMode &T) {
+ T.writeToStream(OS);
+ return OS;
+ }
+}
+
LLVM_DUMP_METHOD
void TypeSetByHwMode::dump() const {
- writeToStream(dbgs());
- dbgs() << '\n';
+ dbgs() << *this << '\n';
}
bool TypeSetByHwMode::intersect(SetType &Out, const SetType &In) {
diff --git a/utils/TableGen/CodeGenDAGPatterns.h b/utils/TableGen/CodeGenDAGPatterns.h
index c82c4d17943..f8bc31fc016 100644
--- a/utils/TableGen/CodeGenDAGPatterns.h
+++ b/utils/TableGen/CodeGenDAGPatterns.h
@@ -240,6 +240,8 @@ private:
bool intersect(SetType &Out, const SetType &In);
};
+raw_ostream &operator<<(raw_ostream &OS, const TypeSetByHwMode &T);
+
struct TypeInfer {
TypeInfer(TreePattern &T) : TP(T), ForceMode(0) {}
diff --git a/utils/TableGen/CodeGenRegisters.cpp b/utils/TableGen/CodeGenRegisters.cpp
index f3b01eb5a94..a6b0a4beb8e 100644
--- a/utils/TableGen/CodeGenRegisters.cpp
+++ b/utils/TableGen/CodeGenRegisters.cpp
@@ -836,7 +836,7 @@ bool CodeGenRegisterClass::contains(const CodeGenRegister *Reg) const {
namespace llvm {
raw_ostream &operator<<(raw_ostream &OS, const CodeGenRegisterClass::Key &K) {
- OS << "{ " << K.RSI.getAsString();
+ OS << "{ " << K.RSI;
for (const auto R : *K.Members)
OS << ", " << R->getName();
return OS << " }";
diff --git a/utils/TableGen/InfoByHwMode.cpp b/utils/TableGen/InfoByHwMode.cpp
index aee0dd6fa6a..7e1e1864356 100644
--- a/utils/TableGen/InfoByHwMode.cpp
+++ b/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,36 @@ 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 << ',';
+ }
+ OS << '}';
+}
+
+namespace llvm {
+ 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;
}
- str << '}';
- return str.str();
}
diff --git a/utils/TableGen/InfoByHwMode.h b/utils/TableGen/InfoByHwMode.h
index 57640fc3025..b2e21749888 100644
--- a/utils/TableGen/InfoByHwMode.h
+++ b/utils/TableGen/InfoByHwMode.h
@@ -27,6 +27,7 @@ namespace llvm {
struct CodeGenHwModes;
class Record;
+class raw_ostream;
template <typename InfoT> struct InfoByHwMode;
@@ -130,7 +131,7 @@ struct ValueTypeByHwMode : public InfoByHwMode<MVT> {
MVT &getOrCreateTypeForMode(unsigned Mode, MVT Type);
static StringRef getMVTName(MVT T);
- std::string getAsString() const;
+ void writeToStream(raw_ostream &OS) const;
void dump() const;
};
@@ -154,7 +155,7 @@ struct RegSizeInfo {
}
bool isSubClassOf(const RegSizeInfo &I) const;
- std::string getAsString() const;
+ void writeToStream(raw_ostream &OS) const;
};
struct RegSizeInfoByHwMode : public InfoByHwMode<RegSizeInfo> {
@@ -169,8 +170,13 @@ struct RegSizeInfoByHwMode : public InfoByHwMode<RegSizeInfo> {
bool isSubClassOf(const RegSizeInfoByHwMode &I) const;
bool hasStricterSpillThan(const RegSizeInfoByHwMode &I) const;
- std::string getAsString() const;
+ void writeToStream(raw_ostream &OS) const;
};
+
+raw_ostream &operator<<(raw_ostream &OS, const ValueTypeByHwMode &T);
+raw_ostream &operator<<(raw_ostream &OS, const RegSizeInfo &T);
+raw_ostream &operator<<(raw_ostream &OS, const RegSizeInfoByHwMode &T);
+
} // namespace llvm
#endif // LLVM_UTILS_TABLEGEN_INFOBYHWMODE_H