unify two copies of the NamedMDNode printing code.
[oota-llvm.git] / lib / MC / MCInst.cpp
index 469dc7975e5d241b3f694f49b5c70dafdb8a00fb..d05031870add8487c8101a2f407505146d857648 100644 (file)
@@ -8,11 +8,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/MC/MCInst.h"
+#include "llvm/MC/MCExpr.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace llvm;
 
-void MCOperand::print(raw_ostream &OS) const {
+void MCOperand::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
   OS << "<MCOperand ";
   if (!isValid())
     OS << "INVALID";
@@ -20,12 +21,9 @@ void MCOperand::print(raw_ostream &OS) const {
     OS << "Reg:" << getReg();
   else if (isImm())
     OS << "Imm:" << getImm();
-  else if (isMBBLabel())
-    OS << "MBB:(" << getMBBLabelFunction() << ","
-       << getMBBLabelBlock() << ")";
-  else if (isMCValue()) {
-    OS << "Value:(";
-    getMCValue().print(OS);
+  else if (isExpr()) {
+    OS << "Expr:(";
+    getExpr()->print(OS, MAI);
     OS << ")";
   } else
     OS << "UNDEFINED";
@@ -33,20 +31,20 @@ void MCOperand::print(raw_ostream &OS) const {
 }
 
 void MCOperand::dump() const {
-  print(errs());
+  print(errs(), 0);
   errs() << "\n";
 }
 
-void MCInst::print(raw_ostream &OS) const {
+void MCInst::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
   OS << "<MCInst " << getOpcode();
   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
     OS << " ";
-    getOperand(i).print(OS);
+    getOperand(i).print(OS, MAI);
   }
   OS << ">";
 }
 
 void MCInst::dump() const {
-  print(errs());
+  print(errs(), 0);
   errs() << "\n";
 }