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"
|
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()) {
|
|
|
|
OS << "Expr:(";
|
2009-09-03 05:46:51 +00:00
|
|
|
getExpr()->print(OS, MAI);
|
2009-08-27 07:57:12 +00:00
|
|
|
OS << ")";
|
|
|
|
} else
|
|
|
|
OS << "UNDEFINED";
|
|
|
|
OS << ">";
|
|
|
|
}
|
|
|
|
|
|
|
|
void MCOperand::dump() const {
|
2009-09-03 05:46:51 +00:00
|
|
|
print(errs(), 0);
|
2009-08-27 07:57:12 +00:00
|
|
|
errs() << "\n";
|
|
|
|
}
|
|
|
|
|
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 << ">";
|
|
|
|
}
|
|
|
|
|
|
|
|
void MCInst::dump() const {
|
2009-09-03 05:46:51 +00:00
|
|
|
print(errs(), 0);
|
2009-08-27 07:57:12 +00:00
|
|
|
errs() << "\n";
|
|
|
|
}
|