forked from OSchip/llvm-project
parent
7055878170
commit
0b2de9f2d4
|
@ -32,8 +32,6 @@ class Module;
|
||||||
class ModuleProvider;
|
class ModuleProvider;
|
||||||
class TargetData;
|
class TargetData;
|
||||||
class Type;
|
class Type;
|
||||||
class IntrinsicLowering;
|
|
||||||
|
|
||||||
|
|
||||||
class ExecutionEngineState {
|
class ExecutionEngineState {
|
||||||
private:
|
private:
|
||||||
|
@ -76,7 +74,7 @@ protected:
|
||||||
// To avoid having libexecutionengine depend on the JIT and interpreter
|
// To avoid having libexecutionengine depend on the JIT and interpreter
|
||||||
// libraries, the JIT and Interpreter set these functions to ctor pointers
|
// libraries, the JIT and Interpreter set these functions to ctor pointers
|
||||||
// at startup time if they are linked in.
|
// at startup time if they are linked in.
|
||||||
typedef ExecutionEngine *(*EECtorFn)(ModuleProvider*, IntrinsicLowering*);
|
typedef ExecutionEngine *(*EECtorFn)(ModuleProvider*);
|
||||||
static EECtorFn JITCtor, InterpCtor;
|
static EECtorFn JITCtor, InterpCtor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -93,10 +91,9 @@ public:
|
||||||
const TargetData &getTargetData() const { return *TD; }
|
const TargetData &getTargetData() const { return *TD; }
|
||||||
|
|
||||||
/// create - This is the factory method for creating an execution engine which
|
/// create - This is the factory method for creating an execution engine which
|
||||||
/// is appropriate for the current machine. If specified, the
|
/// is appropriate for the current machine.
|
||||||
/// IntrinsicLowering implementation should be allocated on the heap.
|
static ExecutionEngine *create(ModuleProvider *MP,
|
||||||
static ExecutionEngine *create(ModuleProvider *MP, bool ForceInterpreter,
|
bool ForceInterpreter = false);
|
||||||
IntrinsicLowering *IL = 0);
|
|
||||||
|
|
||||||
/// runFunction - Execute the specified function with the specified arguments,
|
/// runFunction - Execute the specified function with the specified arguments,
|
||||||
/// and return the result.
|
/// and return the result.
|
||||||
|
|
|
@ -160,24 +160,22 @@ int ExecutionEngine::runFunctionAsMain(Function *Fn,
|
||||||
/// NULL is returned.
|
/// NULL is returned.
|
||||||
///
|
///
|
||||||
ExecutionEngine *ExecutionEngine::create(ModuleProvider *MP,
|
ExecutionEngine *ExecutionEngine::create(ModuleProvider *MP,
|
||||||
bool ForceInterpreter,
|
bool ForceInterpreter) {
|
||||||
IntrinsicLowering *IL) {
|
|
||||||
ExecutionEngine *EE = 0;
|
ExecutionEngine *EE = 0;
|
||||||
|
|
||||||
// Unless the interpreter was explicitly selected, try making a JIT.
|
// Unless the interpreter was explicitly selected, try making a JIT.
|
||||||
if (!ForceInterpreter && JITCtor)
|
if (!ForceInterpreter && JITCtor)
|
||||||
EE = JITCtor(MP, IL);
|
EE = JITCtor(MP);
|
||||||
|
|
||||||
// If we can't make a JIT, make an interpreter instead.
|
// If we can't make a JIT, make an interpreter instead.
|
||||||
if (EE == 0 && InterpCtor)
|
if (EE == 0 && InterpCtor)
|
||||||
EE = InterpCtor(MP, IL);
|
EE = InterpCtor(MP);
|
||||||
|
|
||||||
if (EE == 0)
|
if (EE) {
|
||||||
delete IL;
|
|
||||||
else
|
|
||||||
// Make sure we can resolve symbols in the program as well. The zero arg
|
// Make sure we can resolve symbols in the program as well. The zero arg
|
||||||
// to the function tells DynamicLibrary to load the program, not a library.
|
// to the function tells DynamicLibrary to load the program, not a library.
|
||||||
sys::DynamicLibrary::LoadLibraryPermanently(0);
|
sys::DynamicLibrary::LoadLibraryPermanently(0);
|
||||||
|
}
|
||||||
|
|
||||||
return EE;
|
return EE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,7 @@ static struct RegisterInterp {
|
||||||
|
|
||||||
/// create - Create a new interpreter object. This can never fail.
|
/// create - Create a new interpreter object. This can never fail.
|
||||||
///
|
///
|
||||||
ExecutionEngine *Interpreter::create(ModuleProvider *MP,
|
ExecutionEngine *Interpreter::create(ModuleProvider *MP) {
|
||||||
IntrinsicLowering *IL) {
|
|
||||||
Module *M;
|
Module *M;
|
||||||
try {
|
try {
|
||||||
M = MP->materializeModule();
|
M = MP->materializeModule();
|
||||||
|
@ -55,17 +54,16 @@ ExecutionEngine *Interpreter::create(ModuleProvider *MP,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Interpreter(M, isLittleEndian, isLongPointer, IL);
|
return new Interpreter(M, isLittleEndian, isLongPointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Interpreter ctor - Initialize stuff
|
// Interpreter ctor - Initialize stuff
|
||||||
//
|
//
|
||||||
Interpreter::Interpreter(Module *M, bool isLittleEndian, bool isLongPointer,
|
Interpreter::Interpreter(Module *M, bool isLittleEndian, bool isLongPointer)
|
||||||
IntrinsicLowering *il)
|
|
||||||
: ExecutionEngine(M),
|
: ExecutionEngine(M),
|
||||||
TD("lli", isLittleEndian, isLongPointer ? 8 : 4, isLongPointer ? 8 : 4,
|
TD("lli", isLittleEndian, isLongPointer ? 8 : 4, isLongPointer ? 8 : 4,
|
||||||
isLongPointer ? 8 : 4), IL(il) {
|
isLongPointer ? 8 : 4) {
|
||||||
|
|
||||||
memset(&ExitValue, 0, sizeof(ExitValue));
|
memset(&ExitValue, 0, sizeof(ExitValue));
|
||||||
setTargetData(TD);
|
setTargetData(TD);
|
||||||
|
@ -74,7 +72,7 @@ Interpreter::Interpreter(Module *M, bool isLittleEndian, bool isLongPointer,
|
||||||
initializeExternalFunctions();
|
initializeExternalFunctions();
|
||||||
emitGlobals();
|
emitGlobals();
|
||||||
|
|
||||||
if (IL == 0) IL = new DefaultIntrinsicLowering();
|
IL = new DefaultIntrinsicLowering();
|
||||||
}
|
}
|
||||||
|
|
||||||
Interpreter::~Interpreter() {
|
Interpreter::~Interpreter() {
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
class IntrinsicLowering;
|
||||||
struct FunctionInfo;
|
struct FunctionInfo;
|
||||||
template<typename T> class generic_gep_type_iterator;
|
template<typename T> class generic_gep_type_iterator;
|
||||||
class ConstantExpr;
|
class ConstantExpr;
|
||||||
|
@ -93,8 +94,7 @@ class Interpreter : public ExecutionEngine, public InstVisitor<Interpreter> {
|
||||||
std::vector<Function*> AtExitHandlers;
|
std::vector<Function*> AtExitHandlers;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Interpreter(Module *M, bool isLittleEndian, bool isLongPointer,
|
Interpreter(Module *M, bool isLittleEndian, bool isLongPointer);
|
||||||
IntrinsicLowering *IL);
|
|
||||||
~Interpreter();
|
~Interpreter();
|
||||||
|
|
||||||
/// runAtExitHandlers - Run any functions registered by the program's calls to
|
/// runAtExitHandlers - Run any functions registered by the program's calls to
|
||||||
|
@ -106,11 +106,9 @@ public:
|
||||||
InterpCtor = create;
|
InterpCtor = create;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// create - Create an interpreter ExecutionEngine. This can never fail. The
|
/// create - Create an interpreter ExecutionEngine. This can never fail.
|
||||||
/// specified IntrinsicLowering implementation will be deleted when the
|
|
||||||
/// Interpreter execution engine is destroyed.
|
|
||||||
///
|
///
|
||||||
static ExecutionEngine *create(ModuleProvider *M, IntrinsicLowering *IL);
|
static ExecutionEngine *create(ModuleProvider *M);
|
||||||
|
|
||||||
/// run - Start execution with the specified function and arguments.
|
/// run - Start execution with the specified function and arguments.
|
||||||
///
|
///
|
||||||
|
|
|
@ -69,11 +69,9 @@ public:
|
||||||
TargetJITInfo &getJITInfo() const { return TJI; }
|
TargetJITInfo &getJITInfo() const { return TJI; }
|
||||||
|
|
||||||
/// create - Create an return a new JIT compiler if there is one available
|
/// create - Create an return a new JIT compiler if there is one available
|
||||||
/// for the current target. Otherwise, return null. If the JIT is created
|
/// for the current target. Otherwise, return null.
|
||||||
/// successfully, it takes responsibility for deleting the specified
|
|
||||||
/// IntrinsicLowering implementation.
|
|
||||||
///
|
///
|
||||||
static ExecutionEngine *create(ModuleProvider *MP, IntrinsicLowering *IL = 0);
|
static ExecutionEngine *create(ModuleProvider *MP);
|
||||||
|
|
||||||
/// run - Start execution with the specified function and arguments.
|
/// run - Start execution with the specified function and arguments.
|
||||||
///
|
///
|
||||||
|
|
|
@ -39,7 +39,7 @@ MAttrs("mattr",
|
||||||
/// create - Create an return a new JIT compiler if there is one available
|
/// create - Create an return a new JIT compiler if there is one available
|
||||||
/// for the current target. Otherwise, return null.
|
/// for the current target. Otherwise, return null.
|
||||||
///
|
///
|
||||||
ExecutionEngine *JIT::create(ModuleProvider *MP, IntrinsicLowering *IL) {
|
ExecutionEngine *JIT::create(ModuleProvider *MP) {
|
||||||
if (MArch == 0) {
|
if (MArch == 0) {
|
||||||
std::string Error;
|
std::string Error;
|
||||||
MArch = TargetMachineRegistry::getClosestTargetForJIT(Error);
|
MArch = TargetMachineRegistry::getClosestTargetForJIT(Error);
|
||||||
|
@ -61,7 +61,7 @@ ExecutionEngine *JIT::create(ModuleProvider *MP, IntrinsicLowering *IL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate a target...
|
// Allocate a target...
|
||||||
TargetMachine *Target = MArch->CtorFn(*MP->getModule(), IL, FeaturesStr);
|
TargetMachine *Target = MArch->CtorFn(*MP->getModule(), 0, FeaturesStr);
|
||||||
assert(Target && "Could not allocate target machine!");
|
assert(Target && "Could not allocate target machine!");
|
||||||
|
|
||||||
// If the target supports JIT code generation, return a new JIT now.
|
// If the target supports JIT code generation, return a new JIT now.
|
||||||
|
|
Loading…
Reference in New Issue