[llvm] r265746 - [RegisterBankInfo] Add print and dump method to the ValueMapping helper

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 7 16:25:44 PDT 2016


Author: qcolombet
Date: Thu Apr  7 18:25:43 2016
New Revision: 265746

URL: http://llvm.org/viewvc/llvm-project?rev=265746&view=rev
Log:
[RegisterBankInfo] Add print and dump method to the ValueMapping helper
class.

Modified:
    llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h
    llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp

Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h?rev=265746&r1=265745&r2=265746&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h Thu Apr  7 18:25:43 2016
@@ -71,6 +71,12 @@ public:
 
     /// Verify that this mapping makes sense for a value of \p ExpectedBitWidth.
     void verify(unsigned ExpectedBitWidth) const;
+
+    /// Print this on dbgs() stream.
+    void dump() const;
+
+    /// Print this on \p OS;
+    void print(raw_ostream &OS) const;
   };
 
   /// Helper class that represents how the value of an instruction may be
@@ -385,6 +391,12 @@ operator<<(raw_ostream &OS,
   PartMapping.print(OS);
   return OS;
 }
+
+inline raw_ostream &
+operator<<(raw_ostream &OS, const RegisterBankInfo::ValueMapping &ValMapping) {
+  ValMapping.print(OS);
+  return OS;
+}
 } // End namespace llvm.
 
 #endif

Modified: llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp?rev=265746&r1=265745&r2=265746&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp Thu Apr  7 18:25:43 2016
@@ -390,6 +390,22 @@ void RegisterBankInfo::ValueMapping::ver
   assert(ValueMask.isAllOnesValue() && "Value is not fully mapped");
 }
 
+void RegisterBankInfo::ValueMapping::dump() const {
+  print(dbgs());
+  dbgs() << '\n';
+}
+
+void RegisterBankInfo::ValueMapping::print(raw_ostream &OS) const {
+  OS << "#BreakDown: " << BreakDown.size() << " ";
+  bool IsFirst = true;
+  for (const PartialMapping &PartMap : BreakDown) {
+    if (!IsFirst)
+      OS << ", ";
+    OS << '[' << PartMap << ']';
+    IsFirst = false;
+  }
+}
+
 void RegisterBankInfo::InstructionMapping::setOperandMapping(
     unsigned OpIdx, unsigned MaskSize, const RegisterBank &RegBank) {
   // Build the value mapping.




More information about the llvm-commits mailing list