LLVM  mainline
Functions
Modules
Core

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

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 1643 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 810 of file Core.cpp.

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

Return an exact copy of the specified module.

Definition at line 127 of file CloneModule.cpp.

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

Destroy a module instance.

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

Definition at line 158 of file Core.cpp.

References llvm::unwrap().

Dump a representation of a module to stderr.

See also:
Module::dump()

Definition at line 180 of file Core.cpp.

References llvm::unwrap().

Obtain the data layout for a module.

See also:
Module::getDataLayout()

Definition at line 163 of file Core.cpp.

References llvm::unwrap().

Obtain an iterator to the first Function in a Module.

See also:
llvm::Module::begin()

Definition at line 1653 of file Core.cpp.

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

Obtain an iterator to the last Function in a Module.

See also:
llvm::Module::end()

Definition at line 1661 of file Core.cpp.

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

Obtain the context to which this module is associated.

See also:
Module::getContext()

Definition at line 222 of file Core.cpp.

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

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 1649 of file Core.cpp.

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

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

See also:
llvm::Module::getNamedMetadata()

Definition at line 792 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 800 of file Core.cpp.

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

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 1669 of file Core.cpp.

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

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 1677 of file Core.cpp.

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

Obtain the target triple for a module.

See also:
Module::getTargetTriple()

Definition at line 172 of file Core.cpp.

References llvm::unwrap().

Obtain a Type from a module by its registered name.

Definition at line 472 of file Core.cpp.

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

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 149 of file Core.cpp.

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

Create a new, empty module in a specific context.

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

Definition at line 153 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 184 of file Core.cpp.

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

Return a string representation of the module.

Use LLVMDisposeMessage to free the string.

See also:
Module::print()

Definition at line 205 of file Core.cpp.

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

void LLVMSetDataLayout ( LLVMModuleRef  M,
const char *  Triple 
)

Set the data layout for a module.

See also:
Module::setDataLayout()

Definition at line 167 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 216 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 176 of file Core.cpp.

References llvm::unwrap().