LLVM API Documentation

Public Types | Public Member Functions
llvm::MCContext Class Reference

#include <MCContext.h>

List of all members.

Public Types

typedef StringMap< MCSymbol
*, BumpPtrAllocator & > 
SymbolTable

Public Member Functions

 MCContext (const MCAsmInfo *MAI, const MCRegisterInfo *MRI, const MCObjectFileInfo *MOFI, const SourceMgr *Mgr=nullptr, bool DoAutoReset=true)
 ~MCContext ()
const SourceMgrgetSourceManager () const
const MCAsmInfogetAsmInfo () const
const MCRegisterInfogetRegisterInfo () const
const MCObjectFileInfogetObjectFileInfo () const
void setAllowTemporaryLabels (bool Value)
char * getSecureLogFile ()
raw_ostreamgetSecureLog ()
bool getSecureLogUsed ()
void setSecureLog (raw_ostream *Value)
void setSecureLogUsed (bool Value)
void * Allocate (unsigned Size, unsigned Align=8)
void Deallocate (void *Ptr)
LLVM_ATTRIBUTE_NORETURN void FatalError (SMLoc L, const Twine &Msg) const
Module Lifetime Management
void reset ()
Symbol Management
MCSymbolCreateLinkerPrivateTempSymbol ()
MCSymbolCreateTempSymbol ()
unsigned getUniqueSymbolID ()
MCSymbolCreateDirectionalLocalSymbol (unsigned LocalLabelVal)
MCSymbolGetDirectionalLocalSymbol (unsigned LocalLabelVal, bool Before)
MCSymbolGetOrCreateSymbol (StringRef Name)
MCSymbolGetOrCreateSymbol (const Twine &Name)
MCSymbolLookupSymbol (StringRef Name) const
 LookupSymbol - Get the symbol for Name, or null.
MCSymbolLookupSymbol (const Twine &Name) const
const SymbolTablegetSymbols () const
Section Management
const MCSectionMachOgetMachOSection (StringRef Segment, StringRef Section, unsigned TypeAndAttributes, unsigned Reserved2, SectionKind K)
const MCSectionMachOgetMachOSection (StringRef Segment, StringRef Section, unsigned TypeAndAttributes, SectionKind K)
const MCSectionELFgetELFSection (StringRef Section, unsigned Type, unsigned Flags, SectionKind Kind)
const MCSectionELFgetELFSection (StringRef Section, unsigned Type, unsigned Flags, SectionKind Kind, unsigned EntrySize, StringRef Group)
void renameELFSection (const MCSectionELF *Section, StringRef Name)
const MCSectionELFCreateELFGroupSection ()
const MCSectionCOFFgetCOFFSection (StringRef Section, unsigned Characteristics, SectionKind Kind, StringRef COMDATSymName, int Selection)
const MCSectionCOFFgetCOFFSection (StringRef Section, unsigned Characteristics, SectionKind Kind)
const MCSectionCOFFgetCOFFSection (StringRef Section)
const MCSectionCOFFgetAssociativeCOFFSection (const MCSectionCOFF *Sec, const MCSymbol *KeySym)
Dwarf Management
StringRef getCompilationDir () const
 Get the compilation directory for DW_AT_comp_dir This can be overridden by clients which want to control the reported compilation directory and have it be something other than the current working directory. Returns an empty string if the current directory cannot be determined.
void setCompilationDir (StringRef S)
 Set the compilation directory for DW_AT_comp_dir Override the default (CWD) compilation directory.
const std::string & getMainFileName () const
 Get the main file name for use in error messages and debug info. This can be set to ensure we've got the correct file name after preprocessing or for -save-temps.
void setMainFileName (StringRef S)
 Set the main file name and override the default.
unsigned GetDwarfFile (StringRef Directory, StringRef FileName, unsigned FileNumber, unsigned CUID)
 GetDwarfFile - creates an entry in the dwarf file and directory tables.
bool isValidDwarfFileNumber (unsigned FileNumber, unsigned CUID=0)
const std::map< unsigned,
MCDwarfLineTable > & 
getMCDwarfLineTables () const
MCDwarfLineTablegetMCDwarfLineTable (unsigned CUID)
const MCDwarfLineTablegetMCDwarfLineTable (unsigned CUID) const
const SmallVectorImpl
< MCDwarfFile > & 
getMCDwarfFiles (unsigned CUID=0)
const SmallVectorImpl
< std::string > & 
getMCDwarfDirs (unsigned CUID=0)
bool hasMCLineSections () const
unsigned getDwarfCompileUnitID ()
void setDwarfCompileUnitID (unsigned CUIndex)
void setMCLineTableCompilationDir (unsigned CUID, StringRef CompilationDir)
void setCurrentDwarfLoc (unsigned FileNum, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator)
void ClearDwarfLocSeen ()
bool getDwarfLocSeen ()
const MCDwarfLocgetCurrentDwarfLoc ()
bool getGenDwarfForAssembly ()
void setGenDwarfForAssembly (bool Value)
unsigned getGenDwarfFileNumber ()
void setGenDwarfFileNumber (unsigned FileNumber)
MapVector< const MCSection
*, std::pair< MCSymbol
*, MCSymbol * > > & 
getGenDwarfSectionSyms ()
std::pair< MapVector< const
MCSection *, std::pair
< MCSymbol *, MCSymbol * >
>::iterator, bool
addGenDwarfSection (const MCSection *Sec)
void finalizeDwarfSections (MCStreamer &MCOS)
const std::vector
< MCGenDwarfLabelEntry > & 
getMCGenDwarfLabelEntries () const
void addMCGenDwarfLabelEntry (const MCGenDwarfLabelEntry &E)
void setDwarfDebugFlags (StringRef S)
StringRef getDwarfDebugFlags ()
void setDwarfDebugProducer (StringRef S)
StringRef getDwarfDebugProducer ()
void setDwarfVersion (uint16_t v)
uint16_t getDwarfVersion () const

Detailed Description

MCContext - Context object for machine code objects. This class owns all of the sections that it creates.

Definition at line 49 of file MCContext.h.


Member Typedef Documentation

Definition at line 53 of file MCContext.h.


Constructor & Destructor Documentation

MCContext::MCContext ( const MCAsmInfo MAI,
const MCRegisterInfo MRI,
const MCObjectFileInfo MOFI,
const SourceMgr Mgr = nullptr,
bool  DoAutoReset = true 
) [explicit]

Definition at line 55 of file MCContext.cpp.

References reset().


Member Function Documentation

std::pair<MapVector<const MCSection *, std::pair<MCSymbol *, MCSymbol *> >::iterator, bool> llvm::MCContext::addGenDwarfSection ( const MCSection Sec) [inline]

Definition at line 402 of file MCContext.h.

Referenced by llvm::MCGenDwarfLabelEntry::Make().

void* llvm::MCContext::Allocate ( unsigned  Size,
unsigned  Align = 8 
) [inline]

Definition at line 376 of file MCContext.h.

Referenced by llvm::MCLineEntry::Make().

Create the definition of a directional local symbol for numbered label (used for "1:" definitions).

Definition at line 182 of file MCContext.cpp.

Definition at line 277 of file MCContext.cpp.

References llvm::SectionKind::getReadOnly(), and llvm::ELF::SHT_GROUP.

CreateLinkerPrivateTempSymbol - Create and return a new linker temporary symbol with a unique but unspecified name.

Definition at line 146 of file MCContext.cpp.

References llvm::MCAsmInfo::getLinkerPrivateGlobalPrefix().

CreateTempSymbol - Create and return a new assembler temporary symbol with a unique but unspecified name.

Definition at line 153 of file MCContext.cpp.

References llvm::MCAsmInfo::getPrivateGlobalPrefix().

Referenced by llvm::ConstantPool::addEntry(), llvm::MachineModuleInfo::addLandingPad(), llvm::DwarfCFIException::beginFunction(), llvm::DwarfDebug::beginInstruction(), llvm::MCDwarfLineTableHeader::Emit(), llvm::MCGenDwarfInfo::Emit(), llvm::MCDwarfFrameEmitter::Emit(), EmitDwarfLineTable(), llvm::AsmPrinter::EmitFunctionBody(), EmitGenDwarfInfo(), llvm::X86AsmPrinter::EmitInstruction(), llvm::ARMAsmPrinter::EmitMachineConstantPoolValue(), llvm::AArch64FrameLowering::emitPrologue(), llvm::EmitUnwindInfo(), llvm::MCObjectStreamer::EmitValueToOffset(), llvm::MCStreamer::EmitWinCFIAllocStack(), llvm::MCStreamer::EmitWinCFIEndChained(), llvm::MCStreamer::EmitWinCFIEndProc(), llvm::MCStreamer::EmitWinCFIEndProlog(), llvm::MCStreamer::EmitWinCFIPushFrame(), llvm::MCStreamer::EmitWinCFIPushReg(), llvm::MCStreamer::EmitWinCFISaveReg(), llvm::MCStreamer::EmitWinCFISaveXMM(), llvm::MCStreamer::EmitWinCFISetFrame(), llvm::MCStreamer::EmitWinCFIStartChained(), llvm::MCStreamer::EmitWinCFIStartProc(), llvm::WinCodeViewLineTables::endFunction(), llvm::DwarfDebug::endInstruction(), finalizeDwarfSections(), forceExpAbs(), llvm::AArch64MCAsmInfoDarwin::getExprForPersonalitySymbol(), llvm::TargetLoweringObjectFile::getTTypeReference(), llvm::SelectionDAGBuilder::LowerCallTo(), llvm::MCLineEntry::Make(), and llvm::MCGenDwarfLabelEntry::Make().

void llvm::MCContext::Deallocate ( void *  Ptr) [inline]

Definition at line 430 of file MCContext.h.

Referenced by operator delete().

void MCContext::FatalError ( SMLoc  L,
const Twine Msg 
) const

finalizeDwarfSections - Emit end symbols for each non-empty code section. Also remove empty sections from SectionStartEndSyms, to avoid generating useless debug info for them.

Definition at line 366 of file MCContext.cpp.

References llvm::MapVector< KeyT, ValueT, MapType, VectorType >::begin(), CreateTempSymbol(), llvm::MCStreamer::EmitLabel(), llvm::MapVector< KeyT, ValueT, MapType, VectorType >::end(), llvm::MapVector< KeyT, ValueT, MapType, VectorType >::erase(), llvm::MCStreamer::getContext(), llvm::MCStreamer::mayHaveInstructions(), and llvm::MCStreamer::SwitchSection().

Referenced by llvm::MCGenDwarfInfo::Emit().

Gets or creates a section equivalent to Sec that is associated with the section containing KeySym. For example, to create a debug info section associated with an inline function, pass the normal debug info section as Sec and the function symbol as KeySym.

Definition at line 324 of file MCContext.cpp.

References Characteristics, llvm::MCSectionCOFF::getCharacteristics(), getCOFFSection(), llvm::MCSection::getKind(), llvm::MCSymbol::getName(), llvm::MCSectionCOFF::getSectionName(), llvm::COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE, and llvm::COFF::IMAGE_SCN_LNK_COMDAT.

Referenced by llvm::WinEH::getUnwindInfoSection().

const MCSectionCOFF * MCContext::getCOFFSection ( StringRef  Section,
unsigned  Characteristics,
SectionKind  Kind,
StringRef  COMDATSymName,
int  Selection 
)
const MCSectionCOFF * MCContext::getCOFFSection ( StringRef  Section,
unsigned  Characteristics,
SectionKind  Kind 
)

Definition at line 310 of file MCContext.cpp.

References getCOFFSection().

Definition at line 315 of file MCContext.cpp.

References T.

Get the compilation directory for DW_AT_comp_dir This can be overridden by clients which want to control the reported compilation directory and have it be something other than the current working directory. Returns an empty string if the current directory cannot be determined.

Definition at line 304 of file MCContext.h.

Referenced by EmitGenDwarfAbbrev(), and EmitGenDwarfInfo().

Definition at line 379 of file MCContext.h.

Referenced by llvm::MCLineEntry::Make().

MCSymbol * MCContext::GetDirectionalLocalSymbol ( unsigned  LocalLabelVal,
bool  Before 
)

Create and return a directional local symbol for numbered label (used for "1b" or 1f" references).

Definition at line 187 of file MCContext.cpp.

Definition at line 351 of file MCContext.h.

Referenced by llvm::MCLineEntry::Make().

Definition at line 407 of file MCContext.h.

Referenced by EmitGenDwarfAbbrev(), and EmitGenDwarfInfo().

Definition at line 410 of file MCContext.h.

Referenced by EmitGenDwarfInfo().

unsigned MCContext::GetDwarfFile ( StringRef  Directory,
StringRef  FileName,
unsigned  FileNumber,
unsigned  CUID 
)

GetDwarfFile - creates an entry in the dwarf file and directory tables.

GetDwarfFile - takes a file name an number to place in the dwarf file and directory tables. If the file number has already been allocated it is an error and zero is returned and the client reports the error, else the allocated file number is returned. The file numbers may be in any order.

Definition at line 347 of file MCContext.cpp.

References llvm::MCDwarfLineTable::getFile().

Referenced by llvm::MCStreamer::EmitDwarfFileDirective().

Definition at line 378 of file MCContext.h.

Referenced by llvm::MCLineEntry::Make().

uint16_t llvm::MCContext::getDwarfVersion ( ) const [inline]

Definition at line 413 of file MCContext.h.

Referenced by EmitGenDwarfInfo().

const MCSectionELF * MCContext::getELFSection ( StringRef  Section,
unsigned  Type,
unsigned  Flags,
SectionKind  Kind,
unsigned  EntrySize,
StringRef  Group 
)

Definition at line 383 of file MCContext.h.

Referenced by llvm::MCGenDwarfLabelEntry::Make().

Definition at line 381 of file MCContext.h.

const MCSectionMachO * MCContext::getMachOSection ( StringRef  Segment,
StringRef  Section,
unsigned  TypeAndAttributes,
unsigned  Reserved2,
SectionKind  K 
)

getMachOSection - Return the MCSection for the specified mach-o section. This requires the operands to be valid.

Definition at line 210 of file MCContext.cpp.

References Name, llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::ARMBuildAttrs::Section, and llvm::SmallString< InternalLen >::str().

Referenced by llvm::X86AsmPrinter::EmitEndOfAsmFile(), llvm::ARMAsmPrinter::EmitStartOfAsmFile(), and getMachOSection().

const MCSectionMachO* llvm::MCContext::getMachOSection ( StringRef  Segment,
StringRef  Section,
unsigned  TypeAndAttributes,
SectionKind  K 
) [inline]

Definition at line 258 of file MCContext.h.

References getMachOSection().

const std::string& llvm::MCContext::getMainFileName ( ) const [inline]

Get the main file name for use in error messages and debug info. This can be set to ensure we've got the correct file name after preprocessing or for -save-temps.

Definition at line 313 of file MCContext.h.

const SmallVectorImpl<std::string>& llvm::MCContext::getMCDwarfDirs ( unsigned  CUID = 0) [inline]

Definition at line 341 of file MCContext.h.

References llvm::MCDwarfLineTable::getMCDwarfDirs(), and getMCDwarfLineTable().

Referenced by EmitGenDwarfInfo().

Definition at line 332 of file MCContext.h.

References I.

Definition at line 324 of file MCContext.h.

Referenced by llvm::MCDwarfLineTable::Emit().

Definition at line 399 of file MCContext.h.

Referenced by EmitGenDwarfInfo().

GetOrCreateSymbol - Lookup the symbol inside with the specified Name. If it exists, return it. If not, create a forward reference and return it.

Parameters:
Name- The symbol name, which must be unique across all symbols.

Definition at line 100 of file MCContext.cpp.

References llvm::StringRef::empty(), and llvm::StringMap< ValueTy, AllocatorTy >::GetOrCreateValue().

Referenced by llvm::AsmPrinter::doFinalization(), EmitCamlGlobal(), llvm::MipsTargetELFStreamer::emitDirectiveCpload(), llvm::AMDGPUAsmPrinter::EmitEndOfAsmFile(), llvm::X86AsmPrinter::EmitEndOfAsmFile(), llvm::EHStreamer::emitExceptionTable(), llvm::AsmPrinter::EmitGlobalVariable(), llvm::ARMAsmPrinter::EmitMachineConstantPoolValue(), llvm::AsmPrinter::EmitSpecialLLVMGlobal(), llvm::X86AsmPrinter::EmitStartOfAsmFile(), GetAnonSym(), getCOFFSection(), llvm::MSP430MCInstLower::GetConstantPoolIndexSymbol(), llvm::AsmPrinter::GetCPISymbol(), llvm::MCStreamer::getDwarfLineTableSymbol(), getELFSection(), llvm::AsmPrinter::GetExternalSymbolSymbol(), llvm::MachineFunction::getJTISymbol(), llvm::AsmPrinter::GetJTSetSymbol(), llvm::MSP430MCInstLower::GetJumpTableSymbol(), GetLazyPtr(), GetOrCreateSymbol(), llvm::MachineFunction::getPICBaseSymbol(), getPICLabel(), llvm::PPCFunctionInfo::getPICOffsetSymbol(), llvm::TargetMachine::getSymbol(), llvm::MachineBasicBlock::getSymbol(), GetSymbolFromOperand(), llvm::TargetLoweringObjectFile::getSymbolWithGlobalValueBase(), llvm::AsmPrinter::GetTempSymbol(), llvm::AMDGPUMCInstLower::lower(), printSymbolOperand(), llvm::StackMaps::serializeToStackMapSection(), llvm::AArch64ExternalSymbolizer::tryAddingSymbolicOperand(), and llvm::MCExternalSymbolizer::tryAddingSymbolicOperand().

Definition at line 141 of file MCContext.cpp.

References GetOrCreateSymbol(), and llvm::Twine::toStringRef().

Definition at line 418 of file MCContext.h.

Definition at line 417 of file MCContext.h.

Definition at line 419 of file MCContext.h.

Definition at line 184 of file MCContext.h.

getSymbols - Get a reference for the symbol table for clients that want to, for example, iterate over all symbols. 'const' because we still want any modifications to the table itself to use the MCContext APIs.

Definition at line 242 of file MCContext.h.

getUniqueSymbolID() - Return a unique identifier for use in constructing symbol names.

Definition at line 216 of file MCContext.h.

Definition at line 345 of file MCContext.h.

bool MCContext::isValidDwarfFileNumber ( unsigned  FileNumber,
unsigned  CUID = 0 
)

isValidDwarfFileNumber - takes a dwarf file number and returns true if it currently is assigned and false otherwise.

Definition at line 355 of file MCContext.cpp.

References llvm::SmallVectorBase::empty(), getMCDwarfFiles(), and llvm::SmallVectorTemplateCommon< T, typename >::size().

LookupSymbol - Get the symbol for Name, or null.

Definition at line 195 of file MCContext.cpp.

References llvm::StringMap< ValueTy, AllocatorTy >::lookup().

Referenced by LookupSymbol().

void MCContext::renameELFSection ( const MCSectionELF Section,
StringRef  Name 
)
void MCContext::reset ( )

Set the compilation directory for DW_AT_comp_dir Override the default (CWD) compilation directory.

Definition at line 308 of file MCContext.h.

References llvm::StringRef::str().

void llvm::MCContext::setCurrentDwarfLoc ( unsigned  FileNum,
unsigned  Line,
unsigned  Column,
unsigned  Flags,
unsigned  Isa,
unsigned  Discriminator 
) [inline]

setCurrentDwarfLoc - saves the information from the currently parsed dwarf .loc directive and sets DwarfLocSeen. When the next instruction is assembled an entry in the line number table with this information and the address of the instruction will be created.

Definition at line 365 of file MCContext.h.

References llvm::MCDwarfLoc::setColumn(), llvm::MCDwarfLoc::setDiscriminator(), llvm::MCDwarfLoc::setFileNum(), llvm::MCDwarfLoc::setFlags(), llvm::MCDwarfLoc::setIsa(), and llvm::MCDwarfLoc::setLine().

Referenced by llvm::MCStreamer::EmitDwarfLocDirective().

Definition at line 354 of file MCContext.h.

Definition at line 406 of file MCContext.h.

Definition at line 409 of file MCContext.h.

void llvm::MCContext::setDwarfVersion ( uint16_t  v) [inline]

Definition at line 412 of file MCContext.h.

Referenced by llvm::DwarfDebug::DwarfDebug().

void llvm::MCContext::setGenDwarfFileNumber ( unsigned  FileNumber) [inline]

Definition at line 384 of file MCContext.h.

Definition at line 382 of file MCContext.h.

Set the main file name and override the default.

Definition at line 316 of file MCContext.h.

void llvm::MCContext::setMCLineTableCompilationDir ( unsigned  CUID,
StringRef  CompilationDir 
) [inline]
void llvm::MCContext::setSecureLog ( raw_ostream Value) [inline]

Definition at line 420 of file MCContext.h.

void llvm::MCContext::setSecureLogUsed ( bool  Value) [inline]

Definition at line 423 of file MCContext.h.


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