LLVM API Documentation

llvm::Module Class Reference

#include <Module.h>

Collaboration diagram for llvm::Module:

Collaboration graph
[legend]
List of all members.

Public Types

typedef iplist< GlobalVariableGlobalListType
typedef iplist< FunctionFunctionListType
typedef SetVector< std::string > LibraryListType
typedef GlobalListType::iterator global_iterator
typedef GlobalListType::const_iterator const_global_iterator
typedef FunctionListType::iterator iterator
typedef FunctionListType::const_iterator const_iterator
typedef LibraryListType::const_iterator lib_iterator
 AnyEndianness
 LittleEndian
 BigEndian
 AnyPointerSize
 Pointer32
 Pointer64
enum  Endianness { AnyEndianness, LittleEndian, BigEndian }
enum  PointerSize { AnyPointerSize, Pointer32, Pointer64 }

Public Member Functions

 Module (const std::string &ModuleID)
 ~Module ()
const std::string & getModuleIdentifier () const
void setModuleIdentifier (const std::string &ID)
const std::string & getTargetTriple () const
void setTargetTriple (const std::string &T)
Endianness getEndianness () const
 Target endian information...
void setEndianness (Endianness E)
PointerSize getPointerSize () const
 Target Pointer Size information...
void setPointerSize (PointerSize PS)
const std::string & getModuleInlineAsm () const
void setModuleInlineAsm (const std::string &Asm)
FunctiongetOrInsertFunction (const std::string &Name, const FunctionType *T)
FunctiongetOrInsertFunction (const std::string &Name, const Type *RetTy,...) END_WITH_NULL
FunctiongetFunction (const std::string &Name, const FunctionType *Ty)
FunctiongetMainFunction ()
FunctiongetNamedFunction (const std::string &Name)
GlobalVariablegetGlobalVariable (const std::string &Name, const Type *Ty, bool AllowInternal=false)
GlobalVariablegetNamedGlobal (const std::string &Name)
bool addTypeName (const std::string &Name, const Type *Ty)
std::string getTypeName (const Type *Ty) const
const TypegetTypeByName (const std::string &Name) const
const GlobalListTypegetGlobalList () const
GlobalListTypegetGlobalList ()
const FunctionListTypegetFunctionList () const
FunctionListTypegetFunctionList ()
SymbolTablegetSymbolTable ()
const SymbolTablegetSymbolTable () const
global_iterator global_begin ()
const_global_iterator global_begin () const
global_iterator global_end ()
const_global_iterator global_end () const
bool global_empty () const
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
size_t size () const
bool empty () const
lib_iterator lib_begin () const
 Get a constant iterator to beginning of dependent library list.
lib_iterator lib_end () const
 Get a constant iterator to end of dependent library list.
size_t lib_size () const
 Returns the number of items in the list of libraries.
void addLibrary (const std::string &Lib)
 Add a library to the list of dependent libraries.
void removeLibrary (const std::string &Lib)
 Remove a library from the list of dependent libraries.
const LibraryListTypegetLibraries () const
 Get all the libraries.
void print (std::ostream &OS) const
void print (std::ostream &OS, AssemblyAnnotationWriter *AAW) const
void dump () const
void dropAllReferences ()

Friends

class Constant

Detailed Description

Definition at line 49 of file Module.h.


Member Typedef Documentation

typedef GlobalListType::const_iterator llvm::Module::const_global_iterator

Definition at line 57 of file Module.h.

typedef FunctionListType::const_iterator llvm::Module::const_iterator

Definition at line 61 of file Module.h.

typedef iplist<Function> llvm::Module::FunctionListType

Definition at line 52 of file Module.h.

typedef GlobalListType::iterator llvm::Module::global_iterator

Definition at line 56 of file Module.h.

typedef iplist<GlobalVariable> llvm::Module::GlobalListType

Definition at line 51 of file Module.h.

typedef FunctionListType::iterator llvm::Module::iterator

Definition at line 60 of file Module.h.

typedef LibraryListType::const_iterator llvm::Module::lib_iterator

Definition at line 64 of file Module.h.

typedef SetVector<std::string> llvm::Module::LibraryListType

Definition at line 53 of file Module.h.


Member Enumeration Documentation

enum llvm::Module::Endianness

Enumerator:
AnyEndianness 
LittleEndian 
BigEndian 

Definition at line 66 of file Module.h.

enum llvm::Module::PointerSize

Enumerator:
AnyPointerSize 
Pointer32 
Pointer64 

Definition at line 67 of file Module.h.


Constructor & Destructor Documentation

Module::Module ( const std::string &  ModuleID  ) 

Definition at line 63 of file Module.cpp.

Module::~Module (  ) 

Definition at line 72 of file Module.cpp.

References llvm::SetVector< T >::clear(), and dropAllReferences().


Member Function Documentation

void llvm::Module::addLibrary ( const std::string &  Lib  )  [inline]

Add a library to the list of dependent libraries.

Definition at line 228 of file Module.h.

References llvm::SetVector< T >::insert().

Referenced by llvm::CloneModule(), and llvm::BytecodeReader::ParseModuleGlobalInfo().

bool Module::addTypeName ( const std::string &  Name,
const Type Ty 
)

addTypeName - Insert an entry in the symbol table mapping Str to Type. If there is already an entry for this name, true is returned and the symbol table is not modified.

Definition at line 250 of file Module.cpp.

References getSymbolTable(), llvm::SymbolTable::insert(), llvm::SymbolTable::lookupType(), and Ty.

Referenced by llvm::CloneModule(), llvm::DISerializer::getTagType(), and setTypeName().

const_iterator llvm::Module::begin (  )  const [inline]

Definition at line 208 of file Module.h.

iterator llvm::Module::begin (  )  [inline]

Definition at line 207 of file Module.h.

Referenced by llvm::DefaultIntrinsicLowering::AddPrototypes(), llvm::BytecodeWriter::BytecodeWriter(), CheckAllGraphs(), llvm::CloneModule(), dropAllReferences(), GetAllDefinedSymbols(), GetAllUndefinedSymbols(), llvm::ProfileInfoLoader::getBlockCounts(), llvm::ProfileInfoLoader::getEdgeCounts(), llvm::ProfileInfoLoader::getFunctionCounts(), getNamedFunction(), llvm::SlotCalculator::getPlane(), getSymbols(), llvm::Mangler::Mangler(), PerModuleInfo::ModuleDone(), printCollection(), llvm::TDDataStructures::runOnModule(), llvm::FunctionPass::runOnModule(), llvm::LocalDataStructures::runOnModule(), llvm::FindUsedTypes::runOnModule(), llvm::EquivClassGraphs::runOnModule(), llvm::CompleteBUDataStructures::runOnModule(), and llvm::BUDataStructures::runOnModule().

void Module::dropAllReferences (  ) 

dropAllReferences() - This function causes all the subinstructions to "let go" of all references that they are maintaining. This allows one to 'delete' a whole class at a time, even though there may be circular references... first all references are dropped, and all use counts go to zero. Then everything is delete'd for real. Note that no operations are valid on an object that has "dropped all references", except operator delete.

Definition at line 299 of file Module.cpp.

References begin(), E, end(), global_begin(), global_end(), and I.

Referenced by ~Module().

void Module::dump (  )  const

Definition at line 83 of file Module.cpp.

References print().

bool llvm::Module::empty (  )  const [inline]

Definition at line 213 of file Module.h.

const_iterator llvm::Module::end (  )  const [inline]

Definition at line 210 of file Module.h.

iterator llvm::Module::end (  )  [inline]

Definition at line 209 of file Module.h.

Referenced by llvm::DefaultIntrinsicLowering::AddPrototypes(), llvm::BytecodeWriter::BytecodeWriter(), CheckAllGraphs(), llvm::CloneModule(), dropAllReferences(), GetAllDefinedSymbols(), GetAllUndefinedSymbols(), llvm::ProfileInfoLoader::getBlockCounts(), llvm::ProfileInfoLoader::getEdgeCounts(), llvm::ProfileInfoLoader::getFunctionCounts(), getNamedFunction(), llvm::SlotCalculator::getPlane(), getSymbols(), llvm::Mangler::Mangler(), PerModuleInfo::ModuleDone(), printCollection(), llvm::TDDataStructures::runOnModule(), llvm::FunctionPass::runOnModule(), llvm::LocalDataStructures::runOnModule(), llvm::FindUsedTypes::runOnModule(), llvm::EquivClassGraphs::runOnModule(), llvm::CompleteBUDataStructures::runOnModule(), and llvm::BUDataStructures::runOnModule().

Endianness llvm::Module::getEndianness (  )  const [inline]

Target endian information...

Definition at line 93 of file Module.h.

Referenced by llvm::BytecodeWriter::BytecodeWriter(), llvm::CloneModule(), llvm::Interpreter::create(), llvm::X86TargetMachine::getModuleMatchQuality(), llvm::SparcTargetMachine::getModuleMatchQuality(), llvm::PPCTargetMachine::getModuleMatchQuality(), llvm::AlphaTargetMachine::getModuleMatchQuality(), and llvm::TargetData::TargetData().

Function * Module::getFunction ( const std::string &  Name,
const FunctionType Ty 
)

getFunction - Look up the specified function in the module symbol table. If it does not exist, return null.

Definition at line 135 of file Module.cpp.

References llvm::PointerType::get(), getSymbolTable(), llvm::SymbolTable::lookup(), and Ty.

Referenced by getMainFunction().

FunctionListType& llvm::Module::getFunctionList (  )  [inline]

Definition at line 187 of file Module.h.

const FunctionListType& llvm::Module::getFunctionList (  )  const [inline]

Definition at line 186 of file Module.h.

Referenced by llvm::Function::eraseFromParent(), llvm::Function::Function(), llvm::Function::removeFromParent(), llvm::CallGraph::removeFunctionFromModule(), ResolveFunctions(), and RunParser().

GlobalListType& llvm::Module::getGlobalList (  )  [inline]

Definition at line 185 of file Module.h.

const GlobalListType& llvm::Module::getGlobalList (  )  const [inline]

Definition at line 184 of file Module.h.

Referenced by llvm::GlobalVariable::eraseFromParent(), getStringRef(), llvm::GlobalVariable::GlobalVariable(), InstallGlobalCtors(), LinkAppendingVars(), OptimizeGlobalAddressOfMalloc(), ParseGlobalVariable(), llvm::GlobalVariable::removeFromParent(), ResolveGlobalVariables(), ShrinkGlobalToBoolean(), and SRAGlobal().

GlobalVariable * Module::getGlobalVariable ( const std::string &  Name,
const Type Ty,
bool  AllowInternal = false 
)

getGlobalVariable - Look up the specified global variable in the module symbol table. If it does not exist, return null. The type argument should be the underlying type of the global, i.e., it should not have the top-level PointerType, which represents the address of the global. If AllowInternal is set to true, this function will return types that have InternalLinkage. By default, these types are not returned.

Definition at line 215 of file Module.cpp.

References llvm::PointerType::get(), getSymbolTable(), llvm::GlobalValue::hasInternalLinkage(), Ty, and V.

Referenced by getGlobalVariablesUsing(), llvm::ProgramInfo::getSourceFiles(), llvm::ProgramInfo::getSourceFunctions(), and ParseGlobalVariable().

const LibraryListType& llvm::Module::getLibraries (  )  const [inline]

Get all the libraries.

Definition at line 234 of file Module.h.

Referenced by llvm::GetBytecodeDependentLibraries(), and llvm::Linker::LinkInLibraries().

Function * Module::getMainFunction (  ) 

getMainFunction - This function looks up main efficiently. This is such a common case, that it is a method in Module. If main cannot be found, a null pointer is returned.

Definition at line 145 of file Module.cpp.

References F, llvm::PointerType::get(), llvm::FunctionType::get(), getFunction(), getNamedFunction(), llvm::Type::IntTy, llvm::Type::SByteTy, and llvm::Type::VoidTy.

Referenced by GetAllUndefinedSymbols(), llvm::TDDataStructures::runOnModule(), llvm::EquivClassGraphs::runOnModule(), llvm::CompleteBUDataStructures::runOnModule(), and llvm::BUDataStructures::runOnModule().

const std::string& llvm::Module::getModuleIdentifier (  )  const [inline]

Definition at line 86 of file Module.h.

Referenced by llvm::CloneModule(), llvm::Linker::LinkInArchive(), llvm::PMDebug::PrintPassInformation(), llvm::ProgramInfo::ProgramInfo(), and ResolveFunctions().

const std::string& llvm::Module::getModuleInlineAsm (  )  const [inline]

Definition at line 101 of file Module.h.

Referenced by llvm::CloneModule(), and llvm::AsmPrinter::doInitialization().

Function * Module::getNamedFunction ( const std::string &  Name  ) 

getNamedFunction - Return the first function in the module with the specified name, of arbitrary type. This method returns null if a function with the specified name is not found.

Definition at line 192 of file Module.cpp.

References begin(), E, end(), and I.

Referenced by CheckVarargs(), EnsureFunctionExists(), getMainFunction(), getPointerToNamedFunction(), ReplaceCallWith(), and RunParser().

GlobalVariable * Module::getNamedGlobal ( const std::string &  Name  ) 

getNamedGlobal - Return the first global variable in the module with the specified name, of arbitrary type. This method returns null if a global with the specified name is not found.

Definition at line 229 of file Module.cpp.

References E, global_begin(), global_end(), and I.

Referenced by llvm::ExecutionEngine::runStaticConstructorsDestructors().

Function * Module::getOrInsertFunction ( const std::string &  Name,
const Type RetTy,
  ... 
)

getOrInsertFunction - Look up the specified function in the module symbol table. If it does not exist, add a prototype for the function and return it. This version of the method takes a null terminated list of function arguments, which makes it easier for clients to use.

Definition at line 115 of file Module.cpp.

References llvm::FunctionType::get(), getOrInsertFunction(), and RetTy.

Function * Module::getOrInsertFunction ( const std::string &  Name,
const FunctionType T 
)

getOrInsertFunction - Look up the specified function in the module symbol table. If it does not exist, add a prototype for the function and return it.

Definition at line 96 of file Module.cpp.

References llvm::GlobalValue::ExternalLinkage, llvm::PointerType::get(), getSymbolTable(), llvm::SymbolTable::lookup(), Ty, and V.

Referenced by CheckVarargs(), EnsureFunctionExists(), getOrInsertFunction(), getUpgradedIntrinsic(), getUpgradedUnaryFn(), llvm::InlineFunction(), InsertInstrumentationCall(), llvm::InsertProfilingInitCall(), llvm::BytecodeReader::ParseInstruction(), ReplaceCallWith(), and RunParser().

PointerSize llvm::Module::getPointerSize (  )  const [inline]

Target Pointer Size information...

Definition at line 97 of file Module.h.

Referenced by llvm::BytecodeWriter::BytecodeWriter(), llvm::CloneModule(), llvm::Interpreter::create(), llvm::X86TargetMachine::getModuleMatchQuality(), llvm::SparcTargetMachine::getModuleMatchQuality(), llvm::PPCTargetMachine::getModuleMatchQuality(), llvm::AlphaTargetMachine::getModuleMatchQuality(), lle_X_sprintf(), and llvm::TargetData::TargetData().

const SymbolTable& llvm::Module::getSymbolTable (  )  const [inline]

Definition at line 193 of file Module.h.

SymbolTable& llvm::Module::getSymbolTable (  )  [inline]

getSymbolTable() - Get access to the symbol table for the module, where global variables and functions are identified.

Definition at line 192 of file Module.h.

Referenced by addTypeName(), llvm::BytecodeWriter::BytecodeWriter(), llvm::CloneModule(), fillTypeNameTable(), ForceRenaming(), getFunction(), getGlobalVariable(), getOrInsertFunction(), llvm::SlotCalculator::getPlane(), getTypeByName(), getTypeName(), lookupInSymbolTable(), llvm::BytecodeReader::ParseModule(), and llvm::Function::renameLocalSymbols().

const std::string& llvm::Module::getTargetTriple (  )  const [inline]

Definition at line 89 of file Module.h.

Referenced by llvm::CloneModule(), llvm::X86TargetMachine::getModuleMatchQuality(), llvm::SparcTargetMachine::getModuleMatchQuality(), llvm::PPCTargetMachine::getModuleMatchQuality(), llvm::IA64TargetMachine::getModuleMatchQuality(), llvm::AlphaTargetMachine::getModuleMatchQuality(), llvm::PPCSubtarget::PPCSubtarget(), and llvm::X86Subtarget::X86Subtarget().

const Type * Module::getTypeByName ( const std::string &  Name  )  const

getTypeByName - Return the type with the specified name in this module, or null if there is none by that name.

Definition at line 264 of file Module.cpp.

References getSymbolTable(), and llvm::SymbolTable::lookupType().

Referenced by getTypeVal(), and setTypeName().

std::string Module::getTypeName ( const Type Ty  )  const

getTypeName - If there is at least one entry in the symbol table for the specified type, return it.

Definition at line 272 of file Module.cpp.

References getSymbolTable(), Ty, llvm::SymbolTable::type_begin(), and llvm::SymbolTable::type_end().

const_global_iterator llvm::Module::global_begin (  )  const [inline]

Definition at line 201 of file Module.h.

global_iterator llvm::Module::global_begin (  )  [inline]

Definition at line 200 of file Module.h.

Referenced by llvm::CloneModule(), llvm::X86SharedAsmPrinter::doFinalization(), llvm::ELFWriter::doFinalization(), dropAllReferences(), llvm::ExecutionEngine::emitGlobals(), GetAllDefinedSymbols(), GetAllUndefinedSymbols(), getNamedGlobal(), llvm::SlotCalculator::getPlane(), getSymbols(), llvm::Mangler::Mangler(), llvm::LocalDataStructures::runOnModule(), llvm::FindUsedTypes::runOnModule(), and llvm::EquivClassGraphs::runOnModule().

bool llvm::Module::global_empty (  )  const [inline]

Definition at line 204 of file Module.h.

const_global_iterator llvm::Module::global_end (  )  const [inline]

Definition at line 203 of file Module.h.

global_iterator llvm::Module::global_end (  )  [inline]

Definition at line 202 of file Module.h.

Referenced by llvm::CloneModule(), llvm::X86SharedAsmPrinter::doFinalization(), llvm::ELFWriter::doFinalization(), dropAllReferences(), llvm::ExecutionEngine::emitGlobals(), GetAllDefinedSymbols(), GetAllUndefinedSymbols(), getNamedGlobal(), llvm::SlotCalculator::getPlane(), getSymbols(), llvm::Mangler::Mangler(), llvm::LocalDataStructures::runOnModule(), llvm::FindUsedTypes::runOnModule(), and llvm::EquivClassGraphs::runOnModule().

lib_iterator llvm::Module::lib_begin (  )  const [inline]

Get a constant iterator to beginning of dependent library list.

Definition at line 219 of file Module.h.

References llvm::SetVector< T >::begin().

Referenced by llvm::CloneModule(), and llvm::Linker::LinkInItems().

lib_iterator llvm::Module::lib_end (  )  const [inline]

Get a constant iterator to end of dependent library list.

Definition at line 222 of file Module.h.

References llvm::SetVector< T >::end().

Referenced by llvm::CloneModule(), and llvm::Linker::LinkInItems().

size_t llvm::Module::lib_size (  )  const [inline]

Returns the number of items in the list of libraries.

Definition at line 225 of file Module.h.

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

void Module::print ( std::ostream &  OS,
AssemblyAnnotationWriter AAW 
) const

Definition at line 1273 of file AsmWriter.cpp.

References llvm::AssemblyWriter::write().

void llvm::Module::print ( std::ostream &  OS  )  const [inline]

Definition at line 239 of file Module.h.

Referenced by dump(), and llvm::operator<<().

void llvm::Module::removeLibrary ( const std::string &  Lib  )  [inline]

Remove a library from the list of dependent libraries.

Definition at line 231 of file Module.h.

References llvm::SetVector< T >::remove().

void llvm::Module::setEndianness ( Endianness  E  )  [inline]

Definition at line 94 of file Module.h.

Referenced by llvm::CloneModule(), and llvm::BytecodeReader::ParseVersionInfo().

void llvm::Module::setModuleIdentifier ( const std::string &  ID  )  [inline]

Definition at line 87 of file Module.h.

void llvm::Module::setModuleInlineAsm ( const std::string &  Asm  )  [inline]

Definition at line 102 of file Module.h.

Referenced by llvm::CloneModule(), and llvm::BytecodeReader::ParseModuleGlobalInfo().

void llvm::Module::setPointerSize ( PointerSize  PS  )  [inline]

Definition at line 98 of file Module.h.

Referenced by llvm::CloneModule(), and llvm::BytecodeReader::ParseVersionInfo().

void llvm::Module::setTargetTriple ( const std::string &  T  )  [inline]

Definition at line 90 of file Module.h.

Referenced by llvm::CloneModule(), and llvm::BytecodeReader::ParseModuleGlobalInfo().

size_t llvm::Module::size (  )  const [inline]

Definition at line 212 of file Module.h.


Friends And Related Function Documentation

friend class Constant [friend]

Definition at line 80 of file Module.h.


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