Skip to content

Commit d0fbef9

Browse files
committed
[Driver] Add defaults for Android ARM FPUs.
Summary: 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. Reviewers: srhines, pirama, javed.absar, kristof.beyls, peter.smith Reviewed By: peter.smith Subscribers: peter.smith, rengolin, kristof.beyls, chrib, cfe-commits Differential Revision: https://reviews.llvm.org/D53121 llvm-svn: 344367
1 parent 6c2327a commit d0fbef9

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

clang/lib/Driver/ToolChains/Arch/ARM.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,13 @@ void arm::getARMTargetFeatures(const ToolChain &TC,
378378
Features);
379379
} else if (FPUArg) {
380380
getARMFPUFeatures(D, FPUArg, Args, FPUArg->getValue(), Features);
381+
} else if (Triple.isAndroid() && getARMSubArchVersionNumber(Triple) >= 7) {
382+
// Android mandates minimum FPU requirements based on OS version.
383+
const char *AndroidFPU =
384+
Triple.isAndroidVersionLT(23) ? "vfpv3-d16" : "neon";
385+
if (!llvm::ARM::getFPUFeatures(llvm::ARM::parseFPU(AndroidFPU), Features))
386+
D.Diag(clang::diag::err_drv_clang_unsupported)
387+
<< std::string("-mfpu=") + AndroidFPU;
381388
}
382389

383390
// Honor -mhwdiv=. ClangAs gives preference to -Wa,-mhwdiv=.

clang/test/Driver/arm-mfpu.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,3 +364,67 @@
364364
// CHECK-SOFT-ABI-FP: "-target-feature" "-fp-armv8"
365365
// CHECK-SOFT-ABI-FP: "-target-feature" "-neon"
366366
// CHECK-SOFT-ABI-FP: "-target-feature" "-crypto"
367+
368+
// RUN: %clang -target arm-linux-androideabi21 %s -### -c 2>&1 \
369+
// RUN: | FileCheck --check-prefix=CHECK-ARM5-ANDROID-FP-DEFAULT %s
370+
// CHECK-ARM5-ANDROID-FP-DEFAULT: "-target-feature" "+soft-float"
371+
// CHECK-ARM5-ANDROID-FP-DEFAULT: "-target-feature" "+soft-float-abi"
372+
// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+d16"
373+
// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+vfp3"
374+
// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
375+
// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
376+
// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+neon"
377+
// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+crypto"
378+
379+
// RUN: %clang -target arm-linux-androideabi21 -march=armv7-a %s -### -c 2>&1 \
380+
// RUN: | FileCheck --check-prefix=CHECK-MARCH-ARM7-ANDROID-FP %s
381+
// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+soft-float"
382+
// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+soft-float-abi"
383+
// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+d16"
384+
// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+vfp3"
385+
// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+vfp4"
386+
// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+fp-armv8"
387+
// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+neon"
388+
// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+crypto"
389+
390+
// RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
391+
// RUN: | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-DEFAULT %s
392+
// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
393+
// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+soft-float-abi"
394+
// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+d16"
395+
// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+vfp3"
396+
// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
397+
// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
398+
// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+neon"
399+
// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+crypto"
400+
401+
// RUN: %clang -target armv7-linux-androideabi21 -mfpu=neon %s -### -c 2>&1 \
402+
// RUN: | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-NEON %s
403+
// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+soft-float"
404+
// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+soft-float-abi"
405+
// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+vfp3"
406+
// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+vfp4"
407+
// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+fp-armv8"
408+
// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+neon"
409+
// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+crypto"
410+
411+
// RUN: %clang -target armv7-linux-androideabi23 %s -### -c 2>&1 \
412+
// RUN: | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-DEFAULT %s
413+
// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
414+
// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+soft-float-abi"
415+
// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+vfp3"
416+
// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
417+
// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
418+
// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+neon"
419+
// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+crypto"
420+
421+
// RUN: %clang -target armv7-linux-androideabi23 %s -mfpu=vfp3-d16 -### -c 2>&1 \
422+
// RUN: | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-D16 %s
423+
// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+soft-float"
424+
// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+soft-float-abi"
425+
// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+d16"
426+
// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+vfp3"
427+
// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+vfp4"
428+
// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+fp-armv8"
429+
// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+neon"
430+
// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+crypto"

0 commit comments

Comments
 (0)