* [musl] [PATCH] Add additional __ARM_FP checks to ARM FPU math functions
@ 2024-11-21 2:26 Jesse DeGuire
0 siblings, 0 replies; only message in thread
From: Jesse DeGuire @ 2024-11-21 2:26 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 1103 bytes --]
Hi everyone!
I found that I was getting compiler errors when I try to build Musl
for an ARMv8.1M Mainline target that does not have floating-point
support but does have the M-Profile Vector Extensions (MVE). The
errors were that Musl wanted to use unsupported floating-point
instructions for fabsf() and sqrtf().
I was able to correct this by adding checks for (__ARM_FP & 4) to the
ARM "fabsf.c" and "sqrtf.c" files, which is all this tiny patch does.
The relevant options I used with Clang were "-march=armv8.1m.main+mve
-mfpu=none -mfloat-abi=hard". MVE uses the FP register file, but
treats them as 8 128-bit registers instead of 16 64-bit registers, so
presumably that's why the hard float ABI is used even when
floating-point operations are not enabled. In this case, an
integer-only subset of MVE is used.
Here is a Godbolt link that shows that you can make this happen on GCC, too.
https://www.godbolt.org/z/Mf4h489s8
I'm not sure if this is totally necessary since I suspect this would
affect only ARM M-Profile devices, but maybe it at least wouldn't hurt
to have.
Thanks,
Jesse DeGuire
[-- Attachment #2: arm_fp_check.patch --]
[-- Type: application/octet-stream, Size: 664 bytes --]
diff --git a/src/math/arm/fabsf.c b/src/math/arm/fabsf.c
index 4a217c98..790d4cfe 100644
--- a/src/math/arm/fabsf.c
+++ b/src/math/arm/fabsf.c
@@ -1,6 +1,6 @@
#include <math.h>
-#if __ARM_PCS_VFP && !BROKEN_VFP_ASM
+#if __ARM_PCS_VFP && !BROKEN_VFP_ASM && (__ARM_FP&4)
float fabsf(float x)
{
diff --git a/src/math/arm/sqrtf.c b/src/math/arm/sqrtf.c
index 32693293..51f44f8c 100644
--- a/src/math/arm/sqrtf.c
+++ b/src/math/arm/sqrtf.c
@@ -1,6 +1,6 @@
#include <math.h>
-#if (__ARM_PCS_VFP || (__VFP_FP__ && !__SOFTFP__)) && !BROKEN_VFP_ASM
+#if (__ARM_PCS_VFP || (__VFP_FP__ && !__SOFTFP__)) && !BROKEN_VFP_ASM && (__ARM_FP&4)
float sqrtf(float x)
{
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-11-21 2:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-21 2:26 [musl] [PATCH] Add additional __ARM_FP checks to ARM FPU math functions Jesse DeGuire
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).