diff --git a/ispc.cpp b/ispc.cpp index a027bd49..cdfa80f5 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -72,10 +72,6 @@ Module *m; bool Target::GetTarget(const char *arch, const char *cpu, const char *isa, Target *t) { - // initialize available targets - LLVMInitializeX86Target(); - LLVMInitializeX86TargetInfo(); - if (cpu == NULL) { std::string hostCPU = llvm::sys::getHostCPUName(); if (hostCPU.size() > 0) diff --git a/main.cpp b/main.cpp index 4a5cdd31..6fee8e30 100644 --- a/main.cpp +++ b/main.cpp @@ -41,9 +41,17 @@ #include #include #ifdef LLVM_2_8 -#include + #include #else -#include + #include +#endif +#if defined(LLVM_3_0) || defined(LLVM_3_0svn) + #include + #include +#else + #include + #include + #include #endif #ifdef ISPC_IS_WINDOWS @@ -154,6 +162,16 @@ int main(int Argc, char *Argv[]) { llvm::sys::PrintStackTraceOnErrorSignal(); llvm::PrettyStackTraceProgram X(argc, argv); + // initialize available LLVM targets + LLVMInitializeX86TargetInfo(); + LLVMInitializeX86Target(); + LLVMInitializeX86AsmPrinter(); + LLVMInitializeX86AsmParser(); + LLVMInitializeX86Disassembler(); +#if defined(LLVM_3_0) || defined(LLVM_3_0svn) + LLVMInitializeX86TargetMC(); +#endif + char *file = NULL; const char *headerFileName = NULL; const char *outFileName = NULL; diff --git a/module.cpp b/module.cpp index 54b16618..36747e55 100644 --- a/module.cpp +++ b/module.cpp @@ -74,14 +74,6 @@ #include #include #include -#if defined(LLVM_3_0) || defined(LLVM_3_0svn) - #include - #include -#else - #include - #include - #include -#endif #include #include #include @@ -935,12 +927,6 @@ Module::WriteOutput(OutputType outputType, const char *outFileName) { bool Module::writeObjectFileOrAssembly(OutputType outputType, const char *outFileName) { -#if defined(LLVM_3_0) || defined(LLVM_3_0svn) - LLVMInitializeX86TargetMC(); -#endif - LLVMInitializeX86AsmPrinter(); - LLVMInitializeX86AsmParser(); - llvm::TargetMachine *targetMachine = g->target.GetTargetMachine(); // Figure out if we're generating object file or assembly output, and