forked from OSchip/llvm-project
Duplicated code is bad. At least make it consistent.
The getARMTargetCPU and getLLVMArchSuffixForARM functions exist in both Toolchain.cpp and Tools.cpp. This stuff needs a thorough overhaul. In the meantime, this patch at least makes them consistent. One version had been converted to use StringSwitch, and the other version had new Cortex M-series processors added. llvm-svn: 153202
This commit is contained in:
parent
e2d4748ae3
commit
7f05ca38e4
|
@ -16,6 +16,7 @@
|
|||
#include "clang/Driver/DriverDiagnostic.h"
|
||||
#include "clang/Driver/ObjCRuntime.h"
|
||||
#include "clang/Driver/Options.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
using namespace clang::driver;
|
||||
using namespace clang;
|
||||
|
@ -93,45 +94,27 @@ static const char *getARMTargetCPU(const ArgList &Args,
|
|||
MArch = Triple.getArchName();
|
||||
}
|
||||
|
||||
if (MArch == "armv2" || MArch == "armv2a")
|
||||
return "arm2";
|
||||
if (MArch == "armv3")
|
||||
return "arm6";
|
||||
if (MArch == "armv3m")
|
||||
return "arm7m";
|
||||
if (MArch == "armv4" || MArch == "armv4t")
|
||||
return "arm7tdmi";
|
||||
if (MArch == "armv5" || MArch == "armv5t")
|
||||
return "arm10tdmi";
|
||||
if (MArch == "armv5e" || MArch == "armv5te")
|
||||
return "arm1026ejs";
|
||||
if (MArch == "armv5tej")
|
||||
return "arm926ej-s";
|
||||
if (MArch == "armv6" || MArch == "armv6k")
|
||||
return "arm1136jf-s";
|
||||
if (MArch == "armv6j")
|
||||
return "arm1136j-s";
|
||||
if (MArch == "armv6z" || MArch == "armv6zk")
|
||||
return "arm1176jzf-s";
|
||||
if (MArch == "armv6t2")
|
||||
return "arm1156t2-s";
|
||||
if (MArch == "armv7" || MArch == "armv7a" || MArch == "armv7-a")
|
||||
return "cortex-a8";
|
||||
if (MArch == "armv7r" || MArch == "armv7-r")
|
||||
return "cortex-r4";
|
||||
if (MArch == "armv7m" || MArch == "armv7-m")
|
||||
return "cortex-m3";
|
||||
if (MArch == "ep9312")
|
||||
return "ep9312";
|
||||
if (MArch == "iwmmxt")
|
||||
return "iwmmxt";
|
||||
if (MArch == "xscale")
|
||||
return "xscale";
|
||||
if (MArch == "armv6m" || MArch == "armv6-m")
|
||||
return "cortex-m0";
|
||||
|
||||
// If all else failed, return the most base CPU LLVM supports.
|
||||
return "arm7tdmi";
|
||||
return llvm::StringSwitch<const char *>(MArch)
|
||||
.Cases("armv2", "armv2a","arm2")
|
||||
.Case("armv3", "arm6")
|
||||
.Case("armv3m", "arm7m")
|
||||
.Cases("armv4", "armv4t", "arm7tdmi")
|
||||
.Cases("armv5", "armv5t", "arm10tdmi")
|
||||
.Cases("armv5e", "armv5te", "arm1026ejs")
|
||||
.Case("armv5tej", "arm926ej-s")
|
||||
.Cases("armv6", "armv6k", "arm1136jf-s")
|
||||
.Case("armv6j", "arm1136j-s")
|
||||
.Cases("armv6z", "armv6zk", "arm1176jzf-s")
|
||||
.Case("armv6t2", "arm1156t2-s")
|
||||
.Cases("armv7", "armv7a", "armv7-a", "cortex-a8")
|
||||
.Cases("armv7r", "armv7-r", "cortex-r4")
|
||||
.Cases("armv7m", "armv7-m", "cortex-m3")
|
||||
.Case("ep9312", "ep9312")
|
||||
.Case("iwmmxt", "iwmmxt")
|
||||
.Case("xscale", "xscale")
|
||||
.Cases("armv6m", "armv6-m", "cortex-m0")
|
||||
// If all else failed, return the most base CPU LLVM supports.
|
||||
.Default("arm7tdmi");
|
||||
}
|
||||
|
||||
/// getLLVMArchSuffixForARM - Get the LLVM arch name to use for a particular
|
||||
|
@ -140,38 +123,22 @@ static const char *getARMTargetCPU(const ArgList &Args,
|
|||
// FIXME: This is redundant with -mcpu, why does LLVM use this.
|
||||
// FIXME: tblgen this, or kill it!
|
||||
static const char *getLLVMArchSuffixForARM(StringRef CPU) {
|
||||
if (CPU == "arm7tdmi" || CPU == "arm7tdmi-s" || CPU == "arm710t" ||
|
||||
CPU == "arm720t" || CPU == "arm9" || CPU == "arm9tdmi" ||
|
||||
CPU == "arm920" || CPU == "arm920t" || CPU == "arm922t" ||
|
||||
CPU == "arm940t" || CPU == "ep9312")
|
||||
return "v4t";
|
||||
|
||||
if (CPU == "arm10tdmi" || CPU == "arm1020t")
|
||||
return "v5";
|
||||
|
||||
if (CPU == "arm9e" || CPU == "arm926ej-s" || CPU == "arm946e-s" ||
|
||||
CPU == "arm966e-s" || CPU == "arm968e-s" || CPU == "arm10e" ||
|
||||
CPU == "arm1020e" || CPU == "arm1022e" || CPU == "xscale" ||
|
||||
CPU == "iwmmxt")
|
||||
return "v5e";
|
||||
|
||||
if (CPU == "arm1136j-s" || CPU == "arm1136jf-s" || CPU == "arm1176jz-s" ||
|
||||
CPU == "arm1176jzf-s" || CPU == "mpcorenovfp" || CPU == "mpcore")
|
||||
return "v6";
|
||||
|
||||
if (CPU == "arm1156t2-s" || CPU == "arm1156t2f-s")
|
||||
return "v6t2";
|
||||
|
||||
if (CPU == "cortex-a8" || CPU == "cortex-a9")
|
||||
return "v7";
|
||||
|
||||
if (CPU == "cortex-m3")
|
||||
return "v7m";
|
||||
|
||||
if (CPU == "cortex-m0")
|
||||
return "v6m";
|
||||
|
||||
return "";
|
||||
return llvm::StringSwitch<const char *>(CPU)
|
||||
.Cases("arm7tdmi", "arm7tdmi-s", "arm710t", "v4t")
|
||||
.Cases("arm720t", "arm9", "arm9tdmi", "v4t")
|
||||
.Cases("arm920", "arm920t", "arm922t", "v4t")
|
||||
.Cases("arm940t", "ep9312","v4t")
|
||||
.Cases("arm10tdmi", "arm1020t", "v5")
|
||||
.Cases("arm9e", "arm926ej-s", "arm946e-s", "v5e")
|
||||
.Cases("arm966e-s", "arm968e-s", "arm10e", "v5e")
|
||||
.Cases("arm1020e", "arm1022e", "xscale", "iwmmxt", "v5e")
|
||||
.Cases("arm1136j-s", "arm1136jf-s", "arm1176jz-s", "v6")
|
||||
.Cases("arm1176jzf-s", "mpcorenovfp", "mpcore", "v6")
|
||||
.Cases("arm1156t2-s", "arm1156t2f-s", "v6t2")
|
||||
.Cases("cortex-a8", "cortex-a9", "v7")
|
||||
.Case("cortex-m3", "v7m")
|
||||
.Case("cortex-m0", "v6m")
|
||||
.Default("");
|
||||
}
|
||||
|
||||
std::string ToolChain::ComputeLLVMTriple(const ArgList &Args,
|
||||
|
|
|
@ -483,6 +483,8 @@ static const char *getLLVMArchSuffixForARM(StringRef CPU) {
|
|||
.Cases("arm1176jzf-s", "mpcorenovfp", "mpcore", "v6")
|
||||
.Cases("arm1156t2-s", "arm1156t2f-s", "v6t2")
|
||||
.Cases("cortex-a8", "cortex-a9", "v7")
|
||||
.Case("cortex-m3", "v7m")
|
||||
.Case("cortex-m0", "v6m")
|
||||
.Default("");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue