LLVM API Documentation

llvm::MCStreamer Class Reference

#include <MCStreamer.h>

Collaboration diagram for llvm::MCStreamer:
[legend]

List of all members.

Public Types

enum  SymbolAttr {
  Global, Hidden, IndirectSymbol, Internal,
  LazyReference, NoDeadStrip, PrivateExtern, Protected,
  Reference, Weak, WeakDefinition, WeakReference,
  SymbolAttrFirst = Global, SymbolAttrLast = WeakReference
}
enum  AssemblerFlag { SubsectionsViaSymbols }

Public Member Functions

virtual ~MCStreamer ()
MCContext & getContext () const
virtual void EmitInstruction (const MCInst &Inst)=0
virtual void Finish ()=0
 Finish - Finish emission of machine code and flush any output.
Symbol & Section Management
virtual void SwitchSection (const MCSection *Section)=0
const MCSection * getCurrentSection () const
virtual void EmitLabel (MCSymbol *Symbol)=0
virtual void EmitAssemblerFlag (AssemblerFlag Flag)=0
 EmitAssemblerFlag - Note in the output the specified.
virtual void EmitAssignment (MCSymbol *Symbol, const MCValue &Value, bool MakeAbsolute=false)=0
virtual void EmitSymbolAttribute (MCSymbol *Symbol, SymbolAttr Attribute)=0
 EmitSymbolAttribute - Add the given.
virtual void EmitSymbolDesc (MCSymbol *Symbol, unsigned DescValue)=0
virtual void EmitLocalSymbol (MCSymbol *Symbol, const MCValue &Value)=0
virtual void EmitCommonSymbol (MCSymbol *Symbol, unsigned Size, unsigned Pow2Alignment, bool IsLocal)=0
virtual void EmitZerofill (MCSection *Section, MCSymbol *Symbol=0, unsigned Size=0, unsigned Pow2Alignment=0)=0
Generating Data
virtual void EmitBytes (const StringRef &Data)=0
virtual void EmitValue (const MCValue &Value, unsigned Size)=0
virtual void EmitValueToAlignment (unsigned ByteAlignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0)=0
virtual void EmitValueToOffset (const MCValue &Offset, unsigned char Value=0)=0

Protected Member Functions

 MCStreamer (MCContext &Ctx)

Protected Attributes

const MCSection * CurSection


Detailed Description

MCStreamer - Streaming machine code generation interface. This interface is intended to provide a programatic interface that is very similar to the level that an assembler .s file provides. It has callbacks to emit bytes, "emit directives", etc. The implementation of this interface retains state to know what the current section is etc.

There are multiple implementations of this interface: one for writing out a .s file, and implementations that write out .o files of various formats.

Definition at line 39 of file MCStreamer.h.


Member Enumeration Documentation

Enumerator:
Global 
Hidden  .globl
IndirectSymbol  .hidden (ELF)
Internal  .indirect_symbol (Apple)
LazyReference  .internal (ELF)
NoDeadStrip  .lazy_reference (Apple)
PrivateExtern  .no_dead_strip (Apple)
Protected  .private_extern (Apple)
Reference  .protected (ELF)
Weak  .reference (Apple)
WeakDefinition  .weak
WeakReference  .weak_definition (Apple)
SymbolAttrFirst  .weak_reference (Apple)
SymbolAttrLast 

Definition at line 41 of file MCStreamer.h.

Enumerator:
SubsectionsViaSymbols  .subsections_via_symbols (Apple)

Definition at line 59 of file MCStreamer.h.


Constructor & Destructor Documentation

MCStreamer::MCStreamer ( MCContext &  Ctx  )  [protected]

Definition at line 14 of file MCStreamer.cpp.

MCStreamer::~MCStreamer (  )  [virtual]

Definition at line 17 of file MCStreamer.cpp.


Member Function Documentation

MCContext& llvm::MCStreamer::getContext (  )  const [inline]

Definition at line 78 of file MCStreamer.h.

virtual void llvm::MCStreamer::SwitchSection ( const MCSection *  Section  )  [pure virtual]

const MCSection* llvm::MCStreamer::getCurrentSection (  )  const [inline]

getCurrentSection - Return the current seciton that the streamer is emitting code to.

Definition at line 92 of file MCStreamer.h.

References CurSection.

Referenced by llvm::AsmPrinter::getCurrentSection().

virtual void llvm::MCStreamer::EmitLabel ( MCSymbol *  Symbol  )  [pure virtual]

EmitLabel - Emit a label for

Parameters:
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.

Referenced by llvm::X86ATTAsmPrinter::printMachineInstruction().

virtual void llvm::MCStreamer::EmitAssemblerFlag ( AssemblerFlag  Flag  )  [pure virtual]

EmitAssemblerFlag - Note in the output the specified.

Parameters:
Flag 

virtual void llvm::MCStreamer::EmitAssignment ( MCSymbol *  Symbol,
const MCValue &  Value,
bool  MakeAbsolute = false 
) [pure virtual]

EmitAssignment - Emit an assignment of

Parameters:
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.
MakeAbsolute - If true, then the symbol should be given the absolute value of
Value,even if
Value would be relocatable expression. This corresponds to the ".set" directive.

virtual void llvm::MCStreamer::EmitSymbolAttribute ( MCSymbol *  Symbol,
SymbolAttr  Attribute 
) [pure virtual]

EmitSymbolAttribute - Add the given.

Parameters:
Attribute to
Symbol. 

virtual void llvm::MCStreamer::EmitSymbolDesc ( MCSymbol *  Symbol,
unsigned  DescValue 
) [pure virtual]

EmitSymbolDesc - Set the

Parameters:
DescValue for the
Symbol. 
Symbol - The symbol to have its n_desc field set.
DescValue - The value to set into the n_desc field.

virtual void llvm::MCStreamer::EmitLocalSymbol ( MCSymbol *  Symbol,
const MCValue &  Value 
) [pure virtual]

EmitLocalSymbol - Emit a local symbol of

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

virtual void llvm::MCStreamer::EmitCommonSymbol ( MCSymbol *  Symbol,
unsigned  Size,
unsigned  Pow2Alignment,
bool  IsLocal 
) [pure virtual]

EmitCommonSymbol - Emit a common or local common symbol of

Parameters:
Size with the
Pow2Alignment if non-zero.
Symbol - The common symbol to emit.
Size - The size of the common symbol.
Pow2Alignment - The alignment of the common symbol if non-zero.
IsLocal - If true, then the symbol is to be a local common

virtual void llvm::MCStreamer::EmitZerofill ( MCSection *  Section,
MCSymbol *  Symbol = 0,
unsigned  Size = 0,
unsigned  Pow2Alignment = 0 
) [pure virtual]

EmitZerofill - Emit a the zerofill section and possiblity a symbol, if

Parameters:
Symbol is non-NULL, for
Size and with the
Pow2Alignment if non-zero.
Section - The zerofill section to create and or to put the symbol
Symbol - The zerofill symbol to emit, if non-NULL.
Size - The size of the zerofill symbol.
Pow2Alignment - The alignment of the zerofill symbol if non-zero.

virtual void llvm::MCStreamer::EmitBytes ( const StringRef &  Data  )  [pure virtual]

EmitBytes - Emit the bytes in

Parameters:
Data into the output.
This is used to implement assembler directives such as .byte, .ascii, etc.

virtual void llvm::MCStreamer::EmitValue ( const MCValue &  Value,
unsigned  Size 
) [pure virtual]

EmitValue - Emit the expression

Parameters:
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.

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

EmitValueToAlignment - Emit some number of copies of

Parameters:
Value until the byte alignment
ByteAlignment is reached.
If the number of bytes need to emit for the alignment is not a multiple of
Parameters:
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.
Size - 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.

Referenced by llvm::AsmPrinter::EmitAlignment().

virtual void llvm::MCStreamer::EmitValueToOffset ( const MCValue &  Offset,
unsigned char  Value = 0 
) [pure virtual]

EmitValueToOffset - Emit some number of copies of

Parameters:
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.

virtual void llvm::MCStreamer::EmitInstruction ( const MCInst &  Inst  )  [pure virtual]

EmitInstruction - Emit the given

Parameters:
Instruction into the current section.

virtual void llvm::MCStreamer::Finish (  )  [pure virtual]

Finish - Finish emission of machine code and flush any output.

Referenced by llvm::AsmPrinter::doFinalization().


Member Data Documentation

CurSection - This is the current section code is being emitted to, it is kept up to date by SwitchSection.

Definition at line 74 of file MCStreamer.h.

Referenced by getCurrentSection().


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