[PATCH] D53121: [Driver] Add defaults for Android ARM FPUs.

Dan Albert via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 10 17:42:37 PDT 2018


danalbert created this revision.
danalbert added reviewers: srhines, pirama.
Herald added a reviewer: javed.absar.
Herald added subscribers: chrib, kristof.beyls.

Android mandates that devices have at least vfpv3-d16 until
Marshmallow and NEON after that. Still honor the user's decision, but
raise the defaults for Android targets.


Repository:
  rC Clang

https://reviews.llvm.org/D53121

Files:
  lib/Driver/ToolChains/Arch/ARM.cpp
  test/Driver/arm-mfpu.c


Index: test/Driver/arm-mfpu.c
===================================================================
--- test/Driver/arm-mfpu.c
+++ test/Driver/arm-mfpu.c
@@ -364,3 +364,56 @@
 // CHECK-SOFT-ABI-FP: "-target-feature" "-fp-armv8"
 // CHECK-SOFT-ABI-FP: "-target-feature" "-neon"
 // CHECK-SOFT-ABI-FP: "-target-feature" "-crypto"
+
+// RUN: %clang -target arm-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM5-ANDROID-FP-DEFAULT %s
+// CHECK-ARM5-ANDROID-FP-DEFAULT: "-target-feature" "+soft-float"
+// CHECK-ARM5-ANDROID-FP-DEFAULT: "-target-feature" "+soft-float-abi"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+d16"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+vfp3"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+neon"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-DEFAULT %s
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+soft-float-abi"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+d16"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+vfp3"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+neon"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi21 -mfpu=neon %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-NEON %s
+// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+soft-float-abi"
+// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+vfp3"
+// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+neon"
+// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi23 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-DEFAULT %s
+// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+soft-float-abi"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+vfp3"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+neon"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi23 %s -mfpu=vfp3-d16 -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-D16 %s
+// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+soft-float-abi"
+// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+d16"
+// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+vfp3"
+// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+neon"
+// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+crypto"
Index: lib/Driver/ToolChains/Arch/ARM.cpp
===================================================================
--- lib/Driver/ToolChains/Arch/ARM.cpp
+++ lib/Driver/ToolChains/Arch/ARM.cpp
@@ -357,6 +357,12 @@
     checkARMCPUName(D, CPUArg, Args, CPUName, ArchName, Features, Triple);
   }
 
+  unsigned ArchVersion;
+  if (ArchName.empty())
+      ArchVersion = getARMSubArchVersionNumber(Triple);
+  else
+      ArchVersion = llvm::ARM::parseArchVersion(ArchName);
+
   // Add CPU features for generic CPUs
   if (CPUName == "native") {
     llvm::StringMap<bool> HostFeatures;
@@ -378,6 +384,13 @@
                       Features);
   } else if (FPUArg) {
     getARMFPUFeatures(D, FPUArg, Args, FPUArg->getValue(), Features);
+  } else if (Triple.isAndroid() && ArchVersion >= 7) {
+    // Android mandates minimum FPU requirements based on OS version.
+    const char *AndroidFPU =
+        Triple.isAndroidVersionLT(23) ? "vfpv3-d16" : "neon";
+    if (!llvm::ARM::getFPUFeatures(llvm::ARM::parseFPU(AndroidFPU), Features))
+      D.Diag(clang::diag::err_drv_clang_unsupported)
+          << std::string("-mfpu=") + AndroidFPU;
   }
 
   // Honor -mhwdiv=. ClangAs gives preference to -Wa,-mhwdiv=.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53121.169138.patch
Type: text/x-patch
Size: 4755 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181011/816060fe/attachment.bin>


More information about the cfe-commits mailing list