From 9ed9e5d0f994c7721185eba963ea9b907dabcde6 Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Tue, 8 May 2012 23:38:45 +0000 Subject: Fix it so llvm-objdump -arch does accept x86 and x86-64 as valid arch names. PR12731. Patch by Meador Inge! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156444 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llc/llc.cpp | 40 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) (limited to 'tools/llc/llc.cpp') diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index ceff8a6..9f4ab70 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -366,42 +366,18 @@ int main(int argc, char **argv) { if (!TargetTriple.empty()) mod.setTargetTriple(Triple::normalize(TargetTriple)); + // Figure out the target triple. Triple TheTriple(mod.getTargetTriple()); if (TheTriple.getTriple().empty()) TheTriple.setTriple(sys::getDefaultTargetTriple()); - // Allocate target machine. First, check whether the user has explicitly - // specified an architecture to compile for. If so we have to look it up by - // name, because it might be a backend that has no mapping to a target triple. - const Target *TheTarget = 0; - if (!MArch.empty()) { - for (TargetRegistry::iterator it = TargetRegistry::begin(), - ie = TargetRegistry::end(); it != ie; ++it) { - if (MArch == it->getName()) { - TheTarget = &*it; - break; - } - } - - if (!TheTarget) { - errs() << argv[0] << ": error: invalid target '" << MArch << "'.\n"; - return 1; - } - - // Adjust the triple to match (if known), otherwise stick with the - // module/host triple. - Triple::ArchType Type = Triple::getArchTypeForLLVMName(MArch); - if (Type != Triple::UnknownArch) - TheTriple.setArch(Type); - } else { - std::string Err; - TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), Err); - if (TheTarget == 0) { - errs() << argv[0] << ": error auto-selecting target for module '" - << Err << "'. Please use the -march option to explicitly " - << "pick a target.\n"; - return 1; - } + // Get the target specific parser. + std::string Error; + const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple, + Error); + if (!TheTarget) { + errs() << argv[0] << ": " << Error; + return 1; } // Package up features to be passed to target/subtarget -- cgit v1.1