r217957 - Basic: add support for ARM ACLE 6.5.1
Saleem Abdulrasool
compnerd at compnerd.org
Wed Sep 17 07:50:28 PDT 2014
Author: compnerd
Date: Wed Sep 17 09:50:27 2014
New Revision: 217957
URL: http://llvm.org/viewvc/llvm-project?rev=217957&view=rev
Log:
Basic: add support for ARM ACLE 6.5.1
Extend ARM ACLE support (Section 6.5.1) for AArch32. Define __ARM_FP if
hardware floating point support is available as per the value defined by the
ACLE.
Added:
cfe/trunk/test/Preprocessor/arm-acle-6.5.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=217957&r1=217956&r2=217957&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Sep 17 09:50:27 2014
@@ -3569,6 +3569,14 @@ class ARMTargetInfo : public TargetInfo
unsigned CRC : 1;
unsigned Crypto : 1;
+ // ACLE 6.5.1 Hardware floating point
+ enum {
+ HW_FP_HP = (1 << 1), /// half (16-bit)
+ HW_FP_SP = (1 << 2), /// single (32-bit)
+ HW_FP_DP = (1 << 3), /// double (64-bit)
+ };
+ uint32_t HW_FP;
+
static const Builtin::Info BuiltinInfo[];
static bool shouldUseInlineAtomic(const llvm::Triple &T) {
@@ -3730,7 +3738,7 @@ class ARMTargetInfo : public TargetInfo
public:
ARMTargetInfo(const llvm::Triple &Triple, bool IsBigEndian)
: TargetInfo(Triple), CPU("arm1136j-s"), FPMath(FP_Default),
- IsAAPCS(true) {
+ IsAAPCS(true), HW_FP(0) {
BigEndian = IsBigEndian;
switch (getTriple().getOS()) {
@@ -3843,28 +3851,36 @@ public:
HWDiv = 0;
for (const auto &Feature : Features) {
- if (Feature == "+soft-float")
+ if (Feature == "+soft-float") {
SoftFloat = true;
- else if (Feature == "+soft-float-abi")
+ } else if (Feature == "+soft-float-abi") {
SoftFloatABI = true;
- else if (Feature == "+vfp2")
+ } else if (Feature == "+vfp2") {
FPU |= VFP2FPU;
- else if (Feature == "+vfp3")
+ HW_FP = HW_FP_SP | HW_FP_DP;
+ } else if (Feature == "+vfp3") {
FPU |= VFP3FPU;
- else if (Feature == "+vfp4")
+ HW_FP = HW_FP_SP | HW_FP_DP;
+ } else if (Feature == "+vfp4") {
FPU |= VFP4FPU;
- else if (Feature == "+fp-armv8")
+ HW_FP = HW_FP_SP | HW_FP_DP | HW_FP_HP;
+ } else if (Feature == "+fp-armv8") {
FPU |= FPARMV8;
- else if (Feature == "+neon")
+ HW_FP = HW_FP_SP | HW_FP_DP | HW_FP_HP;
+ } else if (Feature == "+neon") {
FPU |= NeonFPU;
- else if (Feature == "+hwdiv")
+ HW_FP = HW_FP_SP | HW_FP_DP;
+ } else if (Feature == "+hwdiv") {
HWDiv |= HWDivThumb;
- else if (Feature == "+hwdiv-arm")
+ } else if (Feature == "+hwdiv-arm") {
HWDiv |= HWDivARM;
- else if (Feature == "+crc")
+ } else if (Feature == "+crc") {
CRC = 1;
- else if (Feature == "+crypto")
+ } else if (Feature == "+crypto") {
Crypto = 1;
+ } else if (Feature == "+fp-only-sp") {
+ HW_FP &= ~HW_FP_DP;
+ }
}
if (!(FPU & NeonFPU) && FPMath == FP_Neon) {
@@ -4012,6 +4028,10 @@ public:
if (!CPUProfile.empty())
Builder.defineMacro("__ARM_ARCH_PROFILE", "'" + CPUProfile + "'");
+ // ACLE 6.5.1 Hardware Floating Point
+ if (HW_FP)
+ Builder.defineMacro("__ARM_FP", std::to_string(HW_FP));
+
// ACLE predefines.
Builder.defineMacro("__ARM_ACLE", "200");
Added: cfe/trunk/test/Preprocessor/arm-acle-6.5.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/arm-acle-6.5.c?rev=217957&view=auto
==============================================================================
--- cfe/trunk/test/Preprocessor/arm-acle-6.5.c (added)
+++ cfe/trunk/test/Preprocessor/arm-acle-6.5.c Wed Sep 17 09:50:27 2014
@@ -0,0 +1,22 @@
+// RUN: %clang -target arm-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-DEFAULT
+
+// CHECK-DEFAULT-NOT: __ARM_FP
+
+// RUN: %clang -target arm-eabi -mfpu=vfp -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+// RUN: %clang -target arm-eabi -mfpu=vfp3 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+// RUN: %clang -target arm-eabi -mfpu=vfp3-d16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+// RUN: %clang -target arm-eabi -mfpu=neon -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+// RUN: %clang -target arm-eabi -mfpu=vfp3 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+// RUN: %clang -target armv7-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+
+// CHECK-SP-DP: __ARM_FP 12
+
+// RUN: %clang -target arm-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+// RUN: %clang -target arm-eabi -mfpu=vfpv4-d16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+// RUN: %clang -target arm-eabi -mfpu=fp-armv8 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+// RUN: %clang -target arm-eabi -mfpu=neon-fp-armv8 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+// RUN: %clang -target arm-eabi -mfpu=crypto-neon-fp-armv8 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+// RUN: %clang -target armv8-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+
+// CHECK-SP-DP-HP: __ARM_FP 14
+
More information about the cfe-commits
mailing list