LLVM  4.0.0
Functions
Modules

Modules represent the top-level structure in an LLVM program. More...

Collaboration diagram for Modules:

Functions

LLVMModuleRef LLVMModuleCreateWithName (const char *ModuleID)
 Create a new, empty module in the global context. More...
 
LLVMModuleRef LLVMModuleCreateWithNameInContext (const char *ModuleID, LLVMContextRef C)
 Create a new, empty module in a specific context. More...
 
LLVMModuleRef LLVMCloneModule (LLVMModuleRef M)
 Return an exact copy of the specified module. More...
 
void LLVMDisposeModule (LLVMModuleRef M)
 Destroy a module instance. More...
 
const char * LLVMGetModuleIdentifier (LLVMModuleRef M, size_t *Len)
 Obtain the identifier of a module. More...
 
void LLVMSetModuleIdentifier (LLVMModuleRef M, const char *Ident, size_t Len)
 Set the identifier of a module to a string Ident with length Len. More...
 
const char * LLVMGetDataLayoutStr (LLVMModuleRef M)
 Obtain the data layout for a module. More...
 
const char * LLVMGetDataLayout (LLVMModuleRef M)
 
void LLVMSetDataLayout (LLVMModuleRef M, const char *DataLayoutStr)
 Set the data layout for a module. More...
 
const char * LLVMGetTarget (LLVMModuleRef M)
 Obtain the target triple for a module. More...
 
void LLVMSetTarget (LLVMModuleRef M, const char *Triple)
 Set the target triple for a module. More...
 
void LLVMDumpModule (LLVMModuleRef M)
 Dump a representation of a module to stderr. More...
 
LLVMBool LLVMPrintModuleToFile (LLVMModuleRef M, const char *Filename, char **ErrorMessage)
 Print a representation of a module to a file. More...
 
char * LLVMPrintModuleToString (LLVMModuleRef M)
 Return a string representation of the module. More...
 
void LLVMSetModuleInlineAsm (LLVMModuleRef M, const char *Asm)
 Set inline assembly for a module. More...
 
LLVMContextRef LLVMGetModuleContext (LLVMModuleRef M)
 Obtain the context to which this module is associated. More...
 
LLVMTypeRef LLVMGetTypeByName (LLVMModuleRef M, const char *Name)
 Obtain a Type from a module by its registered name. More...
 
unsigned LLVMGetNamedMetadataNumOperands (LLVMModuleRef M, const char *Name)
 Obtain the number of operands for named metadata in a module. More...
 
void LLVMGetNamedMetadataOperands (LLVMModuleRef M, const char *Name, LLVMValueRef *Dest)
 Obtain the named metadata operands for a module. More...
 
void LLVMAddNamedMetadataOperand (LLVMModuleRef M, const char *Name, LLVMValueRef Val)
 Add an operand to named metadata. More...
 
LLVMValueRef LLVMAddFunction (LLVMModuleRef M, const char *Name, LLVMTypeRef FunctionTy)
 Add a function to a module under a specified name. More...
 
LLVMValueRef LLVMGetNamedFunction (LLVMModuleRef M, const char *Name)
 Obtain a Function value from a Module by its name. More...
 
LLVMValueRef LLVMGetFirstFunction (LLVMModuleRef M)
 Obtain an iterator to the first Function in a Module. More...
 
LLVMValueRef LLVMGetLastFunction (LLVMModuleRef M)
 Obtain an iterator to the last Function in a Module. More...
 
LLVMValueRef LLVMGetNextFunction (LLVMValueRef Fn)
 Advance a Function iterator to the next Function. More...
 
LLVMValueRef LLVMGetPreviousFunction (LLVMValueRef Fn)
 Decrement a Function iterator to the previous Function. More...
 

Detailed Description

Modules represent the top-level structure in an LLVM program.

An LLVM module is effectively a translation unit or a collection of translation units merged together.

Function Documentation

LLVMValueRef LLVMAddFunction ( LLVMModuleRef  M,
const char *  Name,
LLVMTypeRef  FunctionTy 
)

Add a function to a module under a specified name.

See Also
llvm::Function::Create()

Definition at line 1755 of file Core.cpp.

References llvm::Function::Create(), llvm::GlobalValue::ExternalLinkage, llvm::unwrap(), and llvm::wrap().

void LLVMAddNamedMetadataOperand ( LLVMModuleRef  M,
const char *  Name,
LLVMValueRef  Val 
)

Add an operand to named metadata.

See Also
llvm::Module::getNamedMetadata()
llvm::MDNode::addOperand()

Definition at line 911 of file Core.cpp.

References llvm::NamedMDNode::addOperand(), extractMDNode(), N, and llvm::unwrap().

LLVMModuleRef LLVMCloneModule ( LLVMModuleRef  M)

Return an exact copy of the specified module.

Definition at line 183 of file CloneModule.cpp.

References llvm::CloneModule(), llvm::release, llvm::unwrap(), and llvm::wrap().

void LLVMDisposeModule ( LLVMModuleRef  M)

Destroy a module instance.

This must be called for every created module or memory will be leaked.

Definition at line 224 of file Core.cpp.

References llvm::unwrap().

void LLVMDumpModule ( LLVMModuleRef  M)

Dump a representation of a module to stderr.

See Also
Module::dump()

Definition at line 261 of file Core.cpp.

References llvm::unwrap().

const char* LLVMGetDataLayout ( LLVMModuleRef  M)

Definition at line 244 of file Core.cpp.

References LLVMGetDataLayoutStr().

const char* LLVMGetDataLayoutStr ( LLVMModuleRef  M)

Obtain the data layout for a module.

See Also
Module::getDataLayoutStr()

LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect, but match the name of another method on the module. Prefer the use of LLVMGetDataLayoutStr, which is not ambiguous.

Definition at line 240 of file Core.cpp.

References llvm::unwrap().

Referenced by LLVMGetDataLayout().

LLVMValueRef LLVMGetFirstFunction ( LLVMModuleRef  M)

Obtain an iterator to the first Function in a Module.

See Also
llvm::Module::begin()

Definition at line 1765 of file Core.cpp.

References llvm::Module::begin(), llvm::Module::end(), I, llvm::unwrap(), and llvm::wrap().

LLVMValueRef LLVMGetLastFunction ( LLVMModuleRef  M)

Obtain an iterator to the last Function in a Module.

See Also
llvm::Module::end()

Definition at line 1773 of file Core.cpp.

References llvm::Module::begin(), llvm::Module::end(), I, llvm::unwrap(), and llvm::wrap().

LLVMContextRef LLVMGetModuleContext ( LLVMModuleRef  M)

Obtain the context to which this module is associated.

See Also
Module::getContext()

Definition at line 303 of file Core.cpp.

References llvm::unwrap(), and llvm::wrap().

const char* LLVMGetModuleIdentifier ( LLVMModuleRef  M,
size_t *  Len 
)

Obtain the identifier of a module.

Parameters
MModule to obtain identifier of
LenOut parameter which holds the length of the returned string.
Returns
The identifier of M.
See Also
Module::getModuleIdentifier()

Definition at line 228 of file Core.cpp.

References llvm::unwrap().

LLVMValueRef LLVMGetNamedFunction ( LLVMModuleRef  M,
const char *  Name 
)

Obtain a Function value from a Module by its name.

The returned value corresponds to a llvm::Function value.

See Also
llvm::Module::getFunction()

Definition at line 1761 of file Core.cpp.

References llvm::unwrap(), and llvm::wrap().

unsigned LLVMGetNamedMetadataNumOperands ( LLVMModuleRef  M,
const char *  Name 
)

Obtain the number of operands for named metadata in a module.

See Also
llvm::Module::getNamedMetadata()

Definition at line 894 of file Core.cpp.

References N, and llvm::unwrap().

void LLVMGetNamedMetadataOperands ( LLVMModuleRef  M,
const char *  Name,
LLVMValueRef Dest 
)

Obtain the named metadata operands for a module.

The passed LLVMValueRef pointer should refer to an array of LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This array will be populated with the LLVMValueRef instances. Each instance corresponds to a llvm::MDNode.

See Also
llvm::Module::getNamedMetadata()
llvm::MDNode::getOperand()

Definition at line 901 of file Core.cpp.

References Context, llvm::MetadataAsValue::get(), llvm::NamedMDNode::getNumOperands(), llvm::NamedMDNode::getOperand(), i, N, llvm::unwrap(), and llvm::wrap().

LLVMValueRef LLVMGetNextFunction ( LLVMValueRef  Fn)

Advance a Function iterator to the next Function.

Returns NULL if the iterator was already at the end and there are no more functions.

Definition at line 1781 of file Core.cpp.

References llvm::Module::end(), llvm::GlobalValue::getParent(), I, and llvm::wrap().

LLVMValueRef LLVMGetPreviousFunction ( LLVMValueRef  Fn)

Decrement a Function iterator to the previous Function.

Returns NULL if the iterator was already at the beginning and there are no previous functions.

Definition at line 1789 of file Core.cpp.

References llvm::Module::begin(), llvm::GlobalValue::getParent(), I, and llvm::wrap().

const char* LLVMGetTarget ( LLVMModuleRef  M)

Obtain the target triple for a module.

See Also
Module::getTargetTriple()

Definition at line 253 of file Core.cpp.

References llvm::unwrap().

LLVMTypeRef LLVMGetTypeByName ( LLVMModuleRef  M,
const char *  Name 
)

Obtain a Type from a module by its registered name.

Definition at line 563 of file Core.cpp.

References llvm::unwrap(), and llvm::wrap().

LLVMModuleRef LLVMModuleCreateWithName ( const char *  ModuleID)

Create a new, empty module in the global context.

This is equivalent to calling LLVMModuleCreateWithNameInContext with LLVMGetGlobalContext() as the context parameter.

Every invocation should be paired with LLVMDisposeModule() or memory will be leaked.

Definition at line 215 of file Core.cpp.

References GlobalContext, and llvm::wrap().

LLVMModuleRef LLVMModuleCreateWithNameInContext ( const char *  ModuleID,
LLVMContextRef  C 
)

Create a new, empty module in a specific context.

Every invocation should be paired with LLVMDisposeModule() or memory will be leaked.

Definition at line 219 of file Core.cpp.

References llvm::unwrap(), and llvm::wrap().

LLVMBool LLVMPrintModuleToFile ( LLVMModuleRef  M,
const char *  Filename,
char **  ErrorMessage 
)

Print a representation of a module to a file.

The ErrorMessage needs to be disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.

See Also
Module::print()

Definition at line 265 of file Core.cpp.

References llvm::raw_fd_ostream::close(), llvm::sys::fs::F_Text, llvm::raw_fd_ostream::has_error(), and llvm::unwrap().

char* LLVMPrintModuleToString ( LLVMModuleRef  M)

Return a string representation of the module.

Use LLVMDisposeMessage to free the string.

See Also
Module::print()

Definition at line 286 of file Core.cpp.

References llvm::raw_ostream::flush(), and llvm::unwrap().

void LLVMSetDataLayout ( LLVMModuleRef  M,
const char *  DataLayoutStr 
)

Set the data layout for a module.

See Also
Module::setDataLayout()

Definition at line 248 of file Core.cpp.

References llvm::unwrap().

void LLVMSetModuleIdentifier ( LLVMModuleRef  M,
const char *  Ident,
size_t  Len 
)

Set the identifier of a module to a string Ident with length Len.

Parameters
MThe module to set identifier
IdentThe string to set M's identifier to
LenLength of Ident
See Also
Module::setModuleIdentifier()

Definition at line 234 of file Core.cpp.

References llvm::unwrap().

void LLVMSetModuleInlineAsm ( LLVMModuleRef  M,
const char *  Asm 
)

Set inline assembly for a module.

See Also
Module::setModuleInlineAsm()

Definition at line 297 of file Core.cpp.

References llvm::unwrap().

void LLVMSetTarget ( LLVMModuleRef  M,
const char *  Triple 
)

Set the target triple for a module.

See Also
Module::setTargetTriple()

Definition at line 257 of file Core.cpp.

References llvm::unwrap().