llvm::MCStreamer

Streaming machine code generation interface.

Synopsis

Declared in <llvm/MC/MCStreamer.h>

class MCStreamer;

Description

This interface is intended to provide a programmatic interface that is very similar to the level that an assembler .s file provides. It has callbacks to emit bytes, handle 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.

Member Functions

NameDescription
MCStreamer [constructor] [deleted]Copy constructor
~MCStreamer [destructor] [virtual]Destructor
operator= [deleted]Copy assignment operator
AddComment [virtual]Add a textual comment.
EnsureValidWinFrameInfo Retrieve the current frame info if one is available and it is not yet closed. Otherwise, issue an error and return null.
addBlankLine [virtual]Emit a blank line to a .s file to pretty it up.
addExplicitComment [virtual]Add explicit comment T. T is required to be a valid comment in the output and does not need to be escaped.
beginCOFFSymbolDef [virtual]Start emitting COFF symbol definition
emitAbsoluteSymbolDiff [virtual]Emit the absolute difference between two symbols.
emitAbsoluteSymbolDiffAsULEB128 [virtual]Emit the absolute difference between two symbols encoded with ULEB128.
emitAddrsig [virtual]
emitAddrsigSym [virtual]
emitAssignment [virtual]Emit an assignment of Value to Symbol.
emitBinaryData [virtual]Functionally identical to EmitBytes. When emitting textual assembly, this method uses .byte directives instead of .ascii or .asciz for readability.
emitBuildVersion [virtual]Emit/Specify Mach-O build version command. Platform should be one of MachO::PlatformType.
emitBundleAlignMode [virtual]Enable aligned instruction bundling with the given bundle size, from this point onward. Once enabled, bundling cannot be disabled and the bundle size cannot be changed. Alignment must be within [2, 2^30]. The default implementations report an error: silently emitting unbundled code would defeat the sandboxing schemes bundling exists for.
emitBundleLock [virtual]The following instructions are a bundle-locked group.
emitBundleUnlock [virtual]Ends a bundle-locked group.
emitBytes [virtual]Emit the bytes in Data into the output.
emitCFIAdjustCfaOffset [virtual]
emitCFIBKeyFrame [virtual]
emitCFIDefCfa [virtual]
emitCFIDefCfaOffset [virtual]
emitCFIDefCfaRegister [virtual]
emitCFIEndProc
emitCFIEscape [virtual]
emitCFIGnuArgsSize [virtual]
emitCFILLVMDefAspaceCfa [virtual]
emitCFILLVMRegisterPair [virtual]
emitCFILLVMSetRAState
emitCFILLVMVectorOffset [virtual]
emitCFILLVMVectorRegisterMask [virtual]
emitCFILLVMVectorRegisters [virtual]
emitCFILabel [virtual]When emitting an object file, create and emit a real label. When emitting textual assembly, this should do nothing to avoid polluting our output.
emitCFILabelDirective [virtual]
emitCFILsda [virtual]
emitCFIMTETaggedFrame [virtual]
emitCFINegateRAState [virtual]
emitCFINegateRAStateWithPC [virtual]
emitCFIOffset [virtual]
emitCFIPersonality [virtual]
emitCFIRegister [virtual]
emitCFIRelOffset [virtual]
emitCFIRememberState [virtual]
emitCFIRestore [virtual]
emitCFIRestoreState [virtual]
emitCFIReturnColumn [virtual]
emitCFISameValue [virtual]
emitCFISections [virtual]
emitCFISignalFrame [virtual]
emitCFIStartProc
emitCFIUndefined [virtual]
emitCFIValOffset [virtual]
emitCFIWindowSave [virtual]
emitCGProfileEntry [virtual]
emitCOFFImgRel32 [virtual]Emits a COFF image relative relocation.
emitCOFFSafeSEH [virtual]
emitCOFFSecNumber [virtual]Emits the physical number of the section containing the given symbol as assigned during object writing (i.e., this is not a runtime relocation).
emitCOFFSecOffset [virtual]Emits the offset of the symbol from the beginning of the section during object writing (i.e., this is not a runtime relocation).
emitCOFFSecRel32 [virtual]Emits a COFF section relative relocation.
emitCOFFSectionIndex [virtual]Emits a COFF section index.
emitCOFFSymbolIndex [virtual]Emits the symbol table index of a Symbol into the current section.
emitCOFFSymbolStorageClass [virtual]Emit the storage class of the symbol.
emitCOFFSymbolType [virtual]Emit the type of the symbol.
emitCVDefRangeDirective This implements the CodeView '.cv_def_range' assembler directive.
emitCVFPOData [virtual]This implements the CodeView '.cv_fpo_data' assembler directive.
emitCVFileChecksumOffsetDirective [virtual]This implements the CodeView '.cv_filechecksumoffset' assembler directive.
emitCVFileChecksumsDirective [virtual]This implements the CodeView '.cv_filechecksums' assembler directive.
emitCVFileDirective [virtual]Associate a filename with a specified logical file number, and also specify that file's checksum information. This implements the '.cv_file 4 "foo.c"' assembler directive. Returns true on success.
emitCVFuncIdDirective [virtual]Introduces a function id for use with .cv_loc.
emitCVInlineLinetableDirective [virtual]This implements the CodeView '.cv_inline_linetable' assembler directive.
emitCVInlineSiteIdDirective [virtual]Introduces an inline call site id for use with .cv_loc. Includes extra information for inline line table generation.
emitCVLinetableDirective [virtual]This implements the CodeView '.cv_linetable' assembler directive.
emitCVLocDirective [virtual]This implements the CodeView '.cv_loc' assembler directive.
emitCVStringTableDirective [virtual]This implements the CodeView '.cv_stringtable' assembler directive.
emitCodeAlignment [virtual]Emit nops until the byte alignment ByteAlignment is reached.
emitCommonSymbol [virtual]Emit a common symbol.
emitConditionalAssignment [virtual]Emit an assignment of Value to Symbol, but only if Value is also emitted.
emitDarwinTargetVariantBuildVersion [virtual]
emitDataRegion [virtual]Note in the output the specified region Kind.
emitDwarfAdvanceLineAddr [virtual]If targets does not support representing debug line section by .loc/.file directives in assembly output, we need to populate debug line section with raw debug line contents.
emitDwarfFile0Directive [virtual]Specify the "root" file of the compilation, using the ".file 0" extension.
emitDwarfFileDirective Associate a filename with a specified logical file number. This implements the DWARF2 '.file 4 "foo.c"' assembler directive.
emitDwarfLineEndEntry [virtual]Emit the debug line end entry.
emitDwarfLineStartLabel [virtual]Emit the debug line start label.
emitDwarfLocDirective [virtual]This implements the DWARF2 '.loc fileno lineno ...' assembler directive.
emitDwarfLocDirectiveWithInlinedAt [virtual]This is same as emitDwarfLocDirective, except it has the capability to add inlined_at information.
emitDwarfLocLabelDirective [virtual]This implements the '.loc_label Name' directive.
emitDwarfUnitLength emitDwarfUnitLength overloads
emitEHSymAttributes [virtual]
emitELFSize [virtual]Emit an ELF .size directive.
emitELFSymverDirective [virtual]Emit an ELF .symver directive.
emitExplicitComments [virtual]Emit added explicit comments.
emitFileDirective emitFileDirective overloads
emitFill emitFill overloads
emitGNUAttribute [virtual]Emit a .gnu_attribute directive.
emitIdent [virtual]Emit the "identifiers" directive. This implements the '.ident "version foo"' assembler directive.
emitInstruction [virtual]Emit the given Instruction into the current section.
emitInt16
emitInt32
emitInt64
emitInt8
emitIntValue Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers.
emitIntValueInHex [virtual]Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers & prints in Hex format for certain modes.
emitIntValueInHexWithPadding [virtual]Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers & prints in Hex format for certain modes, pads the field with leading zeros to Size width
emitLOHDirective [virtual]Emit a Linker Optimization Hint (LOH) directive.
emitLabel [virtual]Emit a label for Symbol into the current section.
emitLineTableLabel
emitLinkerOptions [virtual]Emit the given list Options of strings as linker options into the output.
emitLocalCommonSymbol [virtual]Emit a local common (.lcomm) symbol.
emitNops [virtual]
emitPrefAlign [virtual]
emitPseudoProbe [virtual]Emit the a pseudo probe into the current section.
emitRawComment [virtual]Print T and prefix it with the comment string (normally #) and optionally a tab. This prints the comment immediately, not at the end of the current line. It is basically a safe version of EmitRawText: since it only prints comments, the object streamer ignores it instead of asserting.
emitRawText If this file is backed by a assembly streamer, this dumps the specified string in the output .s file. This capability is indicated by the hasRawTextSupport() predicate. By default this aborts.
emitRelocDirective [virtual]Record a relocation described by the .reloc directive.
emitSLEB128IntValue Special case of EmitSLEB128Value that avoids the client having to pass in a MCExpr for constant integers.
emitSLEB128Value [virtual]
emitSubsectionsViaSymbols [virtual]Emit a .subsection_via_symbols directive.
emitSymbolAttribute [virtual]Add the given Attribute to Symbol.
emitSymbolDesc [virtual]Set the DescValue for the Symbol.
emitSymbolValue Special case of EmitValue that avoids the client having to pass in a MCExpr for MCSymbols.
emitSyntaxDirective [virtual]
emitTBSSSymbol [virtual]Emit a thread local bss (.tbss) symbol.
emitTargetTriple [virtual]
emitULEB128IntValue Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integers.
emitULEB128Value [virtual]
emitValue
emitValueImpl [virtual]Emit the expression Value into the output as a native integer of the given Size bytes.
emitValueToAlignment [virtual]Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
emitValueToOffset [virtual]Emit some number of copies of Value until the byte offset Offset is reached.
emitVersionForTarget
emitVersionMin [virtual]Specify the Mach-O minimum deployment target version.
emitWeakReference [virtual]Emit an weak reference from Alias to Symbol.
emitWinCFIAllocStack [virtual]
emitWinCFIBeginEpilogue [virtual]
emitWinCFIEndEpilogue [virtual]
emitWinCFIEndProc [virtual]
emitWinCFIEndProlog [virtual]
emitWinCFIFuncletOrFuncEnd [virtual]This is used on platforms, such as Windows on ARM64, that require function or funclet sizes to be emitted in .xdata before the End marker is emitted for the frame. We cannot use the End marker, as it is not set at the point of emitting .xdata, in order to indicate that the frame is active.
emitWinCFIPush2Regs [virtual]
emitWinCFIPushFrame [virtual]
emitWinCFIPushReg [virtual]
emitWinCFISaveReg [virtual]
emitWinCFISaveXMM [virtual]
emitWinCFISetFrame [virtual]
emitWinCFISplitChained [virtual]
emitWinCFIStartProc [virtual]
emitWinCFIUnwindV2Start [virtual]
emitWinCFIUnwindVersion [virtual]
emitWinEHHandler [virtual]
emitWinEHHandlerData [virtual]
emitXCOFFCInfoSym [virtual]Emit a C_INFO symbol with XCOFF embedded metadata to the .info section.
emitXCOFFExceptDirective [virtual]Emit an XCOFF .except directive which adds information about a trap instruction to the object file exception section
emitXCOFFLocalCommonSymbol [virtual]Emits an lcomm directive with XCOFF csect information.
emitXCOFFRefDirective [virtual]Emit a XCOFF .ref directive which creates R_REF type entry in the relocation table for one or more symbols.
emitXCOFFRenameDirective [virtual]Emit a XCOFF .rename directive which creates a synonym for an illegal or undesirable name.
emitXCOFFSymbolLinkageWithVisibility [virtual]Emit a symbol's linkage and visibility with a linkage directive for XCOFF.
emitZerofill [virtual]Emit the zerofill section and an optional symbol.
emitZeros Emit NumBytes worth of zeros. This function properly handles data in virtual sections.
endCOFFSymbolDef [virtual]Marks the end of the symbol definition.
endSection
finish Finish emission of machine code.
finishImpl [virtual]Streamer specific finalization.
getAllowAutoPadding
getAssemblerPtr [virtual]
getAssociatedPDataSection Get the .pdata section used for the given section. Typically the given section is either the main .text section or some other COMDAT .text section, but it may be any section containing code.
getAssociatedXDataSection Get the .xdata section used for the given section.
getCommentOS [virtual]Return a raw_ostream that comments can be written to. Unlike AddComment, you are required to terminate comments with if you use this method.
getContext
getCurFragSize
getCurrentFragment
getCurrentSection Return the current section that the streamer is emitting code to.
getCurrentSectionOnly
getCurrentWinEpilog
getDefaultWinCFIUnwindVersion
getDwarfFrameInfos
getDwarfLineTableSymbol [virtual]
getLFIRewriter
getMnemonic [virtual]Returns the mnemonic for MI, if the streamer has access to a instruction printer and returns an empty string otherwise.
getNumFrameInfos
getNumWinFrameInfos
getPreviousSection Return the previous section that the streamer is emitting code to.
getStartTokLoc
getTargetStreamer
getUseAssemblerInfoForParsing
getWinFrameInfos
hasRawTextSupport [virtual]Return true if this asm streamer supports emitting unformatted text to the .s file with EmitRawText.
hasUnfinishedDwarfFrameInfo
initSections [virtual]Create the default sections and set the initial one.
isInEpilogCFI
isIntegratedAssemblerRequired [virtual]Is the integrated assembler required for this streamer to function correctly?
isObj
isVerboseAsm [virtual]Return true if this streamer supports verbose assembly and if it is enabled.
isWinCFIPrologEnded Returns true if a WinCFI prolog has been completed (.seh_endprologue) in the current frame.
mayHaveInstructions [virtual]
maybeEmitDwarf64Mark Emit a special value of 0xffffffff if producing 64-bit debugging info.
popSection [virtual]Restore the current and previous section from the section stack. Calls changeSection as needed.
pushSection Save the current and previous section on the section stack.
reset [virtual]State management
setAllowAutoPadding
setDefaultWinCFIUnwindVersion Set the default unwind version for new WinCFI frames.
setLFIRewriter
setStartTokLocPtr
setTargetStreamer
setUseAssemblerInfoForParsing
switchSection Set the current section where code is being emitted to Section. This is required to update CurSection.
switchSectionNoPrint Similar to switchSection, but does not print the section directive.
tryEmitDwarfFileDirective [virtual]Associate a filename with a specified logical file number. Also associate a directory, optional checksum, and optional source text with the logical file. This implements the DWARF2 '.file 4 "dir/foo.c"' assembler directive, and the DWARF5 '.file 4 "dir/foo.c" md5 "..." source "..."' assembler directive.
visitUsedExpr
visitUsedSymbol [virtual]

Protected Member Functions

NameDescription
MCStreamer [constructor]Construct from MCContext
addFragment
changeSection [virtual]This is called by popSection and switchSection, if the current section changes.
checkCVLocSection Returns true if the .cv_loc directive is in the right section.
emitCFIEndProcImpl [virtual]
emitCFIStartProcImpl [virtual]
emitRawTextImpl [virtual]
emitWindowsUnwindTables
getCurrentWinFrameInfo

Protected Data Members

Name
CurFrag
CurrentWinEpilog
DwarfFrameInfos
IsObj
LFIRewriter

Non-Member Functions

NameDescription
createAsmStreamerCreate a machine code streamer which will print out assembly for the native target, suitable for compiling with a native assembler.
createNullStreamerCreate a dummy machine code streamer, which does nothing. This is useful for timing the assembler front end.

Derived Classes

NameDescription
CFIFunctionFrameStreamer This class is an MCStreamer implementation that watches for machine instructions and CFI directives. It cuts the stream into function frames and channels them to CFIFunctionFrameReceiver. A function frame is the machine instructions and CFI directives that are between .cfi_startproc and .cfi_endproc directives.
MCAsmBaseStreamer
MCObjectStreamer Streaming object file generation interface.