1//===- MCInstPrinter.h - MCInst to target assembly syntax -------*- C++ -*-===//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//===----------------------------------------------------------------------===//
9#ifndef LLVM_MC_MCINSTPRINTER_H
10#define LLVM_MC_MCINSTPRINTER_H
30/// Convert `Bytes' to a hex string and output to `OS'
40}
// end namespace HexStyle
42struct AliasMatchingData;
44/// This is an instance of a target assembly language printer that
45/// converts an MCInst to valid target assembly syntax.
48 /// A stream that comments can be emitted to if desired. Each comment
49 /// must end with a newline. This will be null if verbose assembly emission
57 /// True if we are printing marked up assembly.
60 /// True if we are printing colored assembly.
63 /// True if we prefer aliases (e.g. nop) to raw mnemonics.
66 /// True if we are printing immediates as hex.
69 /// Which style to use for printing hexadecimal values.
72 /// If true, a branch immediate (e.g. bl 4) will be printed as a hexadecimal
73 /// address (e.g. bl 0x20004). This is useful for a stream disassembler
74 /// (llvm-objdump -d).
77 /// If true, symbolize branch target and memory reference operands.
82 /// Utility function for printing annotations.
85 /// Helper for matching MCInsts to alias patterns when printing instructions.
105 Markup M,
bool EnableMarkup,
126 /// Customize the printer according to a command line option.
127 /// @return true if the option is recognized and applied.
130 /// Specify a stream to emit comments to.
133 /// Returns a pair containing the mnemonic for \p MI and the number of bits
134 /// left for further processing by printInstruction (generated by tablegen).
135 virtual std::pair<const char *, uint64_t>
138 /// Print the specified MCInst to the specified raw_ostream.
140 /// \p Address the address of current instruction on most targets, used to
141 /// print a PC relative immediate as the target address. On targets where a PC
142 /// relative immediate is relative to the next instruction and the length of a
143 /// MCInst is difficult to measure (e.g. x86), this is the address of the next
144 /// instruction. If Address is 0, the immediate will be printed.
148 /// Return the name of the specified opcode enum (e.g. "MOV32ri") or
149 /// empty if we can't resolve it.
152 /// Print the assembler register name.
175 /// Utility function to print immediates in decimal or hex.
180 /// Utility functions to print decimal/hexadecimal values.
186/// Map from opcode to pattern list by binary search.
193/// Data for each alias pattern. Includes feature bits, string, number of
194/// operands, and a variadic list of conditions to check.
206 K_OrFeature,
// Match only if one of a set of features is enabled.
210 K_Reg,
// Match a specific register.
212 K_Imm,
// Match a specific immediate.
221/// Tablegenerated data structures needed to match alias patterns.
228 unsigned PredicateIndex);
231}
// end namespace llvm
233#endif // LLVM_MC_MCINSTPRINTER_H
#define LLVM_CTOR_NODISCARD
static StringRef getOpcodeName(uint8_t Opcode, uint8_t OpcodeBase)
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This class is intended to be used as a base class for asm properties and features specific to the tar...
WithMarkup & operator<<(const T &O)
WithMarkup & operator<<(T &O)
LLVM_CTOR_NODISCARD LLVM_ABI WithMarkup(MCInstPrinter &IP, raw_ostream &OS, Markup M, bool EnableMarkup, bool EnableColor)
void setPrintBranchImmAsAddress(bool Value)
bool UseMarkup
True if we are printing marked up assembly.
void setMCInstrAnalysis(const MCInstrAnalysis *Value)
format_object< int64_t > formatHex(int64_t Value) const
bool PrintImmHex
True if we are printing immediates as hex.
void setCommentStream(raw_ostream &OS)
Specify a stream to emit comments to.
virtual bool applyTargetSpecificCLOption(StringRef Opt)
Customize the printer according to a command line option.
void setUseColor(bool Value)
raw_ostream * CommentStream
A stream that comments can be emitted to if desired.
bool getPrintImmHex() const
void setSymbolizeOperands(bool Value)
bool SymbolizeOperands
If true, symbolize branch target and memory reference operands.
void setPrintImmHex(bool Value)
SmallVector< raw_ostream::Colors, 4 > ColorStack
void setUseMarkup(bool Value)
format_object< int64_t > formatDec(int64_t Value) const
Utility functions to print decimal/hexadecimal values.
const MCRegisterInfo & MRI
format_object< int64_t > formatImm(int64_t Value) const
Utility function to print immediates in decimal or hex.
bool UseColor
True if we are printing colored assembly.
bool getUseMarkup() const
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.
bool PrintBranchImmAsAddress
If true, a branch immediate (e.g.
virtual void printRegName(raw_ostream &OS, MCRegister Reg)
Print the assembler register name.
virtual std::pair< const char *, uint64_t > getMnemonic(const MCInst &MI) const =0
Returns a pair containing the mnemonic for MI and the number of bits left for further processing by p...
void setPrintHexStyle(HexStyle::Style Value)
const MCInstrAnalysis * MIA
MCInstPrinter(const MCAsmInfo &mai, const MCInstrInfo &mii, const MCRegisterInfo &mri)
HexStyle::Style PrintHexStyle
Which style to use for printing hexadecimal values.
bool PrintAliases
True if we prefer aliases (e.g. nop) to raw mnemonics.
Instances of this class represent a single low-level machine instruction.
Interface to description of machine instruction set.
Instances of this class represent operands of the MCInst class.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Wrapper class representing physical registers. Should be passed by value.
Generic base class for all target subtargets.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void dumpBytes(ArrayRef< uint8_t > Bytes, raw_ostream &OS)
Convert ‘Bytes’ to a hex string and output to ‘OS’.
Tablegenerated data structures needed to match alias patterns.
ArrayRef< AliasPatternCond > PatternConds
bool(* ValidateMCOperand)(const MCOperand &MCOp, const MCSubtargetInfo &STI, unsigned PredicateIndex)
ArrayRef< PatternsForOpcode > OpToPatterns
ArrayRef< AliasPattern > Patterns
Data for each alias pattern.
Map from opcode to pattern list by binary search.