blob: f19056bc9add5732497af4eb5182f61b2754975c [file] [log] [blame]
Daniel Dunbar4b770c22009-08-27 07:57:12 +00001//===- 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 Dunbar8c2eebe2009-08-31 08:08:38 +000011#include "llvm/MC/MCExpr.h"
Daniel Dunbar4b770c22009-08-27 07:57:12 +000012#include "llvm/Support/raw_ostream.h"
13
14using namespace llvm;
15
Chris Lattner684c593d2009-09-03 05:46:51 +000016void MCOperand::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
Daniel Dunbar4b770c22009-08-27 07:57:12 +000017 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 Dunbar8c2eebe2009-08-31 08:08:38 +000027 else if (isExpr()) {
28 OS << "Expr:(";
Chris Lattner684c593d2009-09-03 05:46:51 +000029 getExpr()->print(OS, MAI);
Daniel Dunbar4b770c22009-08-27 07:57:12 +000030 OS << ")";
31 } else
32 OS << "UNDEFINED";
33 OS << ">";
34}
35
36void MCOperand::dump() const {
Chris Lattner684c593d2009-09-03 05:46:51 +000037 print(errs(), 0);
Daniel Dunbar4b770c22009-08-27 07:57:12 +000038 errs() << "\n";
39}
40
Chris Lattner684c593d2009-09-03 05:46:51 +000041void MCInst::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
Daniel Dunbar4b770c22009-08-27 07:57:12 +000042 OS << "<MCInst " << getOpcode();
43 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
44 OS << " ";
Chris Lattner684c593d2009-09-03 05:46:51 +000045 getOperand(i).print(OS, MAI);
Daniel Dunbar4b770c22009-08-27 07:57:12 +000046 }
47 OS << ">";
48}
49
50void MCInst::dump() const {
Chris Lattner684c593d2009-09-03 05:46:51 +000051 print(errs(), 0);
Daniel Dunbar4b770c22009-08-27 07:57:12 +000052 errs() << "\n";
53}