[llvm] 91fe9e6 - [TableGen] Move printing to stream directly to MachineValueTypeSet
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 7 09:29:04 PDT 2022
Author: Krzysztof Parzyszek
Date: 2022-07-07T09:28:28-07:00
New Revision: 91fe9e6ed39edfc4eea952355485fda3373bfe2e
URL: https://github.com/llvm/llvm-project/commit/91fe9e6ed39edfc4eea952355485fda3373bfe2e
DIFF: https://github.com/llvm/llvm-project/commit/91fe9e6ed39edfc4eea952355485fda3373bfe2e.diff
LOG: [TableGen] Move printing to stream directly to MachineValueTypeSet
Added:
Modified:
llvm/utils/TableGen/CodeGenDAGPatterns.cpp
llvm/utils/TableGen/CodeGenDAGPatterns.h
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
index 9d6adb6d2c37b..e886962e988b4 100644
--- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
+++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -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;
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.h b/llvm/utils/TableGen/CodeGenDAGPatterns.h
index 94694a96eb90d..f6a5743107d36 100644
--- a/llvm/utils/TableGen/CodeGenDAGPatterns.h
+++ b/llvm/utils/TableGen/CodeGenDAGPatterns.h
@@ -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 @@ struct MachineValueTypeSet {
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); }
More information about the llvm-commits
mailing list