[PATCH] D72633: [ARM][MVE] Fix a corner case of checking for MVE-I with -mfpu=none

Momchil Velikov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 11 04:04:08 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGda3f2b414ace: [ARM][MVE] Fix a corner case of checking for MVE-I with -mfpu=none (authored by chill).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D72633?vs=240836&id=243803#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72633/new/

https://reviews.llvm.org/D72633

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-mfpu.c
  clang/test/Preprocessor/arm-target-features.c


Index: clang/test/Preprocessor/arm-target-features.c
===================================================================
--- clang/test/Preprocessor/arm-target-features.c
+++ 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
 
Index: clang/test/Driver/arm-mfpu.c
===================================================================
--- clang/test/Driver/arm-mfpu.c
+++ 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"
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -278,6 +278,13 @@
   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 @@
 
     // 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");
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72633.243803.patch
Type: text/x-patch
Size: 4392 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200211/ac39a75c/attachment.bin>


More information about the cfe-commits mailing list