mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-27 15:29:51 +00:00
MCInst: Add ::dump_pretty.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99216 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a69ec09364
commit
67c076cf59
@ -17,11 +17,13 @@
|
|||||||
#define LLVM_MC_MCINST_H
|
#define LLVM_MC_MCINST_H
|
||||||
|
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/System/DataTypes.h"
|
#include "llvm/System/DataTypes.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
class MCAsmInfo;
|
class MCAsmInfo;
|
||||||
|
class MCInstPrinter;
|
||||||
class MCExpr;
|
class MCExpr;
|
||||||
|
|
||||||
/// MCOperand - Instances of this class represent operands of the MCInst class.
|
/// MCOperand - Instances of this class represent operands of the MCInst class.
|
||||||
@ -125,6 +127,13 @@ public:
|
|||||||
|
|
||||||
void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
|
void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
|
||||||
void dump() const;
|
void dump() const;
|
||||||
|
|
||||||
|
/// \brief Dump the MCInst as prettily as possible using the additional MC
|
||||||
|
/// structures, if given. Operators are separated by the \arg Separator
|
||||||
|
/// string.
|
||||||
|
void dump_pretty(raw_ostream &OS, const MCAsmInfo *MAI = 0,
|
||||||
|
const MCInstPrinter *Printer = 0,
|
||||||
|
StringRef Separator = " ") const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -623,24 +623,10 @@ void MCAsmStreamer::EmitInstruction(const MCInst &Inst) {
|
|||||||
AddEncodingComment(Inst);
|
AddEncodingComment(Inst);
|
||||||
|
|
||||||
// Show the MCInst if enabled.
|
// Show the MCInst if enabled.
|
||||||
if (ShowInst) {
|
if (ShowInst)
|
||||||
raw_ostream &OS = GetCommentOS();
|
Inst.dump_pretty(GetCommentOS(), &MAI, InstPrinter.get(), "\n ");
|
||||||
OS << "<MCInst #" << Inst.getOpcode();
|
|
||||||
|
|
||||||
StringRef InstName;
|
|
||||||
if (InstPrinter)
|
|
||||||
InstName = InstPrinter->getOpcodeName(Inst.getOpcode());
|
|
||||||
if (!InstName.empty())
|
|
||||||
OS << ' ' << InstName;
|
|
||||||
|
|
||||||
for (unsigned i = 0, e = Inst.getNumOperands(); i != e; ++i) {
|
|
||||||
OS << "\n ";
|
|
||||||
Inst.getOperand(i).print(OS, &MAI);
|
|
||||||
}
|
|
||||||
OS << ">\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we have an AsmPrinter, use that to print, otherwise dump the MCInst.
|
// If we have an AsmPrinter, use that to print, otherwise print the MCInst.
|
||||||
if (InstPrinter)
|
if (InstPrinter)
|
||||||
InstPrinter->printInst(&Inst);
|
InstPrinter->printInst(&Inst);
|
||||||
else
|
else
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "llvm/MC/MCInst.h"
|
#include "llvm/MC/MCInst.h"
|
||||||
#include "llvm/MC/MCExpr.h"
|
#include "llvm/MC/MCExpr.h"
|
||||||
|
#include "llvm/MC/MCInstPrinter.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
|
||||||
@ -43,6 +44,22 @@ void MCInst::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
|
|||||||
OS << ">";
|
OS << ">";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
OS << ">\n";
|
||||||
|
}
|
||||||
|
|
||||||
void MCInst::dump() const {
|
void MCInst::dump() const {
|
||||||
print(dbgs(), 0);
|
print(dbgs(), 0);
|
||||||
dbgs() << "\n";
|
dbgs() << "\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user