aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-24 19:50:53 +0000
committerChris Lattner <sabre@nondot.org>2003-08-24 19:50:53 +0000
commit39c07264da992fd5d37fa7eaac0b9f02f55f80d0 (patch)
tree8272f4fdfbabda52456df604bd85d18ae616fc51
parent62c720a5bdd36b85dd497a1c3575db5731eca208 (diff)
downloadexternal_llvm-39c07264da992fd5d37fa7eaac0b9f02f55f80d0.zip
external_llvm-39c07264da992fd5d37fa7eaac0b9f02f55f80d0.tar.gz
external_llvm-39c07264da992fd5d37fa7eaac0b9f02f55f80d0.tar.bz2
Targets now configure themselves based on the source module, not on the
ad-hoc "Config" flags git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8134 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/ExecutionEngine/ExecutionEngine.h6
-rw-r--r--lib/ExecutionEngine/Interpreter/Interpreter.cpp35
-rw-r--r--lib/ExecutionEngine/Interpreter/Interpreter.h3
-rw-r--r--lib/ExecutionEngine/JIT/JIT.cpp6
-rw-r--r--tools/lli/lli.cpp8
5 files changed, 36 insertions, 22 deletions
diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h
index 45f7a27..e2d43c9 100644
--- a/include/llvm/ExecutionEngine/ExecutionEngine.h
+++ b/include/llvm/ExecutionEngine/ExecutionEngine.h
@@ -51,12 +51,12 @@ public:
/// 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);
+ static ExecutionEngine *createJIT(Module *M);
/// createInterpreter - Create a new interpreter object. This can never fail.
///
- static ExecutionEngine *createInterpreter(Module *M, unsigned Config,
- bool DebugMode, bool TraceMode);
+ static ExecutionEngine *createInterpreter(Module *M, bool DebugMode,
+ bool TraceMode);
void addGlobalMapping(const Function *F, void *Addr) {
void *&CurVal = GlobalAddress[(const GlobalValue*)F];
diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.cpp b/lib/ExecutionEngine/Interpreter/Interpreter.cpp
index 4fdd6a1..950e6a5 100644
--- a/lib/ExecutionEngine/Interpreter/Interpreter.cpp
+++ b/lib/ExecutionEngine/Interpreter/Interpreter.cpp
@@ -7,27 +7,44 @@
//===----------------------------------------------------------------------===//
#include "Interpreter.h"
-#include "llvm/Target/TargetMachineImpls.h"
+#include "llvm/Module.h"
/// createInterpreter - Create a new interpreter object. This can never fail.
///
ExecutionEngine *ExecutionEngine::createInterpreter(Module *M,
- unsigned Config,
bool DebugMode,
bool TraceMode) {
- return new Interpreter(M, Config, DebugMode, TraceMode);
+ bool isLittleEndian;
+ switch (M->getEndianness()) {
+ case Module::LittleEndian: isLittleEndian = true; break;
+ case Module::BigEndian: isLittleEndian = false; break;
+ case Module::AnyPointerSize:
+ int Test = 0;
+ *(char*)&Test = 1; // Return true if the host is little endian
+ isLittleEndian = (Test == 1);
+ break;
+ }
+
+ bool isLongPointer;
+ switch (M->getPointerSize()) {
+ case Module::Pointer32: isLongPointer = false; break;
+ case Module::Pointer64: isLongPointer = true; break;
+ case Module::AnyPointerSize:
+ isLongPointer = (sizeof(void*) == 8); // Follow host
+ break;
+ }
+
+ return new Interpreter(M, isLittleEndian, isLongPointer, DebugMode,TraceMode);
}
//===----------------------------------------------------------------------===//
// Interpreter ctor - Initialize stuff
//
-Interpreter::Interpreter(Module *M, unsigned Config,
- bool DebugMode, bool TraceMode)
+Interpreter::Interpreter(Module *M, bool isLittleEndian, bool isLongPointer,
+ bool DebugMode, bool TraceMode)
: ExecutionEngine(M), ExitCode(0), Debug(DebugMode), Trace(TraceMode),
- CurFrame(-1), TD("lli", (Config & TM::EndianMask) == TM::LittleEndian,
- (Config & TM::PtrSizeMask) == TM::PtrSize64 ? 8 : 4,
- (Config & TM::PtrSizeMask) == TM::PtrSize64 ? 8 : 4,
- (Config & TM::PtrSizeMask) == TM::PtrSize64 ? 8 : 4) {
+ CurFrame(-1), TD("lli", isLittleEndian, isLongPointer ? 8 : 4,
+ isLongPointer ? 8 : 4, isLongPointer ? 8 : 4) {
setTargetData(TD);
// Initialize the "backend"
diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.h b/lib/ExecutionEngine/Interpreter/Interpreter.h
index d3963ef..89581e0 100644
--- a/lib/ExecutionEngine/Interpreter/Interpreter.h
+++ b/lib/ExecutionEngine/Interpreter/Interpreter.h
@@ -87,7 +87,8 @@ class Interpreter : public ExecutionEngine, public InstVisitor<Interpreter> {
// AtExitHandlers - List of functions to call when the program exits.
std::vector<Function*> AtExitHandlers;
public:
- Interpreter(Module *M, unsigned Config, bool DebugMode, bool TraceMode);
+ Interpreter(Module *M, bool isLittleEndian, bool isLongPointer,
+ bool DebugMode, bool TraceMode);
inline ~Interpreter() { CW.setModule(0); }
// getExitCode - return the code that should be the exit code for the lli
diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp
index 7f4877b..57d7b89 100644
--- a/lib/ExecutionEngine/JIT/JIT.cpp
+++ b/lib/ExecutionEngine/JIT/JIT.cpp
@@ -44,9 +44,9 @@ namespace {
/// createJIT - Create an return a new JIT compiler if there is one available
/// for the current target. Otherwise it returns null.
///
-ExecutionEngine *ExecutionEngine::createJIT(Module *M, unsigned Config) {
+ExecutionEngine *ExecutionEngine::createJIT(Module *M) {
- TargetMachine* (*TargetMachineAllocator)(unsigned) = 0;
+ TargetMachine* (*TargetMachineAllocator)(const Module &) = 0;
// Allow a command-line switch to override what *should* be the default target
// machine for this platform. This allows for debugging a Sparc JIT on X86 --
@@ -71,7 +71,7 @@ ExecutionEngine *ExecutionEngine::createJIT(Module *M, unsigned Config) {
}
// Allocate a target...
- TargetMachine *Target = (*TargetMachineAllocator)(Config);
+ TargetMachine *Target = TargetMachineAllocator(*M);
assert(Target && "Could not allocate target machine!");
// Create the virtual machine object...
diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp
index 6c537ec..4c48eb6 100644
--- a/tools/lli/lli.cpp
+++ b/tools/lli/lli.cpp
@@ -75,19 +75,15 @@ int main(int argc, char** argv, const char ** envp) {
}
#endif
- // FIXME: in adddition to being gross, this is also wrong: This should use the
- // pointersize/endianness of the host if the pointer size is not specified!!
- unsigned Config = (M->getEndianness() != Module::BigEndian ? TM::LittleEndian : TM::BigEndian) |
- (M->getPointerSize() != Module::Pointer64 ? TM::PtrSize32 : TM::PtrSize64);
ExecutionEngine *EE = 0;
// If there is nothing that is forcing us to use the interpreter, make a JIT.
if (!ForceInterpreter && !DebugMode && !TraceMode)
- EE = ExecutionEngine::createJIT(M, Config);
+ EE = ExecutionEngine::createJIT(M);
// If we can't make a JIT, make an interpreter instead.
if (EE == 0)
- EE = ExecutionEngine::createInterpreter(M, Config, DebugMode, TraceMode);
+ EE = ExecutionEngine::createInterpreter(M, DebugMode, TraceMode);
// Add the module name to the start of the argv vector...
// But delete .bc first, since programs (and users) might not expect to