forked from OSchip/llvm-project
Allow case-insensitive values for -march for ARM in line with GCC.
GCC allows case-insensitive values for -mcpu, -march and -mtune options. This patch implements the same behaviour for the -march option for ARM. llvm-svn: 239527
This commit is contained in:
parent
647e61244b
commit
cebcb3b52f
|
@ -679,7 +679,7 @@ static void getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
|
||||||
// getARMArch is used here instead of just checking the -march value in order
|
// getARMArch is used here instead of just checking the -march value in order
|
||||||
// to handle -march=native correctly.
|
// to handle -march=native correctly.
|
||||||
if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
|
if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
|
||||||
StringRef Arch = arm::getARMArch(Args, Triple);
|
std::string Arch = arm::getARMArch(Args, Triple);
|
||||||
if (llvm::ARMTargetParser::parseArch(Arch) == llvm::ARM::AK_INVALID)
|
if (llvm::ARMTargetParser::parseArch(Arch) == llvm::ARM::AK_INVALID)
|
||||||
D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
|
D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
|
||||||
}
|
}
|
||||||
|
@ -689,7 +689,7 @@ static void getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
|
||||||
// getLLVMArchSuffixForARM which also needs an architecture.
|
// getLLVMArchSuffixForARM which also needs an architecture.
|
||||||
if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
|
if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
|
||||||
std::string CPU = arm::getARMTargetCPU(Args, Triple);
|
std::string CPU = arm::getARMTargetCPU(Args, Triple);
|
||||||
StringRef Arch = arm::getARMArch(Args, Triple);
|
std::string Arch = arm::getARMArch(Args, Triple);
|
||||||
if (strcmp(arm::getLLVMArchSuffixForARM(CPU, Arch), "") == 0)
|
if (strcmp(arm::getLLVMArchSuffixForARM(CPU, Arch), "") == 0)
|
||||||
D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
|
D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
|
||||||
}
|
}
|
||||||
|
@ -5631,9 +5631,9 @@ void hexagon::Link::ConstructJob(Compilation &C, const JobAction &JA,
|
||||||
}
|
}
|
||||||
// Hexagon tools end.
|
// Hexagon tools end.
|
||||||
|
|
||||||
const StringRef arm::getARMArch(const ArgList &Args,
|
const std::string arm::getARMArch(const ArgList &Args,
|
||||||
const llvm::Triple &Triple) {
|
const llvm::Triple &Triple) {
|
||||||
StringRef MArch;
|
std::string MArch;
|
||||||
if (Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
|
if (Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
|
||||||
// Otherwise, if we have -march= choose the base CPU for that arch.
|
// Otherwise, if we have -march= choose the base CPU for that arch.
|
||||||
MArch = A->getValue();
|
MArch = A->getValue();
|
||||||
|
@ -5641,6 +5641,7 @@ const StringRef arm::getARMArch(const ArgList &Args,
|
||||||
// Otherwise, use the Arch from the triple.
|
// Otherwise, use the Arch from the triple.
|
||||||
MArch = Triple.getArchName();
|
MArch = Triple.getArchName();
|
||||||
}
|
}
|
||||||
|
MArch = StringRef(MArch).lower();
|
||||||
|
|
||||||
// Handle -march=native.
|
// Handle -march=native.
|
||||||
if (MArch == "native") {
|
if (MArch == "native") {
|
||||||
|
@ -5662,7 +5663,7 @@ const StringRef arm::getARMArch(const ArgList &Args,
|
||||||
/// Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
|
/// Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
|
||||||
const char *arm::getARMCPUForMArch(const ArgList &Args,
|
const char *arm::getARMCPUForMArch(const ArgList &Args,
|
||||||
const llvm::Triple &Triple) {
|
const llvm::Triple &Triple) {
|
||||||
StringRef MArch = getARMArch(Args, Triple);
|
std::string MArch = getARMArch(Args, Triple);
|
||||||
// getARMCPUForArch defaults to the triple if MArch is empty, but empty MArch
|
// getARMCPUForArch defaults to the triple if MArch is empty, but empty MArch
|
||||||
// here means an -march=native that we can't handle, so instead return no CPU.
|
// here means an -march=native that we can't handle, so instead return no CPU.
|
||||||
if (MArch.empty())
|
if (MArch.empty())
|
||||||
|
|
|
@ -227,8 +227,8 @@ namespace hexagon {
|
||||||
namespace arm {
|
namespace arm {
|
||||||
std::string getARMTargetCPU(const llvm::opt::ArgList &Args,
|
std::string getARMTargetCPU(const llvm::opt::ArgList &Args,
|
||||||
const llvm::Triple &Triple);
|
const llvm::Triple &Triple);
|
||||||
const StringRef getARMArch(const llvm::opt::ArgList &Args,
|
const std::string getARMArch(const llvm::opt::ArgList &Args,
|
||||||
const llvm::Triple &Triple);
|
const llvm::Triple &Triple);
|
||||||
const char* getARMCPUForMArch(const llvm::opt::ArgList &Args,
|
const char* getARMCPUForMArch(const llvm::opt::ArgList &Args,
|
||||||
const llvm::Triple &Triple);
|
const llvm::Triple &Triple);
|
||||||
const char* getLLVMArchSuffixForARM(StringRef CPU, StringRef Arch);
|
const char* getLLVMArchSuffixForARM(StringRef CPU, StringRef Arch);
|
||||||
|
|
|
@ -402,3 +402,12 @@
|
||||||
// RUN: %clang -target arm-linux-gnueabi -mcpu=CorteX-a15 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CASE-INSENSITIVE-CPUV7A %s
|
// RUN: %clang -target arm-linux-gnueabi -mcpu=CorteX-a15 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CASE-INSENSITIVE-CPUV7A %s
|
||||||
// RUN: %clang -target arm-linux-gnueabi -mcpu=CorteX-A17 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CASE-INSENSITIVE-CPUV7A %s
|
// RUN: %clang -target arm-linux-gnueabi -mcpu=CorteX-A17 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CASE-INSENSITIVE-CPUV7A %s
|
||||||
// CHECK-CASE-INSENSITIVE-CPUV7A: "-cc1"{{.*}} "-triple" "armv7-{{.*}}
|
// CHECK-CASE-INSENSITIVE-CPUV7A: "-cc1"{{.*}} "-triple" "armv7-{{.*}}
|
||||||
|
|
||||||
|
// ================== Check whether -march accepts mixed-case values.
|
||||||
|
// RUN: %clang -target arm -march=Armv5 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CASE-INSENSITIVE-V5 %s
|
||||||
|
// RUN: %clang -target arm -march=ARMV5 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CASE-INSENSITIVE-V5 %s
|
||||||
|
// CHECK-CASE-INSENSITIVE-V5: "-cc1"{{.*}} "-triple" "armv5-{{.*}} "-target-cpu" "arm10tdmi"
|
||||||
|
|
||||||
|
// RUN: %clang -target arm -march=Armv6t2 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CASE-INSENSITIVE-V6T2-THUMB %s
|
||||||
|
// RUN: %clang -target arm -march=ARMV6T2 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CASE-INSENSITIVE-V6T2-THUMB %s
|
||||||
|
// CHECK-CASE-INSENSITIVE-V6T2-THUMB: "-cc1"{{.*}} "-triple" "thumbv6t2-{{.*}} "-target-cpu" "arm1156t2-s"
|
||||||
|
|
Loading…
Reference in New Issue