LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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 giterator
typedef GlobalListType::const_iterator const_giterator
typedef std::reverse_iterator<
giterator
reverse_giterator
typedef std::reverse_iterator<
const_giterator
const_reverse_giterator
typedef FunctionListType::iterator iterator
typedef FunctionListType::const_iterator const_iterator
typedef std::reverse_iterator<
iterator
reverse_iterator
typedef std::reverse_iterator<
const_iterator
const_reverse_iterator
typedef LibraryListType::const_iterator lib_iterator
enum  Endianness { AnyEndianness, LittleEndian, BigEndian }
enum  PointerSize { AnyPointerSize, Pointer32, Pointer64 }

Public Member Functions

 Module (const std::string &ModuleID)
 ~Module ()
const std::string & getModuleIdentifier () const
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)
FunctiongetOrInsertFunction (const std::string &Name, const FunctionType *T)
FunctiongetOrInsertFunction (const std::string &Name, const Type *RetTy,...)
FunctiongetFunction (const std::string &Name, const FunctionType *Ty)
FunctiongetMainFunction ()
FunctiongetNamedFunction (const std::string &Name)
GlobalVariablegetGlobalVariable (const std::string &Name, const Type *Ty)
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
 Get the underlying elements of the Module...
GlobalListTypegetGlobalList ()
const FunctionListTypegetFunctionList () const
FunctionListTypegetFunctionList ()
SymbolTablegetSymbolTable ()
const SymbolTablegetSymbolTable () const
giterator gbegin ()
const_giterator gbegin () const
giterator gend ()
const_giterator gend () const
reverse_giterator grbegin ()
const_reverse_giterator grbegin () const
reverse_giterator grend ()
const_reverse_giterator grend () const
size_t gsize () const
bool gempty () const
const GlobalVariablegfront () const
GlobalVariablegfront ()
const GlobalVariablegback () const
GlobalVariablegback ()
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
reverse_iterator rbegin ()
const_reverse_iterator rbegin () const
reverse_iterator rend ()
const_reverse_iterator rend () const
size_t size () const
bool empty () const
const Functionfront () const
Functionfront ()
const Functionback () const
Functionback ()
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 46 of file Module.h.


Member Typedef Documentation

typedef GlobalListType::const_iterator llvm::Module::const_giterator
 

Definition at line 54 of file Module.h.

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

Definition at line 60 of file Module.h.

typedef std::reverse_iterator<const_giterator> llvm::Module::const_reverse_giterator
 

Definition at line 56 of file Module.h.

typedef std::reverse_iterator<const_iterator> llvm::Module::const_reverse_iterator
 

Definition at line 62 of file Module.h.

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

Definition at line 49 of file Module.h.

typedef GlobalListType::iterator llvm::Module::giterator
 

Definition at line 53 of file Module.h.

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

Definition at line 48 of file Module.h.

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

Definition at line 59 of file Module.h.

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

Definition at line 65 of file Module.h.

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

Definition at line 50 of file Module.h.

typedef std::reverse_iterator<giterator> llvm::Module::reverse_giterator
 

Definition at line 55 of file Module.h.

typedef std::reverse_iterator<iterator> llvm::Module::reverse_iterator
 

Definition at line 61 of file Module.h.


Member Enumeration Documentation

enum llvm::Module::Endianness
 

Enumerator:
AnyEndianness 
LittleEndian 
BigEndian 

Definition at line 67 of file Module.h.

enum llvm::Module::PointerSize
 

Enumerator:
AnyPointerSize 
Pointer32 
Pointer64 

Definition at line 68 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 237 of file Module.h.

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

Referenced by llvm::LinkModules(), 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 236 of file Module.cpp.

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

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

Function& llvm::Module::back  )  [inline]
 

Definition at line 222 of file Module.h.

const Function& llvm::Module::back  )  const [inline]
 

Definition at line 221 of file Module.h.

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(), llvm::CloneModule(), dropAllReferences(), llvm::GetAllDefinedSymbols(), llvm::GetAllUndefinedSymbols(), llvm::ProfileInfoLoader::getBlockCounts(), llvm::ProfileInfoLoader::getEdgeCounts(), llvm::ProfileInfoLoader::getFunctionCounts(), getNamedFunction(), getSymbols(), LinkFunctionBodies(), LinkFunctionProtos(), llvm::LinkModules(), llvm::Mangler::Mangler(), printCollection(), llvm::TDDataStructures::runOnModule(), llvm::FunctionPass::runOnModule(), llvm::MemoryDepAnalysis::runOnModule(), llvm::LocalDataStructures::runOnModule(), llvm::IPModRef::runOnModule(), llvm::FindUsedTypes::runOnModule(), llvm::FindUnsafePointerTypes::runOnModule(), llvm::CompleteBUDataStructures::runOnModule(), llvm::CallGraph::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 285 of file Module.cpp.

References begin(), E, end(), gbegin(), gend(), 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 218 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(), llvm::CloneModule(), dropAllReferences(), llvm::GetAllDefinedSymbols(), llvm::GetAllUndefinedSymbols(), llvm::ProfileInfoLoader::getBlockCounts(), llvm::ProfileInfoLoader::getEdgeCounts(), llvm::ProfileInfoLoader::getFunctionCounts(), getNamedFunction(), getSymbols(), LinkFunctionBodies(), LinkFunctionProtos(), llvm::LinkModules(), llvm::Mangler::Mangler(), printCollection(), llvm::TDDataStructures::runOnModule(), llvm::FunctionPass::runOnModule(), llvm::MemoryDepAnalysis::runOnModule(), llvm::LocalDataStructures::runOnModule(), llvm::IPModRef::runOnModule(), llvm::FindUsedTypes::runOnModule(), llvm::FindUnsafePointerTypes::runOnModule(), llvm::CompleteBUDataStructures::runOnModule(), llvm::CallGraph::runOnModule(), and llvm::BUDataStructures::runOnModule().

Function& llvm::Module::front  )  [inline]
 

Definition at line 220 of file Module.h.

const Function& llvm::Module::front  )  const [inline]
 

Definition at line 219 of file Module.h.

GlobalVariable& llvm::Module::gback  )  [inline]
 

Definition at line 204 of file Module.h.

const GlobalVariable& llvm::Module::gback  )  const [inline]
 

Definition at line 203 of file Module.h.

const_giterator llvm::Module::gbegin  )  const [inline]
 

Definition at line 190 of file Module.h.

giterator llvm::Module::gbegin  )  [inline]
 

Definition at line 189 of file Module.h.

Referenced by llvm::CloneModule(), dropAllReferences(), llvm::GetAllDefinedSymbols(), llvm::GetAllUndefinedSymbols(), getSymbols(), LinkGlobalInits(), LinkGlobals(), llvm::LinkModules(), llvm::Mangler::Mangler(), llvm::LocalDataStructures::runOnModule(), and llvm::FindUsedTypes::runOnModule().

bool llvm::Module::gempty  )  const [inline]
 

Definition at line 200 of file Module.h.

const_giterator llvm::Module::gend  )  const [inline]
 

Definition at line 192 of file Module.h.

giterator llvm::Module::gend  )  [inline]
 

Definition at line 191 of file Module.h.

Referenced by llvm::CloneModule(), dropAllReferences(), llvm::GetAllDefinedSymbols(), llvm::GetAllUndefinedSymbols(), getSymbols(), LinkGlobalInits(), LinkGlobals(), llvm::LinkModules(), llvm::Mangler::Mangler(), llvm::LocalDataStructures::runOnModule(), and llvm::FindUsedTypes::runOnModule().

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

Target endian information...

Definition at line 94 of file Module.h.

Referenced by llvm::BytecodeWriter::BytecodeWriter(), llvm::CloneModule(), llvm::Interpreter::create(), llvm::X86TargetMachine::getModuleMatchQuality(), llvm::PPC64TargetMachine::getModuleMatchQuality(), llvm::PPC32TargetMachine::getModuleMatchQuality(), llvm::LinkModules(), 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(), and llvm::SymbolTable::lookup().

Referenced by getMainFunction(), and LinkFunctionProtos().

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

Definition at line 176 of file Module.h.

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

Definition at line 175 of file Module.h.

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

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

Definition at line 174 of file Module.h.

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

Get the underlying elements of the Module...

Definition at line 173 of file Module.h.

Referenced by llvm::GlobalVariable::eraseFromParent(), getStringRef(), llvm::GlobalVariable::GlobalVariable(), LinkAppendingVars(), LinkGlobals(), OptimizeGlobalAddressOfMalloc(), ParseGlobalVariable(), llvm::GlobalVariable::removeFromParent(), ResolveGlobalVariables(), llvm::ProfilePaths::runOnFunction(), and SRAGlobal().

GlobalVariable * Module::getGlobalVariable const std::string &  Name,
const Type Ty
 

getGlobalVariable - Look up the specified global variable in the module symbol table. If it does not exist, return null. Note that this only returns a global variable if it does not have internal linkage. 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.

Definition at line 215 of file Module.cpp.

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

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

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

Get all the libraries.

Definition at line 243 of file Module.h.

Referenced by llvm::GetBytecodeDependentLibraries(), and llvm::LinkLibraries().

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 llvm::TDDataStructures::runOnModule(), llvm::CompleteBUDataStructures::runOnModule(), and llvm::BUDataStructures::runOnModule().

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

Definition at line 89 of file Module.h.

Referenced by llvm::CloneModule(), llvm::LinkModules(), llvm::PMDebug::PrintPassInformation(), and llvm::ProgramInfo::ProgramInfo().

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 llvm::RunVMAsmParser().

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(), and getOrInsertFunction().

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(), and V.

Referenced by CheckVarargs(), Cilkifier::Cilkifier(), EnsureFunctionExists(), getOrInsertFunction(), llvm::getTriggerCode(), InsertInstrumentationCall(), llvm::InsertProfilingInitCall(), ReplaceCallWith(), llvm::ProfilePaths::runOnFunction(), and llvm::RunVMAsmParser().

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

Target Pointer Size information...

Definition at line 98 of file Module.h.

Referenced by llvm::BytecodeWriter::BytecodeWriter(), llvm::CloneModule(), llvm::Interpreter::create(), llvm::X86TargetMachine::getModuleMatchQuality(), llvm::PPC64TargetMachine::getModuleMatchQuality(), llvm::PPC32TargetMachine::getModuleMatchQuality(), llvm::LinkModules(), lle_X_sprintf(), and llvm::TargetData::TargetData().

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

Definition at line 182 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 181 of file Module.h.

Referenced by addTypeName(), llvm::BytecodeWriter::BytecodeWriter(), llvm::CloneModule(), fillTypeNameTable(), ForceRenaming(), getFunction(), getGlobalVariable(), getOrInsertFunction(), getTypeByName(), getTypeName(), LinkFunctionProtos(), LinkGlobals(), LinkTypes(), lookupInSymbolTable(), llvm::BytecodeReader::ParseModule(), llvm::Function::renameLocalSymbols(), llvm::GlobalVariable::setName(), and llvm::Function::setName().

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

Definition at line 90 of file Module.h.

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 250 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 258 of file Module.cpp.

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

GlobalVariable& llvm::Module::gfront  )  [inline]
 

Definition at line 202 of file Module.h.

const GlobalVariable& llvm::Module::gfront  )  const [inline]
 

Definition at line 201 of file Module.h.

const_reverse_giterator llvm::Module::grbegin  )  const [inline]
 

Definition at line 195 of file Module.h.

reverse_giterator llvm::Module::grbegin  )  [inline]
 

Definition at line 194 of file Module.h.

const_reverse_giterator llvm::Module::grend  )  const [inline]
 

Definition at line 197 of file Module.h.

reverse_giterator llvm::Module::grend  )  [inline]
 

Definition at line 196 of file Module.h.

size_t llvm::Module::gsize  )  const [inline]
 

Definition at line 199 of file Module.h.

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

Get a constant iterator to beginning of dependent library list.

Definition at line 228 of file Module.h.

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

Referenced by llvm::LinkModules().

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

Get a constant iterator to end of dependent library list.

Definition at line 231 of file Module.h.

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

Referenced by llvm::LinkModules().

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

Returns the number of items in the list of libraries.

Definition at line 234 of file Module.h.

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

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

Definition at line 1188 of file AsmWriter.cpp.

References llvm::AssemblyWriter::write().

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

Definition at line 248 of file Module.h.

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

const_reverse_iterator llvm::Module::rbegin  )  const [inline]
 

Definition at line 213 of file Module.h.

reverse_iterator llvm::Module::rbegin  )  [inline]
 

Definition at line 212 of file Module.h.

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

Remove a library from the list of dependent libraries.

Definition at line 240 of file Module.h.

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

Referenced by llvm::LinkModules().

const_reverse_iterator llvm::Module::rend  )  const [inline]
 

Definition at line 215 of file Module.h.

reverse_iterator llvm::Module::rend  )  [inline]
 

Definition at line 214 of file Module.h.

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

Definition at line 95 of file Module.h.

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

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

Definition at line 99 of file Module.h.

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

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

Definition at line 91 of file Module.h.

Referenced by llvm::BytecodeReader::ParseModuleGlobalInfo().

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

Definition at line 217 of file Module.h.


Friends And Related Function Documentation

friend class Constant [friend]
 

Definition at line 83 of file Module.h.


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