# HG changeset patch # User Benjamin Kramer # Date 1247691711 -7200 # Node ID 21d691518d82bd5181b42e522d6270360f42ad4f # Parent ba2a5d2fe748e383d412773dce6115076e3b1f90 Use TargetRegistry instead of TargetMachineRegistry for Target lookups This fixes the build for LLVM >= r75774 and will probably break older LLVM revs. diff -r ba2a5d2fe748 -r 21d691518d82 gen/main.cpp --- a/gen/main.cpp Wed Jul 15 20:04:42 2009 +0200 +++ b/gen/main.cpp Wed Jul 15 23:01:51 2009 +0200 @@ -432,22 +432,27 @@ // Allocate target machine. // first initialize llvm -#define LLVM_TARGET(A) LLVMInitialize##A##Target(); LLVMInitialize##A##AsmPrinter(); +#define LLVM_TARGET(A) LLVMInitialize##A##TargetInfo(); LLVMInitialize##A##Target(); LLVMInitialize##A##AsmPrinter(); // this is defined to be LLVM_TARGET(target name 1) LLVM_TARGET(target name 2) ... LDC_TARGETS #undef LLVM_TARGET + const llvm::Target *theTarget; // Check whether the user has explicitly specified an architecture to compile for. if (mArch == 0) { std::string Err; - mArch = llvm::TargetMachineRegistry::getClosestStaticTargetForModule(mod, Err); - if (mArch == 0) + theTarget = llvm::TargetRegistry::getClosestStaticTargetForModule(mod, Err); + if (theTarget == 0) { error("failed to auto-select target: %s, please use the -march option", Err.c_str()); fatal(); } } + else + { + theTarget = &mArch->TheTarget; + } // Package up features to be passed to target/subtarget std::string FeaturesStr; @@ -460,7 +465,7 @@ FeaturesStr = Features.getString(); } - std::auto_ptr target(mArch->CtorFn(mod, FeaturesStr)); + std::auto_ptr target(theTarget->createTargetMachine(mod, FeaturesStr)); assert(target.get() && "Could not allocate target machine!"); gTargetMachine = target.get(); gTargetData = gTargetMachine->getTargetData(); @@ -469,7 +474,7 @@ std::string datalayout = gTargetData->getStringRepresentation(); global.params.dataLayout = datalayout.c_str(); - global.params.llvmArch = mArch->Name; + global.params.llvmArch = theTarget->getName(); if (strcmp(global.params.llvmArch,"x86")==0) { VersionCondition::addPredefinedGlobalIdent("X86");