1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-10-27 12:15:39 +03:00

arm: Add ARM VFPv4 VFMA instruction support in fma/fmaf (BZ 15503)

It is enabled through math-use-builtins-fma.h if  glibc is built
for VPFv4 (__ARM_FEATURE_FMA predefined by GCC), or through IFUNC
(testing HWCAP_ARM_VFPv4) otherwise.

Checked on arm-linux-gnueabihf.

Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
This commit is contained in:
Adhemerval Zanella
2025-09-23 19:47:10 +00:00
parent 61ac7c6a75
commit 0c8cdb10a1
11 changed files with 78 additions and 0 deletions

View File

@@ -24,6 +24,9 @@
#define arm_libc_ifunc_redirected(redirected_name, name, expr) \
__ifunc (redirected_name, name, expr(hwcap), int hwcap, INIT_ARCH)
#define arm_libm_ifunc(name, expr) \
__ifunc (name, name, expr, int hwcap, libm_ifunc_init)
#if defined SHARED
# define arm_libc_ifunc_hidden_def(redirect_name, name) \
__hidden_ver1 (name, __GI_##name, redirect_name) \

View File

@@ -0,0 +1,11 @@
ifeq ($(subdir),math)
libm-sysdep_routines += \
s_fma-generic \
s_fma-vpfv4 \
s_fmaf-generic \
s_fmaf-vpfv4 \
# libm-sysdep_routinesA
CFLAGS-s_fma-vpfv4.c = -mfpu=vfpv4
CFLAGS-s_fmaf-vpfv4.c = -mfpu=vfpv4
endif

View File

@@ -0,0 +1,5 @@
#include <libm-alias-double.h>
#define __fma __fma_generic
#undef libm_alias_double
#define libm_alias_double(a, b)
#include <sysdeps/ieee754/dbl-64/s_fma.c>

View File

@@ -0,0 +1,5 @@
#include <libm-alias-double.h>
#define __fma __fma_vpfv4
#undef libm_alias_double
#define libm_alias_double(a, b)
#include <sysdeps/ieee754/dbl-64/s_fma.c>

View File

@@ -0,0 +1,19 @@
#define NO_MATH_REDIRECT
#include <arm-ifunc.h>
#define dfmal __hide_dfmal
#define f32xfmaf64 __hide_f32xfmaf64
#include <math.h>
#undef dfmal
#undef f32xfmaf64
#undef fma
#include <libm-alias-double.h>
#include <math-narrow-alias.h>
extern __typeof (fma) __fma_vpfv4 attribute_hidden;
extern __typeof (fma) __fma_generic attribute_hidden;
arm_libm_ifunc (__fma, hwcap & HWCAP_ARM_VFPv4
? __fma_vpfv4
: __fma_generic);
libm_alias_double (__fma, fma)
libm_alias_double_narrow (__fma, fma)

View File

@@ -0,0 +1,5 @@
#include <libm-alias-float.h>
#define __fmaf __fmaf_generic
#undef libm_alias_float
#define libm_alias_float(a, b)
#include <sysdeps/ieee754/dbl-64/s_fmaf.c>

View File

@@ -0,0 +1,5 @@
#include <libm-alias-float.h>
#define __fmaf __fmaf_vpfv4
#undef libm_alias_float
#define libm_alias_float(a, b)
#include <sysdeps/ieee754/dbl-64/s_fmaf.c>

View File

@@ -0,0 +1,12 @@
#define NO_MATH_REDIRECT
#include <arm-ifunc.h>
#include <math.h>
#include <libm-alias-float.h>
extern __typeof (fmaf) __fmaf_vpfv4 attribute_hidden;
extern __typeof (fmaf) __fmaf_generic attribute_hidden;
arm_libm_ifunc (__fmaf, hwcap & HWCAP_ARM_VFPv4
? __fmaf_vpfv4
: __fmaf_generic)
libm_alias_float (__fma, fma)

View File

@@ -0,0 +1 @@
arm/armv7/fpu/multiarch

View File

@@ -0,0 +1,11 @@
#if defined __ARM_FEATURE_FMA && __ARM_FP & 0x4
# define USE_FMA_BUILTIN 1
#endif
#if defined __ARM_FEATURE_FMA && __ARM_FP & 0x2
# define USE_FMAF_BUILTIN 1
#else
# define USE_FMA_BUILTIN 0
# define USE_FMAF_BUILTIN 0
#endif
#define USE_FMAL_BUILTIN 0
#define USE_FMAF128_BUILTIN 0

View File

@@ -0,0 +1 @@
arm/armv7/fpu/multiarch