LLVM 19.0.0git
Classes | Public Types | Public Member Functions | Public Attributes | Friends | List of all members
llvm::MCAssembler Class Reference

#include "llvm/MC/MCAssembler.h"

Classes

struct  CGProfileEntry
 
struct  Symver
 

Public Types

using SectionListType = std::vector< MCSection * >
 
using SymbolDataListType = std::vector< const MCSymbol * >
 
using const_iterator = pointee_iterator< SectionListType::const_iterator >
 
using iterator = pointee_iterator< SectionListType::iterator >
 
using const_symbol_iterator = pointee_iterator< SymbolDataListType::const_iterator >
 
using symbol_iterator = pointee_iterator< SymbolDataListType::iterator >
 
using symbol_range = iterator_range< symbol_iterator >
 
using const_symbol_range = iterator_range< const_symbol_iterator >
 
using const_indirect_symbol_iterator = std::vector< IndirectSymbolData >::const_iterator
 
using indirect_symbol_iterator = std::vector< IndirectSymbolData >::iterator
 
using const_data_region_iterator = std::vector< DataRegionData >::const_iterator
 
using data_region_iterator = std::vector< DataRegionData >::iterator
 
using VersionInfoType = { bool EmitBuildVersion
 MachO specific deployment target version info.
 

Public Member Functions

 MCAssembler (MCContext &Context, std::unique_ptr< MCAsmBackend > Backend, std::unique_ptr< MCCodeEmitter > Emitter, std::unique_ptr< MCObjectWriter > Writer)
 Construct a new assembler instance.
 
 MCAssembler (const MCAssembler &)=delete
 
MCAssembleroperator= (const MCAssembler &)=delete
 
 ~MCAssembler ()
 
uint64_t computeFragmentSize (const MCAsmLayout &Layout, const MCFragment &F) const
 Compute the effective fragment size assuming it is laid out at the given SectionAddress and FragmentOffset.
 
const MCSymbolgetAtom (const MCSymbol &S) const
 Find the symbol which defines the atom containing the given symbol, or null if there is no such symbol.
 
bool isSymbolLinkerVisible (const MCSymbol &SD) const
 Check whether a particular symbol is visible to the linker and is required in the symbol table, or whether it can be discarded by the assembler.
 
void writeSectionData (raw_ostream &OS, const MCSection *Section, const MCAsmLayout &Layout) const
 Emit the section contents to OS.
 
bool isThumbFunc (const MCSymbol *Func) const
 Check whether a given symbol has been flagged with .thumb_func.
 
void setIsThumbFunc (const MCSymbol *Func)
 Flag a function symbol as the target of a .thumb_func directive.
 
unsigned getELFHeaderEFlags () const
 ELF e_header flags.
 
void setELFHeaderEFlags (unsigned Flags)
 
const VersionInfoTypegetVersionInfo () const
 MachO deployment target version information.
 
void setVersionMin (MCVersionMinType Type, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion=VersionTuple())
 
void setBuildVersion (MachO::PlatformType Platform, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion=VersionTuple())
 
const VersionInfoTypegetDarwinTargetVariantVersionInfo () const
 
void setDarwinTargetVariantBuildVersion (MachO::PlatformType Platform, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
 
void reset ()
 Reuse an assembler instance.
 
MCContextgetContext () const
 
MCAsmBackendgetBackendPtr () const
 
MCCodeEmittergetEmitterPtr () const
 
MCObjectWritergetWriterPtr () const
 
MCAsmBackendgetBackend () const
 
MCCodeEmittergetEmitter () const
 
MCObjectWritergetWriter () const
 
MCDwarfLineTableParams getDWARFLinetableParams () const
 
void setDWARFLinetableParams (MCDwarfLineTableParams P)
 
void Finish ()
 Finish - Do final processing and write the object to the output stream.
 
void layout (MCAsmLayout &Layout)
 
bool getSubsectionsViaSymbols () const
 
void setSubsectionsViaSymbols (bool Value)
 
bool isIncrementalLinkerCompatible () const
 
void setIncrementalLinkerCompatible (bool Value)
 
bool getRelaxAll () const
 
void setRelaxAll (bool Value)
 
bool isBundlingEnabled () const
 
unsigned getBundleAlignSize () const
 
void setBundleAlignSize (unsigned Size)
 
void dump () const
 
Section List Access
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
size_t size () const
 
Symbol List Access
symbol_iterator symbol_begin ()
 
const_symbol_iterator symbol_begin () const
 
symbol_iterator symbol_end ()
 
const_symbol_iterator symbol_end () const
 
symbol_range symbols ()
 
const_symbol_range symbols () const
 
size_t symbol_size () const
 
Indirect Symbol List Access
std::vector< IndirectSymbolData > & getIndirectSymbols ()
 
indirect_symbol_iterator indirect_symbol_begin ()
 
const_indirect_symbol_iterator indirect_symbol_begin () const
 
indirect_symbol_iterator indirect_symbol_end ()
 
const_indirect_symbol_iterator indirect_symbol_end () const
 
size_t indirect_symbol_size () const
 
Linker Option List Access
std::vector< std::vector< std::string > > & getLinkerOptions ()
 
Backend Data Access
bool registerSection (MCSection &Section)
 
bool registerSymbol (const MCSymbol &Symbol)
 
MutableArrayRef< std::pair< std::string, size_t > > getFileNames ()
 
void addFileName (StringRef FileName)
 
void setCompilerVersion (std::string CompilerVers)
 
StringRef getCompilerVersion ()
 
void writeFragmentPadding (raw_ostream &OS, const MCEncodedFragment &F, uint64_t FSize) const
 Write the necessary bundle padding to OS.
 

Public Attributes

union {
   MCVersionMinType   Type
 Used when EmitBuildVersion==false. More...
 
   MachO::PlatformType   Platform
 Used when EmitBuildVersion==true. More...
 
TypeOrPlatform
 
unsigned Major
 
unsigned Minor
 
unsigned Update
 
VersionTuple SDKVersion
 An optional version of the SDK that was used to build the source.
 
std::vector< SymverSymvers
 

Friends

class MCAsmLayout
 

Data Region List Access

std::vector< CGProfileEntryCGProfile
 
std::vector< DataRegionData > & getDataRegions ()
 
data_region_iterator data_region_begin ()
 
const_data_region_iterator data_region_begin () const
 
data_region_iterator data_region_end ()
 
const_data_region_iterator data_region_end () const
 
size_t data_region_size () const
 
MCLOHContainergetLOHContainer ()
 
const MCLOHContainergetLOHContainer () const
 

Detailed Description

Definition at line 73 of file MCAssembler.h.

Member Typedef Documentation

◆ const_data_region_iterator

Definition at line 94 of file MCAssembler.h.

◆ const_indirect_symbol_iterator

Definition at line 90 of file MCAssembler.h.

◆ const_iterator

using llvm::MCAssembler::const_iterator = pointee_iterator<SectionListType::const_iterator>

Definition at line 80 of file MCAssembler.h.

◆ const_symbol_iterator

using llvm::MCAssembler::const_symbol_iterator = pointee_iterator<SymbolDataListType::const_iterator>

Definition at line 83 of file MCAssembler.h.

◆ const_symbol_range

Definition at line 88 of file MCAssembler.h.

◆ data_region_iterator

Definition at line 96 of file MCAssembler.h.

◆ indirect_symbol_iterator

Definition at line 92 of file MCAssembler.h.

◆ iterator

using llvm::MCAssembler::iterator = pointee_iterator<SectionListType::iterator>

Definition at line 81 of file MCAssembler.h.

◆ SectionListType

Definition at line 77 of file MCAssembler.h.

◆ symbol_iterator

using llvm::MCAssembler::symbol_iterator = pointee_iterator<SymbolDataListType::iterator>

Definition at line 85 of file MCAssembler.h.

◆ symbol_range

Definition at line 87 of file MCAssembler.h.

◆ SymbolDataListType

Definition at line 78 of file MCAssembler.h.

◆ VersionInfoType

using llvm::MCAssembler::VersionInfoType = { bool EmitBuildVersion

MachO specific deployment target version info.

Definition at line 101 of file MCAssembler.h.

Constructor & Destructor Documentation

◆ MCAssembler() [1/2]

MCAssembler::MCAssembler ( MCContext Context,
std::unique_ptr< MCAsmBackend Backend,
std::unique_ptr< MCCodeEmitter Emitter,
std::unique_ptr< MCObjectWriter Writer 
)

Construct a new assembler instance.

Definition at line 84 of file MCAssembler.cpp.

References Context.

◆ MCAssembler() [2/2]

llvm::MCAssembler::MCAssembler ( const MCAssembler )
delete

◆ ~MCAssembler()

MCAssembler::~MCAssembler ( )
default

Member Function Documentation

◆ addFileName()

void llvm::MCAssembler::addFileName ( StringRef  FileName)
inline

Definition at line 487 of file MCAssembler.h.

Referenced by llvm::MCObjectStreamer::emitFileDirective().

◆ begin() [1/2]

iterator llvm::MCAssembler::begin ( )
inline

Definition at line 378 of file MCAssembler.h.

Referenced by dump().

◆ begin() [2/2]

const_iterator llvm::MCAssembler::begin ( ) const
inline

Definition at line 379 of file MCAssembler.h.

◆ computeFragmentSize()

uint64_t MCAssembler::computeFragmentSize ( const MCAsmLayout Layout,
const MCFragment F 
) const

◆ data_region_begin() [1/2]

data_region_iterator llvm::MCAssembler::data_region_begin ( )
inline

Definition at line 446 of file MCAssembler.h.

◆ data_region_begin() [2/2]

const_data_region_iterator llvm::MCAssembler::data_region_begin ( ) const
inline

Definition at line 447 of file MCAssembler.h.

◆ data_region_end() [1/2]

data_region_iterator llvm::MCAssembler::data_region_end ( )
inline

Definition at line 451 of file MCAssembler.h.

◆ data_region_end() [2/2]

const_data_region_iterator llvm::MCAssembler::data_region_end ( ) const
inline

Definition at line 452 of file MCAssembler.h.

◆ data_region_size()

size_t llvm::MCAssembler::data_region_size ( ) const
inline

Definition at line 456 of file MCAssembler.h.

◆ dump()

LLVM_DUMP_METHOD void MCAssembler::dump ( ) const

Definition at line 1267 of file MCAssembler.cpp.

References begin(), end(), llvm::errs(), OS, symbol_begin(), and symbol_end().

Referenced by layout().

◆ end() [1/2]

iterator llvm::MCAssembler::end ( )
inline

Definition at line 381 of file MCAssembler.h.

Referenced by dump().

◆ end() [2/2]

const_iterator llvm::MCAssembler::end ( ) const
inline

Definition at line 382 of file MCAssembler.h.

◆ Finish()

void MCAssembler::Finish ( )

Finish - Do final processing and write the object to the output stream.

Writer is used for custom object writer (as the MCJIT does), if not specified it is automatically created from backend.

Definition at line 948 of file MCAssembler.cpp.

References getWriter(), layout(), and llvm::MCObjectWriter::writeObject().

Referenced by llvm::MCObjectStreamer::finishImpl().

◆ getAtom()

const MCSymbol * MCAssembler::getAtom ( const MCSymbol S) const

Find the symbol which defines the atom containing the given symbol, or null if there is no such symbol.

Definition at line 177 of file MCAssembler.cpp.

References llvm::MCFragment::getAtom(), getContext(), llvm::MCSymbol::getFragment(), llvm::MCFragment::getParent(), llvm::MCSymbol::isInSection(), and isSymbolLinkerVisible().

◆ getBackend()

MCAsmBackend & llvm::MCAssembler::getBackend ( ) const
inline

◆ getBackendPtr()

MCAsmBackend * llvm::MCAssembler::getBackendPtr ( ) const
inline

◆ getBundleAlignSize()

unsigned llvm::MCAssembler::getBundleAlignSize ( ) const
inline

◆ getCompilerVersion()

StringRef llvm::MCAssembler::getCompilerVersion ( )
inline

Definition at line 495 of file MCAssembler.h.

◆ getContext()

MCContext & llvm::MCAssembler::getContext ( ) const
inline

◆ getDarwinTargetVariantVersionInfo()

const VersionInfoType & llvm::MCAssembler::getDarwinTargetVariantVersionInfo ( ) const
inline

Definition at line 307 of file MCAssembler.h.

Referenced by llvm::MachObjectWriter::writeObject().

◆ getDataRegions()

std::vector< DataRegionData > & llvm::MCAssembler::getDataRegions ( )
inline

Definition at line 444 of file MCAssembler.h.

◆ getDWARFLinetableParams()

MCDwarfLineTableParams llvm::MCAssembler::getDWARFLinetableParams ( ) const
inline

Definition at line 340 of file MCAssembler.h.

Referenced by llvm::MCObjectStreamer::emitDwarfAdvanceLineAddr().

◆ getELFHeaderEFlags()

unsigned llvm::MCAssembler::getELFHeaderEFlags ( ) const
inline

◆ getEmitter()

MCCodeEmitter & llvm::MCAssembler::getEmitter ( ) const
inline

◆ getEmitterPtr()

MCCodeEmitter * llvm::MCAssembler::getEmitterPtr ( ) const
inline

◆ getFileNames()

MutableArrayRef< std::pair< std::string, size_t > > llvm::MCAssembler::getFileNames ( )
inline

Definition at line 483 of file MCAssembler.h.

◆ getIndirectSymbols()

std::vector< IndirectSymbolData > & llvm::MCAssembler::getIndirectSymbols ( )
inline

Definition at line 409 of file MCAssembler.h.

◆ getLinkerOptions()

std::vector< std::vector< std::string > > & llvm::MCAssembler::getLinkerOptions ( )
inline

Definition at line 433 of file MCAssembler.h.

◆ getLOHContainer() [1/2]

MCLOHContainer & llvm::MCAssembler::getLOHContainer ( )
inline

Definition at line 465 of file MCAssembler.h.

Referenced by getLOHContainer(), and reset().

◆ getLOHContainer() [2/2]

const MCLOHContainer & llvm::MCAssembler::getLOHContainer ( ) const
inline

Definition at line 466 of file MCAssembler.h.

References getLOHContainer().

◆ getRelaxAll()

bool llvm::MCAssembler::getRelaxAll ( ) const
inline

Definition at line 362 of file MCAssembler.h.

Referenced by canReuseDataFragment(), and llvm::MCAsmLayout::layoutFragment().

◆ getSubsectionsViaSymbols()

bool llvm::MCAssembler::getSubsectionsViaSymbols ( ) const
inline

Definition at line 352 of file MCAssembler.h.

◆ getVersionInfo()

const VersionInfoType & llvm::MCAssembler::getVersionInfo ( ) const
inline

MachO deployment target version information.

Definition at line 285 of file MCAssembler.h.

Referenced by llvm::MachObjectWriter::writeObject().

◆ getWriter()

MCObjectWriter & llvm::MCAssembler::getWriter ( ) const
inline

◆ getWriterPtr()

MCObjectWriter * llvm::MCAssembler::getWriterPtr ( ) const
inline

Definition at line 332 of file MCAssembler.h.

Referenced by reset().

◆ indirect_symbol_begin() [1/2]

indirect_symbol_iterator llvm::MCAssembler::indirect_symbol_begin ( )
inline

Definition at line 413 of file MCAssembler.h.

◆ indirect_symbol_begin() [2/2]

const_indirect_symbol_iterator llvm::MCAssembler::indirect_symbol_begin ( ) const
inline

Definition at line 416 of file MCAssembler.h.

◆ indirect_symbol_end() [1/2]

indirect_symbol_iterator llvm::MCAssembler::indirect_symbol_end ( )
inline

Definition at line 420 of file MCAssembler.h.

◆ indirect_symbol_end() [2/2]

const_indirect_symbol_iterator llvm::MCAssembler::indirect_symbol_end ( ) const
inline

Definition at line 423 of file MCAssembler.h.

◆ indirect_symbol_size()

size_t llvm::MCAssembler::indirect_symbol_size ( ) const
inline

Definition at line 427 of file MCAssembler.h.

◆ isBundlingEnabled()

bool llvm::MCAssembler::isBundlingEnabled ( ) const
inline

◆ isIncrementalLinkerCompatible()

bool llvm::MCAssembler::isIncrementalLinkerCompatible ( ) const
inline

Definition at line 355 of file MCAssembler.h.

◆ isSymbolLinkerVisible()

bool MCAssembler::isSymbolLinkerVisible ( const MCSymbol SD) const

Check whether a particular symbol is visible to the linker and is required in the symbol table, or whether it can be discarded by the assembler.

This also effects whether the assembler treats the label as potentially defining a separate atom.

Definition at line 166 of file MCAssembler.cpp.

Referenced by getAtom().

◆ isThumbFunc()

bool MCAssembler::isThumbFunc ( const MCSymbol Func) const

Check whether a given symbol has been flagged with .thumb_func.

Definition at line 135 of file MCAssembler.cpp.

References llvm::MCExpr::evaluateAsRelocatable(), isThumbFunc(), llvm::Ref, Sym, and llvm::MCSymbolRefExpr::VK_None.

Referenced by isThumbFunc().

◆ layout()

void MCAssembler::layout ( MCAsmLayout Layout)

◆ operator=()

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

◆ registerSection()

bool MCAssembler::registerSection ( MCSection Section)

◆ registerSymbol()

bool MCAssembler::registerSymbol ( const MCSymbol Symbol)

◆ reset()

void MCAssembler::reset ( )

◆ setBuildVersion()

void llvm::MCAssembler::setBuildVersion ( MachO::PlatformType  Platform,
unsigned  Major,
unsigned  Minor,
unsigned  Update,
VersionTuple  SDKVersion = VersionTuple() 
)
inline

Definition at line 296 of file MCAssembler.h.

References Major, Minor, Platform, SDKVersion, and Update.

◆ setBundleAlignSize()

void llvm::MCAssembler::setBundleAlignSize ( unsigned  Size)
inline

Definition at line 369 of file MCAssembler.h.

References assert(), and Size.

Referenced by llvm::MCELFStreamer::emitBundleAlignMode().

◆ setCompilerVersion()

void llvm::MCAssembler::setCompilerVersion ( std::string  CompilerVers)
inline

Definition at line 491 of file MCAssembler.h.

Referenced by llvm::MCObjectStreamer::emitFileDirective().

◆ setDarwinTargetVariantBuildVersion()

void llvm::MCAssembler::setDarwinTargetVariantBuildVersion ( MachO::PlatformType  Platform,
unsigned  Major,
unsigned  Minor,
unsigned  Update,
VersionTuple  SDKVersion 
)
inline

Definition at line 310 of file MCAssembler.h.

References Major, Minor, Platform, SDKVersion, and Update.

◆ setDWARFLinetableParams()

void llvm::MCAssembler::setDWARFLinetableParams ( MCDwarfLineTableParams  P)
inline

Definition at line 341 of file MCAssembler.h.

References P.

◆ setELFHeaderEFlags()

void llvm::MCAssembler::setELFHeaderEFlags ( unsigned  Flags)
inline

◆ setIncrementalLinkerCompatible()

void llvm::MCAssembler::setIncrementalLinkerCompatible ( bool  Value)
inline

Definition at line 358 of file MCAssembler.h.

◆ setIsThumbFunc()

void llvm::MCAssembler::setIsThumbFunc ( const MCSymbol Func)
inline

Flag a function symbol as the target of a .thumb_func directive.

Definition at line 278 of file MCAssembler.h.

References llvm::SmallPtrSetImpl< PtrType >::insert().

◆ setRelaxAll()

void llvm::MCAssembler::setRelaxAll ( bool  Value)
inline

◆ setSubsectionsViaSymbols()

void llvm::MCAssembler::setSubsectionsViaSymbols ( bool  Value)
inline

Definition at line 353 of file MCAssembler.h.

Referenced by llvm::MCELFStreamer::emitAssemblerFlag().

◆ setVersionMin()

void llvm::MCAssembler::setVersionMin ( MCVersionMinType  Type,
unsigned  Major,
unsigned  Minor,
unsigned  Update,
VersionTuple  SDKVersion = VersionTuple() 
)
inline

Definition at line 286 of file MCAssembler.h.

References Major, Minor, SDKVersion, Type, and Update.

◆ size()

size_t llvm::MCAssembler::size ( ) const
inline

Definition at line 384 of file MCAssembler.h.

◆ symbol_begin() [1/2]

symbol_iterator llvm::MCAssembler::symbol_begin ( )
inline

Definition at line 389 of file MCAssembler.h.

Referenced by dump(), and symbols().

◆ symbol_begin() [2/2]

const_symbol_iterator llvm::MCAssembler::symbol_begin ( ) const
inline

Definition at line 390 of file MCAssembler.h.

◆ symbol_end() [1/2]

symbol_iterator llvm::MCAssembler::symbol_end ( )
inline

Definition at line 392 of file MCAssembler.h.

Referenced by dump(), and symbols().

◆ symbol_end() [2/2]

const_symbol_iterator llvm::MCAssembler::symbol_end ( ) const
inline

Definition at line 393 of file MCAssembler.h.

◆ symbol_size()

size_t llvm::MCAssembler::symbol_size ( ) const
inline

Definition at line 400 of file MCAssembler.h.

◆ symbols() [1/2]

symbol_range llvm::MCAssembler::symbols ( )
inline

Definition at line 395 of file MCAssembler.h.

References llvm::make_range(), symbol_begin(), and symbol_end().

◆ symbols() [2/2]

const_symbol_range llvm::MCAssembler::symbols ( ) const
inline

Definition at line 396 of file MCAssembler.h.

References llvm::make_range(), symbol_begin(), and symbol_end().

◆ writeFragmentPadding()

void MCAssembler::writeFragmentPadding ( raw_ostream OS,
const MCEncodedFragment F,
uint64_t  FSize 
) const

◆ writeSectionData()

void MCAssembler::writeSectionData ( raw_ostream OS,
const MCSection Section,
const MCAsmLayout Layout 
) const

Friends And Related Function Documentation

◆ MCAsmLayout

friend class MCAsmLayout
friend

Definition at line 74 of file MCAssembler.h.

Member Data Documentation

◆ CGProfile

std::vector<CGProfileEntry> llvm::MCAssembler::CGProfile

◆ Major

unsigned llvm::MCAssembler::Major

◆ Minor

unsigned llvm::MCAssembler::Minor

◆ Platform

MachO::PlatformType llvm::MCAssembler::Platform

Used when EmitBuildVersion==true.

Definition at line 105 of file MCAssembler.h.

Referenced by setBuildVersion(), and setDarwinTargetVariantBuildVersion().

◆ SDKVersion

VersionTuple llvm::MCAssembler::SDKVersion

An optional version of the SDK that was used to build the source.

Definition at line 111 of file MCAssembler.h.

Referenced by setBuildVersion(), setDarwinTargetVariantBuildVersion(), and setVersionMin().

◆ Symvers

std::vector<Symver> llvm::MCAssembler::Symvers

Definition at line 240 of file MCAssembler.h.

Referenced by llvm::MCELFStreamer::emitELFSymverDirective().

◆ Type

MCVersionMinType llvm::MCAssembler::Type

Used when EmitBuildVersion==false.

Definition at line 104 of file MCAssembler.h.

Referenced by setVersionMin().

◆ 

union { ... } llvm::MCAssembler::TypeOrPlatform

◆ Update

unsigned llvm::MCAssembler::Update

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