blob: 0634c9faf6fad26e2db09ae964a4858e00d0bec6 [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()) {
Chris Lattner8cb9a3b2010-01-18 00:37:40 +000026 OS << "Expr:(" << *getExpr() << ")";
Daniel Dunbar4b770c22009-08-27 07:57:12 +000027 } else
28 OS << "UNDEFINED";
29 OS << ">";
30}
31
32void MCOperand::dump() const {
David Greene593b6e42010-01-05 01:28:22 +000033 print(dbgs(), 0);
34 dbgs() << "\n";
Daniel Dunbar4b770c22009-08-27 07:57:12 +000035}
36
Chris Lattner684c593d2009-09-03 05:46:51 +000037void MCInst::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
Daniel Dunbar4b770c22009-08-27 07:57:12 +000038 OS << "<MCInst " << getOpcode();
39 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
40 OS << " ";
Chris Lattner684c593d2009-09-03 05:46:51 +000041 getOperand(i).print(OS, MAI);
Daniel Dunbar4b770c22009-08-27 07:57:12 +000042 }
43 OS << ">";
44}
45
46void MCInst::dump() const {
David Greene593b6e42010-01-05 01:28:22 +000047 print(dbgs(), 0);
48 dbgs() << "\n";
Daniel Dunbar4b770c22009-08-27 07:57:12 +000049}