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=0, 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)
Module Lifetime Management
void reset ()
Symbol Management
MCSymbolCreateTempSymbol ()
unsigned getUniqueSymbolID ()
MCSymbolCreateDirectionalLocalSymbol (int64_t LocalLabelVal)
MCSymbolGetDirectionalLocalSymbol (int64_t LocalLabelVal, int bORf)
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)
const MCSectionELFCreateELFGroupSection ()
const MCSectiongetCOFFSection (StringRef Section, unsigned Characteristics, int Selection, SectionKind Kind)
const MCSectiongetCOFFSection (StringRef Section, unsigned Characteristics, SectionKind Kind)
Dwarf Management
const std::string & 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.
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)
bool hasDwarfFiles () const
const SmallVectorImpl
< MCDwarfFile * > & 
getMCDwarfFiles (unsigned CUID=0)
const SmallVectorImpl
< StringRef > & 
getMCDwarfDirs (unsigned CUID=0)
const DenseMap< const
MCSection *, MCLineSection * > & 
getMCLineSections () const
const std::vector< const
MCSection * > & 
getMCLineSectionOrder () const
void addMCLineSection (const MCSection *Sec, MCLineSection *Line)
unsigned getDwarfCompileUnitID ()
void setDwarfCompileUnitID (unsigned CUIndex)
const DenseMap< unsigned,
MCSymbol * > & 
getMCLineTableSymbols () const
MCSymbolgetMCLineTableSymbol (unsigned ID) const
void setMCLineTableSymbol (MCSymbol *Sym, unsigned ID)
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 ()
unsigned nextGenDwarfFileNumber ()
const MCSectiongetGenDwarfSection ()
void setGenDwarfSection (const MCSection *Sec)
MCSymbolgetGenDwarfSectionStartSym ()
void setGenDwarfSectionStartSym (MCSymbol *Sym)
MCSymbolgetGenDwarfSectionEndSym ()
void setGenDwarfSectionEndSym (MCSymbol *Sym)
const std::vector< const
MCGenDwarfLabelEntry * > & 
getMCGenDwarfLabelEntries () const
void addMCGenDwarfLabelEntry (const MCGenDwarfLabelEntry *E)
void setDwarfDebugFlags (StringRef S)
StringRef getDwarfDebugFlags ()
void setDwarfDebugProducer (StringRef S)
StringRef getDwarfDebugProducer ()

Detailed Description

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

Definition at line 44 of file MCContext.h.


Member Typedef Documentation

Definition at line 48 of file MCContext.h.


Constructor & Destructor Documentation

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

Definition at line 59 of file MCContext.cpp.

References reset().


Member Function Documentation

void llvm::MCContext::addMCGenDwarfLabelEntry ( const MCGenDwarfLabelEntry E) [inline]

Definition at line 381 of file MCContext.h.

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

void llvm::MCContext::addMCLineSection ( const MCSection Sec,
MCLineSection Line 
) [inline]

Definition at line 319 of file MCContext.h.

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

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

Definition at line 403 of file MCContext.h.

References Align(), and llvm::BumpPtrAllocator::Allocate().

Referenced by GetDwarfFile(), operator new(), and operator new[]().

void llvm::MCContext::ClearDwarfLocSeen ( ) [inline]

Definition at line 358 of file MCContext.h.

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

MCSymbol * MCContext::CreateDirectionalLocalSymbol ( int64_t  LocalLabelVal)

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

Definition at line 177 of file MCContext.cpp.

References GetOrCreateSymbol(), and llvm::MCAsmInfo::getPrivateGlobalPrefix().

const MCSectionELF * MCContext::CreateELFGroupSection ( )

Definition at line 266 of file MCContext.cpp.

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

MCSymbol * MCContext::CreateTempSymbol ( )

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

Definition at line 156 of file MCContext.cpp.

References llvm::MCAsmInfo::getPrivateGlobalPrefix().

Referenced by llvm::MachineModuleInfo::addLandingPad(), llvm::DwarfDebug::beginInstruction(), llvm::MCGenDwarfInfo::Emit(), llvm::MCDwarfFrameEmitter::Emit(), llvm::MCDwarfFileTable::EmitCU(), EmitDwarfLineTable(), llvm::AsmPrinter::EmitFunctionBody(), EmitGenDwarfAranges(), EmitGenDwarfInfo(), llvm::X86AsmPrinter::EmitInstruction(), llvm::ARMAsmPrinter::EmitMachineConstantPoolValue(), llvm::Mips16FrameLowering::emitPrologue(), llvm::MipsSEFrameLowering::emitPrologue(), llvm::XCoreFrameLowering::emitPrologue(), llvm::PPCFrameLowering::emitPrologue(), llvm::SystemZFrameLowering::emitPrologue(), llvm::AArch64FrameLowering::emitPrologue(), llvm::X86FrameLowering::emitPrologue(), llvm::EmitUnwindInfo(), llvm::MCObjectStreamer::EmitValueToOffset(), llvm::MCStreamer::EmitWin64EHAllocStack(), llvm::MCStreamer::EmitWin64EHEndChained(), llvm::MCStreamer::EmitWin64EHEndProc(), llvm::MCStreamer::EmitWin64EHEndProlog(), llvm::MCStreamer::EmitWin64EHPushFrame(), llvm::MCStreamer::EmitWin64EHPushReg(), llvm::MCStreamer::EmitWin64EHSaveReg(), llvm::MCStreamer::EmitWin64EHSaveXMM(), llvm::MCStreamer::EmitWin64EHStartChained(), llvm::MCStreamer::EmitWin64EHStartProc(), llvm::DwarfDebug::endInstruction(), llvm::MCStreamer::ForceExpAbs(), llvm::TargetLoweringObjectFile::getTTypeReference(), llvm::SelectionDAGBuilder::LowerCallTo(), llvm::MCLineEntry::Make(), llvm::MCGenDwarfLabelEntry::Make(), llvm::MCStreamer::RecordProcEnd(), llvm::MCStreamer::RecordProcStart(), and llvm::XCoreFrameLowering::spillCalleeSavedRegisters().

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

Definition at line 406 of file MCContext.h.

Referenced by operator delete().

void MCContext::FatalError ( SMLoc  L,
const Twine Msg 
)
const MCAsmInfo& llvm::MCContext::getAsmInfo ( ) const [inline]
const MCSection * MCContext::getCOFFSection ( StringRef  Section,
unsigned  Characteristics,
int  Selection,
SectionKind  Kind 
)
const MCSection* llvm::MCContext::getCOFFSection ( StringRef  Section,
unsigned  Characteristics,
SectionKind  Kind 
) [inline]

Definition at line 260 of file MCContext.h.

References getCOFFSection().

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

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.

Definition at line 275 of file MCContext.h.

Referenced by EmitGenDwarfInfo().

const MCDwarfLoc& llvm::MCContext::getCurrentDwarfLoc ( ) [inline]

Definition at line 361 of file MCContext.h.

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

MCSymbol * MCContext::GetDirectionalLocalSymbol ( int64_t  LocalLabelVal,
int  bORf 
)

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

Definition at line 183 of file MCContext.cpp.

References GetOrCreateSymbol(), and llvm::MCAsmInfo::getPrivateGlobalPrefix().

unsigned llvm::MCContext::getDwarfCompileUnitID ( ) [inline]

Definition at line 323 of file MCContext.h.

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

StringRef llvm::MCContext::getDwarfDebugFlags ( ) [inline]

Definition at line 386 of file MCContext.h.

Referenced by EmitGenDwarfAbbrev(), and EmitGenDwarfInfo().

StringRef llvm::MCContext::getDwarfDebugProducer ( ) [inline]

Definition at line 389 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 301 of file MCContext.cpp.

References Allocate(), llvm::StringRef::data(), llvm::StringRef::empty(), ARMBuildAttrs::File, llvm::sys::path::filename(), llvm::LibFunc::memcpy, llvm::sys::path::parent_path(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::SmallVectorImpl< T >::resize(), llvm::StringRef::size(), and llvm::SmallVectorTemplateCommon< T >::size().

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

bool llvm::MCContext::getDwarfLocSeen ( ) [inline]

Definition at line 360 of file MCContext.h.

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

const MCSectionELF * MCContext::getELFSection ( StringRef  Section,
unsigned  Type,
unsigned  Flags,
SectionKind  Kind 
)
const MCSectionELF * MCContext::getELFSection ( StringRef  Section,
unsigned  Type,
unsigned  Flags,
SectionKind  Kind,
unsigned  EntrySize,
StringRef  Group 
)
unsigned llvm::MCContext::getGenDwarfFileNumber ( ) [inline]

Definition at line 365 of file MCContext.h.

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

bool llvm::MCContext::getGenDwarfForAssembly ( ) [inline]

Definition at line 363 of file MCContext.h.

const MCSection* llvm::MCContext::getGenDwarfSection ( ) [inline]

Definition at line 367 of file MCContext.h.

Referenced by EmitGenDwarfAranges(), and llvm::MCGenDwarfLabelEntry::Make().

MCSymbol* llvm::MCContext::getGenDwarfSectionEndSym ( ) [inline]

Definition at line 373 of file MCContext.h.

Referenced by EmitGenDwarfInfo().

MCSymbol* llvm::MCContext::getGenDwarfSectionStartSym ( ) [inline]

Definition at line 369 of file MCContext.h.

Referenced by EmitGenDwarfAranges(), and EmitGenDwarfInfo().

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 206 of file MCContext.cpp.

References llvm::SmallVectorTemplateBase< char, isPodLike< char >::value >::push_back(), 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 241 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 284 of file MCContext.h.

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

Definition at line 308 of file MCContext.h.

Referenced by llvm::MCDwarfFileTable::EmitCU(), and EmitGenDwarfInfo().

const SmallVectorImpl<MCDwarfFile *>& llvm::MCContext::getMCDwarfFiles ( unsigned  CUID = 0) [inline]

Definition at line 305 of file MCContext.h.

Referenced by llvm::MCDwarfFileTable::EmitCU(), and EmitGenDwarfInfo().

const std::vector<const MCGenDwarfLabelEntry *>& llvm::MCContext::getMCGenDwarfLabelEntries ( ) const [inline]

Definition at line 378 of file MCContext.h.

Referenced by EmitGenDwarfInfo().

const std::vector<const MCSection *>& llvm::MCContext::getMCLineSectionOrder ( ) const [inline]

Definition at line 316 of file MCContext.h.

Referenced by llvm::MCDwarfFileTable::EmitCU().

const DenseMap<const MCSection *, MCLineSection *>& llvm::MCContext::getMCLineSections ( ) const [inline]
MCSymbol* llvm::MCContext::getMCLineTableSymbol ( unsigned  ID) const [inline]
const DenseMap<unsigned, MCSymbol *>& llvm::MCContext::getMCLineTableSymbols ( ) const [inline]

Definition at line 329 of file MCContext.h.

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

const MCObjectFileInfo* llvm::MCContext::getObjectFileInfo ( ) const [inline]
MCSymbol * MCContext::GetOrCreateSymbol ( StringRef  Name)

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 109 of file MCContext.cpp.

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

Referenced by CreateDirectionalLocalSymbol(), EmitCamlGlobal(), llvm::X86AsmPrinter::EmitEndOfAsmFile(), llvm::DwarfException::EmitExceptionTable(), llvm::MCELFStreamer::EmitFileDirective(), llvm::AsmPrinter::EmitFunctionHeader(), llvm::AsmPrinter::EmitGlobalVariable(), llvm::ARMAsmPrinter::EmitMachineConstantPoolValue(), llvm::AsmPrinter::EmitSpecialLLVMGlobal(), GetAnonSym(), llvm::MSP430MCInstLower::GetConstantPoolIndexSymbol(), llvm::MBlazeMCInstLower::GetConstantPoolIndexSymbol(), llvm::AsmPrinter::GetCPISymbol(), GetDirectionalLocalSymbol(), getELFSection(), llvm::AsmPrinter::GetExternalSymbolSymbol(), llvm::MachineFunction::getJTISymbol(), llvm::AsmPrinter::GetJTSetSymbol(), llvm::MSP430MCInstLower::GetJumpTableSymbol(), llvm::MBlazeMCInstLower::GetJumpTableSymbol(), GetLazyPtr(), GetOrCreateSymbol(), llvm::MachineFunction::getPICBaseSymbol(), getPICLabel(), llvm::Mangler::getSymbol(), llvm::MachineBasicBlock::getSymbol(), GetSymbolFromOperand(), llvm::AsmPrinter::GetSymbolWithGlobalValueBase(), llvm::AsmPrinter::GetTempSymbol(), LowerTlsAddr(), llvm::X86AsmPrinter::printSymbolOperand(), and tryAddingSymbolicOperand().

MCSymbol * MCContext::GetOrCreateSymbol ( const Twine Name)
const MCRegisterInfo& llvm::MCContext::getRegisterInfo ( ) const [inline]
raw_ostream* llvm::MCContext::getSecureLog ( ) [inline]

Definition at line 394 of file MCContext.h.

char* llvm::MCContext::getSecureLogFile ( ) [inline]

Definition at line 393 of file MCContext.h.

bool llvm::MCContext::getSecureLogUsed ( ) [inline]

Definition at line 395 of file MCContext.h.

const SourceMgr* llvm::MCContext::getSourceManager ( ) const [inline]

Definition at line 171 of file MCContext.h.

const SymbolTable& llvm::MCContext::getSymbols ( ) const [inline]

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 225 of file MCContext.h.

unsigned llvm::MCContext::getUniqueSymbolID ( ) [inline]

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

Definition at line 199 of file MCContext.h.

bool llvm::MCContext::hasDwarfFiles ( ) const [inline]

Definition at line 295 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 368 of file MCContext.cpp.

References llvm::SmallVectorTemplateCommon< T >::size().

MCSymbol * MCContext::LookupSymbol ( StringRef  Name) const

LookupSymbol - Get the symbol for Name, or null.

Definition at line 191 of file MCContext.cpp.

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

Referenced by LookupSymbol().

MCSymbol * MCContext::LookupSymbol ( const Twine Name) const
unsigned llvm::MCContext::nextGenDwarfFileNumber ( ) [inline]

Definition at line 366 of file MCContext.h.

void MCContext::reset ( )

reset - return object to right after construction state to prepare to process a new module

Definition at line 75 of file MCContext.cpp.

References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::clear(), llvm::StringMap< ValueTy, AllocatorTy >::clear(), DWARF2_FLAG_IS_STMT, and llvm::BumpPtrAllocator::Reset().

Referenced by llvm::MachineModuleInfo::doFinalization(), and ~MCContext().

void llvm::MCContext::setAllowTemporaryLabels ( bool  Value) [inline]
void llvm::MCContext::setCompilationDir ( StringRef  S) [inline]

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

Definition at line 279 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 347 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().

void llvm::MCContext::setDwarfCompileUnitID ( unsigned  CUIndex) [inline]

Definition at line 326 of file MCContext.h.

void llvm::MCContext::setDwarfDebugFlags ( StringRef  S) [inline]

Definition at line 385 of file MCContext.h.

void llvm::MCContext::setDwarfDebugProducer ( StringRef  S) [inline]

Definition at line 388 of file MCContext.h.

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

Definition at line 364 of file MCContext.h.

void llvm::MCContext::setGenDwarfSection ( const MCSection Sec) [inline]

Definition at line 368 of file MCContext.h.

void llvm::MCContext::setGenDwarfSectionEndSym ( MCSymbol Sym) [inline]

Definition at line 374 of file MCContext.h.

Referenced by EmitGenDwarfAranges().

void llvm::MCContext::setGenDwarfSectionStartSym ( MCSymbol Sym) [inline]

Definition at line 370 of file MCContext.h.

void llvm::MCContext::setMainFileName ( StringRef  S) [inline]

Set the main file name and override the default.

Definition at line 287 of file MCContext.h.

References llvm::StringRef::str().

void llvm::MCContext::setMCLineTableSymbol ( MCSymbol Sym,
unsigned  ID 
) [inline]

Definition at line 339 of file MCContext.h.

void llvm::MCContext::setSecureLog ( raw_ostream Value) [inline]

Definition at line 396 of file MCContext.h.

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

Definition at line 399 of file MCContext.h.


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