LLVM API Documentation

Public Member Functions | Static Public Member Functions | Protected Member Functions
llvm::MCObjectStreamer Class Reference

Streaming object file generation interface. More...

#include <MCObjectStreamer.h>

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

List of all members.

Public Member Functions

virtual void reset ()
 state management
MCAssemblergetAssembler ()
MCStreamer Interface
virtual void EmitLabel (MCSymbol *Symbol)
virtual void EmitDebugLabel (MCSymbol *Symbol)
virtual void EmitAssignment (MCSymbol *Symbol, const MCExpr *Value)
virtual void EmitValueImpl (const MCExpr *Value, unsigned Size, unsigned AddrSpace)
virtual void EmitULEB128Value (const MCExpr *Value)
virtual void EmitSLEB128Value (const MCExpr *Value)
virtual void EmitWeakReference (MCSymbol *Alias, const MCSymbol *Symbol)
virtual void ChangeSection (const MCSection *Section, const MCExpr *Subsection)
virtual void EmitInstruction (const MCInst &Inst)
virtual void EmitInstToFragment (const MCInst &Inst)
 Emit an instruction to a special fragment, because this instruction can change its size during relaxation.
virtual void EmitBundleAlignMode (unsigned AlignPow2)
 Set the bundle alignment mode from now on in the section. The argument is the power of 2 to which the alignment is set. The value 0 means turn the bundle alignment off.
virtual void EmitBundleLock (bool AlignToEnd)
 The following instructions are a bundle-locked group.
virtual void EmitBundleUnlock ()
 Ends a bundle-locked group.
virtual void EmitBytes (StringRef Data, unsigned AddrSpace=0)
virtual void EmitValueToAlignment (unsigned ByteAlignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0)
virtual void EmitCodeAlignment (unsigned ByteAlignment, unsigned MaxBytesToEmit=0)
virtual bool EmitValueToOffset (const MCExpr *Offset, unsigned char Value)
virtual void EmitDwarfAdvanceLineAddr (int64_t LineDelta, const MCSymbol *LastLabel, const MCSymbol *Label, unsigned PointerSize)
virtual void EmitDwarfAdvanceFrameAddr (const MCSymbol *LastLabel, const MCSymbol *Label)
virtual void EmitGPRel32Value (const MCExpr *Value)
virtual void EmitGPRel64Value (const MCExpr *Value)
virtual void EmitFill (uint64_t NumBytes, uint8_t FillValue, unsigned AddrSpace=0)
virtual void FinishImpl ()
 FinishImpl - Streamer specific finalization.

Static Public Member Functions

static bool classof (const MCStreamer *S)

Protected Member Functions

 MCObjectStreamer (StreamerKind Kind, MCContext &Context, MCAsmBackend &TAB, raw_ostream &_OS, MCCodeEmitter *_Emitter)
 MCObjectStreamer (StreamerKind Kind, MCContext &Context, MCAsmBackend &TAB, raw_ostream &_OS, MCCodeEmitter *_Emitter, MCAssembler *_Assembler)
 ~MCObjectStreamer ()
MCSectionDatagetCurrentSectionData () const
MCFragmentgetCurrentFragment () const
void insert (MCFragment *F) const
MCDataFragmentgetOrCreateDataFragment () const
const MCExprAddValueSymbols (const MCExpr *Value)

Detailed Description

Streaming object file generation interface.

This class provides an implementation of the MCStreamer interface which is suitable for use with the assembler backend. Specific object file formats are expected to subclass this interface to implement directives specific to that file format or custom semantics expected by the object writer implementation.

Definition at line 33 of file MCObjectStreamer.h.


Constructor & Destructor Documentation

MCObjectStreamer::MCObjectStreamer ( StreamerKind  Kind,
MCContext Context,
MCAsmBackend TAB,
raw_ostream _OS,
MCCodeEmitter _Emitter 
) [protected]

Definition at line 24 of file MCObjectStreamer.cpp.

MCObjectStreamer::MCObjectStreamer ( StreamerKind  Kind,
MCContext Context,
MCAsmBackend TAB,
raw_ostream _OS,
MCCodeEmitter _Emitter,
MCAssembler _Assembler 
) [protected]

Definition at line 32 of file MCObjectStreamer.cpp.

MCObjectStreamer::~MCObjectStreamer ( ) [protected]

Member Function Documentation

const MCExpr * MCObjectStreamer::AddValueSymbols ( const MCExpr Value) [protected]
void MCObjectStreamer::ChangeSection ( const MCSection ,
const MCExpr  
) [virtual]

ChangeSection - Update streamer for a new active section.

This is called by PopSection and SwitchSection, if the current section changes.

Implements llvm::MCStreamer.

Reimplemented in llvm::MCELFStreamer.

Definition at line 170 of file MCObjectStreamer.cpp.

References getAssembler(), llvm::MCAssembler::getOrCreateSectionData(), llvm::MCSectionData::getSubsectionInsertionPoint(), and llvm::report_fatal_error().

static bool llvm::MCObjectStreamer::classof ( const MCStreamer S) [inline, static]
void MCObjectStreamer::EmitAssignment ( MCSymbol Symbol,
const MCExpr Value 
) [virtual]

EmitAssignment - Emit an assignment of Value to Symbol.

This corresponds to an assembler statement such as: symbol = value

The assignment generates no code, but has the side effect of binding the value in the current context. For the assembly streamer, this prints the binding into the .s file.

Parameters:
Symbol- The symbol being assigned to.
Value- The value for the symbol.

Implements llvm::MCStreamer.

Definition at line 186 of file MCObjectStreamer.cpp.

References AddValueSymbols(), getAssembler(), llvm::MCAssembler::getOrCreateSymbolData(), and llvm::MCSymbol::setVariableValue().

void MCObjectStreamer::EmitBundleAlignMode ( unsigned  AlignPow2) [virtual]

Set the bundle alignment mode from now on in the section. The argument is the power of 2 to which the alignment is set. The value 0 means turn the bundle alignment off.

Implements llvm::MCStreamer.

Definition at line 248 of file MCObjectStreamer.cpp.

References BundlingNotImplementedMsg, and llvm_unreachable.

void MCObjectStreamer::EmitBundleLock ( bool  AlignToEnd) [virtual]

The following instructions are a bundle-locked group.

Parameters:
AlignToEnd- If true, the bundle-locked group will be aligned to the end of a bundle.

Implements llvm::MCStreamer.

Definition at line 252 of file MCObjectStreamer.cpp.

References BundlingNotImplementedMsg, and llvm_unreachable.

void MCObjectStreamer::EmitBundleUnlock ( ) [virtual]

Ends a bundle-locked group.

Implements llvm::MCStreamer.

Definition at line 256 of file MCObjectStreamer.cpp.

References BundlingNotImplementedMsg, and llvm_unreachable.

void MCObjectStreamer::EmitBytes ( StringRef  Data,
unsigned  AddrSpace = 0 
) [virtual]

EmitBytes - Emit the bytes in Data into the output.

This is used to implement assembler directives such as .byte, .ascii, etc.

Implements llvm::MCStreamer.

Definition at line 290 of file MCObjectStreamer.cpp.

References llvm::SmallVectorImpl< T >::append(), llvm::StringRef::begin(), llvm::StringRef::end(), llvm::MCDataFragment::getContents(), and getOrCreateDataFragment().

void MCObjectStreamer::EmitCodeAlignment ( unsigned  ByteAlignment,
unsigned  MaxBytesToEmit = 0 
) [virtual]

EmitCodeAlignment - Emit nops until the byte alignment ByteAlignment is reached.

This used to align code where the alignment bytes may be executed. This can emit different bytes for different sizes to optimize execution.

Parameters:
ByteAlignment- The alignment to reach. This must be a power of two on some targets.
MaxBytesToEmit- The maximum numbers of bytes to emit, or 0. If the alignment cannot be reached in this many bytes, no bytes are emitted.

Implements llvm::MCStreamer.

Definition at line 308 of file MCObjectStreamer.cpp.

References EmitValueToAlignment(), and getCurrentFragment().

void MCObjectStreamer::EmitDebugLabel ( MCSymbol Symbol) [virtual]

Reimplemented from llvm::MCStreamer.

Reimplemented in llvm::MCELFStreamer.

Definition at line 141 of file MCObjectStreamer.cpp.

References EmitLabel().

void MCObjectStreamer::EmitDwarfAdvanceFrameAddr ( const MCSymbol LastLabel,
const MCSymbol Label 
) [virtual]
void MCObjectStreamer::EmitDwarfAdvanceLineAddr ( int64_t  LineDelta,
const MCSymbol LastLabel,
const MCSymbol Label,
unsigned  PointerSize 
) [virtual]
void MCObjectStreamer::EmitFill ( uint64_t  NumBytes,
uint8_t  FillValue,
unsigned  AddrSpace = 0 
) [virtual]

EmitFill - Emit NumBytes bytes worth of the value specified by FillValue. This implements directives such as '.space'.

Reimplemented from llvm::MCStreamer.

Definition at line 354 of file MCObjectStreamer.cpp.

References llvm::SmallVectorImpl< T >::append(), llvm::MCDataFragment::getContents(), and getOrCreateDataFragment().

Referenced by EmitValueToOffset().

void MCObjectStreamer::EmitGPRel32Value ( const MCExpr Value) [virtual]

EmitGPRel32Value - Emit the expression Value into the output as a gprel32 (32-bit GP relative) value.

This is used to implement assembler directives such as .gprel32 on targets that support them.

Reimplemented from llvm::MCStreamer.

Definition at line 337 of file MCObjectStreamer.cpp.

References llvm::MCFixup::Create(), llvm::X86II::DF, llvm::FK_GPRel_4, llvm::MCDataFragment::getContents(), llvm::MCDataFragment::getFixups(), getOrCreateDataFragment(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::SmallVectorImpl< T >::resize(), and llvm::SmallVectorTemplateCommon< T, typename >::size().

void MCObjectStreamer::EmitGPRel64Value ( const MCExpr Value) [virtual]

EmitGPRel64Value - Emit the expression Value into the output as a gprel64 (64-bit GP relative) value.

This is used to implement assembler directives such as .gpdword on targets that support them.

Reimplemented from llvm::MCStreamer.

Definition at line 346 of file MCObjectStreamer.cpp.

References llvm::MCFixup::Create(), llvm::X86II::DF, llvm::FK_GPRel_4, llvm::MCDataFragment::getContents(), llvm::MCDataFragment::getFixups(), getOrCreateDataFragment(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::SmallVectorImpl< T >::resize(), and llvm::SmallVectorTemplateCommon< T, typename >::size().

void MCObjectStreamer::EmitInstruction ( const MCInst Inst) [virtual]
void MCObjectStreamer::EmitInstToFragment ( const MCInst Inst) [virtual]
void MCObjectStreamer::EmitLabel ( MCSymbol Symbol) [virtual]

EmitLabel - Emit a label for Symbol into the current section.

This corresponds to an assembler statement such as: foo:

Parameters:
Symbol- The symbol to emit. A given symbol should only be emitted as a label once, and symbols emitted as a label should never be used in an assignment.

Reimplemented from llvm::MCStreamer.

Reimplemented in llvm::MCELFStreamer.

Definition at line 126 of file MCObjectStreamer.cpp.

References F(), getAssembler(), llvm::MCDataFragment::getContents(), llvm::MCSymbolData::getFragment(), getOrCreateDataFragment(), llvm::MCAssembler::getOrCreateSymbolData(), llvm::MCSymbolData::setFragment(), llvm::MCSymbolData::setOffset(), and llvm::SmallVectorTemplateCommon< T, typename >::size().

Referenced by EmitDebugLabel(), and EmitValueToOffset().

void MCObjectStreamer::EmitSLEB128Value ( const MCExpr Value) [virtual]
void MCObjectStreamer::EmitULEB128Value ( const MCExpr Value) [virtual]
void MCObjectStreamer::EmitValueImpl ( const MCExpr Value,
unsigned  Size,
unsigned  AddrSpace 
) [virtual]

EmitValue - Emit the expression Value into the output as a native integer of the given Size bytes.

This is used to implement assembler directives such as .word, .quad, etc.

Parameters:
Value- The value to emit.
Size- The size of the integer (in bytes) to emit. This must match a native machine width.

Implements llvm::MCStreamer.

Reimplemented in llvm::MCELFStreamer.

Definition at line 101 of file MCObjectStreamer.cpp.

References AddValueSymbols(), llvm::MCFixup::Create(), llvm::X86II::DF, llvm::MCStreamer::EmitIntValue(), getAssembler(), llvm::MCDataFragment::getContents(), llvm::MCDataFragment::getFixups(), llvm::MCFixup::getKindForSize(), getOrCreateDataFragment(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::SmallVectorImpl< T >::resize(), and llvm::SmallVectorTemplateCommon< T, typename >::size().

void MCObjectStreamer::EmitValueToAlignment ( unsigned  ByteAlignment,
int64_t  Value = 0,
unsigned  ValueSize = 1,
unsigned  MaxBytesToEmit = 0 
) [virtual]

EmitValueToAlignment - Emit some number of copies of Value until the byte alignment ByteAlignment is reached.

If the number of bytes need to emit for the alignment is not a multiple of ValueSize, then the contents of the emitted fill bytes is undefined.

This used to implement the .align assembler directive.

Parameters:
ByteAlignment- The alignment to reach. This must be a power of two on some targets.
Value- The value to use when filling bytes.
ValueSize- The size of the integer (in bytes) to emit for Value. This must match a native machine width.
MaxBytesToEmit- The maximum numbers of bytes to emit, or 0. If the alignment cannot be reached in this many bytes, no bytes are emitted.

Implements llvm::MCStreamer.

Reimplemented in llvm::MCELFStreamer.

Definition at line 295 of file MCObjectStreamer.cpp.

References llvm::LCOMM::ByteAlignment, getCurrentSectionData(), insert(), and llvm::MCSectionData::setAlignment().

Referenced by EmitCodeAlignment().

bool MCObjectStreamer::EmitValueToOffset ( const MCExpr Offset,
unsigned char  Value 
) [virtual]

EmitValueToOffset - Emit some number of copies of Value until the byte offset Offset is reached.

This is used to implement assembler directives such as .org.

Parameters:
Offset- The offset to reach. This may be an expression, but the expression must be associated with the current section.
Value- The value to use when filling bytes.
Returns:
false on success, true if the offset was invalid.

Implements llvm::MCStreamer.

Definition at line 314 of file MCObjectStreamer.cpp.

References llvm::MCSymbolRefExpr::Create(), llvm::MCBinaryExpr::Create(), llvm::MCContext::CreateTempSymbol(), EmitFill(), EmitLabel(), getAssembler(), llvm::MCStreamer::getContext(), insert(), llvm::MCBinaryExpr::Sub, and llvm::MCSymbolRefExpr::VK_None.

void MCObjectStreamer::EmitWeakReference ( MCSymbol Alias,
const MCSymbol Symbol 
) [virtual]

EmitWeakReference - Emit an weak reference from Alias to Symbol.

This corresponds to an assembler statement such as: .weakref alias, symbol

Parameters:
Alias- The alias that is being created.
Symbol- The symbol being aliased.

Implements llvm::MCStreamer.

Reimplemented in llvm::MCELFStreamer.

Definition at line 165 of file MCObjectStreamer.cpp.

References llvm::report_fatal_error().

void MCObjectStreamer::FinishImpl ( ) [virtual]

FinishImpl - Streamer specific finalization.

Implements llvm::MCStreamer.

Reimplemented in llvm::MCELFStreamer.

Definition at line 362 of file MCObjectStreamer.cpp.

References llvm::MCDwarfFileTable::Emit(), llvm::MCGenDwarfInfo::Emit(), llvm::MCAssembler::Finish(), getAssembler(), and llvm::MCStreamer::getContext().

MCAssembler& llvm::MCObjectStreamer::getAssembler ( ) [inline]
MCFragment * MCObjectStreamer::getCurrentFragment ( ) const [protected]
MCSectionData* llvm::MCObjectStreamer::getCurrentSectionData ( ) const [inline, protected]
MCDataFragment * MCObjectStreamer::getOrCreateDataFragment ( ) const [protected]

Get a data fragment to write into, creating a new one if the current fragment is not a data fragment.

Definition at line 62 of file MCObjectStreamer.cpp.

References F(), getCurrentFragment(), llvm::MCDataFragment::hasInstructions(), insert(), and llvm::MCAssembler::isBundlingEnabled().

Referenced by EmitBytes(), EmitFill(), EmitGPRel32Value(), EmitGPRel64Value(), EmitLabel(), and EmitValueImpl().

void llvm::MCObjectStreamer::insert ( MCFragment F) const [inline, protected]
void MCObjectStreamer::reset ( ) [virtual]

state management

Reimplemented from llvm::MCStreamer.

Definition at line 45 of file MCObjectStreamer.cpp.

References llvm::MCAssembler::reset().


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