blob: 7c7a6447736c507e80c08f1a04bd8f0db69261d1 [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"
David Greene593b6e42010-01-05 01:28:22 +000012#include "llvm/Support/Debug.h"
Daniel Dunbar4b770c22009-08-27 07:57:12 +000013#include "llvm/Support/raw_ostream.h"
14
15using namespace llvm;
16
Chris Lattner684c593d2009-09-03 05:46:51 +000017void MCOperand::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
Daniel Dunbar4b770c22009-08-27 07:57:12 +000018 OS << "<MCOperand ";
19 if (!isValid())
20 OS << "INVALID";
21 else if (isReg())
22 OS << "Reg:" << getReg();
23 else if (isImm())
24 OS << "Imm:" << getImm();
Daniel Dunbar8c2eebe2009-08-31 08:08:38 +000025 else if (isExpr()) {
26 OS << "Expr:(";
Chris Lattner684c593d2009-09-03 05:46:51 +000027 getExpr()->print(OS, MAI);
Daniel Dunbar4b770c22009-08-27 07:57:12 +000028 OS << ")";
29 } else
30 OS << "UNDEFINED";
31 OS << ">";
32}
33
34void MCOperand::dump() const {
David Greene593b6e42010-01-05 01:28:22 +000035 print(dbgs(), 0);
36 dbgs() << "\n";
Daniel Dunbar4b770c22009-08-27 07:57:12 +000037}
38
Chris Lattner684c593d2009-09-03 05:46:51 +000039void MCInst::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
Daniel Dunbar4b770c22009-08-27 07:57:12 +000040 OS << "<MCInst " << getOpcode();
41 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
42 OS << " ";
Chris Lattner684c593d2009-09-03 05:46:51 +000043 getOperand(i).print(OS, MAI);
Daniel Dunbar4b770c22009-08-27 07:57:12 +000044 }
45 OS << ">";
46}
47
48void MCInst::dump() const {
David Greene593b6e42010-01-05 01:28:22 +000049 print(dbgs(), 0);
50 dbgs() << "\n";
Daniel Dunbar4b770c22009-08-27 07:57:12 +000051}