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

#include "llvm/MC/MCAssembler.h"

Classes

struct  CGProfileEntry
 
struct  Symver
 

Public Types

using SectionListType = SmallVector< MCSection *, 0 >
 
using const_iterator = pointee_iterator< SectionListType::const_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 MCFragment &F) const
 Compute the effective fragment size.
 
void layoutBundle (MCFragment *Prev, MCFragment *F) const
 
void ensureValid (MCSection &Sec) const
 
uint64_t getFragmentOffset (const MCFragment &F) const
 
uint64_t getSectionAddressSize (const MCSection &Sec) const
 
uint64_t getSectionFileSize (const MCSection &Sec) const
 
bool getSymbolOffset (const MCSymbol &S, uint64_t &Val) const
 
uint64_t getSymbolOffset (const MCSymbol &S) const
 
const MCSymbolgetBaseSymbol (const MCSymbol &Symbol) const
 
void writeSectionData (raw_ostream &OS, const MCSection *Section) 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 ()
 
bool getSubsectionsViaSymbols () const
 
void setSubsectionsViaSymbols (bool Value)
 
bool isIncrementalLinkerCompatible () const
 
void setIncrementalLinkerCompatible (bool Value)
 
bool hasLayout () const
 
bool getRelaxAll () const
 
void setRelaxAll (bool Value)
 
bool isBundlingEnabled () const
 
unsigned getBundleAlignSize () const
 
void setBundleAlignSize (unsigned Size)
 
const_iterator begin () const
 
const_iterator end () const
 
iterator_range< pointee_iterator< typename SmallVector< const MCSymbol *, 0 >::const_iterator > > symbols () const
 
void dump () const
 
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
 

Linker Option List Access

std::vector< CGProfileEntryCGProfile
 
std::vector< std::vector< std::string > > & getLinkerOptions ()
 
MCLOHContainergetLOHContainer ()
 
const MCLOHContainergetLOHContainer () const
 

Detailed Description

Definition at line 57 of file MCAssembler.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 60 of file MCAssembler.h.

◆ SectionListType

Definition at line 59 of file MCAssembler.h.

◆ VersionInfoType

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

MachO specific deployment target version info.

Definition at line 65 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 82 of file MCAssembler.cpp.

◆ 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 369 of file MCAssembler.h.

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

◆ begin()

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

Definition at line 327 of file MCAssembler.h.

◆ computeFragmentSize()

uint64_t MCAssembler::computeFragmentSize ( const MCFragment F) const

◆ dump()

LLVM_DUMP_METHOD void MCAssembler::dump ( ) const

Definition at line 1337 of file MCAssembler.cpp.

References llvm::MCSection::dump(), llvm::errs(), llvm::First, OS, Sym, and symbols().

Referenced by layout().

◆ end()

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

Definition at line 328 of file MCAssembler.h.

◆ ensureValid()

void MCAssembler::ensureValid ( MCSection Sec) const

◆ 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 1061 of file MCAssembler.cpp.

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

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

◆ getBackend()

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

◆ getBackendPtr()

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

◆ getBaseSymbol()

const MCSymbol * MCAssembler::getBaseSymbol ( const MCSymbol Symbol) const

◆ getBundleAlignSize()

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

◆ getCompilerVersion()

StringRef llvm::MCAssembler::getCompilerVersion ( )
inline

Definition at line 377 of file MCAssembler.h.

◆ getContext()

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

◆ getDarwinTargetVariantVersionInfo()

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

Definition at line 258 of file MCAssembler.h.

◆ getDWARFLinetableParams()

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

Definition at line 291 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 365 of file MCAssembler.h.

◆ getFragmentOffset()

uint64_t MCAssembler::getFragmentOffset ( const MCFragment F) const

Definition at line 468 of file MCAssembler.cpp.

References ensureValid(), and F.

Referenced by computeFragmentSize(), and getSectionAddressSize().

◆ getLinkerOptions()

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

Definition at line 340 of file MCAssembler.h.

◆ getLOHContainer() [1/2]

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

Definition at line 347 of file MCAssembler.h.

Referenced by getLOHContainer(), and reset().

◆ getLOHContainer() [2/2]

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

Definition at line 348 of file MCAssembler.h.

References getLOHContainer().

◆ getRelaxAll()

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

Definition at line 314 of file MCAssembler.h.

◆ getSectionAddressSize()

uint64_t MCAssembler::getSectionAddressSize ( const MCSection Sec) const

◆ getSectionFileSize()

uint64_t MCAssembler::getSectionFileSize ( const MCSection Sec) const

Definition at line 577 of file MCAssembler.cpp.

References getSectionAddressSize(), and llvm::MCSection::isVirtualSection().

Referenced by writeSectionData().

◆ getSubsectionsViaSymbols()

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

Definition at line 303 of file MCAssembler.h.

◆ getSymbolOffset() [1/2]

uint64_t MCAssembler::getSymbolOffset ( const MCSymbol S) const

Definition at line 527 of file MCAssembler.cpp.

References getSymbolOffsetImpl().

◆ getSymbolOffset() [2/2]

bool MCAssembler::getSymbolOffset ( const MCSymbol S,
uint64_t Val 
) const

Definition at line 523 of file MCAssembler.cpp.

References getSymbolOffsetImpl().

Referenced by computeFragmentSize().

◆ getVersionInfo()

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

MachO deployment target version information.

Definition at line 236 of file MCAssembler.h.

◆ getWriter()

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

◆ getWriterPtr()

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

Definition at line 283 of file MCAssembler.h.

Referenced by reset().

◆ hasLayout()

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

Definition at line 313 of file MCAssembler.h.

◆ isBundlingEnabled()

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

◆ isIncrementalLinkerCompatible()

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

Definition at line 306 of file MCAssembler.h.

◆ isThumbFunc()

bool MCAssembler::isThumbFunc ( const MCSymbol Func) const

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

Definition at line 130 of file MCAssembler.cpp.

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

Referenced by isThumbFunc().

◆ layout()

void MCAssembler::layout ( )

◆ layoutBundle()

void MCAssembler::layoutBundle ( MCFragment Prev,
MCFragment F 
) const

◆ 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 247 of file MCAssembler.h.

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

◆ setBundleAlignSize()

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

Definition at line 321 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 373 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 261 of file MCAssembler.h.

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

◆ setDWARFLinetableParams()

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

Definition at line 292 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 309 of file MCAssembler.h.

Referenced by llvm::MCWinCOFFStreamer::MCWinCOFFStreamer().

◆ setIsThumbFunc()

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

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

Definition at line 229 of file MCAssembler.h.

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

◆ setRelaxAll()

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

Definition at line 315 of file MCAssembler.h.

◆ setSubsectionsViaSymbols()

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

Definition at line 304 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 237 of file MCAssembler.h.

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

◆ symbols()

iterator_range< pointee_iterator< typename SmallVector< const MCSymbol *, 0 >::const_iterator > > llvm::MCAssembler::symbols ( ) const
inline

Definition at line 332 of file MCAssembler.h.

References llvm::make_pointee_range().

Referenced by dump().

◆ 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

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 69 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 75 of file MCAssembler.h.

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

◆ Symvers

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

Definition at line 184 of file MCAssembler.h.

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

◆ Type

MCVersionMinType llvm::MCAssembler::Type

Used when EmitBuildVersion==false.

Definition at line 68 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: