libs/libc/machine/arm/armv7-m: Add Cortex M4F mach optimized fabsf and sqrtf.
This commit is contained in:
parent
9f24fb5b4b
commit
f2b96016ad
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
45
libs/libc/machine/arm/armv7-m/arch_fabsf.c
Normal file
45
libs/libc/machine/arm/armv7-m/arch_fabsf.c
Normal file
@ -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 <david.s.alessio@gmail.com>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
#include <math.h>
|
||||
|
||||
/****************************************************************************
|
||||
* 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
|
45
libs/libc/machine/arm/armv7-m/arch_sqrtf.c
Normal file
45
libs/libc/machine/arm/armv7-m/arch_sqrtf.c
Normal file
@ -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 <david.s.alessio@gmail.com>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
#include <math.h>
|
||||
|
||||
/****************************************************************************
|
||||
* 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
|
@ -29,13 +29,16 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <math.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_LIBM_ARCH_FABSF
|
||||
float fabsf(float x)
|
||||
{
|
||||
return ((x < 0) ? -x : x);
|
||||
}
|
||||
#endif
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user