1 //===-- VM.h - Definitions for Virtual Machine ------------------*- C++ -*-===//
3 // This file defines the top-level Virtual Machine data structure.
5 //===----------------------------------------------------------------------===//
10 #include "../ExecutionEngine.h"
11 #include "llvm/PassManager.h"
18 class MachineCodeEmitter;
20 class VM : public ExecutionEngine {
21 TargetMachine &TM; // The current target we are compiling to
22 FunctionPassManager PM; // Passes to compile a function
23 MachineCodeEmitter *MCE; // MCE object
26 VM(Module *M, TargetMachine *tm);
29 /// create - Create an return a new JIT compiler if there is one available
30 /// for the current target. Otherwise, return null.
32 static ExecutionEngine *create(Module *M);
34 /// run - Start execution with the specified function and arguments.
36 virtual GenericValue run(Function *F,
37 const std::vector<GenericValue> &ArgValues);
39 /// getPointerToNamedFunction - This method returns the address of the
40 /// specified function by using the dlsym function call. As such it is only
41 /// useful for resolving library symbols, not code generated symbols.
43 void *getPointerToNamedFunction(const std::string &Name);
45 // CompilationCallback - Invoked the first time that a call site is found,
46 // which causes lazy compilation of the target function.
48 static void CompilationCallback();
50 /// runAtExitHandlers - Before exiting the program, at_exit functions must be
51 /// called. This method calls them.
53 static void runAtExitHandlers();
55 /// getPointerToFunction - This returns the address of the specified function,
56 /// compiling it if necessary.
57 void *getPointerToFunction(Function *F);
60 static MachineCodeEmitter *createEmitter(VM &V);
61 void setupPassManager();