2009-08-27 07:57:12 +00:00
|
|
|
//===- lib/MC/MCInst.cpp - MCInst implementation --------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/MC/MCInst.h"
|
2009-08-31 08:08:38 +00:00
|
|
|
#include "llvm/MC/MCExpr.h"
|
2010-03-22 21:49:34 +00:00
|
|
|
#include "llvm/MC/MCInstPrinter.h"
|
2010-01-05 01:28:22 +00:00
|
|
|
#include "llvm/Support/Debug.h"
|
2009-08-27 07:57:12 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2009-09-03 05:46:51 +00:00
|
|
|
void MCOperand::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
|
2009-08-27 07:57:12 +00:00
|
|
|
OS << "<MCOperand ";
|
|
|
|
if (!isValid())
|
|
|
|
OS << "INVALID";
|
|
|
|
else if (isReg())
|
|
|
|
OS << "Reg:" << getReg();
|
|
|
|
else if (isImm())
|
|
|
|
OS << "Imm:" << getImm();
|
2009-08-31 08:08:38 +00:00
|
|
|
else if (isExpr()) {
|
2010-01-18 00:37:40 +00:00
|
|
|
OS << "Expr:(" << *getExpr() << ")";
|
2009-08-27 07:57:12 +00:00
|
|
|
} else
|
|
|
|
OS << "UNDEFINED";
|
|
|
|
OS << ">";
|
|
|
|
}
|
|
|
|
|
|
|
|
void MCOperand::dump() const {
|
2010-01-05 01:28:22 +00:00
|
|
|
print(dbgs(), 0);
|
|
|
|
dbgs() << "\n";
|
2009-08-27 07:57:12 +00:00
|
|
|
}
|
|
|
|
|
2009-09-03 05:46:51 +00:00
|
|
|
void MCInst::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
|
2009-08-27 07:57:12 +00:00
|
|
|
OS << "<MCInst " << getOpcode();
|
|
|
|
for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
|
|
|
|
OS << " ";
|
2009-09-03 05:46:51 +00:00
|
|
|
getOperand(i).print(OS, MAI);
|
2009-08-27 07:57:12 +00:00
|
|
|
}
|
|
|
|
OS << ">";
|
|
|
|
}
|
|
|
|
|
2010-03-22 21:49:34 +00:00
|
|
|
void MCInst::dump_pretty(raw_ostream &OS, const MCAsmInfo *MAI,
|
|
|
|
const MCInstPrinter *Printer,
|
|
|
|
StringRef Separator) const {
|
|
|
|
OS << "<MCInst #" << getOpcode();
|
|
|
|
|
|
|
|
// Show the instruction opcode name if we have access to a printer.
|
|
|
|
if (Printer)
|
|
|
|
OS << ' ' << Printer->getOpcodeName(getOpcode());
|
|
|
|
|
|
|
|
for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
|
|
|
|
OS << Separator;
|
|
|
|
getOperand(i).print(OS, MAI);
|
|
|
|
}
|
2010-05-26 15:18:13 +00:00
|
|
|
OS << ">";
|
2010-03-22 21:49:34 +00:00
|
|
|
}
|
|
|
|
|
2009-08-27 07:57:12 +00:00
|
|
|
void MCInst::dump() const {
|
2010-01-05 01:28:22 +00:00
|
|
|
print(dbgs(), 0);
|
|
|
|
dbgs() << "\n";
|
2009-08-27 07:57:12 +00:00
|
|
|
}
|