[llvm] d36936f - [RISCV][InsertVSETVLI] Add debug output capability to DemandedFields [nfc]

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 3 13:57:06 PST 2023


Author: Philip Reames
Date: 2023-01-03T13:56:57-08:00
New Revision: d36936fdb462fdda29326a51c2193a3fd10d6807

URL: https://github.com/llvm/llvm-project/commit/d36936fdb462fdda29326a51c2193a3fd10d6807
DIFF: https://github.com/llvm/llvm-project/commit/d36936fdb462fdda29326a51c2193a3fd10d6807.diff

LOG: [RISCV][InsertVSETVLI] Add debug output capability to DemandedFields [nfc]

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
index dddcd5dcf7fa8..438e8ee619c85 100644
--- a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -146,8 +146,36 @@ struct DemandedFields {
     TailPolicy = true;
     MaskPolicy = true;
   }
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+  /// Support for debugging, callable in GDB: V->dump()
+  LLVM_DUMP_METHOD void dump() const {
+    print(dbgs());
+    dbgs() << "\n";
+  }
+
+  /// Implement operator<<.
+  void print(raw_ostream &OS) const {
+    OS << "{";
+    OS << "VL=" << VL << ", ";
+    OS << "SEW=" << SEW << ", ";
+    OS << "LMUL=" << LMUL << ", ";
+    OS << "SEWLMULRatio=" << SEWLMULRatio << ", ";
+    OS << "TailPolicy=" << TailPolicy << ", ";
+    OS << "MaskPolicy=" << MaskPolicy;
+    OS << "}";
+  }
+#endif
 };
 
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+LLVM_ATTRIBUTE_USED
+inline raw_ostream &operator<<(raw_ostream &OS, const DemandedFields &DF) {
+  DF.print(OS);
+  return OS;
+}
+#endif
+
+
 /// Return true if the two values of the VTYPE register provided are
 /// indistinguishable from the perspective of an instruction (or set of
 /// instructions) which use only the Used subfields and properties.


        


More information about the llvm-commits mailing list