LLVM  6.0.0svn
Public Member Functions | Protected Member Functions | List of all members
llvm::MCAsmBackend Class Referenceabstract

Generic interface to target specific assembler backends. More...

#include "llvm/MC/MCAsmBackend.h"

Inheritance diagram for llvm::MCAsmBackend:
Inheritance graph
[legend]

Public Member Functions

 MCAsmBackend (const MCAsmBackend &)=delete
 
MCAsmBackendoperator= (const MCAsmBackend &)=delete
 
virtual ~MCAsmBackend ()
 
virtual void reset ()
 lifetime management More...
 
virtual std::unique_ptr< MCObjectWritercreateObjectWriter (raw_pwrite_stream &OS) const =0
 Create a new MCObjectWriter instance for use by the assembler backend to emit the final object file. More...
 
virtual unsigned getMinimumNopSize () const
 Returns the minimum size of a nop in bytes on this target. More...
 
virtual bool writeNopData (uint64_t Count, MCObjectWriter *OW) 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...
 
void handleCodePaddingBasicBlockStart (MCObjectStreamer *OS, const MCCodePaddingContext &Context)
 Handles all target related code padding when starting to write a new basic block to an object file. More...
 
void handleCodePaddingBasicBlockEnd (const MCCodePaddingContext &Context)
 Handles all target related code padding after writing a block to an object file. More...
 
void handleCodePaddingInstructionBegin (const MCInst &Inst)
 Handles all target related code padding before writing a new instruction to an object file. More...
 
void handleCodePaddingInstructionEnd (const MCInst &Inst)
 Handles all target related code padding after writing an instruction to an object file. More...
 
bool relaxFragment (MCPaddingFragment *PF, MCAsmLayout &Layout)
 Relaxes a fragment (changes the size of the padding) according to target requirements. More...
 
Target Fixup Interfaces
virtual unsigned getNumFixupKinds () const =0
 Get the number of target specific fixup kinds. More...
 
virtual Optional< MCFixupKindgetFixupKind (StringRef Name) const
 Map a relocation name used in .reloc to a fixup kind. More...
 
virtual const MCFixupKindInfogetFixupKindInfo (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 void applyFixup (const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef< char > Data, uint64_t Value, bool IsResolved) 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 =0
 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
 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 (const MCInst &Inst, const MCSubtargetInfo &STI, MCInst &Res) const =0
 Relax the instruction in the given fragment to the next wider instruction. More...
 

Protected Member Functions

 MCAsmBackend ()
 
 MCAsmBackend (std::unique_ptr< MCCodePadder > TargetCodePadder)
 

Detailed Description

Generic interface to target specific assembler backends.

Definition at line 40 of file MCAsmBackend.h.

Constructor & Destructor Documentation

◆ MCAsmBackend() [1/3]

MCAsmBackend::MCAsmBackend ( )
protected

Definition at line 21 of file MCAsmBackend.cpp.

◆ MCAsmBackend() [2/3]

MCAsmBackend::MCAsmBackend ( std::unique_ptr< MCCodePadder TargetCodePadder)
protected

Definition at line 23 of file MCAsmBackend.cpp.

References ~MCAsmBackend().

◆ MCAsmBackend() [3/3]

llvm::MCAsmBackend::MCAsmBackend ( const MCAsmBackend )
delete

◆ ~MCAsmBackend()

MCAsmBackend::~MCAsmBackend ( )
virtualdefault

Referenced by MCAsmBackend().

Member Function Documentation

◆ applyFixup()

virtual void llvm::MCAsmBackend::applyFixup ( const MCAssembler Asm,
const MCFixup Fixup,
const MCValue Target,
MutableArrayRef< char Data,
uint64_t  Value,
bool  IsResolved 
) const
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.

Implemented in llvm::ARMAsmBackend, llvm::AVRAsmBackend, llvm::MipsAsmBackend, and llvm::Nios2AsmBackend.

Referenced by llvm::MCAssembler::layout(), and shouldForceRelocation().

◆ createObjectWriter()

virtual std::unique_ptr<MCObjectWriter> llvm::MCAsmBackend::createObjectWriter ( raw_pwrite_stream OS) const
pure virtual

Create a new MCObjectWriter instance for use by the assembler backend to emit the final object file.

Implemented in llvm::AVRAsmBackend, llvm::MipsAsmBackend, llvm::Nios2AsmBackend, and llvm::ARMAsmBackendDarwin.

Referenced by llvm::MCELFStreamer::MCELFStreamer(), and reset().

◆ finishLayout()

virtual void llvm::MCAsmBackend::finishLayout ( MCAssembler const Asm,
MCAsmLayout Layout 
) const
inlinevirtual

Give backend an opportunity to finish layout after relaxation.

Definition at line 133 of file MCAsmBackend.h.

Referenced by llvm::MCAssembler::Finish().

◆ fixupNeedsRelaxation()

virtual bool llvm::MCAsmBackend::fixupNeedsRelaxation ( const MCFixup Fixup,
uint64_t  Value,
const MCRelaxableFragment DF,
const MCAsmLayout Layout 
) const
pure virtual

Simple predicate for targets where !Resolved implies requiring relaxation.

Implemented in llvm::MipsAsmBackend, llvm::ARMAsmBackend, llvm::Nios2AsmBackend, and llvm::AVRAsmBackend.

Referenced by fixupNeedsRelaxationAdvanced(), and shouldForceRelocation().

◆ fixupNeedsRelaxationAdvanced()

bool MCAsmBackend::fixupNeedsRelaxationAdvanced ( const MCFixup Fixup,
bool  Resolved,
uint64_t  Value,
const MCRelaxableFragment DF,
const MCAsmLayout Layout 
) const
virtual

Target specific predicate for whether a given fixup requires the associated instruction to be relaxed.

Definition at line 59 of file MCAsmBackend.cpp.

References fixupNeedsRelaxation().

Referenced by llvm::MCAssembler::Finish(), and shouldForceRelocation().

◆ generateCompactUnwindEncoding()

virtual uint32_t llvm::MCAsmBackend::generateCompactUnwindEncoding ( ArrayRef< MCCFIInstruction ) const
inlinevirtual

◆ getFixupKind()

Optional< MCFixupKind > MCAsmBackend::getFixupKind ( StringRef  Name) const
virtual

Map a relocation name used in .reloc to a fixup kind.

Reimplemented in llvm::MipsAsmBackend, and llvm::Nios2AsmBackend.

Definition at line 28 of file MCAsmBackend.cpp.

References llvm::None.

Referenced by llvm::Nios2AsmBackend::getFixupKind(), llvm::MipsAsmBackend::getFixupKind(), getRelaxedOpcode(), and reset().

◆ getFixupKindInfo()

const MCFixupKindInfo & MCAsmBackend::getFixupKindInfo ( MCFixupKind  Kind) const
virtual

◆ getMinimumNopSize()

virtual unsigned llvm::MCAsmBackend::getMinimumNopSize ( ) const
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 124 of file MCAsmBackend.h.

References writeNopData().

Referenced by llvm::MCAssembler::computeFragmentSize().

◆ getNumFixupKinds()

virtual unsigned llvm::MCAsmBackend::getNumFixupKinds ( ) const
pure virtual

Get the number of target specific fixup kinds.

Implemented in llvm::MipsAsmBackend, llvm::AVRAsmBackend, llvm::Nios2AsmBackend, and llvm::ARMAsmBackend.

Referenced by reset().

◆ handleAssemblerFlag()

virtual void llvm::MCAsmBackend::handleAssemblerFlag ( MCAssemblerFlag  Flag)
inlinevirtual

Handle any target-specific assembler flags. By default, do nothing.

Reimplemented in llvm::ARMAsmBackend.

Definition at line 137 of file MCAsmBackend.h.

Referenced by llvm::MCELFStreamer::EmitAssemblerFlag(), and llvm::MCWasmStreamer::EmitAssemblerFlag().

◆ handleCodePaddingBasicBlockEnd()

void MCAsmBackend::handleCodePaddingBasicBlockEnd ( const MCCodePaddingContext Context)

Handles all target related code padding after writing a block to an object file.

Parameters
Contextthe context of the padding, Embeds the basic block's parameters.

Definition at line 72 of file MCAsmBackend.cpp.

Referenced by llvm::MCObjectStreamer::EmitCodePaddingBasicBlockEnd(), and generateCompactUnwindEncoding().

◆ handleCodePaddingBasicBlockStart()

void MCAsmBackend::handleCodePaddingBasicBlockStart ( MCObjectStreamer OS,
const MCCodePaddingContext Context 
)

Handles all target related code padding when starting to write a new basic block to an object file.

Parameters
OSThe streamer used for writing the padding data and function.
Contextthe context of the padding, Embeds the basic block's parameters.

Definition at line 67 of file MCAsmBackend.cpp.

Referenced by llvm::MCObjectStreamer::EmitCodePaddingBasicBlockStart(), and generateCompactUnwindEncoding().

◆ handleCodePaddingInstructionBegin()

void MCAsmBackend::handleCodePaddingInstructionBegin ( const MCInst Inst)

Handles all target related code padding before writing a new instruction to an object file.

Parameters
Instthe instruction.

Definition at line 77 of file MCAsmBackend.cpp.

Referenced by llvm::MCObjectStreamer::EmitInstruction(), and generateCompactUnwindEncoding().

◆ handleCodePaddingInstructionEnd()

void MCAsmBackend::handleCodePaddingInstructionEnd ( const MCInst Inst)

Handles all target related code padding after writing an instruction to an object file.

Parameters
Instthe instruction.

Definition at line 81 of file MCAsmBackend.cpp.

Referenced by llvm::MCObjectStreamer::EmitInstruction(), and generateCompactUnwindEncoding().

◆ mayNeedRelaxation()

virtual bool llvm::MCAsmBackend::mayNeedRelaxation ( const MCInst Inst) const
pure virtual

Check whether the given instruction may need relaxation.

Parameters
Inst- The instruction to test.

Implemented in llvm::MipsAsmBackend, llvm::Nios2AsmBackend, llvm::ARMAsmBackend, and llvm::AVRAsmBackend.

Referenced by llvm::MCObjectStreamer::EmitInstruction(), and shouldForceRelocation().

◆ operator=()

MCAsmBackend& llvm::MCAsmBackend::operator= ( const MCAsmBackend )
delete

◆ relaxFragment()

bool MCAsmBackend::relaxFragment ( MCPaddingFragment PF,
MCAsmLayout Layout 
)

Relaxes a fragment (changes the size of the padding) according to target requirements.

The new size computation is done w.r.t a layout.

Parameters
PFThe fragment to relax.
LayoutCode layout information.
Returns
true iff any relaxation occured.

Definition at line 85 of file MCAsmBackend.cpp.

Referenced by generateCompactUnwindEncoding().

◆ relaxInstruction()

virtual void llvm::MCAsmBackend::relaxInstruction ( const MCInst Inst,
const MCSubtargetInfo STI,
MCInst Res 
) const
pure virtual

Relax the instruction in the given fragment to the next wider instruction.

Parameters
InstThe instruction to relax, which may be the same as the output.
STIthe subtarget information for the associated instruction.
[out]ResOn return, the relaxed instruction.

Implemented in llvm::MipsAsmBackend, llvm::Nios2AsmBackend, llvm::ARMAsmBackend, and llvm::AVRAsmBackend.

Referenced by llvm::MCObjectStreamer::EmitInstruction(), llvm::MCAssembler::Finish(), and shouldForceRelocation().

◆ reset()

virtual void llvm::MCAsmBackend::reset ( )
inlinevirtual

lifetime management

Definition at line 53 of file MCAsmBackend.h.

References createObjectWriter(), getFixupKind(), getFixupKindInfo(), getNumFixupKinds(), and Kind.

Referenced by llvm::MCAssembler::reset().

◆ shouldForceRelocation()

virtual bool llvm::MCAsmBackend::shouldForceRelocation ( const MCAssembler Asm,
const MCFixup Fixup,
const MCValue Target 
)
inlinevirtual

Hook to check if a relocation is needed for some target specific reason.

Reimplemented in llvm::AVRAsmBackend, and llvm::ARMAsmBackend.

Definition at line 73 of file MCAsmBackend.h.

References applyFixup(), llvm::HexStyle::Asm, llvm::Data, Fixup, fixupNeedsRelaxation(), fixupNeedsRelaxationAdvanced(), mayNeedRelaxation(), and relaxInstruction().

Referenced by llvm::MCAssembler::getAtom().

◆ writeNopData()

virtual bool llvm::MCAsmBackend::writeNopData ( uint64_t  Count,
MCObjectWriter OW 
) const
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.

Returns
- True on success.

Implemented in llvm::MipsAsmBackend, llvm::ARMAsmBackend, llvm::AVRAsmBackend, and llvm::Nios2AsmBackend.

Referenced by getMinimumNopSize(), and writeFragment().


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