LLVM  13.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())
 
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 454 of file MCAssembler.h.

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

◆ begin() [1/2]

iterator llvm::MCAssembler::begin ( )
inline

Definition at line 344 of file MCAssembler.h.

Referenced by dump().

◆ begin() [2/2]

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

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

◆ data_region_begin() [2/2]

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

Definition at line 413 of file MCAssembler.h.

◆ data_region_end() [1/2]

data_region_iterator llvm::MCAssembler::data_region_end ( )
inline

Definition at line 417 of file MCAssembler.h.

◆ data_region_end() [2/2]

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

Definition at line 418 of file MCAssembler.h.

◆ data_region_size()

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

Definition at line 422 of file MCAssembler.h.

◆ dump()

LLVM_DUMP_METHOD void MCAssembler::dump ( ) const

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

Referenced by dump().

◆ end() [2/2]

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

Definition at line 348 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 945 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 173 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

◆ getDataRegions()

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

Definition at line 410 of file MCAssembler.h.

◆ getDWARFLinetableParams()

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

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

◆ getIndirectSymbols()

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

Definition at line 375 of file MCAssembler.h.

◆ getLinkerOptions()

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

Definition at line 399 of file MCAssembler.h.

◆ getLOHContainer() [1/2]

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

Definition at line 431 of file MCAssembler.h.

Referenced by getLOHContainer(), and reset().

◆ getLOHContainer() [2/2]

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

Definition at line 432 of file MCAssembler.h.

References getLOHContainer().

◆ getRelaxAll()

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

Definition at line 328 of file MCAssembler.h.

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

◆ getSubsectionsViaSymbols()

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

Definition at line 318 of file MCAssembler.h.

◆ getVersionInfo()

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

MachO deployment target version information.

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

Referenced by reset().

◆ indirect_symbol_begin() [1/2]

indirect_symbol_iterator llvm::MCAssembler::indirect_symbol_begin ( )
inline

Definition at line 379 of file MCAssembler.h.

◆ indirect_symbol_begin() [2/2]

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

Definition at line 382 of file MCAssembler.h.

◆ indirect_symbol_end() [1/2]

indirect_symbol_iterator llvm::MCAssembler::indirect_symbol_end ( )
inline

Definition at line 386 of file MCAssembler.h.

◆ indirect_symbol_end() [2/2]

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

Definition at line 389 of file MCAssembler.h.

◆ indirect_symbol_size()

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

Definition at line 393 of file MCAssembler.h.

◆ isBundlingEnabled()

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

◆ isIncrementalLinkerCompatible()

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

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

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

◆ setBundleAlignSize()

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

Definition at line 335 of file MCAssembler.h.

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

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

◆ setDWARFLinetableParams()

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

Definition at line 307 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 324 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 259 of file MCAssembler.h.

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

◆ setRelaxAll()

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

Definition at line 329 of file MCAssembler.h.

◆ setSubsectionsViaSymbols()

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

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

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

◆ size()

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

Definition at line 350 of file MCAssembler.h.

◆ symbol_begin() [1/2]

symbol_iterator llvm::MCAssembler::symbol_begin ( )
inline

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

◆ symbol_end() [1/2]

symbol_iterator llvm::MCAssembler::symbol_end ( )
inline

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

◆ symbol_size()

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

Definition at line 366 of file MCAssembler.h.

◆ symbols() [1/2]

symbol_range llvm::MCAssembler::symbols ( )
inline

Definition at line 361 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 362 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

Write the necessary bundle padding to OS.

Expects a fragment F containing instructions and its size FSize.

Definition at line 473 of file MCAssembler.cpp.

References llvm::MCEncodedFragment::alignToBundleEnd(), assert(), getBackend(), getBackendPtr(), getBundleAlignSize(), llvm::MCEncodedFragment::getBundlePadding(), llvm::MCFragment::hasInstructions(), isBundlingEnabled(), and llvm::report_fatal_error().

◆ 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

Definition at line 94 of file MCAssembler.h.

Referenced by setBuildVersion(), and setVersionMin().

◆ Minor

unsigned llvm::MCAssembler::Minor

Definition at line 95 of file MCAssembler.h.

Referenced by setBuildVersion(), and setVersionMin().

◆ Platform

MachO::PlatformType llvm::MCAssembler::Platform

Used when EmitBuildVersion==true.

Definition at line 92 of file MCAssembler.h.

Referenced by setBuildVersion().

◆ 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(), and setVersionMin().

◆ Symvers

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

Definition at line 221 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

Definition at line 96 of file MCAssembler.h.

Referenced by setBuildVersion(), and setVersionMin().


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