[ARM] Fix the extensions implied by a cpu name
Summary: When using `clang -mcpu=CPUNAME+FEATURELIST`, the implied features defined by CPUNAME are not obtained, as the entire string is passed. This fixes that by spiting the cpuname string in the first `+`, if any. For example, when using ```clang -### --target=arm-arm-none-eabi -march=armv7-a -mcpu=cortex-a8+nocrc``` the intrinsic ```"target-feature" "+dsp"``` implied by `cortex-a8` is missing. Reviewers: keith.walker.arm, DavidSpickett, carwil Reviewed By: DavidSpickett Subscribers: javed.absar, kristof.beyls, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61668 llvm-svn: 360324
This commit is contained in:
parent
3cdf898105
commit
543913c3b4
|
@ -88,6 +88,7 @@ static bool DecodeARMFeatures(const Driver &D, StringRef text,
|
||||||
|
|
||||||
static void DecodeARMFeaturesFromCPU(const Driver &D, StringRef CPU,
|
static void DecodeARMFeaturesFromCPU(const Driver &D, StringRef CPU,
|
||||||
std::vector<StringRef> &Features) {
|
std::vector<StringRef> &Features) {
|
||||||
|
CPU = CPU.split("+").first;
|
||||||
if (CPU != "generic") {
|
if (CPU != "generic") {
|
||||||
llvm::ARM::ArchKind ArchKind = llvm::ARM::parseCPUArch(CPU);
|
llvm::ARM::ArchKind ArchKind = llvm::ARM::parseCPUArch(CPU);
|
||||||
unsigned Extension = llvm::ARM::getDefaultExtensions(CPU, ArchKind);
|
unsigned Extension = llvm::ARM::getDefaultExtensions(CPU, ArchKind);
|
||||||
|
@ -350,11 +351,9 @@ void arm::getARMTargetFeatures(const ToolChain &TC,
|
||||||
D.Diag(clang::diag::warn_drv_unused_argument)
|
D.Diag(clang::diag::warn_drv_unused_argument)
|
||||||
<< CPUArg->getAsString(Args);
|
<< CPUArg->getAsString(Args);
|
||||||
CPUName = StringRef(WaCPU->getValue()).substr(6);
|
CPUName = StringRef(WaCPU->getValue()).substr(6);
|
||||||
checkARMCPUName(D, WaCPU, Args, CPUName, ArchName, Features, Triple);
|
CPUArg = WaCPU;
|
||||||
} else if (CPUArg) {
|
} else if (CPUArg)
|
||||||
CPUName = CPUArg->getValue();
|
CPUName = CPUArg->getValue();
|
||||||
checkARMCPUName(D, CPUArg, Args, CPUName, ArchName, Features, Triple);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add CPU features for generic CPUs
|
// Add CPU features for generic CPUs
|
||||||
if (CPUName == "native") {
|
if (CPUName == "native") {
|
||||||
|
@ -367,6 +366,8 @@ void arm::getARMTargetFeatures(const ToolChain &TC,
|
||||||
DecodeARMFeaturesFromCPU(D, CPUName, Features);
|
DecodeARMFeaturesFromCPU(D, CPUName, Features);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CPUArg)
|
||||||
|
checkARMCPUName(D, CPUArg, Args, CPUName, ArchName, Features, Triple);
|
||||||
// Honor -mfpu=. ClangAs gives preference to -Wa,-mfpu=.
|
// Honor -mfpu=. ClangAs gives preference to -Wa,-mfpu=.
|
||||||
const Arg *FPUArg = Args.getLastArg(options::OPT_mfpu_EQ);
|
const Arg *FPUArg = Args.getLastArg(options::OPT_mfpu_EQ);
|
||||||
if (WaFPU) {
|
if (WaFPU) {
|
||||||
|
|
|
@ -340,30 +340,31 @@
|
||||||
// RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-FP16 %s
|
// RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-FP16 %s
|
||||||
// RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+nofp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-NOFP16 %s
|
// RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+nofp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-NOFP16 %s
|
||||||
// CHECK-CORTEX-A53-FP16: "-cc1" {{.*}}"-target-cpu" "cortex-a53" {{.*}}"-target-feature" "+fullfp16"
|
// CHECK-CORTEX-A53-FP16: "-cc1" {{.*}}"-target-cpu" "cortex-a53" {{.*}}"-target-feature" "+fullfp16"
|
||||||
// CHECK-CORTEX-A53-FP16-NOT: "-target-feature" "{{[+-]}}fp16fml"
|
// CHECK-CORTEX-A53-FP16-NOT: "-target-feature" "+fp16fml"
|
||||||
// CHECK-CORTEX-A53-NOFP16: "-cc1" {{.*}}"-target-cpu" "cortex-a53" {{.*}}"-target-feature" "-fullfp16" "-target-feature" "-fp16fml"
|
// CHECK-CORTEX-A53-NOFP16-NOT: "+fullfp16"
|
||||||
|
// CHECK-CORTEX-A53-NOFP16-NOT: "+fp16fml"
|
||||||
|
|
||||||
// RUN: %clang -target armv8a-linux-eabi -march=armv8-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-NOFP16FML %s
|
// RUN: %clang -target armv8a-linux-eabi -march=armv8-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-NOFP16FML %s
|
||||||
// CHECK-V8A-NOFP16FML-NOT: "-target-feature" "{{[+-]}}fp16fml"
|
// CHECK-V8A-NOFP16FML-NOT: "-target-feature" "+fp16fml"
|
||||||
// CHECK-V8A-NOFP16FML-NOT: "-target-feature" "{{[+-]}}fullfp16"
|
// CHECK-V8A-NOFP16FML-NOT: "-target-feature" "+fullfp16"
|
||||||
|
|
||||||
// RUN: %clang -target armv8a-linux-eabi -march=armv8-a+fp16 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-FP16 %s
|
// RUN: %clang -target armv8a-linux-eabi -march=armv8-a+fp16 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-FP16 %s
|
||||||
// CHECK-V8A-FP16-NOT: "-target-feature" "{{[+-]}}fp16fml"
|
// CHECK-V8A-FP16-NOT: "-target-feature" "+fp16fml"
|
||||||
// CHECK-V8A-FP16: "-target-feature" "+fullfp16"
|
// CHECK-V8A-FP16: "-target-feature" "+fullfp16"
|
||||||
// CHECK-V8A-FP16-NOT: "-target-feature" "{{[+-]}}fp16fml"
|
// CHECK-V8A-FP16-NOT: "-target-feature" "+fp16fml"
|
||||||
// CHECK-V8A-FP16-SAME: {{$}}
|
// CHECK-V8A-FP16-SAME: {{$}}
|
||||||
|
|
||||||
// RUN: %clang -target armv8a-linux-eabi -march=armv8-a+fp16fml -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-FP16FML %s
|
// RUN: %clang -target armv8a-linux-eabi -march=armv8-a+fp16fml -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-FP16FML %s
|
||||||
// CHECK-V8A-FP16FML: "-target-feature" "+fp16fml" "-target-feature" "+fullfp16"
|
// CHECK-V8A-FP16FML: "-target-feature" "+fp16fml" "-target-feature" "+fullfp16"
|
||||||
|
|
||||||
// RUN: %clang -target armv8a-linux-eabi -march=armv8.2-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A-NOFP16FML %s
|
// RUN: %clang -target armv8a-linux-eabi -march=armv8.2-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A-NOFP16FML %s
|
||||||
// CHECK-V82A-NOFP16FML-NOT: "-target-feature" "{{[+-]}}fp16fml"
|
// CHECK-V82A-NOFP16FML-NOT: "-target-feature" "+fp16fml"
|
||||||
// CHECK-V82A-NOFP16FML-NOT: "-target-feature" "{{[+-]}}fullfp16"
|
// CHECK-V82A-NOFP16FML-NOT: "-target-feature" "+fullfp16"
|
||||||
|
|
||||||
// RUN: %clang -target armv8a-linux-eabi -march=armv8.2-a+fp16 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A-FP16 %s
|
// RUN: %clang -target armv8a-linux-eabi -march=armv8.2-a+fp16 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A-FP16 %s
|
||||||
// CHECK-V82A-FP16-NOT: "-target-feature" "{{[+-]}}fp16fml"
|
// CHECK-V82A-FP16-NOT: "-target-feature" "+fp16fml"
|
||||||
// CHECK-V82A-FP16: "-target-feature" "+fullfp16"
|
// CHECK-V82A-FP16: "-target-feature" "+fullfp16"
|
||||||
// CHECK-V82A-FP16-NOT: "-target-feature" "{{[+-]}}fp16fml"
|
// CHECK-V82A-FP16-NOT: "-target-feature" "+fp16fml"
|
||||||
// CHECK-V82A-FP16-SAME: {{$}}
|
// CHECK-V82A-FP16-SAME: {{$}}
|
||||||
|
|
||||||
// RUN: %clang -target armv8a-linux-eabi -march=armv8.2-a+fp16fml -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A-FP16FML %s
|
// RUN: %clang -target armv8a-linux-eabi -march=armv8.2-a+fp16fml -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A-FP16FML %s
|
||||||
|
@ -382,13 +383,13 @@
|
||||||
// CHECK-V82A-NOFP16-FP16FML: "-target-feature" "+fp16fml" "-target-feature" "+fullfp16"
|
// CHECK-V82A-NOFP16-FP16FML: "-target-feature" "+fp16fml" "-target-feature" "+fullfp16"
|
||||||
|
|
||||||
// RUN: %clang -target armv8a-linux-eabi -march=armv8.3-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V83A-NOFP16FML %s
|
// RUN: %clang -target armv8a-linux-eabi -march=armv8.3-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V83A-NOFP16FML %s
|
||||||
// CHECK-V83A-NOFP16FML-NOT: "-target-feature" "{{[+-]}}fp16fml"
|
// CHECK-V83A-NOFP16FML-NOT: "-target-feature" "+fp16fml"
|
||||||
// CHECK-V83A-NOFP16FML-NOT: "-target-feature" "{{[+-]}}fullfp16"
|
// CHECK-V83A-NOFP16FML-NOT: "-target-feature" "+fullfp16"
|
||||||
|
|
||||||
// RUN: %clang -target armv8a-linux-eabi -march=armv8.3-a+fp16 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V83A-FP16 %s
|
// RUN: %clang -target armv8a-linux-eabi -march=armv8.3-a+fp16 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V83A-FP16 %s
|
||||||
// CHECK-V83A-FP16-NOT: "-target-feature" "{{[+-]}}fp16fml"
|
// CHECK-V83A-FP16-NOT: "-target-feature" "+fp16fml"
|
||||||
// CHECK-V83A-FP16: "-target-feature" "+fullfp16"
|
// CHECK-V83A-FP16: "-target-feature" "+fullfp16"
|
||||||
// CHECK-V83A-FP16-NOT: "-target-feature" "{{[+-]}}fp16fml"
|
// CHECK-V83A-FP16-NOT: "-target-feature" "+fp16fml"
|
||||||
// CHECK-V83A-FP16-SAME: {{$}}
|
// CHECK-V83A-FP16-SAME: {{$}}
|
||||||
|
|
||||||
// RUN: %clang -target armv8a-linux-eabi -march=armv8.3-a+fp16fml -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V83A-FP16FML %s
|
// RUN: %clang -target armv8a-linux-eabi -march=armv8.3-a+fp16fml -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V83A-FP16FML %s
|
||||||
|
@ -407,8 +408,8 @@
|
||||||
// CHECK-V83A-NOFP16-FP16FML: "-target-feature" "+fp16fml" "-target-feature" "+fullfp16"
|
// CHECK-V83A-NOFP16-FP16FML: "-target-feature" "+fp16fml" "-target-feature" "+fullfp16"
|
||||||
|
|
||||||
// RUN: %clang -target armv8a-linux-eabi -march=armv8.4-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V84A-NOFP16FML %s
|
// RUN: %clang -target armv8a-linux-eabi -march=armv8.4-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V84A-NOFP16FML %s
|
||||||
// CHECK-V84A-NOFP16FML-NOT: "-target-feature" "{{[+-]}}fp16fml"
|
// CHECK-V84A-NOFP16FML-NOT: "-target-feature" "+fp16fml"
|
||||||
// CHECK-V84A-NOFP16FML-NOT: "-target-feature" "{{[+-]}}fullfp16"
|
// CHECK-V84A-NOFP16FML-NOT: "-target-feature" "+fullfp16"
|
||||||
|
|
||||||
// RUN: %clang -target armv8a-linux-eabi -march=armv8.4-a+fp16 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V84A-FP16 %s
|
// RUN: %clang -target armv8a-linux-eabi -march=armv8.4-a+fp16 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V84A-FP16 %s
|
||||||
// CHECK-V84A-FP16: "-target-feature" "+fullfp16" "-target-feature" "+fp16fml"
|
// CHECK-V84A-FP16: "-target-feature" "+fullfp16" "-target-feature" "+fp16fml"
|
||||||
|
@ -853,3 +854,7 @@
|
||||||
// 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
|
||||||
// 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"
|
// CHECK-CASE-INSENSITIVE-V6T2-THUMB: "-cc1"{{.*}} "-triple" "thumbv6t2-{{.*}} "-target-cpu" "arm1156t2-s"
|
||||||
|
|
||||||
|
// ================== Check that the correct PROCESSOR features are added when used -mcpu=PROCESSOR+FEATURESLIST
|
||||||
|
// RUN: %clang -### --target=arm-arm-none-eabi -march=armv7-a -mcpu=cortex-a8+nocrc -x c -S -o - - <<< "" 2>&1 | FileCheck -check-prefix=A8FEATURES %s
|
||||||
|
// A8FEATURES: "-target-feature" "+dsp"
|
||||||
|
|
Loading…
Reference in New Issue