1 //===- lib/MC/MCInst.cpp - MCInst implementation --------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/MC/MCInst.h"
11 #include "llvm/MC/MCExpr.h"
12 #include "llvm/MC/MCInstPrinter.h"
13 #include "llvm/Support/Compiler.h"
14 #include "llvm/Support/Debug.h"
15 #include "llvm/Support/raw_ostream.h"
19 void MCOperand::print(raw_ostream &OS) const {
24 OS << "Reg:" << getReg();
26 OS << "Imm:" << getImm();
28 OS << "FPImm:" << getFPImm();
30 OS << "Expr:(" << *getExpr() << ")";
31 } else if (isInst()) {
32 OS << "Inst:(" << *getInst() << ")";
38 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
39 LLVM_DUMP_METHOD void MCOperand::dump() const {
45 void MCInst::print(raw_ostream &OS) const {
46 OS << "<MCInst " << getOpcode();
47 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
49 getOperand(i).print(OS);
54 void MCInst::dump_pretty(raw_ostream &OS, const MCInstPrinter *Printer,
55 StringRef Separator) const {
56 OS << "<MCInst #" << getOpcode();
58 // Show the instruction opcode name if we have access to a printer.
60 OS << ' ' << Printer->getOpcodeName(getOpcode());
62 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
64 getOperand(i).print(OS);
69 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
70 LLVM_DUMP_METHOD void MCInst::dump() const {