LLVM
15.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 () |
virtual bool | allowAutoPadding () const |
Return true if this target might automatically pad instructions and thus need to emit padding enable/disable directives around sensative code. More... | |
virtual 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. More... | |
virtual void | emitInstructionBegin (MCObjectStreamer &OS, const MCInst &Inst, const MCSubtargetInfo &STI) |
Give the target a chance to manipulate state related to instruction alignment (e.g. More... | |
virtual void | emitInstructionEnd (MCObjectStreamer &OS, const MCInst &Inst) |
virtual void | reset () |
lifetime management More... | |
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. More... | |
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. More... | |
virtual std::unique_ptr< MCObjectTargetWriter > | createObjectTargetWriter () const =0 |
virtual unsigned | getMinimumNopSize () const |
Returns the minimum size of a nop in bytes on this target. More... | |
virtual unsigned | getMaximumNopSize (const MCSubtargetInfo &STI) const |
Returns the maximum size of a nop in bytes on this target. More... | |
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. More... | |
virtual void | finishLayout (MCAssembler const &Asm, MCAsmLayout &Layout) const |
Give backend an opportunity to finish layout after relaxation. More... | |
virtual void | handleAssemblerFlag (MCAssemblerFlag Flag) |
Handle any target-specific assembler flags. By default, do nothing. More... | |
virtual uint32_t | generateCompactUnwindEncoding (ArrayRef< MCCFIInstruction >) const |
Generate the compact unwind encoding for the CFI instructions. More... | |
virtual bool | isMicroMips (const MCSymbol *Sym) const |
Check whether a given symbol has been flagged with MICROMIPS flag. More... | |
Target Fixup Interfaces | |
virtual unsigned | getNumFixupKinds () const =0 |
Get the number of target specific fixup kinds. More... | |
virtual Optional< MCFixupKind > | getFixupKind (StringRef Name) const |
Map a relocation name used in .reloc to a fixup kind. More... | |
virtual const MCFixupKindInfo & | getFixupKindInfo (MCFixupKind Kind) const |
Get information on a fixup kind. More... | |
virtual bool | shouldForceRelocation (const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &Target) |
Hook to check if a relocation is needed for some target specific reason. More... | |
virtual bool | shouldInsertExtraNopBytesForCodeAlign (const MCAlignFragment &AF, unsigned &Size) |
Hook to check if extra nop bytes must be inserted for alignment directive. More... | |
virtual bool | shouldInsertFixupForCodeAlign (MCAssembler &Asm, const MCAsmLayout &Layout, MCAlignFragment &AF) |
Hook which indicates if the target requires a fixup to be generated when handling an align directive in an executable section. More... | |
virtual bool | evaluateTargetFixup (const MCAssembler &Asm, const MCAsmLayout &Layout, const MCFixup &Fixup, const MCFragment *DF, const MCValue &Target, uint64_t &Value, bool &WasForced) |
virtual void | applyFixup (const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef< char > Data, uint64_t Value, bool IsResolved, const MCSubtargetInfo *STI) const =0 |
Apply the Value for given Fixup into the provided data fragment, at the offset specified by the fixup and following the fixup kind as appropriate. More... | |
Target Relaxation Interfaces | |
virtual bool | mayNeedRelaxation (const MCInst &Inst, const MCSubtargetInfo &STI) const |
Check whether the given instruction may need relaxation. More... | |
virtual bool | fixupNeedsRelaxationAdvanced (const MCFixup &Fixup, bool Resolved, uint64_t Value, const MCRelaxableFragment *DF, const MCAsmLayout &Layout, const bool WasForced) const |
Target specific predicate for whether a given fixup requires the associated instruction to be relaxed. More... | |
virtual bool | fixupNeedsRelaxation (const MCFixup &Fixup, uint64_t Value, const MCRelaxableFragment *DF, const MCAsmLayout &Layout) const =0 |
Simple predicate for targets where !Resolved implies requiring relaxation. More... | |
virtual void | relaxInstruction (MCInst &Inst, const MCSubtargetInfo &STI) const |
Relax the instruction in the given fragment to the next wider instruction. More... | |
virtual bool | relaxDwarfLineAddr (MCDwarfLineAddrFragment &DF, MCAsmLayout &Layout, bool &WasRelaxed) const |
virtual bool | relaxDwarfCFA (MCDwarfCallFrameFragment &DF, MCAsmLayout &Layout, bool &WasRelaxed) const |
Public Attributes | |
const support::endianness | Endian |
Protected Member Functions | |
MCAsmBackend (support::endianness Endian) | |
Generic interface to target specific assembler backends.
Definition at line 42 of file MCAsmBackend.h.
|
protected |
Definition at line 26 of file MCAsmBackend.cpp.
|
delete |
|
virtualdefault |
|
inlinevirtual |
Return true if this target might automatically pad instructions and thus need to emit padding enable/disable directives around sensative code.
Definition at line 55 of file MCAsmBackend.h.
|
inlinevirtual |
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 59 of file MCAsmBackend.h.
|
pure virtual |
Apply the Value
for given Fixup
into the provided data fragment, at the offset specified by the fixup and following the fixup kind as appropriate.
Errors (such as an out of range fixup value) should be reported via Ctx
. The STI
is present only for fragments of type MCRelaxableFragment and MCDataFragment with hasInstructions() == true.
Implemented in llvm::RISCVAsmBackend, llvm::ARMAsmBackend, llvm::MipsAsmBackend, llvm::AVRAsmBackend, llvm::LoongArchAsmBackend, and llvm::CSKYAsmBackend.
Referenced by llvm::MCAssembler::layout().
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 58 of file MCAsmBackend.cpp.
References llvm::createELFDwoObjectWriter(), createObjectTargetWriter(), llvm::createWasmDwoObjectWriter(), llvm::Triple::ELF, Endian, llvm::support::little, move, llvm::report_fatal_error(), and llvm::Triple::Wasm.
Referenced by llvm::LLVMTargetMachine::createMCStreamer().
|
pure virtual |
Implemented in llvm::RISCVAsmBackend, llvm::CSKYAsmBackend, llvm::LoongArchAsmBackend, llvm::MipsAsmBackend, llvm::AVRAsmBackend, and llvm::ARMAsmBackendDarwin.
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 31 of file MCAsmBackend.cpp.
References llvm::Triple::COFF, llvm::createELFObjectWriter(), llvm::createMachObjectWriter(), createObjectTargetWriter(), llvm::createSPIRVObjectWriter(), llvm::createWasmObjectWriter(), llvm::createWinCOFFObjectWriter(), llvm::createXCOFFObjectWriter(), llvm::Triple::ELF, Endian, llvm::support::little, llvm_unreachable, llvm::Triple::MachO, move, llvm::Triple::SPIRV, llvm::Triple::Wasm, and llvm::Triple::XCOFF.
Referenced by llvm::LLVMTargetMachine::addPassesToEmitMC(), llvm::LLVMTargetMachine::createMCStreamer(), and llvm::DwarfStreamer::init().
|
inlinevirtual |
Give the target a chance to manipulate state related to instruction alignment (e.g.
padding for optimization), instruction relaxablility, etc. before and after actually emitting the instruction.
Definition at line 64 of file MCAsmBackend.h.
Referenced by llvm::MCObjectStreamer::emitInstruction().
|
inlinevirtual |
Definition at line 66 of file MCAsmBackend.h.
Referenced by llvm::MCObjectStreamer::emitInstruction().
|
inlinevirtual |
Reimplemented in llvm::RISCVAsmBackend.
Definition at line 120 of file MCAsmBackend.h.
References llvm_unreachable.
|
inlinevirtual |
Give backend an opportunity to finish layout after relaxation.
Definition at line 207 of file MCAsmBackend.h.
|
pure virtual |
Simple predicate for targets where !Resolved implies requiring relaxation.
Implemented in llvm::RISCVAsmBackend, llvm::ARMAsmBackend, llvm::MipsAsmBackend, llvm::AVRAsmBackend, llvm::LoongArchAsmBackend, and llvm::CSKYAsmBackend.
Referenced by fixupNeedsRelaxationAdvanced().
|
virtual |
Target specific predicate for whether a given fixup requires the associated instruction to be relaxed.
Reimplemented in llvm::RISCVAsmBackend, and llvm::CSKYAsmBackend.
Definition at line 108 of file MCAsmBackend.cpp.
References DF, Fixup, and fixupNeedsRelaxation().
|
inlinevirtual |
Generate the compact unwind encoding for the CFI instructions.
Reimplemented in llvm::ARMAsmBackendDarwin.
Definition at line 215 of file MCAsmBackend.h.
Referenced by llvm::MCStreamer::generateCompactUnwindEncodings().
|
virtual |
Map a relocation name used in .reloc to a fixup kind.
Reimplemented in llvm::RISCVAsmBackend, llvm::MipsAsmBackend, and llvm::ARMAsmBackend.
Definition at line 74 of file MCAsmBackend.cpp.
References llvm::None.
Referenced by llvm::MCObjectStreamer::emitRelocDirective(), and llvm::MipsAsmBackend::getFixupKind().
|
virtual |
Get information on a fixup kind.
Reimplemented in llvm::RISCVAsmBackend, llvm::MipsAsmBackend, llvm::AVRAsmBackend, llvm::ARMAsmBackend, and llvm::CSKYAsmBackend.
Definition at line 78 of file MCAsmBackend.cpp.
References llvm::array_lengthof(), assert(), and llvm::MCFixupKindInfo::FKF_IsPCRel.
Referenced by llvm::CSKYAsmBackend::getFixupKindInfo(), llvm::ARMAsmBackend::getFixupKindInfo(), llvm::AVRAsmBackend::getFixupKindInfo(), llvm::MipsAsmBackend::getFixupKindInfo(), and llvm::RISCVAsmBackend::getFixupKindInfo().
|
inlinevirtual |
Returns the maximum size of a nop in bytes on this target.
Definition at line 195 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 191 of file MCAsmBackend.h.
|
pure virtual |
Get the number of target specific fixup kinds.
Implemented in llvm::RISCVAsmBackend, llvm::MipsAsmBackend, llvm::AVRAsmBackend, llvm::LoongArchAsmBackend, llvm::ARMAsmBackend, and llvm::CSKYAsmBackend.
|
inlinevirtual |
Handle any target-specific assembler flags. By default, do nothing.
Reimplemented in llvm::ARMAsmBackend.
Definition at line 211 of file MCAsmBackend.h.
Referenced by llvm::MCWinCOFFStreamer::emitAssemblerFlag(), llvm::MCWasmStreamer::emitAssemblerFlag(), and llvm::MCELFStreamer::emitAssemblerFlag().
Check whether a given symbol has been flagged with MICROMIPS flag.
Reimplemented in llvm::MipsAsmBackend.
Definition at line 220 of file MCAsmBackend.h.
|
inlinevirtual |
Check whether the given instruction may need relaxation.
Inst | - The instruction to test. |
STI | - The MCSubtargetInfo in effect when the instruction was encoded. |
Reimplemented in llvm::RISCVAsmBackend, llvm::ARMAsmBackend, and llvm::CSKYAsmBackend.
Definition at line 149 of file MCAsmBackend.h.
|
delete |
|
inlinevirtual |
Reimplemented in llvm::RISCVAsmBackend.
Definition at line 180 of file MCAsmBackend.h.
|
inlinevirtual |
Reimplemented in llvm::RISCVAsmBackend.
Definition at line 175 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::RISCVAsmBackend, llvm::ARMAsmBackend, llvm::LoongArchAsmBackend, and llvm::CSKYAsmBackend.
Definition at line 172 of file MCAsmBackend.h.
|
inlinevirtual |
lifetime management
Definition at line 69 of file MCAsmBackend.h.
Referenced by llvm::MCAssembler::reset().
|
inlinevirtual |
Hook to check if a relocation is needed for some target specific reason.
Reimplemented in llvm::MipsAsmBackend, llvm::RISCVAsmBackend, llvm::AVRAsmBackend, llvm::CSKYAsmBackend, llvm::ARMAsmBackend, and llvm::LoongArchAsmBackend.
Definition at line 98 of file MCAsmBackend.h.
|
inlinevirtual |
Hook to check if extra nop bytes must be inserted for alignment directive.
For some targets this may be necessary in order to support linker relaxation. The number of bytes to insert are returned in Size.
Reimplemented in llvm::RISCVAsmBackend.
Definition at line 107 of file MCAsmBackend.h.
|
inlinevirtual |
Hook which indicates if the target requires a fixup to be generated when handling an align directive in an executable section.
Reimplemented in llvm::RISCVAsmBackend.
Definition at line 114 of file MCAsmBackend.h.
Referenced by llvm::MCAssembler::layout().
|
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::RISCVAsmBackend, llvm::ARMAsmBackend, llvm::MipsAsmBackend, llvm::AVRAsmBackend, llvm::LoongArchAsmBackend, and llvm::CSKYAsmBackend.
const support::endianness llvm::MCAsmBackend::Endian |
Definition at line 51 of file MCAsmBackend.h.
Referenced by llvm::ARMAsmBackend::adjustFixupValue(), llvm::CSKYAsmBackend::applyFixup(), llvm::MipsAsmBackend::applyFixup(), llvm::ARMAsmBackend::applyFixup(), createDwoObjectWriter(), createObjectWriter(), llvm::ARMAsmBackend::getFixupKindInfo(), llvm::MipsAsmBackend::getFixupKindInfo(), and llvm::ARMAsmBackend::writeNopData().