[clang] da3f2b4 - [ARM][MVE] Fix a corner case of checking for MVE-I with -mfpu=none
Momchil Velikov via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 11 04:03:54 PST 2020
Author: Momchil Velikov
Date: 2020-02-11T12:03:41Z
New Revision: da3f2b414ace1f24054ae9255f811b653d9cff99
URL: https://github.com/llvm/llvm-project/commit/da3f2b414ace1f24054ae9255f811b653d9cff99
DIFF: https://github.com/llvm/llvm-project/commit/da3f2b414ace1f24054ae9255f811b653d9cff99.diff
LOG: [ARM][MVE] Fix a corner case of checking for MVE-I with -mfpu=none
-march=armv8.1-m.main+mve.fp+nomve -mfpu=none should disable FP
registers and instructions moving to/from FP registers.
This patch fixes the case when "+mve" (added to the feature list by
"+mve.fp"), is followed by "-mve" (added by "+nomve").
Differential Revision: https://reviews.llvm.org/D72633
Added:
Modified:
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/test/Driver/arm-mfpu.c
clang/test/Preprocessor/arm-target-features.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 18bd1317fbc2..afe896b4a65b 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -278,6 +278,13 @@ arm::FloatABI arm::getARMFloatABI(const Driver &D, const llvm::Triple &Triple,
return ABI;
}
+static bool hasIntegerMVE(const std::vector<StringRef> &F) {
+ auto MVE = llvm::find(llvm::reverse(F), "+mve");
+ auto NoMVE = llvm::find(llvm::reverse(F), "-mve");
+ return MVE != F.rend() &&
+ (NoMVE == F.rend() || std::distance(MVE, NoMVE) > 0);
+}
+
void arm::getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args, ArgStringList &CmdArgs,
std::vector<StringRef> &Features, bool ForAS) {
@@ -456,18 +463,13 @@ void arm::getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
// Disable all features relating to hardware FP, not already disabled by the
// above call.
- Features.insert(Features.end(), {"-neon", "-crypto", "-dotprod", "-fp16fml",
- "-mve", "-mve.fp", "-fpregs"});
+ Features.insert(Features.end(),
+ {"-dotprod", "-fp16fml", "-mve", "-mve.fp", "-fpregs"});
} else if (FPUID == llvm::ARM::FK_NONE) {
// -mfpu=none is *very* similar to -mfloat-abi=soft, only that it should not
// disable MVE-I.
- Features.insert(Features.end(),
- {"-neon", "-crypto", "-dotprod", "-fp16fml", "-mve.fp"});
- // Even though we remove MVE-FP, we still need to check if it was originally
- // present among the requested extensions, because it implies MVE-I, which
- // should not be disabled by -mfpu-none.
- if (!llvm::is_contained(Features, "+mve") &&
- !llvm::is_contained(Features, "+mve.fp"))
+ Features.insert(Features.end(), {"-dotprod", "-fp16fml", "-mve.fp"});
+ if (!hasIntegerMVE(Features))
Features.emplace_back("-fpregs");
}
diff --git a/clang/test/Driver/arm-mfpu.c b/clang/test/Driver/arm-mfpu.c
index 5309977d0f90..fc6f09df1bae 100644
--- a/clang/test/Driver/arm-mfpu.c
+++ b/clang/test/Driver/arm-mfpu.c
@@ -419,6 +419,21 @@
// CHECK-MVEFP-FPUNONE-DAG: "-target-feature" "-mve.fp"
// CHECK-MVEFP-FPUNONE-NOT: "-target-feature" "-fpregs"
+// RUN: %clang -target arm-none-none-eabi %s -march=armv8.1-m.main+mve.fp+nomve -mfpu=none -### -c 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-MVEFP-NOMVE-FPUNONE %s
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-vfp2sp"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-vfp3d16sp"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-vfp4d16sp"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-fp-armv8d16sp"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-fp64"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-d32"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-neon"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-crypto"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "+dsp"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-mve"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-mve.fp"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-fpregs"
+
// RUN: %clang -target arm-none-none-eabi %s -march=armv8.1-m.main+mve -mfpu=none -### -c 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-MVEI-FPUNONE %s
// CHECK-MVEI-FPUNONE-DAG: "-target-feature" "-mve.fp"
diff --git a/clang/test/Preprocessor/arm-target-features.c b/clang/test/Preprocessor/arm-target-features.c
index 72b77b6124fe..401e0a41a769 100644
--- a/clang/test/Preprocessor/arm-target-features.c
+++ b/clang/test/Preprocessor/arm-target-features.c
@@ -761,8 +761,9 @@
// CHECK-V81M-MVEFP: #define __ARM_FEATURE_SIMD32 1
// CHECK-V81M-MVEFP: #define __ARM_FPV5__ 1
-// nofp discards mve.fp, but not mve/dsp
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp+nofp -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V81M-MVEFP-NOFP %s
+// fpu=none/nofp discards mve.fp, but not mve/dsp
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp+nofp -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V81M-MVEFP-NOFP %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp -mfpu=none -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V81M-MVEFP-NOFP %s
// CHECK-V81M-MVEFP-NOFP: #define __ARM_FEATURE_DSP 1
// CHECK-V81M-MVEFP-NOFP: #define __ARM_FEATURE_MVE 1
More information about the cfe-commits
mailing list