//===- ExecutionEngine.h - Abstract Execution Engine Interface --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
//
// This file defines the abstract interface that implements execution support
// for LLVM.
#include <map>
#include <cassert>
class Constant;
-class Type;
-class GlobalValue;
class Function;
+union GenericValue;
+class GlobalValue;
class Module;
+class ModuleProvider;
class TargetData;
-union GenericValue;
+class Type;
class ExecutionEngine {
Module &CurMod;
const TargetData *TD;
protected:
+ ModuleProvider *MP;
// GlobalAddress - A mapping between LLVM global values and their actualized
// version...
std::map<const GlobalValue*, void *> GlobalAddress;
void setTargetData(const TargetData &td) {
TD = &td;
}
+
public:
- ExecutionEngine(Module *M) : CurMod(*M) {
- assert(M && "Module is null?");
- }
+ ExecutionEngine(ModuleProvider *P);
+ ExecutionEngine(Module *M);
virtual ~ExecutionEngine();
Module &getModule() const { return CurMod; }
/// run - Start execution with the specified function, arguments, and
/// environment.
///
- virtual int run(const std::string &FnName,
- const std::vector<std::string> &Args,
- const char ** envp) = 0;
+ virtual GenericValue run(Function *F,
+ const std::vector<GenericValue> &ArgValues) = 0;
- static ExecutionEngine *create (Module *M, bool ForceInterpreter,
- bool TraceMode);
-
- /// createJIT - Create an return a new JIT compiler if there is one available
- /// for the current target. Otherwise it returns null.
- ///
- static ExecutionEngine *createJIT(Module *M);
-
- /// createInterpreter - Create a new interpreter object. This can never fail.
- ///
- static ExecutionEngine *createInterpreter(Module *M, bool TraceMode);
+ static ExecutionEngine *create(ModuleProvider *MP, bool ForceInterpreter,
+ bool TraceMode);
void addGlobalMapping(const Function *F, void *Addr) {
void *&CurVal = GlobalAddress[(const GlobalValue*)F];
//
virtual void *getPointerToFunction(Function *F) = 0;
+ void StoreValueToMemory(GenericValue Val, GenericValue *Ptr, const Type *Ty);
+ void InitializeMemory(const Constant *Init, void *Addr);
+
protected:
void emitGlobals();
-
-public: // FIXME: protected: // API shared among subclasses
GenericValue getConstantValue(const Constant *C);
- void StoreValueToMemory(GenericValue Val, GenericValue *Ptr, const Type *Ty);
GenericValue LoadValueFromMemory(GenericValue *Ptr, const Type *Ty);
- void *CreateArgv(const std::vector<std::string> &InputArgv);
- void InitializeMemory(const Constant *Init, void *Addr);
};
#endif