diff --git a/libs/libc/machine/arm/armv7-m/Kconfig b/libs/libc/machine/arm/armv7-m/Kconfig index a95e6f5a148..f3ca62226b4 100644 --- a/libs/libc/machine/arm/armv7-m/Kconfig +++ b/libs/libc/machine/arm/armv7-m/Kconfig @@ -3,9 +3,39 @@ # see the file kconfig-language.txt in the NuttX tools repository. # +if ARCH_ARMV7M + config ARMV7M_MEMCPY bool "Enable optimized memcpy() for ARMv7-M" + default n + select MACHINE_OPTS_ARMV7M select LIBC_ARCH_MEMCPY depends on ARCH_TOOLCHAIN_GNU ---help--- Enable optimized ARMv7-M specific memcpy() library function + +config ARMV7M_LIBM + bool "Architecture specific FPU optimizations" + default n + select MACHINE_OPTS_ARMV7M + select LIBM_ARCH_FABSF + select LIBM_ARCH_SQRTF + depends on ARCH_FPU + depends on LIBM + ---help--- + Enable ARMv7E-M specific floating point optimizations + for fabsf() and fsqrtf() + +config MACHINE_OPTS_ARMV7M + bool + default n + +config LIBM_ARCH_FABSF + bool + default n + +config LIBM_ARCH_SQRTF + bool + default n + +endif diff --git a/libs/libc/machine/arm/armv7-m/Make.defs b/libs/libc/machine/arm/armv7-m/Make.defs index 48dbec79167..f03aa94715a 100644 --- a/libs/libc/machine/arm/armv7-m/Make.defs +++ b/libs/libc/machine/arm/armv7-m/Make.defs @@ -34,20 +34,26 @@ ############################################################################ ifeq ($(CONFIG_ARMV7M_MEMCPY),y) - ASRCS += arch_memcpy.S - DEPPATH += --dep-path machine/arm/armv7-m/gnu VPATH += :machine/arm/armv7-m/gnu - endif -ifeq ($(CONFIG_LIBC_ARCH_ELF),y) +ifeq ($(CONFIG_MACHINE_OPTS_ARMV7M),y) + +ifeq ($(CONFIG_LIBC_ARCH_ELF),y) CSRCS += arch_elf.c +endif + +ifeq ($(CONFIG_LIBM_ARCH_FABSF),y) +CSRCS += arch_fabsf.c +endif + +ifeq ($(CONFIG_LIBM_ARCH_SQRTF),y) +CSRCS += arch_sqrtf.c +endif DEPPATH += --dep-path machine/arm/armv7-m VPATH += :machine/arm/armv7-m - endif - diff --git a/libs/libc/machine/arm/armv7-m/arch_fabsf.c b/libs/libc/machine/arm/armv7-m/arch_fabsf.c new file mode 100644 index 00000000000..5e01cc2af92 --- /dev/null +++ b/libs/libc/machine/arm/armv7-m/arch_fabsf.c @@ -0,0 +1,45 @@ +/**************************************************************************** + * libs/libc/machine/arm/armv7-m/math/arch_fabsf.c + * + * This file is a part of NuttX: + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: David S. Alessio + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#if (__ARM_ARCH >= 7) && (__ARM_FP >= 4) + +float fabsf(float x) +{ + float result; + asm volatile ( "vabs.f32\t%0, %1" : "=t" (result) : "t" (x) ); + return result; +} + +#else +# warning fabsf() not built +#endif diff --git a/libs/libc/machine/arm/armv7-m/arch_sqrtf.c b/libs/libc/machine/arm/armv7-m/arch_sqrtf.c new file mode 100644 index 00000000000..7e8afcb8685 --- /dev/null +++ b/libs/libc/machine/arm/armv7-m/arch_sqrtf.c @@ -0,0 +1,45 @@ +/**************************************************************************** + * libs/libc/machine/arm/armv7-m/math/arch_sqrtf.c + * + * This file is a part of NuttX: + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: David S. Alessio + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#if (__ARM_ARCH >= 7) && (__ARM_FP >= 4) + +float sqrtf(float x) +{ + float result; + asm volatile ( "vsqrt.f32\t%0, %1" : "=t" (result) : "t" (x) ); + return result; +} + +#else +# warning fabsf() not built +#endif diff --git a/libs/libc/math/lib_fabsf.c b/libs/libc/math/lib_fabsf.c index 645e60e5ef6..99c430fc3be 100644 --- a/libs/libc/math/lib_fabsf.c +++ b/libs/libc/math/lib_fabsf.c @@ -29,13 +29,16 @@ * Included Files ****************************************************************************/ +#include #include /**************************************************************************** * Public Functions ****************************************************************************/ +#ifndef CONFIG_LIBM_ARCH_FABSF float fabsf(float x) { return ((x < 0) ? -x : x); } +#endif diff --git a/libs/libc/math/lib_sqrtf.c b/libs/libc/math/lib_sqrtf.c index b173a2c3c38..a99f8786663 100644 --- a/libs/libc/math/lib_sqrtf.c +++ b/libs/libc/math/lib_sqrtf.c @@ -41,6 +41,7 @@ * Public Functions ****************************************************************************/ +#ifndef CONFIG_LIBM_ARCH_SQRTF float sqrtf(float x) { float y; @@ -82,3 +83,4 @@ float sqrtf(float x) return y; } +#endif diff --git a/libs/libc/stdio/lib_libvsprintf.c b/libs/libc/stdio/lib_libvsprintf.c index eb3829b7d68..6b9dfb5a3d5 100644 --- a/libs/libc/stdio/lib_libvsprintf.c +++ b/libs/libc/stdio/lib_libvsprintf.c @@ -384,7 +384,8 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream, * (1) the eZ80 which has sizeof(size_t) = 3 which is the * same as the sizeof(int). And (2) if CONFIG_LIBC_LONG_LONG * is not enabled and sizeof(size_t) is equal to - * sizeof(unsigned long long). This latter case is an error. + * sizeof(unsigned long long). This latter case is an + * error. */ default: