class MCInstPrinter

Declaration

class MCInstPrinter { /* full declaration omitted */ };

Description

This is an instance of a target assembly language printer that converts an MCInst to valid target assembly syntax.

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:43

Member Variables

protected llvm::raw_ostream* CommentStream = nullptr
A stream that comments can be emitted to if desired. Each comment must end with a newline. This will be null if verbose assembly emission is disabled.
protected const llvm::MCAsmInfo& MAI
protected const llvm::MCInstrInfo& MII
protected const llvm::MCRegisterInfo& MRI
protected const llvm::MCInstrAnalysis* MIA = nullptr
protected bool UseMarkup = false
True if we are printing marked up assembly.
protected bool PrintAliases = true
True if we prefer aliases (e.g. nop) to raw mnemonics.
protected bool PrintImmHex = false
True if we are printing immediates as hex.
protected HexStyle::Style PrintHexStyle = HexStyle::C
Which style to use for printing hexadecimal values.
protected bool PrintBranchImmAsAddress = false
If true, a branch immediate (e.g. bl 4) will be printed as a hexadecimal address (e.g. bl 0x20004). This is useful for a stream disassembler (llvm-objdump -d).
protected bool SymbolizeOperands = false
If true, symbolize branch target and memory reference operands.

Method Overview

Methods

MCInstPrinter(const llvm::MCAsmInfo& mai,
              const llvm::MCInstrInfo& mii,
              const llvm::MCRegisterInfo& mri)

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:82

Parameters

const llvm::MCAsmInfo& mai
const llvm::MCInstrInfo& mii
const llvm::MCRegisterInfo& mri

virtual bool applyTargetSpecificCLOption(
    llvm::StringRef Opt)

Description

Customize the printer according to a command line option.

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:89

Parameters

llvm::StringRef Opt

Returns

true if the option is recognized and applied.

format_object<int64_t> formatDec(
    int64_t Value) const

Description

Utility functions to print decimal/hexadecimal values.

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:139

Parameters

int64_t Value

format_object<uint64_t> formatHex(
    uint64_t Value) const

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:141

Parameters

uint64_t Value

format_object<int64_t> formatHex(
    int64_t Value) const

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:140

Parameters

int64_t Value

format_object<int64_t> formatImm(
    int64_t Value) const

Description

Utility function to print immediates in decimal or hex.

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:134

Parameters

int64_t Value

virtual std::pair<const char*, uint64_t>
getMnemonic(const llvm::MCInst* MI)

Description

Returns a pair containing the mnemonic for \p MI and the number of bits left for further processing by printInstruction (generated by tablegen).

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:96

Parameters

const llvm::MCInst* MI

llvm::StringRef getOpcodeName(
    unsigned int Opcode) const

Description

Return the name of the specified opcode enum (e.g. "MOV32ri") or empty if we can't resolve it.

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:110

Parameters

unsigned int Opcode

bool getPrintImmHex() const

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:121

bool getUseMarkup() const

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:115

llvm::StringRef markup(llvm::StringRef s) const

Description

Utility functions to make adding mark ups simpler.

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:119

Parameters

llvm::StringRef s

const char* matchAliasPatterns(
    const llvm::MCInst* MI,
    const llvm::MCSubtargetInfo* STI,
    const llvm::AliasMatchingData& M)

Description

Helper for matching MCInsts to alias patterns when printing instructions.

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:78

Parameters

const llvm::MCInst* MI
const llvm::MCSubtargetInfo* STI
const llvm::AliasMatchingData& M

void printAnnotation(llvm::raw_ostream& OS,
                     llvm::StringRef Annot)

Description

Utility function for printing annotations.

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:75

Parameters

llvm::raw_ostream& OS
llvm::StringRef Annot

virtual void printInst(
    const llvm::MCInst* MI,
    uint64_t Address,
    llvm::StringRef Annot,
    const llvm::MCSubtargetInfo& STI,
    llvm::raw_ostream& OS)

Description

Print the specified MCInst to the specified raw_ostream. \p Address the address of current instruction on most targets, used to print a PC relative immediate as the target address. On targets where a PC relative immediate is relative to the next instruction and the length of a MCInst is difficult to measure (e.g. x86), this is the address of the next instruction. If Address is 0, the immediate will be printed.

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:105

Parameters

const llvm::MCInst* MI
uint64_t Address
llvm::StringRef Annot
const llvm::MCSubtargetInfo& STI
llvm::raw_ostream& OS

virtual void printRegName(
    llvm::raw_ostream& OS,
    unsigned int RegNo) const

Description

Print the assembler register name.

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:113

Parameters

llvm::raw_ostream& OS
unsigned int RegNo

void setCommentStream(llvm::raw_ostream& OS)

Description

Specify a stream to emit comments to.

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:92

Parameters

llvm::raw_ostream& OS

void setMCInstrAnalysis(
    const llvm::MCInstrAnalysis* Value)

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:131

Parameters

const llvm::MCInstrAnalysis* Value

void setPrintBranchImmAsAddress(bool Value)

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:126

Parameters

bool Value

void setPrintHexStyle(HexStyle::Style Value)

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:124

Parameters

HexStyle::Style Value

void setPrintImmHex(bool Value)

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:122

Parameters

bool Value

void setSymbolizeOperands(bool Value)

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:130

Parameters

bool Value

void setUseMarkup(bool Value)

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:116

Parameters

bool Value

virtual ~MCInstPrinter()

Declared at: llvm/include/llvm/MC/MCInstPrinter.h:85