1 //===- ExecutionEngine.h - Abstract Execution Engine Interface --*- C++ -*-===//
3 // This file defines the abstract interface that implements execution support
6 //===----------------------------------------------------------------------===//
8 #ifndef EXECUTION_ENGINE_H
9 #define EXECUTION_ENGINE_H
24 class ExecutionEngine {
30 // GlobalAddress - A mapping between LLVM global values and their actualized
32 std::map<const GlobalValue*, void *> GlobalAddress;
34 void setTargetData(const TargetData &td) {
39 ExecutionEngine(ModuleProvider *P);
40 ExecutionEngine(Module *M);
41 virtual ~ExecutionEngine();
43 Module &getModule() const { return CurMod; }
44 const TargetData &getTargetData() const { return *TD; }
46 /// run - Start execution with the specified function, arguments, and
49 virtual GenericValue run(Function *F,
50 const std::vector<GenericValue> &ArgValues) = 0;
52 static ExecutionEngine *create(ModuleProvider *MP, bool ForceInterpreter,
55 void addGlobalMapping(const Function *F, void *Addr) {
56 void *&CurVal = GlobalAddress[(const GlobalValue*)F];
57 assert(CurVal == 0 && "GlobalMapping already established!");
61 // getPointerToGlobalIfAvailable - This returns the address of the specified
62 // global value if it is available, otherwise it returns null.
64 void *getPointerToGlobalIfAvailable(const GlobalValue *GV) {
65 std::map<const GlobalValue*, void*>::iterator I = GlobalAddress.find(GV);
66 return I != GlobalAddress.end() ? I->second : 0;
69 // getPointerToGlobal - This returns the address of the specified global
70 // value. This may involve code generation if it's a function.
72 void *getPointerToGlobal(const GlobalValue *GV);
74 // getPointerToFunction - The different EE's represent function bodies in
75 // different ways. They should each implement this to say what a function
76 // pointer should look like.
78 virtual void *getPointerToFunction(Function *F) = 0;
80 void StoreValueToMemory(GenericValue Val, GenericValue *Ptr, const Type *Ty);
81 void InitializeMemory(const Constant *Init, void *Addr);
85 GenericValue getConstantValue(const Constant *C);
86 GenericValue LoadValueFromMemory(GenericValue *Ptr, const Type *Ty);