From f67bcaf8315ee19e622256505627033ba7aae227 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 24 Dec 2002 00:01:22 +0000 Subject: [PATCH] Initial checkin llvm-svn: 5127 --- lib/ExecutionEngine/JIT/VM.h | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 lib/ExecutionEngine/JIT/VM.h diff --git a/lib/ExecutionEngine/JIT/VM.h b/lib/ExecutionEngine/JIT/VM.h new file mode 100644 index 00000000000..d3745e50827 --- /dev/null +++ b/lib/ExecutionEngine/JIT/VM.h @@ -0,0 +1,54 @@ +//===-- VM.h - Definitions for Virtual Machine ------------------*- C++ -*-===// +// +// This file defines the top-level Virtual Machine data structure. +// +//===----------------------------------------------------------------------===// + +#ifndef VM_H +#define VM_H + +#include "../ExecutionEngine.h" +#include "llvm/PassManager.h" +#include + +class Function; +class GlobalValue; +class Constant; +class TargetMachine; +class MachineCodeEmitter; + +class VM : public ExecutionEngine { + TargetMachine &TM; // The current target we are compiling to + PassManager PM; // Passes to compile a function + MachineCodeEmitter *MCE; // MCE object + + // FunctionRefs - A mapping between addresses that refer to unresolved + // functions and the LLVM function object itself. This is used by the fault + // handler to lazily patch up references... + // + std::map FunctionRefs; +public: + VM(Module *M, TargetMachine *tm); + ~VM(); + + /// run - Start execution with the specified function and arguments. + /// + virtual int run(const std::string &FnName, + const std::vector &Args); + + void addFunctionRef(void *Ref, Function *F) { + FunctionRefs[Ref] = F; + } + + const std::string &getFunctionReferencedName(void *RefAddr); + + void *resolveFunctionReference(void *RefAddr); + +private: + static MachineCodeEmitter *createEmitter(VM &V); + void setupPassManager(); + void *getPointerToFunction(const Function *F); + void registerCallback(); +}; + +#endif