LLVM  7.0.0svn
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]

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)
 
void setBuildVersion (MachO::PlatformType Platform, unsigned Major, unsigned Minor, unsigned Update)
 
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 ()
 
Data Region List Access
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
 
Backend Data Access
bool registerSection (MCSection &Section)
 
void registerSymbol (const MCSymbol &Symbol, bool *Created=nullptr)
 
ArrayRef< std::string > getFileNames ()
 
void addFileName (StringRef FileName)
 
void writeFragmentPadding (raw_ostream &OS, const MCFragment &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
 
std::vector< std::pair< StringRef, const MCSymbol * > > Symvers
 

Friends

class MCAsmLayout
 

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

References ~MCAssembler().

◆ MCAssembler() [2/2]

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

◆ ~MCAssembler()

MCAssembler::~MCAssembler ( )
default

Referenced by MCAssembler().

Member Function Documentation

◆ addFileName()

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

◆ begin() [1/2]

iterator llvm::MCAssembler::begin ( )
inline

◆ begin() [2/2]

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

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

◆ data_region_begin() [2/2]

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

Definition at line 399 of file MCAssembler.h.

◆ data_region_end() [1/2]

data_region_iterator llvm::MCAssembler::data_region_end ( )
inline

Definition at line 403 of file MCAssembler.h.

◆ data_region_end() [2/2]

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

Definition at line 404 of file MCAssembler.h.

◆ data_region_size()

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

Definition at line 408 of file MCAssembler.h.

◆ dump()

LLVM_DUMP_METHOD void MCAssembler::dump ( ) const

Definition at line 469 of file MCFragment.cpp.

References llvm::sys::path::begin(), llvm::sys::path::end(), and llvm::errs().

Referenced by layout().

◆ end() [1/2]

iterator llvm::MCAssembler::end ( )
inline

◆ end() [2/2]

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

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

References assert(), llvm::MCSection::begin(), begin(), llvm::SmallVectorImpl< T >::clear(), computeFragmentSize(), llvm::Data, llvm::MCDwarfLineAddr::Encode(), llvm::MCDwarfFrameEmitter::EncodeAdvanceLoc(), llvm::CodeViewContext::encodeDefRange(), llvm::CodeViewContext::encodeInlineLineTable(), llvm::MCCodeEmitter::encodeInstruction(), llvm::encodeSLEB128(), llvm::encodeULEB128(), llvm::MCSection::end(), end(), llvm::MCExpr::evaluateKnownAbsolute(), llvm::MCAsmBackend::finishLayout(), llvm::MCAsmBackend::fixupNeedsRelaxationAdvanced(), llvm::FK_Data_1, llvm::MCFragment::FT_CVDefRange, llvm::MCFragment::FT_CVInlineLines, llvm::MCFragment::FT_Dwarf, llvm::MCFragment::FT_DwarfFrame, llvm::MCFragment::FT_LEB, llvm::MCFragment::FT_Padding, llvm::MCFragment::FT_Relaxable, llvm::MCDwarfLineAddrFragment::getAddrDelta(), llvm::MCDwarfCallFrameFragment::getAddrDelta(), llvm::MCAsmLayout::getAssembler(), getBackend(), getBackendPtr(), llvm::MCEncodedFragmentWithContents< ContentsSize >::getContents(), llvm::MCLEBFragment::getContents(), llvm::MCDwarfLineAddrFragment::getContents(), llvm::MCDwarfCallFrameFragment::getContents(), llvm::MCCVInlineLineTableFragment::getContents(), getContext(), llvm::MCContext::getCVContext(), getDWARFLinetableParams(), getEmitter(), getEmitterPtr(), llvm::MCEncodedFragmentWithFixups< ContentsSize, FixupsSize >::getFixups(), llvm::MCAsmLayout::getFragmentOffset(), llvm::MCRelaxableFragment::getInst(), llvm::MCFixup::getKind(), llvm::MCSymbolRefExpr::getKind(), llvm::MCDwarfLineAddrFragment::getLineDelta(), getRelaxAll(), llvm::MCAsmLayout::getSectionOrder(), llvm::MCPaddingFragment::getSize(), llvm::MCRelaxableFragment::getSubtargetInfo(), llvm::MCValue::getSymA(), llvm::MCLEBFragment::getValue(), getWriter(), I, llvm::ARM_PROC::IE, llvm::MCAsmLayout::invalidateFragmentsFrom(), llvm::MCLEBFragment::isSigned(), layout(), llvm::MCSection::rbegin(), llvm::MCAsmBackend::relaxInstruction(), llvm::report_fatal_error(), llvm::ARMBuildAttrs::Section, llvm::MCRelaxableFragment::setInst(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::MCSymbolRefExpr::VK_X86_ABS8, and llvm::MCObjectWriter::writeObject().

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

◆ getAtom()

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

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

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

◆ getDWARFLinetableParams()

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

Definition at line 292 of file MCAssembler.h.

Referenced by Finish().

◆ getELFHeaderEFlags()

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

◆ getEmitter()

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

◆ getEmitterPtr()

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

Definition at line 282 of file MCAssembler.h.

Referenced by Finish(), and reset().

◆ getFileNames()

ArrayRef<std::string> llvm::MCAssembler::getFileNames ( )
inline

Definition at line 429 of file MCAssembler.h.

Referenced by getTime(), and isWeak().

◆ getIndirectSymbols()

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

Definition at line 361 of file MCAssembler.h.

◆ getLinkerOptions()

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

Definition at line 385 of file MCAssembler.h.

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

◆ getLOHContainer() [1/2]

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

Definition at line 417 of file MCAssembler.h.

Referenced by reset(), and llvm::MachObjectWriter::writeObject().

◆ getLOHContainer() [2/2]

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

◆ getRelaxAll()

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

◆ getSubsectionsViaSymbols()

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

◆ getVersionInfo()

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

MachO deployment target version information.

Definition at line 256 of file MCAssembler.h.

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

◆ getWriter()

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

Definition at line 290 of file MCAssembler.h.

Referenced by Finish(), layout(), and writeSectionData().

◆ getWriterPtr()

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

Definition at line 284 of file MCAssembler.h.

Referenced by getAtom(), and reset().

◆ indirect_symbol_begin() [1/2]

indirect_symbol_iterator llvm::MCAssembler::indirect_symbol_begin ( )
inline

Definition at line 365 of file MCAssembler.h.

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

◆ indirect_symbol_begin() [2/2]

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

Definition at line 368 of file MCAssembler.h.

◆ indirect_symbol_end() [1/2]

indirect_symbol_iterator llvm::MCAssembler::indirect_symbol_end ( )
inline

Definition at line 372 of file MCAssembler.h.

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

◆ indirect_symbol_end() [2/2]

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

Definition at line 375 of file MCAssembler.h.

◆ indirect_symbol_size()

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

Definition at line 379 of file MCAssembler.h.

◆ isBundlingEnabled()

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

◆ isIncrementalLinkerCompatible()

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

Definition at line 307 of file MCAssembler.h.

Referenced by isAssociative().

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

References llvm::MCSymbol::isInSection(), llvm::MCSymbol::isTemporary(), and llvm::MCSymbol::isUsedInReloc().

Referenced by llvm::MachObjectWriter::computeSymbolTable(), and 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 
)
inline

Definition at line 265 of file MCAssembler.h.

◆ setBundleAlignSize()

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

◆ setDWARFLinetableParams()

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

Definition at line 293 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 310 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 249 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.

Referenced by llvm::createELFStreamer(), and llvm::createWasmStreamer().

◆ setSubsectionsViaSymbols()

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

Definition at line 305 of file MCAssembler.h.

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

◆ setVersionMin()

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

Definition at line 257 of file MCAssembler.h.

◆ size()

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

Definition at line 336 of file MCAssembler.h.

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

◆ symbol_begin() [1/2]

symbol_iterator llvm::MCAssembler::symbol_begin ( )
inline

Definition at line 341 of file MCAssembler.h.

◆ symbol_begin() [2/2]

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

Definition at line 342 of file MCAssembler.h.

◆ symbol_end() [1/2]

symbol_iterator llvm::MCAssembler::symbol_end ( )
inline

Definition at line 344 of file MCAssembler.h.

◆ symbol_end() [2/2]

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

Definition at line 345 of file MCAssembler.h.

◆ symbol_size()

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

Definition at line 352 of file MCAssembler.h.

◆ symbols() [1/2]

symbol_range llvm::MCAssembler::symbols ( )
inline

Definition at line 347 of file MCAssembler.h.

References llvm::make_range().

Referenced by llvm::MachObjectWriter::computeSymbolTable(), isInSymtab(), and isWeak().

◆ symbols() [2/2]

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

Definition at line 348 of file MCAssembler.h.

References llvm::make_range().

◆ writeFragmentPadding()

void MCAssembler::writeFragmentPadding ( raw_ostream OS,
const MCFragment 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 453 of file MCAssembler.cpp.

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

Referenced by llvm::MCELFStreamer::MCELFStreamer(), and writeFragment().

◆ 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

◆ Major

unsigned llvm::MCAssembler::Major

Definition at line 94 of file MCAssembler.h.

◆ Minor

unsigned llvm::MCAssembler::Minor

Definition at line 95 of file MCAssembler.h.

◆ Platform

MachO::PlatformType llvm::MCAssembler::Platform

Used when EmitBuildVersion==true.

Definition at line 92 of file MCAssembler.h.

◆ Symvers

std::vector<std::pair<StringRef, const MCSymbol *> > llvm::MCAssembler::Symvers

Definition at line 211 of file MCAssembler.h.

Referenced by llvm::MCELFStreamer::emitELFSymverDirective(), and isWeak().

◆ Type

MCVersionMinType llvm::MCAssembler::Type

Used when EmitBuildVersion==false.

Definition at line 91 of file MCAssembler.h.

◆ TypeOrPlatform

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

◆ Update

unsigned llvm::MCAssembler::Update

Definition at line 96 of file MCAssembler.h.


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