[llvm] r241087 - MIR Printer: extract the code that prints MBB references into a new method. NFC.

Alex Lorenz arphaman at gmail.com
Tue Jun 30 11:00:16 PDT 2015


Author: arphaman
Date: Tue Jun 30 13:00:16 2015
New Revision: 241087

URL: http://llvm.org/viewvc/llvm-project?rev=241087&view=rev
Log:
MIR Printer: extract the code that prints MBB references into a new method. NFC.

This commit enables the MIR printer to reuse the code that prints MBB
references.

Modified:
    llvm/trunk/lib/CodeGen/MIRPrinter.cpp

Modified: llvm/trunk/lib/CodeGen/MIRPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRPrinter.cpp?rev=241087&r1=241086&r2=241087&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRPrinter.cpp Tue Jun 30 13:00:16 2015
@@ -61,6 +61,7 @@ public:
       : M(M), OS(OS), RegisterMaskIds(RegisterMaskIds) {}
 
   void print(const MachineInstr &MI);
+  void printMBBReference(const MachineBasicBlock &MBB);
   void print(const MachineOperand &Op, const TargetRegisterInfo *TRI);
 };
 
@@ -193,6 +194,14 @@ static void printReg(unsigned Reg, raw_o
     llvm_unreachable("Can't print this kind of register yet");
 }
 
+void MIPrinter::printMBBReference(const MachineBasicBlock &MBB) {
+  OS << "%bb." << MBB.getNumber();
+  if (const auto *BB = MBB.getBasicBlock()) {
+    if (BB->hasName())
+      OS << '.' << BB->getName();
+  }
+}
+
 void MIPrinter::print(const MachineOperand &Op, const TargetRegisterInfo *TRI) {
   switch (Op.getType()) {
   case MachineOperand::MO_Register:
@@ -204,11 +213,7 @@ void MIPrinter::print(const MachineOpera
     OS << Op.getImm();
     break;
   case MachineOperand::MO_MachineBasicBlock:
-    OS << "%bb." << Op.getMBB()->getNumber();
-    if (const auto *BB = Op.getMBB()->getBasicBlock()) {
-      if (BB->hasName())
-        OS << '.' << BB->getName();
-    }
+    printMBBReference(*Op.getMBB());
     break;
   case MachineOperand::MO_GlobalAddress:
     // FIXME: Make this faster - print as operand will create a slot tracker to





More information about the llvm-commits mailing list