summaryrefslogtreecommitdiff
path: root/lib/MC/MCInst.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-08-27 07:57:12 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-08-27 07:57:12 +0000
commit4b770c20778ccb5d2f304fa73e0522a7ab8c4623 (patch)
tree6a809fe4972845cc636f464a85fee286b3f89ef0 /lib/MC/MCInst.cpp
parentf2f6b0c0e9088da25a0367c88263ef8e7637a82c (diff)
downloadllvm-4b770c20778ccb5d2f304fa73e0522a7ab8c4623.tar.gz
llvm-4b770c20778ccb5d2f304fa73e0522a7ab8c4623.tar.bz2
llvm-4b770c20778ccb5d2f304fa73e0522a7ab8c4623.tar.xz
Add {MCInst,MCOperand}::{print,dump}
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80231 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCInst.cpp')
-rw-r--r--lib/MC/MCInst.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/MC/MCInst.cpp b/lib/MC/MCInst.cpp
new file mode 100644
index 0000000000..469dc7975e
--- /dev/null
+++ b/lib/MC/MCInst.cpp
@@ -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";
+}