#include <vector>
#include <string>
#include <map>
+#include <cassert>
class Constant;
class Type;
class GlobalValue;
void setTargetData(const TargetData &td) {
TD = &td;
- emitGlobals();
}
public:
ExecutionEngine(Module *M) : CurMod(*M) {
Module &getModule() const { return CurMod; }
const TargetData &getTargetData() const { return *TD; }
- /// run - Start execution with the specified function and arguments.
+ /// run - Start execution with the specified function, arguments, and
+ /// environment.
///
virtual int run(const std::string &FnName,
- const std::vector<std::string> &Args) = 0;
+ const std::vector<std::string> &Args,
+ const char ** envp) = 0;
- /// 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, unsigned Config);
-
- /// createInterpreter - Create a new interpreter object. This can never fail.
- ///
- static ExecutionEngine *createInterpreter(Module *M, unsigned Config,
- bool DebugMode, bool TraceMode);
+ static ExecutionEngine *create (Module *M, bool ForceInterpreter,
+ bool TraceMode);
void addGlobalMapping(const Function *F, void *Addr) {
void *&CurVal = GlobalAddress[(const GlobalValue*)F];
CurVal = Addr;
}
+ // getPointerToGlobalIfAvailable - This returns the address of the specified
+ // global value if it is available, otherwise it returns null.
+ //
+ void *getPointerToGlobalIfAvailable(const GlobalValue *GV) {
+ std::map<const GlobalValue*, void*>::iterator I = GlobalAddress.find(GV);
+ return I != GlobalAddress.end() ? I->second : 0;
+ }
+
// getPointerToGlobal - This returns the address of the specified global
// value. This may involve code generation if it's a function.
//
// different ways. They should each implement this to say what a function
// pointer should look like.
//
- virtual void *getPointerToFunction(const Function *F) = 0;
+ virtual void *getPointerToFunction(Function *F) = 0;
-private:
+protected:
void emitGlobals();
public: // FIXME: protected: // API shared among subclasses