[PATCH][newlib][ARM] Add arm directory to libm, use vrint for standard rounding functions
Richard Earnshaw
rearnsha@arm.com
Thu Dec 6 12:40:00 GMT 2012
On 16/11/12 11:38, Kyrylo Tkachov wrote:
> Hi all,
>
> This patch adds ARM-specific support for the single and double precision
> libm functions: ceil, floor, nearbyint, rint, round, trunk.
> These functions can be implemented using the vrint family of instructions
> introduced in ARMv8 so we use those when the target supports it, otherwise
> we revert to the generic implementations.
> If approved, can the commiter please generate/regenerate the appropriate
> files?
> An arm directory is added to libm/machine. The following files need to be
> generated with autoconf/automake:
> * libm/machine/arm/Makefile.in
> * libm/machine/arm/aclocal.m4
> * libm/machine/arm/configure
>
> The file
> * libm/machine/configure needs to be regenerated.
>
> The patch has been tested with an arm-eabi toolchain running on a model. It
> is for the AArch32 / ARM backend of newlib.
>
> Thanks,
> Kyrill
>
> P.S. I had sent this to a wrong address before... Sorry if you received this
> multiple times.
>
> newlib/ChangeLog
>
> 2012-11-14 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
>
> * configure.host: Define libm_machine_dir value for arm.
> * libm/machine/configure.in: Add arm to libm machines list.
> * libm/machine/configure: Regenerate.
> * libm/machine/arm/Makefile.am: New file.
> * libm/machine/arm/Makefile.in: Generated.
> * libm/machine/arm/aclocal.m4: Generated.
> * libm/machine/arm/configure: Generated.
> * libm/machine/arm/configure.in: New file.
> * libm/machine/arm/s_ceil.c: Likewise.
> * libm/machine/arm/s_floor.c: Likewise.
> * libm/machine/arm/s_nearbyint.c: Likewise.
> * libm/machine/arm/s_rint.c: Likewise.
> * libm/machine/arm/s_round.c: Likewise.
> * libm/machine/arm/s_trunc.c: Likewise.
> * libm/machine/arm/sf_ceil.c: Likewise.
> * libm/machine/arm/sf_floor.c: Likewise.
> * libm/machine/arm/sf_nearbyint.c: Likewise.
> * libm/machine/arm/sf_rint.c: Likewise.
> * libm/machine/arm/sf_round.c: Likewise.
> * libm/machine/arm/sf_trunc.c: Likewise.
>
>
Nearly, but not quite.
When building soft-float, we need to fall back to the standard C
implementations. Secondly, for future proofing, you should use
__ARM_ARCH rather than testing a specific architecture version.
So instead of
#ifdef __ARM_ARCH_8A__
use something like:
#if __ARM_ARCH >= 8 && !defined(__SOFTFP__)
R.
> newlib_vrint2.txt
>
>
> --- a/newlib/configure.host
> +++ b/newlib/configure.host
> @@ -104,6 +104,7 @@ case "${host_cpu}" in
> ;;
> arm*)
> machine_dir=arm
> + libm_machine_dir=arm
> ;;
> avr*)
> newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mcall-prologues"
> diff --git a/newlib/libm/machine/arm/Makefile.am b/newlib/libm/machine/arm/Makefile.am
> new file mode 100644
> index 0000000..f0ab84f
> --- /dev/null
> +++ b/newlib/libm/machine/arm/Makefile.am
> @@ -0,0 +1,31 @@
> +## Process this file with automake to generate Makefile.in
> +
> +AUTOMAKE_OPTIONS = cygnus
> +
> +INCLUDES = -I $(newlib_basedir)/../newlib/libm/common $(NEWLIB_CFLAGS) \
> + $(CROSS_CFLAGS) $(TARGET_CFLAGS)
> +
> +LIB_SOURCES = \
> + s_ceil.c \
> + s_floor.c \
> + s_nearbyint.c \
> + s_rint.c \
> + s_round.c \
> + s_trunc.c \
> + sf_ceil.c \
> + sf_floor.c \
> + sf_nearbyint.c \
> + sf_rint.c \
> + sf_round.c \
> + sf_trunc.c
> +
> +noinst_LIBRARIES = lib.a
> +lib_a_SOURCES = $(LIB_SOURCES)
> +lib_a_CFLAGS = $(AM_CFLAGS)
> +lib_a_CCASFLAGS = $(AM_CCASFLAGS)
> +noinst_DATA =
> +
> +include $(srcdir)/../../../Makefile.shared
> +
> +ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
> +CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
> diff --git a/newlib/libm/machine/arm/configure.in b/newlib/libm/machine/arm/configure.in
> new file mode 100644
> index 0000000..acbbadc
> --- /dev/null
> +++ b/newlib/libm/machine/arm/configure.in
> @@ -0,0 +1,14 @@
> +dnl This is the newlib/libm/machine/arm configure.in file.
> +dnl Process this file with autoconf to produce a configure script.
> +
> +AC_PREREQ(2.59)
> +AC_INIT([newlib],[NEWLIB_VERSION])
> +AC_CONFIG_SRCDIR([Makefile.am])
> +
> +dnl Can't be done in NEWLIB_CONFIGURE because that confuses automake.
> +AC_CONFIG_AUX_DIR(../../../..)
> +
> +NEWLIB_CONFIGURE(../../..)
> +
> +AC_CONFIG_FILES([Makefile])
> +AC_OUTPUT
> diff --git a/newlib/libm/machine/arm/s_ceil.c b/newlib/libm/machine/arm/s_ceil.c
> new file mode 100644
> index 0000000..e1d33b7
> --- /dev/null
> +++ b/newlib/libm/machine/arm/s_ceil.c
> @@ -0,0 +1,40 @@
> +/* s_ceil.c -- define ceil
> + Copyright (c) 2012 ARM Ltd. All rights reserved.
> +
> + Redistribution and use in source and binary forms, with or without
> + modification, are permitted provided that the following conditions
> + are met:
> + 1. Redistributions of source code must retain the above copyright
> + notice, this list of conditions and the following disclaimer.
> + 2. Redistributions in binary form must reproduce the above copyright
> + notice, this list of conditions and the following disclaimer in the
> + documentation and/or other materials provided with the distribution.
> + 3. The name of the company may not be used to endorse or promote
> + products derived from this software without specific prior written
> + permission.
> +
> + THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
> + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
> + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
> + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
> + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
> + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
> +
> +#ifdef __ARM_ARCH_8A__
> +#include <math.h>
> +
> +double
> +ceil (double x)
> +{
> + double result;
> + asm volatile ( "vrintp.f64\t%P0, %P1" : "=w" (result) : "w" (x) );
> + return result;
> +}
> +
> +#else
> +#include "../../math/s_ceil.c"
> +#endif
> diff --git a/newlib/libm/machine/arm/s_floor.c b/newlib/libm/machine/arm/s_floor.c
> new file mode 100644
> index 0000000..49f7dff
> --- /dev/null
> +++ b/newlib/libm/machine/arm/s_floor.c
> @@ -0,0 +1,40 @@
> +/* s_floor.c -- define floor
> + Copyright (c) 2012 ARM Ltd. All rights reserved.
> +
> + Redistribution and use in source and binary forms, with or without
> + modification, are permitted provided that the following conditions
> + are met:
> + 1. Redistributions of source code must retain the above copyright
> + notice, this list of conditions and the following disclaimer.
> + 2. Redistributions in binary form must reproduce the above copyright
> + notice, this list of conditions and the following disclaimer in the
> + documentation and/or other materials provided with the distribution.
> + 3. The name of the company may not be used to endorse or promote
> + products derived from this software without specific prior written
> + permission.
> +
> + THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
> + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
> + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
> + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
> + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
> + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
> +
> +#ifdef __ARM_ARCH_8A__
> +#include <math.h>
> +
> +double
> +floor (double x)
> +{
> + double result;
> + asm volatile ("vrintm.f64\t%P0, %P1" : "=w" (result) : "w" (x));
> + return result;
> +}
> +
> +#else
> +#include "../../math/s_floor.c"
> +#endif
> diff --git a/newlib/libm/machine/arm/s_nearbyint.c b/newlib/libm/machine/arm/s_nearbyint.c
> new file mode 100644
> index 0000000..eacb33c
> --- /dev/null
> +++ b/newlib/libm/machine/arm/s_nearbyint.c
> @@ -0,0 +1,40 @@
> +/* s_nearbyint.c -- define nearbyint
> + Copyright (c) 2012 ARM Ltd. All rights reserved.
> +
> + Redistribution and use in source and binary forms, with or without
> + modification, are permitted provided that the following conditions
> + are met:
> + 1. Redistributions of source code must retain the above copyright
> + notice, this list of conditions and the following disclaimer.
> + 2. Redistributions in binary form must reproduce the above copyright
> + notice, this list of conditions and the following disclaimer in the
> + documentation and/or other materials provided with the distribution.
> + 3. The name of the company may not be used to endorse or promote
> + products derived from this software without specific prior written
> + permission.
> +
> + THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
> + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
> + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
> + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
> + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
> + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
> +
> +#ifdef __ARM_ARCH_8A__
> +#include <math.h>
> +
> +double
> +nearbyint (double x)
> +{
> + double result;
> + asm volatile ("vrintr.f64\t%P0, %P1" : "=w" (result) : "w" (x));
> + return result;
> +}
> +
> +#else
> +#include "../../common/s_nearbyint.c"
> +#endif
> diff --git a/newlib/libm/machine/arm/s_rint.c b/newlib/libm/machine/arm/s_rint.c
> new file mode 100644
> index 0000000..01d6997
> --- /dev/null
> +++ b/newlib/libm/machine/arm/s_rint.c
> @@ -0,0 +1,40 @@
> +/* s_rint.c -- define rint
> + Copyright (c) 2012 ARM Ltd. All rights reserved.
> +
> + Redistribution and use in source and binary forms, with or without
> + modification, are permitted provided that the following conditions
> + are met:
> + 1. Redistributions of source code must retain the above copyright
> + notice, this list of conditions and the following disclaimer.
> + 2. Redistributions in binary form must reproduce the above copyright
> + notice, this list of conditions and the following disclaimer in the
> + documentation and/or other materials provided with the distribution.
> + 3. The name of the company may not be used to endorse or promote
> + products derived from this software without specific prior written
> + permission.
> +
> + THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
> + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
> + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
> + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
> + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
> + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
> +
> +#ifdef __ARM_ARCH_8A__
> +#include <math.h>
> +
> +double
> +rint (double x)
> +{
> + double result;
> + asm volatile ("vrintx.f64\t%P0, %P1" : "=w" (result) : "w" (x));
> + return result;
> +}
> +
> +#else
> +#include "../../common/s_rint.c"
> +#endif
> diff --git a/newlib/libm/machine/arm/s_round.c b/newlib/libm/machine/arm/s_round.c
> new file mode 100644
> index 0000000..9e378c8
> --- /dev/null
> +++ b/newlib/libm/machine/arm/s_round.c
> @@ -0,0 +1,40 @@
> +/* s_round.c -- define round
> + Copyright (c) 2012 ARM Ltd. All rights reserved.
> +
> + Redistribution and use in source and binary forms, with or without
> + modification, are permitted provided that the following conditions
> + are met:
> + 1. Redistributions of source code must retain the above copyright
> + notice, this list of conditions and the following disclaimer.
> + 2. Redistributions in binary form must reproduce the above copyright
> + notice, this list of conditions and the following disclaimer in the
> + documentation and/or other materials provided with the distribution.
> + 3. The name of the company may not be used to endorse or promote
> + products derived from this software without specific prior written
> + permission.
> +
> + THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
> + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
> + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
> + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
> + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
> + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
> +
> +#ifdef __ARM_ARCH_8A__
> +#include <math.h>
> +
> +double
> +round (double x)
> +{
> + double result;
> + asm volatile ("vrinta.f64\t%P0, %P1" : "=w" (result) : "w" (x));
> + return result;
> +}
> +
> +#else
> +#include "../../common/s_round.c"
> +#endif
> diff --git a/newlib/libm/machine/arm/s_trunc.c b/newlib/libm/machine/arm/s_trunc.c
> new file mode 100644
> index 0000000..a58cbc6
> --- /dev/null
> +++ b/newlib/libm/machine/arm/s_trunc.c
> @@ -0,0 +1,40 @@
> +/* s_trunc.c -- define trunc
> + Copyright (c) 2012 ARM Ltd. All rights reserved.
> +
> + Redistribution and use in source and binary forms, with or without
> + modification, are permitted provided that the following conditions
> + are met:
> + 1. Redistributions of source code must retain the above copyright
> + notice, this list of conditions and the following disclaimer.
> + 2. Redistributions in binary form must reproduce the above copyright
> + notice, this list of conditions and the following disclaimer in the
> + documentation and/or other materials provided with the distribution.
> + 3. The name of the company may not be used to endorse or promote
> + products derived from this software without specific prior written
> + permission.
> +
> + THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
> + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
> + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
> + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
> + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
> + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
> +
> +#ifdef __ARM_ARCH_8A__
> +#include <math.h>
> +
> +double
> +trunc (double x)
> +{
> + double result;
> + asm volatile ("vrintz.f64\t%P0, %P1" : "=w" (result) : "w" (x));
> + return result;
> +}
> +
> +#else
> +#include "../../common/s_trunc.c"
> +#endif
> diff --git a/newlib/libm/machine/arm/sf_ceil.c b/newlib/libm/machine/arm/sf_ceil.c
> new file mode 100644
> index 0000000..61a2aad
> --- /dev/null
> +++ b/newlib/libm/machine/arm/sf_ceil.c
> @@ -0,0 +1,40 @@
> +/* sf_ceil.c -- define ceilf
> + Copyright (c) 2012 ARM Ltd. All rights reserved.
> +
> + Redistribution and use in source and binary forms, with or without
> + modification, are permitted provided that the following conditions
> + are met:
> + 1. Redistributions of source code must retain the above copyright
> + notice, this list of conditions and the following disclaimer.
> + 2. Redistributions in binary form must reproduce the above copyright
> + notice, this list of conditions and the following disclaimer in the
> + documentation and/or other materials provided with the distribution.
> + 3. The name of the company may not be used to endorse or promote
> + products derived from this software without specific prior written
> + permission.
> +
> + THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
> + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
> + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
> + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
> + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
> + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
> +
> +#ifdef __ARM_ARCH_8A__
> +#include <math.h>
> +
> +float
> +ceilf (float x)
> +{
> + float result;
> + asm volatile ( "vrintp.f32\t%0, %1" : "=t" (result) : "t" (x) );
> + return result;
> +}
> +
> +#else
> +#include "../../math/sf_ceil.c"
> +#endif
> diff --git a/newlib/libm/machine/arm/sf_floor.c b/newlib/libm/machine/arm/sf_floor.c
> new file mode 100644
> index 0000000..65a89b1
> --- /dev/null
> +++ b/newlib/libm/machine/arm/sf_floor.c
> @@ -0,0 +1,40 @@
> +/* sf_floor.c -- define floorf
> + Copyright (c) 2012 ARM Ltd. All rights reserved.
> +
> + Redistribution and use in source and binary forms, with or without
> + modification, are permitted provided that the following conditions
> + are met:
> + 1. Redistributions of source code must retain the above copyright
> + notice, this list of conditions and the following disclaimer.
> + 2. Redistributions in binary form must reproduce the above copyright
> + notice, this list of conditions and the following disclaimer in the
> + documentation and/or other materials provided with the distribution.
> + 3. The name of the company may not be used to endorse or promote
> + products derived from this software without specific prior written
> + permission.
> +
> + THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
> + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
> + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
> + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
> + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
> + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
> +
> +#ifdef __ARM_ARCH_8A__
> +#include <math.h>
> +
> +float
> +floorf (float x)
> +{
> + float result;
> + asm volatile ( "vrintm.f32\t%0, %1" : "=t" (result) : "t" (x) );
> + return result;
> +}
> +
> +#else
> +#include "../../math/sf_floor.c"
> +#endif
> diff --git a/newlib/libm/machine/arm/sf_nearbyint.c b/newlib/libm/machine/arm/sf_nearbyint.c
> new file mode 100644
> index 0000000..5fdcb65
> --- /dev/null
> +++ b/newlib/libm/machine/arm/sf_nearbyint.c
> @@ -0,0 +1,40 @@
> +/* sf_nearbyint.c -- define nearbyintf
> + Copyright (c) 2012 ARM Ltd. All rights reserved.
> +
> + Redistribution and use in source and binary forms, with or without
> + modification, are permitted provided that the following conditions
> + are met:
> + 1. Redistributions of source code must retain the above copyright
> + notice, this list of conditions and the following disclaimer.
> + 2. Redistributions in binary form must reproduce the above copyright
> + notice, this list of conditions and the following disclaimer in the
> + documentation and/or other materials provided with the distribution.
> + 3. The name of the company may not be used to endorse or promote
> + products derived from this software without specific prior written
> + permission.
> +
> + THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
> + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
> + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
> + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
> + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
> + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
> +
> +#ifdef __ARM_ARCH_8A__
> +#include <math.h>
> +
> +float
> +nearbyintf (float x)
> +{
> + float result;
> + asm volatile ("vrintr.f32\t%0, %1" : "=t" (result) : "t" (x));
> + return result;
> +}
> +
> +#else
> +#include "../../common/sf_nearbyint.c"
> +#endif
> diff --git a/newlib/libm/machine/arm/sf_rint.c b/newlib/libm/machine/arm/sf_rint.c
> new file mode 100644
> index 0000000..f425d61
> --- /dev/null
> +++ b/newlib/libm/machine/arm/sf_rint.c
> @@ -0,0 +1,40 @@
> +/* sf_rint.c -- define rintf
> + Copyright (c) 2012 ARM Ltd. All rights reserved.
> +
> + Redistribution and use in source and binary forms, with or without
> + modification, are permitted provided that the following conditions
> + are met:
> + 1. Redistributions of source code must retain the above copyright
> + notice, this list of conditions and the following disclaimer.
> + 2. Redistributions in binary form must reproduce the above copyright
> + notice, this list of conditions and the following disclaimer in the
> + documentation and/or other materials provided with the distribution.
> + 3. The name of the company may not be used to endorse or promote
> + products derived from this software without specific prior written
> + permission.
> +
> + THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
> + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
> + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
> + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
> + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
> + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
> +
> +#ifdef __ARM_ARCH_8A__
> +#include <math.h>
> +
> +float
> +rintf (float x)
> +{
> + float result;
> + asm volatile ("vrintx.f32\t%0, %1" : "=t" (result) : "t" (x));
> + return result;
> +}
> +
> +#else
> +#include "../../common/sf_rint.c"
> +#endif
> diff --git a/newlib/libm/machine/arm/sf_round.c b/newlib/libm/machine/arm/sf_round.c
> new file mode 100644
> index 0000000..3217ea3
> --- /dev/null
> +++ b/newlib/libm/machine/arm/sf_round.c
> @@ -0,0 +1,40 @@
> +/* sf_round.c -- define roundf
> + Copyright (c) 2012 ARM Ltd. All rights reserved.
> +
> + Redistribution and use in source and binary forms, with or without
> + modification, are permitted provided that the following conditions
> + are met:
> + 1. Redistributions of source code must retain the above copyright
> + notice, this list of conditions and the following disclaimer.
> + 2. Redistributions in binary form must reproduce the above copyright
> + notice, this list of conditions and the following disclaimer in the
> + documentation and/or other materials provided with the distribution.
> + 3. The name of the company may not be used to endorse or promote
> + products derived from this software without specific prior written
> + permission.
> +
> + THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
> + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
> + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
> + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
> + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
> + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
> +
> +#ifdef __ARM_ARCH_8A__
> +#include <math.h>
> +
> +float
> +roundf (float x)
> +{
> + float result;
> + asm volatile ("vrinta.f32\t%0, %1" : "=t" (result) : "t" (x));
> + return result;
> +}
> +
> +#else
> +#include "../../common/sf_round.c"
> +#endif
> diff --git a/newlib/libm/machine/arm/sf_trunc.c b/newlib/libm/machine/arm/sf_trunc.c
> new file mode 100644
> index 0000000..bb4e134
> --- /dev/null
> +++ b/newlib/libm/machine/arm/sf_trunc.c
> @@ -0,0 +1,40 @@
> +/* sf_trunc.c -- define truncf
> + Copyright (c) 2012 ARM Ltd. All rights reserved.
> +
> + Redistribution and use in source and binary forms, with or without
> + modification, are permitted provided that the following conditions
> + are met:
> + 1. Redistributions of source code must retain the above copyright
> + notice, this list of conditions and the following disclaimer.
> + 2. Redistributions in binary form must reproduce the above copyright
> + notice, this list of conditions and the following disclaimer in the
> + documentation and/or other materials provided with the distribution.
> + 3. The name of the company may not be used to endorse or promote
> + products derived from this software without specific prior written
> + permission.
> +
> + THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
> + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
> + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
> + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
> + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
> + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
> +
> +#ifdef __ARM_ARCH_8A__
> +#include <math.h>
> +
> +float
> +truncf (float x)
> +{
> + float result;
> + asm volatile ("vrintz.f32\t%0, %1" : "=t" (result) : "t" (x));
> + return result;
> +}
> +
> +#else
> +#include "../../common/sf_trunc.c"
> +#endif
> diff --git a/newlib/libm/machine/configure.in b/newlib/libm/machine/configure.in
> index b236491..85c5c41 100644
> --- a/newlib/libm/machine/configure.in
> +++ b/newlib/libm/machine/configure.in
> @@ -26,6 +26,7 @@ machlib=
> if test -n "${libm_machine_dir}"; then
> case ${libm_machine_dir} in
> aarch64) AC_CONFIG_SUBDIRS(aarch64) ;;
> + arm) AC_CONFIG_SUBDIRS(arm) ;;
> i386) AC_CONFIG_SUBDIRS(i386) ;;
> spu) AC_CONFIG_SUBDIRS(spu) ;;
> esac;
>
More information about the Newlib
mailing list