LLVM API Documentation
#include <Module.h>
Collaboration diagram for llvm::Module:
Public Types | |
typedef iplist< GlobalVariable > | GlobalListType |
typedef iplist< Function > | FunctionListType |
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) |
Function * | getOrInsertFunction (const std::string &Name, const FunctionType *T) |
Function * | getOrInsertFunction (const std::string &Name, const Type *RetTy,...) END_WITH_NULL |
Function * | getFunction (const std::string &Name, const FunctionType *Ty) |
Function * | getMainFunction () |
Function * | getNamedFunction (const std::string &Name) |
GlobalVariable * | getGlobalVariable (const std::string &Name, const Type *Ty, bool AllowInternal=false) |
GlobalVariable * | getNamedGlobal (const std::string &Name) |
bool | addTypeName (const std::string &Name, const Type *Ty) |
std::string | getTypeName (const Type *Ty) const |
const Type * | getTypeByName (const std::string &Name) const |
const GlobalListType & | getGlobalList () const |
GlobalListType & | getGlobalList () |
const FunctionListType & | getFunctionList () const |
FunctionListType & | getFunctionList () |
SymbolTable & | getSymbolTable () |
const SymbolTable & | getSymbolTable () 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 LibraryListType & | getLibraries () 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 |
Definition at line 49 of file Module.h.
typedef GlobalListType::const_iterator llvm::Module::const_global_iterator |
typedef FunctionListType::const_iterator llvm::Module::const_iterator |
typedef iplist<Function> llvm::Module::FunctionListType |
typedef iplist<GlobalVariable> llvm::Module::GlobalListType |
typedef SetVector<std::string> llvm::Module::LibraryListType |
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().
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] |
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 |
const_iterator llvm::Module::end | ( | ) | const [inline] |
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] |
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] |
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().
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] |
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] |
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().
const_global_iterator llvm::Module::global_end | ( | ) | const [inline] |
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 |
void llvm::Module::print | ( | std::ostream & | OS | ) | const [inline] |
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] |
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().