mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-13 01:15:32 +00:00
Use more structured command line option processing
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6742 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7aefa966cd
commit
97ac14f33c
@ -15,18 +15,23 @@
|
|||||||
#include "llvm/PassManager.h"
|
#include "llvm/PassManager.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
cl::opt<std::string>
|
enum ArchName { nojit, x86, sparc };
|
||||||
Arch("march", cl::desc("Architecture: `x86' or `sparc'"), cl::Prefix,
|
|
||||||
cl::value_desc("machine architecture"));
|
|
||||||
|
|
||||||
static std::string DefaultArch =
|
cl::opt<ArchName>
|
||||||
#if defined(i386) || defined(__i386__) || defined(__x86__)
|
Arch("march", cl::desc("Architecture to JIT to:"), cl::Prefix,
|
||||||
"x86";
|
cl::values(clEnumVal(x86, " IA-32 (pentium and above)"),
|
||||||
#elif defined(sparc) || defined(__sparc__) || defined(__sparcv9)
|
#if defined(sparc) || defined(__sparc__) || defined(__sparcv9)
|
||||||
"sparc";
|
clEnumVal(sparc, " Sparc-V9"),
|
||||||
#else
|
|
||||||
"";
|
|
||||||
#endif
|
#endif
|
||||||
|
0),
|
||||||
|
#if defined(i386) || defined(__i386__) || defined(__x86__)
|
||||||
|
cl::init(x86)
|
||||||
|
#elif defined(sparc) || defined(__sparc__) || defined(__sparcv9)
|
||||||
|
cl::init(sparc)
|
||||||
|
#else
|
||||||
|
cl::init(nojit)
|
||||||
|
#endif
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// createJIT - Create an return a new JIT compiler if there is one available
|
/// createJIT - Create an return a new JIT compiler if there is one available
|
||||||
@ -35,30 +40,31 @@ namespace {
|
|||||||
ExecutionEngine *ExecutionEngine::createJIT(Module *M, unsigned Config) {
|
ExecutionEngine *ExecutionEngine::createJIT(Module *M, unsigned Config) {
|
||||||
|
|
||||||
TargetMachine* (*TargetMachineAllocator)(unsigned) = 0;
|
TargetMachine* (*TargetMachineAllocator)(unsigned) = 0;
|
||||||
if (Arch == "")
|
|
||||||
Arch = DefaultArch;
|
|
||||||
|
|
||||||
// Allow a command-line switch to override what *should* be the default target
|
// 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 --
|
// machine for this platform. This allows for debugging a Sparc JIT on X86 --
|
||||||
// our X86 machines are much faster at recompiling LLVM and linking lli.
|
// our X86 machines are much faster at recompiling LLVM and linking lli.
|
||||||
if (Arch == "x86") {
|
switch (Arch) {
|
||||||
|
case x86:
|
||||||
TargetMachineAllocator = allocateX86TargetMachine;
|
TargetMachineAllocator = allocateX86TargetMachine;
|
||||||
|
break;
|
||||||
#if defined(sparc) || defined(__sparc__) || defined(__sparcv9)
|
#if defined(sparc) || defined(__sparc__) || defined(__sparcv9)
|
||||||
} else if (Arch == "sparc") {
|
case sparc:
|
||||||
TargetMachineAllocator = allocateSparcTargetMachine;
|
TargetMachineAllocator = allocateSparcTargetMachine;
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
default:
|
||||||
|
assert(0 && "-march flag not supported on this host!");
|
||||||
|
case nojit:
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TargetMachineAllocator) {
|
|
||||||
// Allocate a target...
|
// Allocate a target...
|
||||||
TargetMachine *Target = (*TargetMachineAllocator)(Config);
|
TargetMachine *Target = (*TargetMachineAllocator)(Config);
|
||||||
assert(Target && "Could not allocate target machine!");
|
assert(Target && "Could not allocate target machine!");
|
||||||
|
|
||||||
// Create the virtual machine object...
|
// Create the virtual machine object...
|
||||||
return new VM(M, Target);
|
return new VM(M, Target);
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VM::VM(Module *M, TargetMachine *tm) : ExecutionEngine(M), TM(*tm) {
|
VM::VM(Module *M, TargetMachine *tm) : ExecutionEngine(M), TM(*tm) {
|
||||||
|
@ -2,25 +2,9 @@ LEVEL = ../..
|
|||||||
TOOLNAME = lli
|
TOOLNAME = lli
|
||||||
PARALLEL_DIRS = Interpreter JIT
|
PARALLEL_DIRS = Interpreter JIT
|
||||||
|
|
||||||
# FIXME: This enables testing the Sparc JIT on x86.
|
JITLIBS = lli-jit codegen x86
|
||||||
# Perhaps in the future this should be a ./configure option.
|
USEDLIBS = lli-interpreter $(JITLIBS) bcreader vmcore scalaropts.a \
|
||||||
|
analysis.a support.a target.a
|
||||||
# Generic JIT libraries
|
|
||||||
JITLIBS = lli-jit codegen
|
|
||||||
ARCHLIBS =
|
|
||||||
|
|
||||||
# What the X86 JIT requires
|
|
||||||
JITLIBS += x86
|
|
||||||
ARCHLIBS +=
|
|
||||||
|
|
||||||
# What the Sparc JIT requires
|
|
||||||
JITLIBS += sparc
|
|
||||||
ARCHLIBS = sched livevar instrument.a profpaths transformutils.a \
|
|
||||||
bcwriter transforms.a ipo.a ipa.a datastructure.a regalloc \
|
|
||||||
mapping select postopts.a preopts
|
|
||||||
|
|
||||||
USEDLIBS = lli-interpreter $(JITLIBS) bcreader vmcore scalaropts \
|
|
||||||
analysis.a support.a target.a $(ARCHLIBS)
|
|
||||||
|
|
||||||
# Have gcc tell the linker to export symbols from the program so that
|
# Have gcc tell the linker to export symbols from the program so that
|
||||||
# dynamically loaded modules can be linked against them.
|
# dynamically loaded modules can be linked against them.
|
||||||
|
@ -2,25 +2,9 @@ LEVEL = ../..
|
|||||||
TOOLNAME = lli
|
TOOLNAME = lli
|
||||||
PARALLEL_DIRS = Interpreter JIT
|
PARALLEL_DIRS = Interpreter JIT
|
||||||
|
|
||||||
# FIXME: This enables testing the Sparc JIT on x86.
|
JITLIBS = lli-jit codegen x86
|
||||||
# Perhaps in the future this should be a ./configure option.
|
USEDLIBS = lli-interpreter $(JITLIBS) bcreader vmcore scalaropts.a \
|
||||||
|
analysis.a support.a target.a
|
||||||
# Generic JIT libraries
|
|
||||||
JITLIBS = lli-jit codegen
|
|
||||||
ARCHLIBS =
|
|
||||||
|
|
||||||
# What the X86 JIT requires
|
|
||||||
JITLIBS += x86
|
|
||||||
ARCHLIBS +=
|
|
||||||
|
|
||||||
# What the Sparc JIT requires
|
|
||||||
JITLIBS += sparc
|
|
||||||
ARCHLIBS = sched livevar instrument.a profpaths transformutils.a \
|
|
||||||
bcwriter transforms.a ipo.a ipa.a datastructure.a regalloc \
|
|
||||||
mapping select postopts.a preopts
|
|
||||||
|
|
||||||
USEDLIBS = lli-interpreter $(JITLIBS) bcreader vmcore scalaropts \
|
|
||||||
analysis.a support.a target.a $(ARCHLIBS)
|
|
||||||
|
|
||||||
# Have gcc tell the linker to export symbols from the program so that
|
# Have gcc tell the linker to export symbols from the program so that
|
||||||
# dynamically loaded modules can be linked against them.
|
# dynamically loaded modules can be linked against them.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user