Skip to content

Commit 91fe9e6

Browse files
author
Krzysztof Parzyszek
committed
[TableGen] Move printing to stream directly to MachineValueTypeSet
1 parent ba4435e commit 91fe9e6

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

llvm/utils/TableGen/CodeGenDAGPatterns.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ static bool berase_if(MachineValueTypeSet &S, Predicate P) {
6161
return Erased;
6262
}
6363

64+
void MachineValueTypeSet::writeToStream(raw_ostream &OS) const {
65+
SmallVector<MVT, 4> Types(begin(), end());
66+
array_pod_sort(Types.begin(), Types.end());
67+
68+
OS << '[';
69+
ListSeparator LS(" ");
70+
for (const MVT &T : Types)
71+
OS << LS << ValueTypeByHwMode::getMVTName(T);
72+
OS << ']';
73+
}
74+
6475
// --- TypeSetByHwMode
6576

6677
// 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 {
193204
OS << '{';
194205
for (unsigned M : Modes) {
195206
OS << ' ' << getModeName(M) << ':';
196-
writeToStream(get(M), OS);
207+
get(M).writeToStream(OS);
197208
}
198209
OS << " }";
199210
}
200211

201-
void TypeSetByHwMode::writeToStream(const SetType &S, raw_ostream &OS) {
202-
SmallVector<MVT, 4> Types(S.begin(), S.end());
203-
array_pod_sort(Types.begin(), Types.end());
204-
205-
OS << '[';
206-
ListSeparator LS(" ");
207-
for (const MVT &T : Types)
208-
OS << LS << ValueTypeByHwMode::getMVTName(T);
209-
OS << ']';
210-
}
211-
212212
bool TypeSetByHwMode::operator==(const TypeSetByHwMode &VTS) const {
213213
// The isSimple call is much quicker than hasDefault - check this first.
214214
bool IsSimple = isSimple();
@@ -253,6 +253,10 @@ bool TypeSetByHwMode::operator==(const TypeSetByHwMode &VTS) const {
253253
}
254254

255255
namespace llvm {
256+
raw_ostream &operator<<(raw_ostream &OS, const MachineValueTypeSet &T) {
257+
T.writeToStream(OS);
258+
return OS;
259+
}
256260
raw_ostream &operator<<(raw_ostream &OS, const TypeSetByHwMode &T) {
257261
T.writeToStream(OS);
258262
return OS;

llvm/utils/TableGen/CodeGenDAGPatterns.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ struct MachineValueTypeSet {
102102
Words[T.SimpleTy / WordWidth] &= ~(WordType(1) << (T.SimpleTy % WordWidth));
103103
}
104104

105+
void writeToStream(raw_ostream &OS) const;
106+
105107
struct const_iterator {
106108
// Some implementations of the C++ library require these traits to be
107109
// defined.
@@ -185,6 +187,8 @@ struct MachineValueTypeSet {
185187
std::array<WordType,NumWords> Words;
186188
};
187189

190+
raw_ostream &operator<<(raw_ostream &OS, const MachineValueTypeSet &T);
191+
188192
struct TypeSetByHwMode : public InfoByHwMode<MachineValueTypeSet> {
189193
using SetType = MachineValueTypeSet;
190194
SmallVector<unsigned, 16> AddrSpaces;
@@ -239,7 +243,6 @@ struct TypeSetByHwMode : public InfoByHwMode<MachineValueTypeSet> {
239243
bool assign_if(const TypeSetByHwMode &VTS, Predicate P);
240244

241245
void writeToStream(raw_ostream &OS) const;
242-
static void writeToStream(const SetType &S, raw_ostream &OS);
243246

244247
bool operator==(const TypeSetByHwMode &VTS) const;
245248
bool operator!=(const TypeSetByHwMode &VTS) const { return !(*this == VTS); }

0 commit comments

Comments
 (0)