469dc7975e5d241b3f694f49b5c70dafdb8a00fb
[oota-llvm.git] / lib / MC / MCInst.cpp
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"
11 #include "llvm/Support/raw_ostream.h"
12
13 using namespace llvm;
14
15 void MCOperand::print(raw_ostream &OS) const {
16   OS << "<MCOperand ";
17   if (!isValid())
18     OS << "INVALID";
19   else if (isReg())
20     OS << "Reg:" << getReg();
21   else if (isImm())
22     OS << "Imm:" << getImm();
23   else if (isMBBLabel())
24     OS << "MBB:(" << getMBBLabelFunction() << ","
25        << getMBBLabelBlock() << ")";
26   else if (isMCValue()) {
27     OS << "Value:(";
28     getMCValue().print(OS);
29     OS << ")";
30   } else
31     OS << "UNDEFINED";
32   OS << ">";
33 }
34
35 void MCOperand::dump() const {
36   print(errs());
37   errs() << "\n";
38 }
39
40 void MCInst::print(raw_ostream &OS) const {
41   OS << "<MCInst " << getOpcode();
42   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
43     OS << " ";
44     getOperand(i).print(OS);
45   }
46   OS << ">";
47 }
48
49 void MCInst::dump() const {
50   print(errs());
51   errs() << "\n";
52 }