Daniel Dunbar | 4b770c2 | 2009-08-27 07:57:12 +0000 | [diff] [blame] | 1 | //===- lib/MC/MCInst.cpp - MCInst implementation --------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "llvm/MC/MCInst.h" |
Daniel Dunbar | 8c2eebe | 2009-08-31 08:08:38 +0000 | [diff] [blame^] | 11 | #include "llvm/MC/MCExpr.h" |
Daniel Dunbar | 4b770c2 | 2009-08-27 07:57:12 +0000 | [diff] [blame] | 12 | #include "llvm/Support/raw_ostream.h" |
| 13 | |
| 14 | using namespace llvm; |
| 15 | |
| 16 | void MCOperand::print(raw_ostream &OS) const { |
| 17 | OS << "<MCOperand "; |
| 18 | if (!isValid()) |
| 19 | OS << "INVALID"; |
| 20 | else if (isReg()) |
| 21 | OS << "Reg:" << getReg(); |
| 22 | else if (isImm()) |
| 23 | OS << "Imm:" << getImm(); |
| 24 | else if (isMBBLabel()) |
| 25 | OS << "MBB:(" << getMBBLabelFunction() << "," |
| 26 | << getMBBLabelBlock() << ")"; |
Daniel Dunbar | 8c2eebe | 2009-08-31 08:08:38 +0000 | [diff] [blame^] | 27 | else if (isExpr()) { |
| 28 | OS << "Expr:("; |
| 29 | getExpr()->print(OS); |
Daniel Dunbar | 4b770c2 | 2009-08-27 07:57:12 +0000 | [diff] [blame] | 30 | OS << ")"; |
| 31 | } else |
| 32 | OS << "UNDEFINED"; |
| 33 | OS << ">"; |
| 34 | } |
| 35 | |
| 36 | void MCOperand::dump() const { |
| 37 | print(errs()); |
| 38 | errs() << "\n"; |
| 39 | } |
| 40 | |
| 41 | void MCInst::print(raw_ostream &OS) const { |
| 42 | OS << "<MCInst " << getOpcode(); |
| 43 | for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { |
| 44 | OS << " "; |
| 45 | getOperand(i).print(OS); |
| 46 | } |
| 47 | OS << ">"; |
| 48 | } |
| 49 | |
| 50 | void MCInst::dump() const { |
| 51 | print(errs()); |
| 52 | errs() << "\n"; |
| 53 | } |