2002-12-24 00:01:22 +00:00
|
|
|
//===-- VM.h - Definitions for Virtual Machine ------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// This file defines the top-level Virtual Machine data structure.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef VM_H
|
|
|
|
#define VM_H
|
|
|
|
|
2003-09-05 19:39:22 +00:00
|
|
|
#include "llvm/ExecutionEngine/ExecutionEngine.h"
|
2002-12-24 00:01:22 +00:00
|
|
|
#include "llvm/PassManager.h"
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
class Function;
|
|
|
|
class GlobalValue;
|
|
|
|
class Constant;
|
|
|
|
class TargetMachine;
|
|
|
|
class MachineCodeEmitter;
|
|
|
|
|
|
|
|
class VM : public ExecutionEngine {
|
|
|
|
TargetMachine &TM; // The current target we are compiling to
|
2003-08-13 18:16:50 +00:00
|
|
|
FunctionPassManager PM; // Passes to compile a function
|
2002-12-24 00:01:22 +00:00
|
|
|
MachineCodeEmitter *MCE; // MCE object
|
|
|
|
|
|
|
|
public:
|
|
|
|
VM(Module *M, TargetMachine *tm);
|
|
|
|
~VM();
|
|
|
|
|
2003-09-03 20:34:19 +00:00
|
|
|
/// create - Create an return a new JIT compiler if there is one available
|
|
|
|
/// for the current target. Otherwise, return null.
|
|
|
|
///
|
|
|
|
static ExecutionEngine *create(Module *M);
|
|
|
|
|
2002-12-24 00:01:22 +00:00
|
|
|
/// run - Start execution with the specified function and arguments.
|
|
|
|
///
|
2003-09-05 18:42:01 +00:00
|
|
|
virtual GenericValue run(Function *F,
|
|
|
|
const std::vector<GenericValue> &ArgValues);
|
2002-12-24 00:01:22 +00:00
|
|
|
|
2003-01-13 01:00:48 +00:00
|
|
|
/// getPointerToNamedFunction - This method returns the address of the
|
|
|
|
/// specified function by using the dlsym function call. As such it is only
|
|
|
|
/// useful for resolving library symbols, not code generated symbols.
|
|
|
|
///
|
|
|
|
void *getPointerToNamedFunction(const std::string &Name);
|
|
|
|
|
2003-05-08 21:34:11 +00:00
|
|
|
// CompilationCallback - Invoked the first time that a call site is found,
|
|
|
|
// which causes lazy compilation of the target function.
|
|
|
|
//
|
|
|
|
static void CompilationCallback();
|
2003-05-14 13:53:40 +00:00
|
|
|
|
|
|
|
/// runAtExitHandlers - Before exiting the program, at_exit functions must be
|
|
|
|
/// called. This method calls them.
|
|
|
|
///
|
|
|
|
static void runAtExitHandlers();
|
|
|
|
|
2003-06-01 23:24:36 +00:00
|
|
|
/// getPointerToFunction - This returns the address of the specified function,
|
|
|
|
/// compiling it if necessary.
|
2003-08-13 18:16:50 +00:00
|
|
|
void *getPointerToFunction(Function *F);
|
2003-06-01 23:24:36 +00:00
|
|
|
|
2002-12-24 00:01:22 +00:00
|
|
|
private:
|
2003-06-02 03:23:16 +00:00
|
|
|
static MachineCodeEmitter *createEmitter(VM &V);
|
2002-12-24 00:01:22 +00:00
|
|
|
void setupPassManager();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|