LLVM 22.0.0git
|
Generic interface to target specific assembler backends. More...
#include "llvm/MC/MCAsmBackend.h"
Public Member Functions | |
MCAsmBackend (const MCAsmBackend &)=delete | |
MCAsmBackend & | operator= (const MCAsmBackend &)=delete |
virtual | ~MCAsmBackend () |
void | setAssembler (MCAssembler *A) |
MCContext & | getContext () const |
bool | allowAutoPadding () const |
Return true if this target might automatically pad instructions and thus need to emit padding enable/disable directives around sensative code. | |
bool | allowEnhancedRelaxation () const |
Return true if this target allows an unrelaxable instruction to be emitted into RelaxableFragment and then we can increase its size in a tricky way for optimization. | |
virtual void | reset () |
lifetime management | |
std::unique_ptr< MCObjectWriter > | createObjectWriter (raw_pwrite_stream &OS) const |
Create a new MCObjectWriter instance for use by the assembler backend to emit the final object file. | |
std::unique_ptr< MCObjectWriter > | createDwoObjectWriter (raw_pwrite_stream &OS, raw_pwrite_stream &DwoOS) const |
Create an MCObjectWriter that writes two object files: a .o file which is linked into the final program and a .dwo file which is used by debuggers. | |
virtual std::unique_ptr< MCObjectTargetWriter > | createObjectTargetWriter () const =0 |
virtual unsigned | getMinimumNopSize () const |
Returns the minimum size of a nop in bytes on this target. | |
virtual unsigned | getMaximumNopSize (const MCSubtargetInfo &STI) const |
Returns the maximum size of a nop in bytes on this target. | |
virtual bool | writeNopData (raw_ostream &OS, uint64_t Count, const MCSubtargetInfo *STI) const =0 |
Write an (optimal) nop sequence of Count bytes to the given output. | |
virtual bool | finishLayout (const MCAssembler &Asm) const |
virtual uint64_t | generateCompactUnwindEncoding (const MCDwarfFrameInfo *FI, const MCContext *Ctxt) const |
Generate the compact unwind encoding for the CFI instructions. | |
bool | isDarwinCanonicalPersonality (const MCSymbol *Sym) const |
Target Fixup Interfaces | |
virtual std::optional< MCFixupKind > | getFixupKind (StringRef Name) const |
Map a relocation name used in .reloc to a fixup kind. | |
virtual MCFixupKindInfo | getFixupKindInfo (MCFixupKind Kind) const |
Get information on a fixup kind. | |
virtual std::optional< bool > | evaluateFixup (const MCFragment &, MCFixup &, MCValue &, uint64_t &) |
void | maybeAddReloc (const MCFragment &, const MCFixup &, const MCValue &, uint64_t &Value, bool IsResolved) |
virtual void | applyFixup (const MCFragment &, const MCFixup &, const MCValue &Target, uint8_t *Data, uint64_t Value, bool IsResolved)=0 |
Target Relaxation Interfaces | |
virtual bool | mayNeedRelaxation (unsigned Opcode, ArrayRef< MCOperand > Operands, const MCSubtargetInfo &STI) const |
Check whether the given instruction (encoded as Opcode+Operands) may need relaxation. | |
virtual bool | fixupNeedsRelaxationAdvanced (const MCFragment &, const MCFixup &, const MCValue &, uint64_t, bool Resolved) const |
Target specific predicate for whether a given fixup requires the associated instruction to be relaxed. | |
virtual bool | fixupNeedsRelaxation (const MCFixup &Fixup, uint64_t Value) const |
Simple predicate for targets where !Resolved implies requiring relaxation. | |
virtual void | relaxInstruction (MCInst &Inst, const MCSubtargetInfo &STI) const |
Relax the instruction in the given fragment to the next wider instruction. | |
virtual bool | relaxAlign (MCFragment &F, unsigned &Size) |
virtual bool | relaxDwarfLineAddr (MCFragment &) const |
virtual bool | relaxDwarfCFA (MCFragment &) const |
virtual std::pair< bool, bool > | relaxLEB128 (MCFragment &, int64_t &Value) const |
Static Public Member Functions | |
static const MCSubtargetInfo * | getSubtargetInfo (const MCFragment &F) |
Public Attributes | |
const llvm::endianness | Endian |
Protected Member Functions | |
MCAsmBackend (llvm::endianness Endian) | |
Protected Attributes | |
MCAssembler * | Asm = nullptr |
bool | AllowAutoPadding = false |
bool | AllowEnhancedRelaxation = false |
Generic interface to target specific assembler backends.
Definition at line 55 of file MCAsmBackend.h.
|
inlineprotected |
Definition at line 57 of file MCAsmBackend.h.
|
delete |
|
virtualdefault |
|
inline |
Return true if this target might automatically pad instructions and thus need to emit padding enable/disable directives around sensative code.
Definition at line 77 of file MCAsmBackend.h.
|
inline |
Return true if this target allows an unrelaxable instruction to be emitted into RelaxableFragment and then we can increase its size in a tricky way for optimization.
Definition at line 81 of file MCAsmBackend.h.
Referenced by llvm::MCObjectStreamer::emitInstruction().
std::unique_ptr< MCObjectWriter > MCAsmBackend::createDwoObjectWriter | ( | raw_pwrite_stream & | OS, |
raw_pwrite_stream & | DwoOS | ||
) | const |
Create an MCObjectWriter that writes two object files: a .o file which is linked into the final program and a .dwo file which is used by debuggers.
This function is only supported with ELF targets.
Definition at line 66 of file MCAsmBackend.cpp.
References llvm::Triple::COFF, createObjectTargetWriter(), llvm::createWasmDwoObjectWriter(), llvm::createWinCOFFDwoObjectWriter(), llvm::Triple::ELF, Endian, llvm::little, OS, llvm::report_fatal_error(), and llvm::Triple::Wasm.
Referenced by llvm::CodeGenTargetMachineImpl::createMCStreamer().
|
pure virtual |
Implemented in llvm::ARMAsmBackendDarwin, llvm::ARMAsmBackendELF, llvm::ARMAsmBackendWinCOFF, llvm::AVRAsmBackend, llvm::CSKYAsmBackend, llvm::LoongArchAsmBackend, llvm::MipsAsmBackend, and llvm::RISCVAsmBackend.
Referenced by createDwoObjectWriter(), and createObjectWriter().
std::unique_ptr< MCObjectWriter > MCAsmBackend::createObjectWriter | ( | raw_pwrite_stream & | OS | ) | const |
Create a new MCObjectWriter instance for use by the assembler backend to emit the final object file.
Definition at line 32 of file MCAsmBackend.cpp.
References llvm::Triple::COFF, llvm::createGOFFObjectWriter(), createObjectTargetWriter(), llvm::createSPIRVObjectWriter(), llvm::createWasmObjectWriter(), llvm::createWinCOFFObjectWriter(), llvm::createXCOFFObjectWriter(), llvm::Triple::DXContainer, llvm::Triple::ELF, Endian, llvm::Triple::GOFF, llvm::little, llvm_unreachable, llvm::Triple::MachO, OS, llvm::Triple::SPIRV, llvm::Triple::Wasm, and llvm::Triple::XCOFF.
Referenced by llvm::CodeGenTargetMachineImpl::addPassesToEmitMC(), llvm::CodeGenTargetMachineImpl::createMCStreamer(), llvm::dwarf_linker::classic::DwarfStreamer::init(), and llvm::dwarf_linker::parallel::DwarfEmitterImpl::init().
|
inlinevirtual |
Reimplemented in llvm::ARMAsmBackend, llvm::CSKYAsmBackend, and llvm::RISCVAsmBackend.
Definition at line 112 of file MCAsmBackend.h.
|
inlinevirtual |
Definition at line 202 of file MCAsmBackend.h.
|
inlinevirtual |
Simple predicate for targets where !Resolved implies requiring relaxation.
Reimplemented in llvm::CSKYAsmBackend.
Definition at line 147 of file MCAsmBackend.h.
References llvm_unreachable.
Referenced by fixupNeedsRelaxationAdvanced().
|
virtual |
Target specific predicate for whether a given fixup requires the associated instruction to be relaxed.
Reimplemented in llvm::ARMAsmBackend, llvm::CSKYAsmBackend, and llvm::RISCVAsmBackend.
Definition at line 109 of file MCAsmBackend.cpp.
References Fixup, and fixupNeedsRelaxation().
|
inlinevirtual |
Generate the compact unwind encoding for the CFI instructions.
Reimplemented in llvm::ARMAsmBackendDarwin.
Definition at line 205 of file MCAsmBackend.h.
Referenced by llvm::MCStreamer::generateCompactUnwindEncodings().
MCContext & MCAsmBackend::getContext | ( | ) | const |
Definition at line 29 of file MCAsmBackend.cpp.
References Asm, and llvm::MCAssembler::getContext().
Referenced by llvm::ARMAsmBackend::adjustFixupValue(), llvm::ARMAsmBackend::applyFixup(), llvm::AVRAsmBackend::applyFixup(), llvm::CSKYAsmBackend::applyFixup(), llvm::LoongArchAsmBackend::applyFixup(), llvm::MipsAsmBackend::applyFixup(), llvm::RISCVAsmBackend::applyFixup(), llvm::RISCVAsmBackend::evaluateFixup(), isDarwinCanonicalPersonality(), llvm::LoongArchAsmBackend::relaxAlign(), llvm::RISCVAsmBackend::relaxAlign(), llvm::LoongArchAsmBackend::relaxDwarfCFA(), llvm::RISCVAsmBackend::relaxDwarfCFA(), llvm::LoongArchAsmBackend::relaxDwarfLineAddr(), and llvm::RISCVAsmBackend::relaxDwarfLineAddr().
|
virtual |
Map a relocation name used in .reloc to a fixup kind.
Reimplemented in llvm::ARMAsmBackend, llvm::ARMAsmBackendELF, llvm::AVRAsmBackend, llvm::LoongArchAsmBackend, llvm::MipsAsmBackend, and llvm::RISCVAsmBackend.
Definition at line 85 of file MCAsmBackend.cpp.
Referenced by llvm::MipsAsmBackend::getFixupKind().
|
virtual |
Get information on a fixup kind.
Reimplemented in llvm::ARMAsmBackend, llvm::AVRAsmBackend, llvm::CSKYAsmBackend, llvm::LoongArchAsmBackend, llvm::MipsAsmBackend, and llvm::RISCVAsmBackend.
Definition at line 89 of file MCAsmBackend.cpp.
References assert(), and llvm::FK_NONE.
Referenced by llvm::ARMAsmBackend::getFixupKindInfo(), llvm::AVRAsmBackend::getFixupKindInfo(), llvm::CSKYAsmBackend::getFixupKindInfo(), llvm::LoongArchAsmBackend::getFixupKindInfo(), llvm::MipsAsmBackend::getFixupKindInfo(), and llvm::RISCVAsmBackend::getFixupKindInfo().
|
inlinevirtual |
Returns the maximum size of a nop in bytes on this target.
Definition at line 189 of file MCAsmBackend.h.
|
inlinevirtual |
Returns the minimum size of a nop in bytes on this target.
The assembler will use this to emit excess padding in situations where the padding required for simple alignment would be less than the minimum nop size.
Definition at line 185 of file MCAsmBackend.h.
|
static |
Definition at line 139 of file MCAsmBackend.cpp.
Referenced by llvm::ARMAsmBackend::applyFixup().
Definition at line 125 of file MCAsmBackend.cpp.
References assert(), getContext(), name, and Sym.
Referenced by llvm::ARMAsmBackendDarwin::generateCompactUnwindEncoding().
void MCAsmBackend::maybeAddReloc | ( | const MCFragment & | F, |
const MCFixup & | Fixup, | ||
const MCValue & | Target, | ||
uint64_t & | Value, | ||
bool | IsResolved | ||
) |
Definition at line 118 of file MCAsmBackend.cpp.
References Asm, F, Fixup, llvm::MCAssembler::getWriter(), and llvm::MCObjectWriter::recordRelocation().
Referenced by llvm::LoongArchAsmBackend::addReloc(), llvm::ARMAsmBackend::applyFixup(), llvm::CSKYAsmBackend::applyFixup(), and llvm::MipsAsmBackend::applyFixup().
|
inlinevirtual |
Check whether the given instruction (encoded as Opcode+Operands) may need relaxation.
Reimplemented in llvm::ARMAsmBackend, llvm::CSKYAsmBackend, and llvm::RISCVAsmBackend.
Definition at line 135 of file MCAsmBackend.h.
Referenced by llvm::MCObjectStreamer::emitInstruction().
|
delete |
|
inlinevirtual |
Reimplemented in llvm::LoongArchAsmBackend, and llvm::RISCVAsmBackend.
Definition at line 168 of file MCAsmBackend.h.
|
inlinevirtual |
Reimplemented in llvm::LoongArchAsmBackend, and llvm::RISCVAsmBackend.
Definition at line 170 of file MCAsmBackend.h.
|
inlinevirtual |
Reimplemented in llvm::LoongArchAsmBackend, and llvm::RISCVAsmBackend.
Definition at line 169 of file MCAsmBackend.h.
|
inlinevirtual |
Relax the instruction in the given fragment to the next wider instruction.
[out] | Inst | The instruction to relax, which is also the relaxed instruction. |
STI | the subtarget information for the associated instruction. |
Reimplemented in llvm::ARMAsmBackend, llvm::CSKYAsmBackend, and llvm::RISCVAsmBackend.
Definition at line 157 of file MCAsmBackend.h.
References llvm_unreachable.
Referenced by llvm::MCObjectStreamer::emitInstruction().
|
inlinevirtual |
Reimplemented in llvm::LoongArchAsmBackend, and llvm::RISCVAsmBackend.
Definition at line 174 of file MCAsmBackend.h.
|
inlinevirtual |
lifetime management
Definition at line 84 of file MCAsmBackend.h.
Referenced by llvm::MCAssembler::reset().
|
inline |
Definition at line 71 of file MCAsmBackend.h.
References A.
|
pure virtual |
Write an (optimal) nop sequence of Count bytes to the given output.
If the target cannot generate such a sequence, it should return an error.
Implemented in llvm::ARMAsmBackend, llvm::AVRAsmBackend, llvm::CSKYAsmBackend, llvm::LoongArchAsmBackend, llvm::MipsAsmBackend, and llvm::RISCVAsmBackend.
|
protected |
Definition at line 61 of file MCAsmBackend.h.
|
protected |
Definition at line 62 of file MCAsmBackend.h.
|
protected |
Definition at line 59 of file MCAsmBackend.h.
Referenced by llvm::LoongArchAsmBackend::addReloc(), llvm::RISCVAsmBackend::addReloc(), llvm::ARMAsmBackend::adjustFixupValue(), llvm::ARMAsmBackend::applyFixup(), llvm::AVRAsmBackend::applyFixup(), llvm::ARMAsmBackend::evaluateFixup(), llvm::CSKYAsmBackend::evaluateFixup(), llvm::RISCVAsmBackend::evaluateFixup(), llvm::ARMAsmBackend::fixupNeedsRelaxationAdvanced(), getContext(), maybeAddReloc(), llvm::RISCVAsmBackend::maybeAddVendorReloc(), llvm::LoongArchAsmBackend::relaxAlign(), llvm::LoongArchAsmBackend::relaxDwarfCFA(), llvm::RISCVAsmBackend::relaxDwarfCFA(), llvm::LoongArchAsmBackend::relaxDwarfLineAddr(), llvm::RISCVAsmBackend::relaxDwarfLineAddr(), llvm::LoongArchAsmBackend::relaxLEB128(), llvm::RISCVAsmBackend::relaxLEB128(), and llvm::ARMAsmBackend::shouldForceRelocation().
const llvm::endianness llvm::MCAsmBackend::Endian |
Definition at line 69 of file MCAsmBackend.h.
Referenced by llvm::ARMAsmBackend::adjustFixupValue(), llvm::ARMAsmBackend::applyFixup(), llvm::CSKYAsmBackend::applyFixup(), llvm::MipsAsmBackend::applyFixup(), llvm::RISCVAsmBackend::applyFixup(), createDwoObjectWriter(), createObjectWriter(), llvm::ARMAsmBackend::getFixupKindInfo(), llvm::MipsAsmBackend::getFixupKindInfo(), llvm::RISCVAsmBackend::relaxDwarfCFA(), llvm::RISCVAsmBackend::relaxDwarfLineAddr(), and llvm::ARMAsmBackend::writeNopData().