LLVM  14.0.0git
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::MCInstPrinter Class Referenceabstract

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

#include "llvm/MC/MCInstPrinter.h"

Inheritance diagram for llvm::MCInstPrinter:
Inheritance graph
[legend]
Collaboration diagram for llvm::MCInstPrinter:
Collaboration graph
[legend]

Public Member Functions

 MCInstPrinter (const MCAsmInfo &mai, const MCInstrInfo &mii, const MCRegisterInfo &mri)
 
virtual ~MCInstPrinter ()
 
virtual bool applyTargetSpecificCLOption (StringRef Opt)
 Customize the printer according to a command line option. More...
 
void setCommentStream (raw_ostream &OS)
 Specify a stream to emit comments to. More...
 
virtual std::pair< const char *, uint64_tgetMnemonic (const MCInst *MI)=0
 Returns a pair containing the mnemonic for MI and the number of bits left for further processing by printInstruction (generated by tablegen). More...
 
virtual void printInst (const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &OS)=0
 Print the specified MCInst to the specified raw_ostream. More...
 
StringRef getOpcodeName (unsigned Opcode) const
 Return the name of the specified opcode enum (e.g. More...
 
virtual void printRegName (raw_ostream &OS, unsigned RegNo) const
 Print the assembler register name. More...
 
bool getUseMarkup () const
 
void setUseMarkup (bool Value)
 
StringRef markup (StringRef s) const
 Utility functions to make adding mark ups simpler. More...
 
bool getPrintImmHex () const
 
void setPrintImmHex (bool Value)
 
void setPrintHexStyle (HexStyle::Style Value)
 
void setPrintBranchImmAsAddress (bool Value)
 
void setSymbolizeOperands (bool Value)
 
void setMCInstrAnalysis (const MCInstrAnalysis *Value)
 
format_object< int64_t > formatImm (int64_t Value) const
 Utility function to print immediates in decimal or hex. More...
 
format_object< int64_t > formatDec (int64_t Value) const
 Utility functions to print decimal/hexadecimal values. More...
 
format_object< int64_t > formatHex (int64_t Value) const
 
format_object< uint64_tformatHex (uint64_t Value) const
 

Protected Member Functions

void printAnnotation (raw_ostream &OS, StringRef Annot)
 Utility function for printing annotations. More...
 
const char * matchAliasPatterns (const MCInst *MI, const MCSubtargetInfo *STI, const AliasMatchingData &M)
 Helper for matching MCInsts to alias patterns when printing instructions. More...
 

Protected Attributes

raw_ostreamCommentStream = nullptr
 A stream that comments can be emitted to if desired. More...
 
const MCAsmInfoMAI
 
const MCInstrInfoMII
 
const MCRegisterInfoMRI
 
const MCInstrAnalysisMIA = nullptr
 
bool UseMarkup = false
 True if we are printing marked up assembly. More...
 
bool PrintAliases = true
 True if we prefer aliases (e.g. nop) to raw mnemonics. More...
 
bool PrintImmHex = false
 True if we are printing immediates as hex. More...
 
HexStyle::Style PrintHexStyle = HexStyle::C
 Which style to use for printing hexadecimal values. More...
 
bool PrintBranchImmAsAddress = false
 If true, a branch immediate (e.g. More...
 
bool SymbolizeOperands = false
 If true, symbolize branch target and memory reference operands. More...
 

Detailed Description

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

Definition at line 43 of file MCInstPrinter.h.

Constructor & Destructor Documentation

◆ MCInstPrinter()

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

Definition at line 82 of file MCInstPrinter.h.

◆ ~MCInstPrinter()

MCInstPrinter::~MCInstPrinter ( )
virtualdefault

Member Function Documentation

◆ applyTargetSpecificCLOption()

virtual bool llvm::MCInstPrinter::applyTargetSpecificCLOption ( StringRef  Opt)
inlinevirtual

Customize the printer according to a command line option.

Returns
true if the option is recognized and applied.

Reimplemented in llvm::CSKYInstPrinter, llvm::AArch64InstPrinter, llvm::RISCVInstPrinter, and llvm::ARMInstPrinter.

Definition at line 89 of file MCInstPrinter.h.

◆ formatDec()

format_object< int64_t > MCInstPrinter::formatDec ( int64_t  Value) const

Utility functions to print decimal/hexadecimal values.

Definition at line 193 of file MCInstPrinter.cpp.

References llvm::format().

Referenced by formatImm(), and llvm::AArch64InstPrinter::printImmSVE().

◆ formatHex() [1/2]

format_object< int64_t > MCInstPrinter::formatHex ( int64_t  Value) const

◆ formatHex() [2/2]

format_object< uint64_t > MCInstPrinter::formatHex ( uint64_t  Value) const

◆ formatImm()

format_object<int64_t> llvm::MCInstPrinter::formatImm ( int64_t  Value) const
inline

Utility function to print immediates in decimal or hex.

Definition at line 134 of file MCInstPrinter.h.

References formatDec(), formatHex(), and PrintImmHex.

Referenced by llvm::ARMInstPrinter::printAddrModeImm12Operand(), llvm::AArch64InstPrinter::printAddSubImm(), llvm::AArch64InstPrinter::printAlignedLabel(), llvm::AArch64InstPrinter::printAMIndexedWB(), llvm::BPFInstPrinter::printBrTargetOperand(), llvm::AArch64InstPrinter::printBTIHintOp(), llvm::AArch64InstPrinter::printImm(), llvm::BPFInstPrinter::printImm64Operand(), llvm::AArch64InstPrinter::printImm8OptLsl(), llvm::ARMInstPrinter::printImmPlusOneOperand(), llvm::AArch64InstPrinter::printImmScale(), llvm::AArch64InstPrinter::printInst(), llvm::X86ATTInstPrinter::printMemOffset(), llvm::X86IntelInstPrinter::printMemOffset(), llvm::BPFInstPrinter::printMemOperand(), llvm::X86ATTInstPrinter::printMemReference(), llvm::X86IntelInstPrinter::printMemReference(), llvm::BPFInstPrinter::printOperand(), llvm::CSKYInstPrinter::printOperand(), llvm::NVPTXInstPrinter::printOperand(), llvm::HexagonInstPrinter::printOperand(), llvm::X86ATTInstPrinter::printOperand(), llvm::X86IntelInstPrinter::printOperand(), llvm::ARMInstPrinter::printOperand(), llvm::X86InstPrinterCommon::printPCRelImm(), llvm::AArch64InstPrinter::printPrefetchOp(), llvm::AArch64InstPrinter::printPSBHintOp(), llvm::AArch64InstPrinter::printSImm(), llvm::AArch64InstPrinter::printSVEPattern(), llvm::AArch64InstPrinter::printSystemPStateField(), llvm::ARMInstPrinter::printT2AddrModeImm0_1020s4Operand(), llvm::ARMInstPrinter::printThumbAddrModeImm5SOperand(), llvm::ARMInstPrinter::printThumbLdrLabelOperand(), llvm::ARMInstPrinter::printThumbS4ImmOperand(), llvm::ARMInstPrinter::printThumbSRImm(), llvm::X86ATTInstPrinter::printU8Imm(), llvm::X86IntelInstPrinter::printU8Imm(), and llvm::AArch64InstPrinter::printUImm12Offset().

◆ getMnemonic()

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

◆ getOpcodeName()

StringRef MCInstPrinter::getOpcodeName ( unsigned  Opcode) const

Return the name of the specified opcode enum (e.g.

getOpcodeName - Return the name of the specified opcode enum (e.g.

"MOV32ri") or empty if we can't resolve it.

Definition at line 41 of file MCInstPrinter.cpp.

References llvm::MCInstrInfo::getName(), and MII.

◆ getPrintImmHex()

bool llvm::MCInstPrinter::getPrintImmHex ( ) const
inline

Definition at line 121 of file MCInstPrinter.h.

References PrintImmHex.

Referenced by llvm::AArch64InstPrinter::printImmSVE().

◆ getUseMarkup()

bool llvm::MCInstPrinter::getUseMarkup ( ) const
inline

Definition at line 115 of file MCInstPrinter.h.

References UseMarkup.

Referenced by markup(), and llvm::ARMInstPrinter::printOperand().

◆ markup()

StringRef MCInstPrinter::markup ( StringRef  s) const

Utility functions to make adding mark ups simpler.

Definition at line 173 of file MCInstPrinter.cpp.

References getUseMarkup(), and s.

Referenced by llvm::ARMInstPrinter::printAddrMode2OffsetOperand(), llvm::ARMInstPrinter::printAddrMode3OffsetOperand(), llvm::ARMInstPrinter::printAddrMode5FP16Operand(), llvm::ARMInstPrinter::printAddrMode5Operand(), llvm::ARMInstPrinter::printAddrMode6Operand(), llvm::ARMInstPrinter::printAddrMode7Operand(), llvm::ARMInstPrinter::printAddrModeImm12Operand(), llvm::ARMInstPrinter::printAddrModeTBB(), llvm::ARMInstPrinter::printAddrModeTBH(), llvm::ARMInstPrinter::printAdrLabelOperand(), llvm::ARMInstPrinter::printAM2PreOrOffsetIndexOp(), llvm::ARMInstPrinter::printAM3PreOrOffsetIndexOp(), llvm::ARMInstPrinter::printBitfieldInvMaskImmOperand(), llvm::X86ATTInstPrinter::printDstIdx(), llvm::ARMInstPrinter::printFBits16(), llvm::ARMInstPrinter::printFBits32(), llvm::ARMInstPrinter::printFPImmOperand(), llvm::ARMInstPrinter::printImmPlusOneOperand(), llvm::ARMInstPrinter::printInst(), llvm::X86ATTInstPrinter::printMemOffset(), llvm::X86ATTInstPrinter::printMemReference(), llvm::ARMInstPrinter::printModImmOperand(), llvm::ARMInstPrinter::printMveAddrModeRQOperand(), llvm::NVPTXInstPrinter::printOperand(), llvm::X86ATTInstPrinter::printOperand(), llvm::ARMInstPrinter::printOperand(), llvm::ARMInstPrinter::printPKHASRShiftImm(), llvm::ARMInstPrinter::printPKHLSLShiftImm(), llvm::ARMInstPrinter::printPostIdxImm8Operand(), llvm::ARMInstPrinter::printPostIdxImm8s4Operand(), llvm::X86ATTInstPrinter::printRegName(), llvm::ARMInstPrinter::printRegName(), llvm::ARMInstPrinter::printRotImmOperand(), llvm::ARMInstPrinter::printShiftImmOperand(), llvm::X86ATTInstPrinter::printSrcIdx(), llvm::X86ATTInstPrinter::printSTiRegOperand(), llvm::ARMInstPrinter::printT2AddrModeImm0_1020s4Operand(), llvm::ARMInstPrinter::printT2AddrModeImm8OffsetOperand(), llvm::ARMInstPrinter::printT2AddrModeImm8Operand(), llvm::ARMInstPrinter::printT2AddrModeImm8s4OffsetOperand(), llvm::ARMInstPrinter::printT2AddrModeImm8s4Operand(), llvm::ARMInstPrinter::printT2AddrModeSoRegOperand(), llvm::ARMInstPrinter::printThumbAddrModeImm5SOperand(), llvm::ARMInstPrinter::printThumbAddrModeRROperand(), llvm::ARMInstPrinter::printThumbLdrLabelOperand(), llvm::ARMInstPrinter::printThumbS4ImmOperand(), llvm::ARMInstPrinter::printThumbSRImm(), llvm::X86ATTInstPrinter::printU8Imm(), and llvm::ARMInstPrinter::printVMOVModImmOperand().

◆ matchAliasPatterns()

const char * MCInstPrinter::matchAliasPatterns ( const MCInst MI,
const MCSubtargetInfo STI,
const AliasMatchingData M 
)
protected

Helper for matching MCInsts to alias patterns when printing instructions.

Definition at line 123 of file MCInstPrinter.cpp.

References llvm::all_of(), assert(), llvm::lower_bound(), M, matchAliasCondition(), MI, MRI, and P.

◆ printAnnotation()

void MCInstPrinter::printAnnotation ( raw_ostream OS,
StringRef  Annot 
)
protected

◆ printInst()

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

Print the specified MCInst to the specified raw_ostream.

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.

Implemented in llvm::HexagonInstPrinter, llvm::WebAssemblyInstPrinter, llvm::NVPTXInstPrinter, llvm::VEInstPrinter, llvm::X86IntelInstPrinter, llvm::X86ATTInstPrinter, llvm::AArch64AppleInstPrinter, llvm::MipsInstPrinter, llvm::SystemZInstPrinter, llvm::PPCInstPrinter, llvm::XCoreInstPrinter, llvm::ARCInstPrinter, llvm::M68kInstPrinter, llvm::AMDGPUInstPrinter, llvm::AVRInstPrinter, llvm::CSKYInstPrinter, llvm::AArch64InstPrinter, llvm::RISCVInstPrinter, llvm::ARMInstPrinter, llvm::LanaiInstPrinter, llvm::SparcInstPrinter, llvm::BPFInstPrinter, llvm::MSP430InstPrinter, and llvm::R600InstPrinter.

Referenced by llvm::MCTargetStreamer::prettyPrintAsm().

◆ printRegName()

void MCInstPrinter::printRegName ( raw_ostream OS,
unsigned  RegNo 
) const
virtual

◆ setCommentStream()

void llvm::MCInstPrinter::setCommentStream ( raw_ostream OS)
inline

Specify a stream to emit comments to.

Definition at line 92 of file MCInstPrinter.h.

References CommentStream.

◆ setMCInstrAnalysis()

void llvm::MCInstPrinter::setMCInstrAnalysis ( const MCInstrAnalysis Value)
inline

Definition at line 131 of file MCInstPrinter.h.

References MIA.

◆ setPrintBranchImmAsAddress()

void llvm::MCInstPrinter::setPrintBranchImmAsAddress ( bool  Value)
inline

Definition at line 126 of file MCInstPrinter.h.

References PrintBranchImmAsAddress.

◆ setPrintHexStyle()

void llvm::MCInstPrinter::setPrintHexStyle ( HexStyle::Style  Value)
inline

Definition at line 124 of file MCInstPrinter.h.

References PrintHexStyle.

◆ setPrintImmHex()

void llvm::MCInstPrinter::setPrintImmHex ( bool  Value)
inline

Definition at line 122 of file MCInstPrinter.h.

References PrintImmHex.

◆ setSymbolizeOperands()

void llvm::MCInstPrinter::setSymbolizeOperands ( bool  Value)
inline

Definition at line 130 of file MCInstPrinter.h.

References SymbolizeOperands.

◆ setUseMarkup()

void llvm::MCInstPrinter::setUseMarkup ( bool  Value)
inline

Definition at line 116 of file MCInstPrinter.h.

References UseMarkup.

Member Data Documentation

◆ CommentStream

raw_ostream* llvm::MCInstPrinter::CommentStream = nullptr
protected

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.

Definition at line 48 of file MCInstPrinter.h.

Referenced by llvm::AArch64InstPrinter::printAddSubImm(), printAnnotation(), llvm::AArch64InstPrinter::printImmSVE(), llvm::X86ATTInstPrinter::printInst(), llvm::X86IntelInstPrinter::printInst(), llvm::X86ATTInstPrinter::printOperand(), llvm::ARMInstPrinter::printOperand(), and setCommentStream().

◆ MAI

const MCAsmInfo& llvm::MCInstPrinter::MAI
protected

Definition at line 49 of file MCInstPrinter.h.

Referenced by llvm::HexagonInstPrinter::getMAI(), llvm::SystemZInstPrinter::printAddress(), llvm::AArch64InstPrinter::printAddSubImm(), llvm::ARMInstPrinter::printAdrLabelOperand(), llvm::AArch64InstPrinter::printAdrpLabel(), llvm::AArch64InstPrinter::printAlignedLabel(), llvm::AArch64InstPrinter::printAMIndexedWB(), printAnnotation(), llvm::CSKYInstPrinter::printConstpool(), llvm::CSKYInstPrinter::printDataSymbol(), llvm::SystemZInstPrinter::printFormattedRegName(), llvm::LanaiInstPrinter::printHi16AndImmOperand(), llvm::LanaiInstPrinter::printHi16ImmOperand(), llvm::AArch64InstPrinter::printInst(), llvm::PPCInstPrinter::printInst(), llvm::R600InstPrinter::printLiteral(), llvm::LanaiInstPrinter::printLo16AndImmOperand(), llvm::LanaiInstPrinter::printMemImmOperand(), llvm::X86ATTInstPrinter::printMemOffset(), llvm::X86IntelInstPrinter::printMemOffset(), llvm::X86ATTInstPrinter::printMemReference(), llvm::X86IntelInstPrinter::printMemReference(), llvm::LanaiInstPrinter::printMemRiOperand(), llvm::LanaiInstPrinter::printMemSplsOperand(), llvm::LanaiInstPrinter::printOperand(), llvm::RISCVInstPrinter::printOperand(), llvm::CSKYInstPrinter::printOperand(), llvm::NVPTXInstPrinter::printOperand(), llvm::R600InstPrinter::printOperand(), llvm::VEInstPrinter::printOperand(), llvm::SystemZInstPrinter::printOperand(), llvm::X86ATTInstPrinter::printOperand(), llvm::WebAssemblyInstPrinter::printOperand(), llvm::SparcInstPrinter::printOperand(), llvm::X86IntelInstPrinter::printOperand(), llvm::ARMInstPrinter::printOperand(), llvm::PPCInstPrinter::printOperand(), llvm::AArch64InstPrinter::printOperand(), llvm::X86InstPrinterCommon::printPCRelImm(), llvm::SystemZInstPrinter::printRegName(), llvm::ARMInstPrinter::printThumbLdrLabelOperand(), llvm::X86IntelInstPrinter::printU8Imm(), and llvm::AArch64InstPrinter::printUImm12Offset().

◆ MIA

const MCInstrAnalysis* llvm::MCInstPrinter::MIA = nullptr
protected

◆ MII

const MCInstrInfo& llvm::MCInstPrinter::MII
protected

◆ MRI

const MCRegisterInfo& llvm::MCInstPrinter::MRI
protected

◆ PrintAliases

bool llvm::MCInstPrinter::PrintAliases = true
protected

◆ PrintBranchImmAsAddress

bool llvm::MCInstPrinter::PrintBranchImmAsAddress = false
protected

◆ PrintHexStyle

HexStyle::Style llvm::MCInstPrinter::PrintHexStyle = HexStyle::C
protected

Which style to use for printing hexadecimal values.

Definition at line 64 of file MCInstPrinter.h.

Referenced by formatHex(), and setPrintHexStyle().

◆ PrintImmHex

bool llvm::MCInstPrinter::PrintImmHex = false
protected

True if we are printing immediates as hex.

Definition at line 61 of file MCInstPrinter.h.

Referenced by formatImm(), getPrintImmHex(), and setPrintImmHex().

◆ SymbolizeOperands

bool llvm::MCInstPrinter::SymbolizeOperands = false
protected

If true, symbolize branch target and memory reference operands.

Definition at line 72 of file MCInstPrinter.h.

Referenced by llvm::X86ATTInstPrinter::printMemReference(), llvm::X86IntelInstPrinter::printMemReference(), llvm::X86InstPrinterCommon::printPCRelImm(), and setSymbolizeOperands().

◆ UseMarkup

bool llvm::MCInstPrinter::UseMarkup = false
protected

The documentation for this class was generated from the following files: