Clean up and centralize LLVM target initialization
This commit is contained in:
4
ispc.cpp
4
ispc.cpp
@@ -72,10 +72,6 @@ Module *m;
|
|||||||
bool
|
bool
|
||||||
Target::GetTarget(const char *arch, const char *cpu, const char *isa,
|
Target::GetTarget(const char *arch, const char *cpu, const char *isa,
|
||||||
Target *t) {
|
Target *t) {
|
||||||
// initialize available targets
|
|
||||||
LLVMInitializeX86Target();
|
|
||||||
LLVMInitializeX86TargetInfo();
|
|
||||||
|
|
||||||
if (cpu == NULL) {
|
if (cpu == NULL) {
|
||||||
std::string hostCPU = llvm::sys::getHostCPUName();
|
std::string hostCPU = llvm::sys::getHostCPUName();
|
||||||
if (hostCPU.size() > 0)
|
if (hostCPU.size() > 0)
|
||||||
|
|||||||
18
main.cpp
18
main.cpp
@@ -45,6 +45,14 @@
|
|||||||
#else
|
#else
|
||||||
#include <llvm/Support/Signals.h>
|
#include <llvm/Support/Signals.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
|
||||||
|
#include <llvm/Support/TargetRegistry.h>
|
||||||
|
#include <llvm/Support/TargetSelect.h>
|
||||||
|
#else
|
||||||
|
#include <llvm/Target/TargetRegistry.h>
|
||||||
|
#include <llvm/Target/TargetSelect.h>
|
||||||
|
#include <llvm/Target/SubtargetFeature.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ISPC_IS_WINDOWS
|
#ifdef ISPC_IS_WINDOWS
|
||||||
#define strcasecmp stricmp
|
#define strcasecmp stricmp
|
||||||
@@ -154,6 +162,16 @@ int main(int Argc, char *Argv[]) {
|
|||||||
llvm::sys::PrintStackTraceOnErrorSignal();
|
llvm::sys::PrintStackTraceOnErrorSignal();
|
||||||
llvm::PrettyStackTraceProgram X(argc, argv);
|
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;
|
char *file = NULL;
|
||||||
const char *headerFileName = NULL;
|
const char *headerFileName = NULL;
|
||||||
const char *outFileName = NULL;
|
const char *outFileName = NULL;
|
||||||
|
|||||||
14
module.cpp
14
module.cpp
@@ -74,14 +74,6 @@
|
|||||||
#include <llvm/Target/TargetMachine.h>
|
#include <llvm/Target/TargetMachine.h>
|
||||||
#include <llvm/Target/TargetOptions.h>
|
#include <llvm/Target/TargetOptions.h>
|
||||||
#include <llvm/Target/TargetData.h>
|
#include <llvm/Target/TargetData.h>
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
|
|
||||||
#include <llvm/Support/TargetRegistry.h>
|
|
||||||
#include <llvm/Support/TargetSelect.h>
|
|
||||||
#else
|
|
||||||
#include <llvm/Target/TargetRegistry.h>
|
|
||||||
#include <llvm/Target/TargetSelect.h>
|
|
||||||
#include <llvm/Target/SubtargetFeature.h>
|
|
||||||
#endif
|
|
||||||
#include <llvm/PassManager.h>
|
#include <llvm/PassManager.h>
|
||||||
#include <llvm/Analysis/Verifier.h>
|
#include <llvm/Analysis/Verifier.h>
|
||||||
#include <llvm/Support/CFG.h>
|
#include <llvm/Support/CFG.h>
|
||||||
@@ -935,12 +927,6 @@ Module::WriteOutput(OutputType outputType, const char *outFileName) {
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
Module::writeObjectFileOrAssembly(OutputType outputType, const char *outFileName) {
|
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();
|
llvm::TargetMachine *targetMachine = g->target.GetTargetMachine();
|
||||||
|
|
||||||
// Figure out if we're generating object file or assembly output, and
|
// Figure out if we're generating object file or assembly output, and
|
||||||
|
|||||||
Reference in New Issue
Block a user