From 391c662c61196569ec91a02404683927977aa448 Mon Sep 17 00:00:00 2001 From: Silviu Baranga Date: Thu, 28 Apr 2016 11:29:08 +0000 Subject: [PATCH] PR27216: Only define __ARM_FEATURE_FMA when the target has VFPv4 Summary: According to the ACLE spec, "__ARM_FEATURE_FMA is defined to 1 if the hardware floating-point architecture supports fused floating-point multiply-accumulate". This changes clang's behaviour from emitting this macro for v7-A and v7-R cores to only emitting it when the target has VFPv4 (and therefore support for the floating point multiply-accumulate instruction). Fixes PR27216 Reviewers: t.p.northover, rengolin Subscribers: aemerson, rengolin, cfe-commits Differential Revision: http://reviews.llvm.org/D18963 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@267869 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Basic/Targets.cpp | 2 +- test/CodeGen/arm-neon-fma.c | 2 +- test/Preprocessor/arm-acle-6.5.c | 9 ++++++--- test/Sema/arm_vfma.c | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 98827b89a1..4e516513b3 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -4931,7 +4931,7 @@ public: Builder.defineMacro("__ARM_FP16_ARGS", "1"); // ACLE 6.5.3 Fused multiply-accumulate (FMA) - if (ArchVersion >= 7 && (CPUProfile != "M" || CPUAttr == "7EM")) + if (ArchVersion >= 7 && (FPU & VFP4FPU)) Builder.defineMacro("__ARM_FEATURE_FMA", "1"); // Subtarget options. diff --git a/test/CodeGen/arm-neon-fma.c b/test/CodeGen/arm-neon-fma.c index 1a2a20f2bd..ff6acbcc2e 100644 --- a/test/CodeGen/arm-neon-fma.c +++ b/test/CodeGen/arm-neon-fma.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -triple thumbv7-none-linux-gnueabihf \ // RUN: -target-abi aapcs \ -// RUN: -target-cpu cortex-a8 \ +// RUN: -target-cpu cortex-a7 \ // RUN: -mfloat-abi hard \ // RUN: -ffreestanding \ // RUN: -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s diff --git a/test/Preprocessor/arm-acle-6.5.c b/test/Preprocessor/arm-acle-6.5.c index 95adad9faa..cc158c82cd 100644 --- a/test/Preprocessor/arm-acle-6.5.c +++ b/test/Preprocessor/arm-acle-6.5.c @@ -49,10 +49,13 @@ // CHECK-NO-FMA-NOT: __ARM_FEATURE_FMA -// RUN: %clang -target armv7a-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA -// RUN: %clang -target armv7r-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA +// RUN: %clang -target armv7a-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FMA +// RUN: %clang -target armv7a-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA +// RUN: %clang -target armv7r-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FMA +// RUN: %clang -target armv7r-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA // RUN: %clang -target armv7em-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA -// RUN: %clang -target armv8-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA +// RUN: %clang -target armv8-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FMA +// RUN: %clang -target armv8-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA // CHECK-FMA: __ARM_FEATURE_FMA 1 diff --git a/test/Sema/arm_vfma.c b/test/Sema/arm_vfma.c index c50a4147b3..8c08b4d8b9 100644 --- a/test/Sema/arm_vfma.c +++ b/test/Sema/arm_vfma.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple thumbv7-none-eabi -target-feature +neon -target-feature +vfp4 -fsyntax-only -verify %s #include // expected-no-diagnostics -- 2.40.0