Add an override to StringRef::getAsInteger which parses into an APInt.
[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/Support/Debug.h"
13 #include "llvm/Support/raw_ostream.h"
14
15 using namespace llvm;
16
17 void MCOperand::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
18   OS << "<MCOperand ";
19   if (!isValid())
20     OS << "INVALID";
21   else if (isReg())
22     OS << "Reg:" << getReg();
23   else if (isImm())
24     OS << "Imm:" << getImm();
25   else if (isExpr()) {
26     OS << "Expr:(" << *getExpr() << ")";
27   } else
28     OS << "UNDEFINED";
29   OS << ">";
30 }
31
32 void MCOperand::dump() const {
33   print(dbgs(), 0);
34   dbgs() << "\n";
35 }
36
37 void MCInst::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
38   OS << "<MCInst " << getOpcode();
39   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
40     OS << " ";
41     getOperand(i).print(OS, MAI);
42   }
43   OS << ">";
44 }
45
46 void MCInst::dump() const {
47   print(dbgs(), 0);
48   dbgs() << "\n";
49 }