blob: d05031870add8487c8101a2f407505146d857648 [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();
Daniel Dunbar8c2eebe2009-08-31 08:08:38 +000024 else if (isExpr()) {
25 OS << "Expr:(";
Chris Lattner684c593d2009-09-03 05:46:51 +000026 getExpr()->print(OS, MAI);
Daniel Dunbar4b770c22009-08-27 07:57:12 +000027 OS << ")";
28 } else
29 OS << "UNDEFINED";
30 OS << ">";
31}
32
33void MCOperand::dump() const {
Chris Lattner684c593d2009-09-03 05:46:51 +000034 print(errs(), 0);
Daniel Dunbar4b770c22009-08-27 07:57:12 +000035 errs() << "\n";
36}
37
Chris Lattner684c593d2009-09-03 05:46:51 +000038void MCInst::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
Daniel Dunbar4b770c22009-08-27 07:57:12 +000039 OS << "<MCInst " << getOpcode();
40 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
41 OS << " ";
Chris Lattner684c593d2009-09-03 05:46:51 +000042 getOperand(i).print(OS, MAI);
Daniel Dunbar4b770c22009-08-27 07:57:12 +000043 }
44 OS << ">";
45}
46
47void MCInst::dump() const {
Chris Lattner684c593d2009-09-03 05:46:51 +000048 print(errs(), 0);
Daniel Dunbar4b770c22009-08-27 07:57:12 +000049 errs() << "\n";
50}