Fix issue with bitwise and precedence.
[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/MC/MCExpr.h"
12 #include "llvm/MC/MCInstPrinter.h"
13 #include "llvm/Support/Debug.h"
14 #include "llvm/Support/raw_ostream.h"
15
16 using namespace llvm;
17
18 void MCOperand::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
19   OS << "<MCOperand ";
20   if (!isValid())
21     OS << "INVALID";
22   else if (isReg())
23     OS << "Reg:" << getReg();
24   else if (isImm())
25     OS << "Imm:" << getImm();
26   else if (isExpr()) {
27     OS << "Expr:(" << *getExpr() << ")";
28   } else if (isInst()) {
29     OS << "Inst:(" << *getInst() << ")";
30   } else
31     OS << "UNDEFINED";
32   OS << ">";
33 }
34
35 void MCOperand::dump() const {
36   print(dbgs(), 0);
37   dbgs() << "\n";
38 }
39
40 void MCInst::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
41   OS << "<MCInst " << getOpcode();
42   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
43     OS << " ";
44     getOperand(i).print(OS, MAI);
45   }
46   OS << ">";
47 }
48
49 void MCInst::dump_pretty(raw_ostream &OS, const MCAsmInfo *MAI,
50                          const MCInstPrinter *Printer,
51                          StringRef Separator) const {
52   OS << "<MCInst #" << getOpcode();
53
54   // Show the instruction opcode name if we have access to a printer.
55   if (Printer)
56     OS << ' ' << Printer->getOpcodeName(getOpcode());
57
58   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
59     OS << Separator;
60     getOperand(i).print(OS, MAI);
61   }
62   OS << ">";
63 }
64
65 void MCInst::dump() const {
66   print(dbgs(), 0);
67   dbgs() << "\n";
68 }