Skip to content

Commit ee3e016

Browse files
committed
[Clang][ARM] Define __VFP_FP__ macro unconditionally
Clang only defines __VFP_FP__ when the FPU is enabled. However, gcc defines it unconditionally. This patch aligns Clang with gcc. Reviewed By: peter.smith, rengolin Differential Revision: https://reviews.llvm.org/D100372
1 parent e6ff89d commit ee3e016

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

clang/lib/Basic/Targets/ARM.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,8 +755,12 @@ void ARMTargetInfo::getTargetDefines(const LangOptions &Opts,
755755
// Note, this is always on in gcc, even though it doesn't make sense.
756756
Builder.defineMacro("__APCS_32__");
757757

758+
// __VFP_FP__ means that the floating-point format is VFP, not that a hardware
759+
// FPU is present. Moreover, the VFP format is the only one supported by
760+
// clang. For these reasons, this macro is always defined.
761+
Builder.defineMacro("__VFP_FP__");
762+
758763
if (FPUModeIsVFP((FPUMode)FPU)) {
759-
Builder.defineMacro("__VFP_FP__");
760764
if (FPU & VFP2FPU)
761765
Builder.defineMacro("__ARM_VFPV2__");
762766
if (FPU & VFP3FPU)

clang/test/Preprocessor/arm-target-features.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@
141141
// CHECK-V7S-NOT: __ARM_FEATURE_DIRECTED_ROUNDING
142142
// CHECK-V7S: #define __ARM_FP 0xe
143143

144+
// RUN: %clang -target arm-arm-none-eabi -march=armv7-m -mfloat-abi=soft -x c -E -dM %s | FileCheck -match-full-lines --check-prefix=CHECK-VFP-FP %s
145+
// RUN: %clang -target arm-arm-none-eabi -march=armv7-m -mfloat-abi=softfp -x c -E -dM %s | FileCheck -match-full-lines --check-prefix=CHECK-VFP-FP %s
146+
// RUN: %clang -target arm-arm-none-eabi -march=armv7-m -mfloat-abi=hard -x c -E -dM %s | FileCheck -match-full-lines --check-prefix=CHECK-VFP-FP %s
147+
// CHECK-VFP-FP: #define __VFP_FP__ 1
148+
144149
// RUN: %clang -target armv8a -mfloat-abi=hard -x c -E -dM %s | FileCheck -match-full-lines --check-prefix=CHECK-V8-BAREHF %s
145150
// CHECK-V8-BAREHF: #define __ARMEL__ 1
146151
// CHECK-V8-BAREHF: #define __ARM_ARCH 8

0 commit comments

Comments
 (0)