[llvm-commits] [llvm] r80231 - in /llvm/trunk: include/llvm/MC/MCInst.h lib/MC/CMakeLists.txt lib/MC/MCInst.cpp

Daniel Dunbar daniel at zuster.org
Thu Aug 27 00:57:13 PDT 2009


Author: ddunbar
Date: Thu Aug 27 02:57:12 2009
New Revision: 80231

URL: http://llvm.org/viewvc/llvm-project?rev=80231&view=rev
Log:
Add {MCInst,MCOperand}::{print,dump}

Added:
    llvm/trunk/lib/MC/MCInst.cpp
Modified:
    llvm/trunk/include/llvm/MC/MCInst.h
    llvm/trunk/lib/MC/CMakeLists.txt

Modified: llvm/trunk/include/llvm/MC/MCInst.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCInst.h?rev=80231&r1=80230&r2=80231&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MC/MCInst.h (original)
+++ llvm/trunk/include/llvm/MC/MCInst.h Thu Aug 27 02:57:12 2009
@@ -22,6 +22,7 @@
 #include "llvm/Support/DebugLoc.h"
 
 namespace llvm {
+class raw_ostream;
 
 /// MCOperand - Instances of this class represent operands of the MCInst class.
 /// This is a simple discriminated union.
@@ -119,6 +120,9 @@
     Op.MCValueVal = Val;
     return Op;
   }
+
+  void print(raw_ostream &OS) const;
+  void dump() const;
 };
 
   
@@ -142,6 +146,9 @@
   void addOperand(const MCOperand &Op) {
     Operands.push_back(Op);
   }
+
+  void print(raw_ostream &OS) const;
+  void dump() const;
 };
 
 

Modified: llvm/trunk/lib/MC/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/CMakeLists.txt?rev=80231&r1=80230&r2=80231&view=diff

==============================================================================
--- llvm/trunk/lib/MC/CMakeLists.txt (original)
+++ llvm/trunk/lib/MC/CMakeLists.txt Thu Aug 27 02:57:12 2009
@@ -8,6 +8,7 @@
   MCAssembler.cpp
   MCCodeEmitter.cpp
   MCContext.cpp
+  MCInst.cpp
   MCMachOStreamer.cpp
   MCNullStreamer.cpp
   MCSection.cpp

Added: llvm/trunk/lib/MC/MCInst.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCInst.cpp?rev=80231&view=auto

==============================================================================
--- llvm/trunk/lib/MC/MCInst.cpp (added)
+++ llvm/trunk/lib/MC/MCInst.cpp Thu Aug 27 02:57:12 2009
@@ -0,0 +1,52 @@
+//===- lib/MC/MCInst.cpp - MCInst implementation --------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/MC/MCInst.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm;
+
+void MCOperand::print(raw_ostream &OS) const {
+  OS << "<MCOperand ";
+  if (!isValid())
+    OS << "INVALID";
+  else if (isReg())
+    OS << "Reg:" << getReg();
+  else if (isImm())
+    OS << "Imm:" << getImm();
+  else if (isMBBLabel())
+    OS << "MBB:(" << getMBBLabelFunction() << ","
+       << getMBBLabelBlock() << ")";
+  else if (isMCValue()) {
+    OS << "Value:(";
+    getMCValue().print(OS);
+    OS << ")";
+  } else
+    OS << "UNDEFINED";
+  OS << ">";
+}
+
+void MCOperand::dump() const {
+  print(errs());
+  errs() << "\n";
+}
+
+void MCInst::print(raw_ostream &OS) const {
+  OS << "<MCInst " << getOpcode();
+  for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
+    OS << " ";
+    getOperand(i).print(OS);
+  }
+  OS << ">";
+}
+
+void MCInst::dump() const {
+  print(errs());
+  errs() << "\n";
+}





More information about the llvm-commits mailing list