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::ExecutionEngine Class Reference

#include <ExecutionEngine.h>

Inheritance diagram for llvm::ExecutionEngine:

Inheritance graph
[legend]
Collaboration diagram for llvm::ExecutionEngine:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ExecutionEngine (ModuleProvider *P)
 ExecutionEngine (Module *M)
virtual ~ExecutionEngine ()
Module & getModule () const
const TargetData & getTargetData () const
virtual GenericValue runFunction (Function *F, const std::vector< GenericValue > &ArgValues)=0
int runFunctionAsMain (Function *Fn, const std::vector< std::string > &argv, const char *const *envp)
void addGlobalMapping (const GlobalValue *GV, void *Addr)
void updateGlobalMapping (const GlobalValue *GV, void *Addr)
void * getPointerToGlobalIfAvailable (const GlobalValue *GV)
void * getPointerToGlobal (const GlobalValue *GV)
virtual void * getPointerToFunction (Function *F)=0
virtual void * getPointerToFunctionOrStub (Function *F)
const GlobalValue * getGlobalValueAtAddress (void *Addr)
void StoreValueToMemory (GenericValue Val, GenericValue *Ptr, const Type *Ty)
void InitializeMemory (const Constant *Init, void *Addr)
virtual void * recompileAndRelinkFunction (Function *F)=0
virtual void freeMachineCodeForFunction (Function *F)=0
virtual void * getOrEmitGlobalVariable (const GlobalVariable *GV)

Static Public Member Functions

static ExecutionEngine * create (ModuleProvider *MP, bool ForceInterpreter, IntrinsicLowering *IL=0)

Protected Member Functions

void setTargetData (const TargetData &td)
void emitGlobals ()
void EmitGlobalVariable (const GlobalVariable *GV)
GenericValue getConstantValue (const Constant *C)
GenericValue LoadValueFromMemory (GenericValue *Ptr, const Type *Ty)

Protected Attributes

ModuleProvider * MP

Detailed Description

Definition at line 36 of file ExecutionEngine.h.


Constructor & Destructor Documentation

ExecutionEngine::ExecutionEngine (  ModuleProvider *  P  ) 
 

Definition at line 36 of file ExecutionEngine.cpp.

ExecutionEngine::ExecutionEngine (  Module *  M  ) 
 

Definition at line 41 of file ExecutionEngine.cpp.

ExecutionEngine::~ExecutionEngine (   )  [virtual]
 

Definition at line 45 of file ExecutionEngine.cpp.

References MP.


Member Function Documentation

void llvm::ExecutionEngine::addGlobalMapping (  const GlobalValue *  GV,
void *  Addr
)  [inline]
 

Definition at line 83 of file ExecutionEngine.h.

References V.

Referenced by emitGlobals(), EmitGlobalVariable(), llvm::JIT::getOrEmitGlobalVariable(), llvm::JIT::getPointerToFunction(), and llvm::JIT::recompileAndRelinkFunction().

ExecutionEngine * ExecutionEngine::create (  ModuleProvider *  MP,
bool  ForceInterpreter,
IntrinsicLowering *  IL = 0
)  [static]
 

create - This is the factory method for creating an execution engine which is appropriate for the current machine. If specified, the IntrinsicLowering implementation should be allocated on the heap.

Definition at line 129 of file ExecutionEngine.cpp.

References llvm::Interpreter::create(), llvm::JIT::create(), EE, llvm::sys::DynamicLibrary::LoadLibraryPermanently(), M, and llvm::ModuleProvider::materializeModule().

void ExecutionEngine::emitGlobals (   )  [protected]
 

EmitGlobals - Emit all of the global variables to memory, storing their addresses into GlobalAddress. This must make sure to copy the contents of their initializers into the memory.

Definition at line 494 of file ExecutionEngine.cpp.

References abort(), addGlobalMapping(), E, EmitGlobalVariable(), getModule(), getTargetData(), llvm::TargetData::getTypeSize(), I, and llvm::sys::DynamicLibrary::SearchForAddressOfSymbol().

Referenced by llvm::Interpreter::Interpreter().

void ExecutionEngine::EmitGlobalVariable (  const GlobalVariable *  GV  )  [protected]
 

Definition at line 532 of file ExecutionEngine.cpp.

References addGlobalMapping(), DEBUG, llvm::SequentialType::getElementType(), llvm::GlobalVariable::getInitializer(), llvm::Value::getName(), getPointerToGlobalIfAvailable(), getTargetData(), llvm::GlobalValue::getType(), llvm::TargetData::getTypeSize(), InitializeMemory(), NumGlobals, and NumInitBytes.

Referenced by emitGlobals().

virtual void llvm::ExecutionEngine::freeMachineCodeForFunction (  Function *  F  )  [pure virtual]
 

freeMachineCodeForFunction - Release memory in the ExecutionEngine corresponding to the machine code emitted to execute this function, useful for garbage-collecting generated code.

Implemented in llvm::Interpreter, and llvm::JIT.

GenericValue ExecutionEngine::getConstantValue (  const Constant *  C  )  [protected]
 

FIXME: document

Definition at line 177 of file ExecutionEngine.cpp.

References abort(), Add(), llvm::Type::BoolTyID, llvm::GenericValue::BoolVal, llvm::Instruction::Cast, llvm::Type::DoubleTyID, llvm::GenericValue::DoubleVal, F, llvm::Type::FloatTyID, llvm::GenericValue::FloatVal, GET_CONST_VAL, llvm::TargetData::getIndexedOffset(), getOrEmitGlobalVariable(), getPointerToFunctionOrStub(), llvm::Value::getType(), llvm::Type::getTypeID(), llvm::Type::IntTyID, llvm::GenericValue::IntVal, llvm::Type::isIntegral(), llvm::Type::LongTyID, llvm::GenericValue::LongVal, llvm::Type::PointerTyID, llvm::GenericValue::PointerVal, llvm::PTOGV(), llvm::Type::SByteTyID, llvm::GenericValue::SByteVal, llvm::Type::ShortTyID, llvm::GenericValue::ShortVal, llvm::Type::UByteTyID, llvm::GenericValue::UByteVal, llvm::Type::UIntTyID, llvm::GenericValue::UIntVal, llvm::Type::ULongTyID, llvm::GenericValue::ULongVal, llvm::Type::UShortTyID, and llvm::GenericValue::UShortVal.

Referenced by InitializeMemory().

const GlobalValue * ExecutionEngine::getGlobalValueAtAddress (  void *  Addr  ) 
 

getGlobalValueAtAddress - Return the LLVM global value object that starts at the specified address.

Definition at line 52 of file ExecutionEngine.cpp.

References E, and I.

Module& llvm::ExecutionEngine::getModule (   )  const [inline]
 

Definition at line 61 of file ExecutionEngine.h.

Referenced by emitGlobals(), getPointerToNamedFunction(), and lle_X_sprintf().

virtual void* llvm::ExecutionEngine::getOrEmitGlobalVariable (  const GlobalVariable *  GV  )  [inline, virtual]
 

getOrEmitGlobalVariable - Return the address of the specified global variable, possibly emitting it to memory if needed. This is used by the Emitter.

Reimplemented in llvm::JIT.

Definition at line 166 of file ExecutionEngine.h.

References getPointerToGlobal().

Referenced by getConstantValue().

virtual void* llvm::ExecutionEngine::getPointerToFunction (  Function *  F  )  [pure virtual]
 

getPointerToFunction - The different EE's represent function bodies in different ways. They should each implement this to say what a function pointer should look like.

Implemented in llvm::JIT.

Referenced by getPointerToFunctionOrStub(), and getPointerToGlobal().

virtual void* llvm::ExecutionEngine::getPointerToFunctionOrStub (  Function *  F  )  [inline, virtual]
 

getPointerToFunctionOrStub - If the specified function has been code-gen'd, return a pointer to the function. If not, compile it, or use a stub to implement lazy compilation if available.

Reimplemented in llvm::JIT.

Definition at line 135 of file ExecutionEngine.h.

References getPointerToFunction().

Referenced by getConstantValue().

void * ExecutionEngine::getPointerToGlobal (  const GlobalValue *  GV  ) 
 

getPointerToGlobal - This returns the address of the specified global value. This may involve code generation if it's a function.

Definition at line 167 of file ExecutionEngine.cpp.

References F, and getPointerToFunction().

Referenced by getOrEmitGlobalVariable().

void* llvm::ExecutionEngine::getPointerToGlobalIfAvailable (  const GlobalValue *  GV  )  [inline]
 

getPointerToGlobalIfAvailable - This returns the address of the specified global value if it is available, otherwise it returns null.

Definition at line 115 of file ExecutionEngine.h.

References I.

Referenced by EmitGlobalVariable(), llvm::JIT::getOrEmitGlobalVariable(), llvm::JIT::getPointerToFunction(), llvm::JIT::getPointerToFunctionOrStub(), and llvm::JIT::recompileAndRelinkFunction().

const TargetData& llvm::ExecutionEngine::getTargetData (   )  const [inline]
 

Definition at line 62 of file ExecutionEngine.h.

Referenced by CreateArgv(), emitGlobals(), EmitGlobalVariable(), llvm::JIT::getOrEmitGlobalVariable(), InitializeMemory(), LoadValueFromMemory(), and StoreValueToMemory().

void ExecutionEngine::InitializeMemory (  const Constant *  Init,
void *  Addr
) 
 

Definition at line 449 of file ExecutionEngine.cpp.

References llvm::Type::ArrayTyID, getConstantValue(), llvm::User::getNumOperands(), llvm::Constant::getOperand(), llvm::TargetData::getStructLayout(), getTargetData(), llvm::ConstantStruct::getType(), llvm::ConstantArray::getType(), llvm::TargetData::getTypeSize(), llvm::StructLayout::MemberOffsets, llvm::Intrinsic::memset, StoreValueToMemory(), and llvm::Type::StructTyID.

Referenced by EmitGlobalVariable().

GenericValue ExecutionEngine::LoadValueFromMemory (  GenericValue *  Ptr,
const Type *  Ty
)  [protected]
 

FIXME: document

Definition at line 371 of file ExecutionEngine.cpp.

References abort(), llvm::Type::BoolTyID, llvm::Type::DoubleTyID, llvm::Type::FloatTyID, getTargetData(), llvm::Type::getTypeID(), llvm::Type::IntTyID, llvm::Type::LongTyID, llvm::Type::PointerTyID, llvm::Type::SByteTyID, llvm::Type::ShortTyID, llvm::Type::UByteTyID, llvm::GenericValue::UByteVal, llvm::Type::UIntTyID, llvm::GenericValue::UIntVal, llvm::Type::ULongTyID, llvm::GenericValue::ULongVal, llvm::GenericValue::Untyped, llvm::Type::UShortTyID, and llvm::GenericValue::UShortVal.

Referenced by llvm::Interpreter::visitLoadInst().

virtual void* llvm::ExecutionEngine::recompileAndRelinkFunction (  Function *  F  )  [pure virtual]
 

recompileAndRelinkFunction - This method is used to force a function which has already been compiled to be compiled again, possibly after it has been modified. Then the entry to the old copy is overwritten with a branch to the new copy. If there was no old copy, this acts just like VM::getPointerToFunction().

Implemented in llvm::Interpreter, and llvm::JIT.

virtual GenericValue llvm::ExecutionEngine::runFunction (  Function *  F,
const std::vector< GenericValue > &  ArgValues
)  [pure virtual]
 

runFunction - Execute the specified function with the specified arguments, and return the result.

Implemented in llvm::Interpreter, and llvm::JIT.

Referenced by runChild(), and runFunctionAsMain().

int ExecutionEngine::runFunctionAsMain (  Function *  Fn,
const std::vector< std::string > &  argv,
const char *const *  envp
) 
 

runFunctionAsMain - This is a helper function which wraps runFunction to handle the common task of starting up main with the specified argc, argv, and envp parameters.

Definition at line 99 of file ExecutionEngine.cpp.

References CreateArgv(), llvm::Function::getFunctionType(), llvm::FunctionType::getNumParams(), llvm::GVTOP(), llvm::GenericValue::IntVal, llvm::PTOGV(), and runFunction().

Referenced by runChild().

void llvm::ExecutionEngine::setTargetData (  const TargetData &  td  )  [inline, protected]
 

Definition at line 52 of file ExecutionEngine.h.

Referenced by llvm::Interpreter::Interpreter().

void ExecutionEngine::StoreValueToMemory (  GenericValue  Val,
GenericValue *  Ptr,
const Type *  Ty
) 
 

FIXME: document

Definition at line 298 of file ExecutionEngine.cpp.

References llvm::Type::BoolTyID, llvm::Type::DoubleTyID, llvm::Type::FloatTyID, getTargetData(), llvm::Type::getTypeID(), llvm::Type::IntTyID, llvm::Type::LongTyID, llvm::Type::PointerTyID, llvm::Type::SByteTyID, llvm::Type::ShortTyID, llvm::Type::UByteTyID, llvm::GenericValue::UByteVal, llvm::Type::UIntTyID, llvm::GenericValue::UIntVal, llvm::Type::ULongTyID, llvm::GenericValue::ULongVal, llvm::GenericValue::Untyped, llvm::Type::UShortTyID, and llvm::GenericValue::UShortVal.

Referenced by ByteswapSCANFResults(), CreateArgv(), InitializeMemory(), and llvm::Interpreter::visitStoreInst().

void llvm::ExecutionEngine::updateGlobalMapping (  const GlobalValue *  GV,
void *  Addr
)  [inline]
 

updateGlobalMapping - Replace an existing mapping for GV with a new address. This updates both maps as required.

Definition at line 98 of file ExecutionEngine.h.

References V.


Member Data Documentation

ModuleProvider* llvm::ExecutionEngine::MP [protected]
 

Definition at line 50 of file ExecutionEngine.h.

Referenced by ~ExecutionEngine().


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