#ifndef LLVM_MC_MCINSTPRINTER_H
#define LLVM_MC_MCINSTPRINTER_H
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/Format.h"
namespace llvm {
class MCInst;
class raw_ostream;
class MCAsmInfo;
class MCInstrInfo;
class MCRegisterInfo;
class MCSubtargetInfo;
class StringRef;
namespace HexStyle {
enum Style {
C, Asm };
}
class MCInstPrinter {
protected:
raw_ostream *CommentStream;
const MCAsmInfo &MAI;
const MCInstrInfo &MII;
const MCRegisterInfo &MRI;
bool UseMarkup;
bool PrintImmHex;
HexStyle::Style PrintHexStyle;
void printAnnotation(raw_ostream &OS, StringRef Annot);
public:
MCInstPrinter(const MCAsmInfo &mai, const MCInstrInfo &mii,
const MCRegisterInfo &mri)
: CommentStream(nullptr), MAI(mai), MII(mii), MRI(mri),
UseMarkup(0), PrintImmHex(0),
PrintHexStyle(HexStyle::C) {}
virtual ~MCInstPrinter();
void setCommentStream(raw_ostream &OS) { CommentStream = &OS; }
virtual void printInst(const MCInst *MI, raw_ostream &OS,
StringRef Annot, const MCSubtargetInfo &STI) = 0;
StringRef getOpcodeName(unsigned Opcode) const;
virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
bool getUseMarkup() const { return UseMarkup; }
void setUseMarkup(bool Value) { UseMarkup = Value; }
StringRef markup(StringRef s) const;
StringRef markup(StringRef a, StringRef b) const;
bool getPrintImmHex() const { return PrintImmHex; }
void setPrintImmHex(bool Value) { PrintImmHex = Value; }
HexStyle::Style getPrintHexStyleHex() const { return PrintHexStyle; }
void setPrintImmHex(HexStyle::Style Value) { PrintHexStyle = Value; }
format_object1<int64_t> formatImm(const int64_t Value) const {
return PrintImmHex ? formatHex(Value) : formatDec(Value);
}
format_object1<int64_t> formatDec(const int64_t Value) const;
format_object1<int64_t> formatHex(const int64_t Value) const;
format_object1<uint64_t> formatHex(const uint64_t Value) const;
};
}
#endif