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

#include "llvm/MC/MCAssembler.h"

Collaboration diagram for llvm::MCAssembler:
Collaboration graph
[legend]

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 = struct { bool EmitBuildVersion
 MachO specific deployment target version info. More...
 

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. More...
 
 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. More...
 
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. More...
 
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. More...
 
void writeSectionData (raw_ostream &OS, const MCSection *Section, const MCAsmLayout &Layout) const
 Emit the section contents to OS. More...
 
bool isThumbFunc (const MCSymbol *Func) const
 Check whether a given symbol has been flagged with .thumb_func. More...
 
void setIsThumbFunc (const MCSymbol *Func)
 Flag a function symbol as the target of a .thumb_func directive. More...
 
unsigned getELFHeaderEFlags () const
 ELF e_header flags. More...
 
void setELFHeaderEFlags (unsigned Flags)
 
const VersionInfoTypegetVersionInfo () const
 MachO deployment target version information. More...
 
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. More...
 
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. More...
 
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)
 
void registerSymbol (const MCSymbol &Symbol, bool *Created=nullptr)
 
MutableArrayRef< std::pair< std::string, size_t > > getFileNames ()
 
void addFileName (StringRef FileName)
 
void writeFragmentPadding (raw_ostream &OS, const MCEncodedFragment &F, uint64_t FSize) const
 Write the necessary bundle padding to OS. More...
 

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. More...
 
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 60 of file MCAssembler.h.

Member Typedef Documentation

◆ const_data_region_iterator

Definition at line 82 of file MCAssembler.h.

◆ const_indirect_symbol_iterator

Definition at line 78 of file MCAssembler.h.

◆ const_iterator

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

Definition at line 67 of file MCAssembler.h.

◆ const_symbol_iterator

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

Definition at line 71 of file MCAssembler.h.

◆ const_symbol_range

Definition at line 75 of file MCAssembler.h.

◆ data_region_iterator

Definition at line 83 of file MCAssembler.h.

◆ indirect_symbol_iterator

Definition at line 79 of file MCAssembler.h.

◆ iterator

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

Definition at line 68 of file MCAssembler.h.

◆ SectionListType

Definition at line 64 of file MCAssembler.h.

◆ symbol_iterator

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

Definition at line 72 of file MCAssembler.h.

◆ symbol_range

Definition at line 74 of file MCAssembler.h.

◆ SymbolDataListType

Definition at line 65 of file MCAssembler.h.

◆ VersionInfoType

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

MachO specific deployment target version info.

Definition at line 89 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 83 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 470 of file MCAssembler.h.

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

◆ begin() [1/2]

iterator llvm::MCAssembler::begin ( )
inline

Definition at line 360 of file MCAssembler.h.

Referenced by dump().

◆ begin() [2/2]

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

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

◆ data_region_begin() [2/2]

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

Definition at line 429 of file MCAssembler.h.

◆ data_region_end() [1/2]

data_region_iterator llvm::MCAssembler::data_region_end ( )
inline

Definition at line 433 of file MCAssembler.h.

◆ data_region_end() [2/2]

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

Definition at line 434 of file MCAssembler.h.

◆ data_region_size()

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

Definition at line 438 of file MCAssembler.h.

◆ dump()

LLVM_DUMP_METHOD void MCAssembler::dump ( ) const

Definition at line 1238 of file MCAssembler.cpp.

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

Referenced by layout().

◆ end() [1/2]

iterator llvm::MCAssembler::end ( )
inline

Definition at line 363 of file MCAssembler.h.

Referenced by dump().

◆ end() [2/2]

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

Definition at line 364 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 934 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 176 of file MCAssembler.cpp.

References getContext(), isSymbolLinkerVisible(), and S.

◆ getBackend()

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

◆ getBackendPtr()

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

◆ getBundleAlignSize()

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

◆ getContext()

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

◆ getDarwinTargetVariantVersionInfo()

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

Definition at line 289 of file MCAssembler.h.

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

◆ getDataRegions()

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

Definition at line 426 of file MCAssembler.h.

◆ getDWARFLinetableParams()

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

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

◆ getIndirectSymbols()

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

Definition at line 391 of file MCAssembler.h.

◆ getLinkerOptions()

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

Definition at line 415 of file MCAssembler.h.

◆ getLOHContainer() [1/2]

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

Definition at line 447 of file MCAssembler.h.

Referenced by getLOHContainer(), and reset().

◆ getLOHContainer() [2/2]

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

Definition at line 448 of file MCAssembler.h.

References getLOHContainer().

◆ getRelaxAll()

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

Definition at line 344 of file MCAssembler.h.

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

◆ getSubsectionsViaSymbols()

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

Definition at line 334 of file MCAssembler.h.

◆ getVersionInfo()

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

MachO deployment target version information.

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

Referenced by reset().

◆ indirect_symbol_begin() [1/2]

indirect_symbol_iterator llvm::MCAssembler::indirect_symbol_begin ( )
inline

Definition at line 395 of file MCAssembler.h.

◆ indirect_symbol_begin() [2/2]

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

Definition at line 398 of file MCAssembler.h.

◆ indirect_symbol_end() [1/2]

indirect_symbol_iterator llvm::MCAssembler::indirect_symbol_end ( )
inline

Definition at line 402 of file MCAssembler.h.

◆ indirect_symbol_end() [2/2]

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

Definition at line 405 of file MCAssembler.h.

◆ indirect_symbol_size()

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

Definition at line 409 of file MCAssembler.h.

◆ isBundlingEnabled()

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

◆ isIncrementalLinkerCompatible()

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

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

References llvm::ARMBuildAttrs::Symbol.

Referenced by getAtom().

◆ isThumbFunc()

bool MCAssembler::isThumbFunc ( const MCSymbol Func) const

◆ layout()

void MCAssembler::layout ( MCAsmLayout Layout)

◆ operator=()

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

◆ registerSection()

bool MCAssembler::registerSection ( MCSection Section)

◆ registerSymbol()

void MCAssembler::registerSymbol ( const MCSymbol Symbol,
bool *  Created = nullptr 
)

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

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

◆ setBundleAlignSize()

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

Definition at line 351 of file MCAssembler.h.

References assert(), and llvm::Check::Size.

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

◆ setDarwinTargetVariantBuildVersion()

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

Definition at line 292 of file MCAssembler.h.

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

◆ setDWARFLinetableParams()

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

Definition at line 323 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 340 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 260 of file MCAssembler.h.

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

◆ setRelaxAll()

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

Definition at line 345 of file MCAssembler.h.

◆ setSubsectionsViaSymbols()

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

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

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

◆ size()

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

Definition at line 366 of file MCAssembler.h.

◆ symbol_begin() [1/2]

symbol_iterator llvm::MCAssembler::symbol_begin ( )
inline

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

◆ symbol_end() [1/2]

symbol_iterator llvm::MCAssembler::symbol_end ( )
inline

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

◆ symbol_size()

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

Definition at line 382 of file MCAssembler.h.

◆ symbols() [1/2]

symbol_range llvm::MCAssembler::symbols ( )
inline

Definition at line 377 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 378 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 61 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 92 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 98 of file MCAssembler.h.

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

◆ Symvers

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

Definition at line 222 of file MCAssembler.h.

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

◆ Type

MCVersionMinType llvm::MCAssembler::Type

Used when EmitBuildVersion==false.

Definition at line 91 of file MCAssembler.h.

Referenced by setVersionMin().

◆ TypeOrPlatform

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

◆ Update

unsigned llvm::MCAssembler::Update

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