[TableGen] Move printing to stream directly to MachineValueTypeSet

This commit is contained in:
Krzysztof Parzyszek 2022-07-06 14:16:38 -07:00
parent ba4435eb62
commit 91fe9e6ed3
2 changed files with 20 additions and 13 deletions

View File

@ -61,6 +61,17 @@ static bool berase_if(MachineValueTypeSet &S, Predicate P) {
return Erased;
}
void MachineValueTypeSet::writeToStream(raw_ostream &OS) const {
SmallVector<MVT, 4> Types(begin(), end());
array_pod_sort(Types.begin(), Types.end());
OS << '[';
ListSeparator LS(" ");
for (const MVT &T : Types)
OS << LS << ValueTypeByHwMode::getMVTName(T);
OS << ']';
}
// --- TypeSetByHwMode
// This is a parameterized type-set class. For each mode there is a list
@ -193,22 +204,11 @@ void TypeSetByHwMode::writeToStream(raw_ostream &OS) const {
OS << '{';
for (unsigned M : Modes) {
OS << ' ' << getModeName(M) << ':';
writeToStream(get(M), OS);
get(M).writeToStream(OS);
}
OS << " }";
}
void TypeSetByHwMode::writeToStream(const SetType &S, raw_ostream &OS) {
SmallVector<MVT, 4> Types(S.begin(), S.end());
array_pod_sort(Types.begin(), Types.end());
OS << '[';
ListSeparator LS(" ");
for (const MVT &T : Types)
OS << LS << ValueTypeByHwMode::getMVTName(T);
OS << ']';
}
bool TypeSetByHwMode::operator==(const TypeSetByHwMode &VTS) const {
// The isSimple call is much quicker than hasDefault - check this first.
bool IsSimple = isSimple();
@ -253,6 +253,10 @@ bool TypeSetByHwMode::operator==(const TypeSetByHwMode &VTS) const {
}
namespace llvm {
raw_ostream &operator<<(raw_ostream &OS, const MachineValueTypeSet &T) {
T.writeToStream(OS);
return OS;
}
raw_ostream &operator<<(raw_ostream &OS, const TypeSetByHwMode &T) {
T.writeToStream(OS);
return OS;

View File

@ -102,6 +102,8 @@ struct MachineValueTypeSet {
Words[T.SimpleTy / WordWidth] &= ~(WordType(1) << (T.SimpleTy % WordWidth));
}
void writeToStream(raw_ostream &OS) const;
struct const_iterator {
// Some implementations of the C++ library require these traits to be
// defined.
@ -185,6 +187,8 @@ private:
std::array<WordType,NumWords> Words;
};
raw_ostream &operator<<(raw_ostream &OS, const MachineValueTypeSet &T);
struct TypeSetByHwMode : public InfoByHwMode<MachineValueTypeSet> {
using SetType = MachineValueTypeSet;
SmallVector<unsigned, 16> AddrSpaces;
@ -239,7 +243,6 @@ struct TypeSetByHwMode : public InfoByHwMode<MachineValueTypeSet> {
bool assign_if(const TypeSetByHwMode &VTS, Predicate P);
void writeToStream(raw_ostream &OS) const;
static void writeToStream(const SetType &S, raw_ostream &OS);
bool operator==(const TypeSetByHwMode &VTS) const;
bool operator!=(const TypeSetByHwMode &VTS) const { return !(*this == VTS); }