mirror of
https://github.com/apache/nuttx.git
synced 2026-09-27 18:58:27 +08:00
libs/libc/machine/arm/armv7-m: Add Cortex M4F mach optimized fabsf and sqrtf.
This commit is contained in:
committed by
Gregory Nutt
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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user