From patchwork Fri Mar 29 13:35:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 161433 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2051286jan; Fri, 29 Mar 2019 06:38:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqznXtdFepILWdvXKNl3o2eez8NFY+DmvMDkceAB+dcMGYkLjCE5brgtKX5c12psm7W/OiJg X-Received: by 2002:a62:6444:: with SMTP id y65mr39124245pfb.56.1553866692266; Fri, 29 Mar 2019 06:38:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553866692; cv=none; d=google.com; s=arc-20160816; b=jXJDFgl5zhUyTwN9jsyPReXNkjp1ph1udoFion2vo0UwQ7Px8pIOJmqzFS87bZxP5E UFLmMP1DAcsjhXjhh0UAyoLSykbqojBR8PGj1+Ba5Gjto9cJvMMyccUbF8QYBjOdNeyX 8KpMM21yOayKZ4N2BEPo2twSCYODo1yvB8SzO1YRdxPAwYrtKYmdiegDzYy1CPU2lHXL 1W0Mqu5IB9t6XdxMMlqvLakZJnwwvICId0mOvKEKLHda0ViBbceTxIUHmjpQ+n/Wy7Nb JCpXVwPo/j3LqzzddfXZxbZQK05Aj841o9zaD5rx52Ea7xrXOq4x+IvzPFcS6e7nMMIm i0Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=oxW5gw7U3vz5PXMPhecDSJ8Vku2Gi3OxbsH3g/JpnjQ=; b=hi9TWwJ+EFLb1mdfWHCY5pQXFronGwDrJvYnj57FOymHmOlVxIXCGegQBE0fEpdf1m sCj6Fu6oZEyZXJyxK+wxdGODEyT1Tu0T86X9yd3in8ZuxWZ9KRr4QD0U+ksZPRd3PJTP YlFbhnItsDMTQPVAVuH148LBOClu6+IWiZxnIGg6BgYfSw7Idxoc9w/k+7vS9yaqOaZt eEzw/YoyldhE1QE22VWTa6299yXZilCBGUtDCZAKcnw+EvZk2cnSm9K3f+Rw8ei5NLVQ 8AejetSEHrv3aRrwViTekdU4jwWjyhPmXEfHyhxAKa0IzlX51WMaCHnzqSGqnEyehxg6 xOJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=vyHusF3i; dkim=pass header.i=@linaro.org header.s=google header.b=HXdMgwBC; spf=pass (google.com: domain of libc-alpha-return-101002-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-101002-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id m3si1907445plt.310.2019.03.29.06.38.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 06:38:12 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-101002-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=vyHusF3i; dkim=pass header.i=@linaro.org header.s=google header.b=HXdMgwBC; spf=pass (google.com: domain of libc-alpha-return-101002-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-101002-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=d7Fr+ws4BfaH1gqTZsDBVmeWvKw/o0f Xcu6rpKiMZAu2C41WqrU6vDyBx0IDx8/UAS8d7f1AZyARvsvYrR1wiCH+aHIAJ4+ AbXsRD//Dpzx5A/RHNx6/acMAGlh3vSwtwh6sPo9hwzLILkQyTeEiNK2XITSUkPw bKDCRWnoosTs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=+A8jyZH2o1kuHCTIasL2SEDH2hE=; b=vyHus F3ivX0LjnofUvNxRHwRxjvJhvR60SBSiO88Hwe0dMMlvfP0xkXiMxdbFhN0dSTbW FjnJ3vI5q8z7bv2+7QHSteScgMBELPJM52QprP9j45EjopXuxeMnu9y2Mh8KT/FH xozzMNGrJHMTCeqTDRxzzkd0s09EowcUJfIGYY= Received: (qmail 119970 invoked by alias); 29 Mar 2019 13:36:00 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 119534 invoked by uid 89); 29 Mar 2019 13:35:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=1011, lc0, a, b, ab X-HELO: mail-ua1-f66.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=oxW5gw7U3vz5PXMPhecDSJ8Vku2Gi3OxbsH3g/JpnjQ=; b=HXdMgwBCWlhUQfPmkxGVQxF8847svNkgPrgd5XUg7uv7fANeYeGC5bLr0IZbUsbxGi 77pcjn4qQbCkJsIg1UBszT1QBOEBzfkBgxqctcHRfcMnagUwNQ4dETsobEtcHtSXlSwQ PKq5RNR0NusONLZ0nCrjrD8UNa1EZFPCds79MTDiU+RybeBZmhPzGipYDhJ+MI0ey49/ pxrOT9TA4NbTOUjEaKNz7zKAqtr2ep54+HgW7e5PzAD8Vzsi/U7QfQy0X7vU7CNkqJ18 bhuWlmg6aX++sjHqsrCqpWc35620pmDogMBMxxJrcTql56sRdaJuEcYt+Oqp69mFzw41 ToRg== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 07/28] powerpc: trunc/truncf refactor Date: Fri, 29 Mar 2019 10:35:08 -0300 Message-Id: <20190329133529.22523-8-adhemerval.zanella@linaro.org> In-Reply-To: <20190329133529.22523-1-adhemerval.zanella@linaro.org> References: <20190329133529.22523-1-adhemerval.zanella@linaro.org> This patches consolidates all the powerpc trunc{f} implementations on the generic sysdeps/powerpc/fpu/s_trunc{f}. The generic implementation uses either the compiler builts for ISA 2.03+ (which generates the frim instruction) or a generic implementation which uses FP only operations. The IFUNC organization for powerpc64 is also change to be enabled only for powerpc64 and not for powerpc64le. Checked on powerpc-linux-gnu (built without --with-cpu, with --with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch), powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+ and --disable-multi-arch). * sysdeps/powerpc/fpu/trunc_to_integer.h (set_truncing_mode): Add TRUNC handling. * sysdeps/powerpc/fpu/s_trunc.c: New file. * sysdeps/powerpc/fpu/s_truncf.c: New file. * sysdeps/powerpc/powerpc32/fpu/s_trunc.S: Remove file. * sysdeps/powerpc/powerpc32/fpu/s_truncf.S: Likewise. * sysdep/powerpc/powepc32/power4/fpu/multiarch/s_trunc-power5+.S: Likewise. * sysdep/powerpc/powepc32/power4/fpu/multiarch/s_trunc-ppc32.S: Likewise. * sysdep/powerpc/powepc32/power4/fpu/multiarch/s_truncf-power5+.S: Likewise. * sysdep/powerpc/powepc32/power4/fpu/multiarch/s_truncf-ppc32.S: Likewise. * sysdep/powerpc/powepc32/power4/fpu/multiarch/s_trunc-power5+.c: New file. * sysdep/powerpc/powepc32/power4/fpu/multiarch/s_trunc-ppc32.c: Likewise. * sysdep/powerpc/powepc32/power4/fpu/multiarch/s_truncf-power5+.c: Likewise. * sysdep/powerpc/powepc32/power4/fpu/multiarch/s_truncf-ppc32.c: Likewise. * sysdep/powerpc/powerpc32/power5+/fpu/s_trunc.S: Remove file. * sysdep/powerpc/powerpc32/power5+/fpu/s_truncf.S: Likewise. * sysdep/powerpc/powerpc64/be/fpu/multiarch/Makefile (libm-sysdep_routines): Add s_trunc-power5+, s_trunc-ppc64, s_truncf-power5+, and s_truncf-ppc64. (CFLAGS-s_trunc-power5+.c, CFLAGS-s_truncf-power5+.c): New rule. * sysdep/powerpc/powercp64/be/fpu/multiarch/s_trunc-power5+.c: New file. * sysdep/powerpc/powercp64/be/fpu/multiarch/s_trunc-ppc64.c: Likewise. * sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc.c: Move to ... * sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc.c: ... here. * sysdep/powerpc/powercp64/be/fpu/multiarch/s_truncf-power5+.c: New file. * sysdep/powerpc/powercp64/be/fpu/multiarch/s_truncf-ppc64.c: Likewise. * sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf.c: Move to ... * sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf.c: ... here. * sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile (libm-sysdep_routines): Remove s_trunc-power5+, s_trunc-ppc64, s_truncf-power5+, and s_truncf-ppc64. * sysdep/powerpc/powerpc64/fpu/multiarch/s_trunc-power5+.S: Remove file. * sysdep/powerpc/powerpc64/fpu/multiarch/s_trunc-ppc64.S: Likewise. * sysdep/powerpc/powerpc64/fpu/multiarch/s_truncf-power5+.S: Likewise. * sysdep/powerpc/powerpc64/fpu/multiarch/s_truncf-ppc64.S: Likewise. * sysdeps/powerpc/powerpc64/fpu/s_trunc.S: Likewise. * sysdeps/powerpc/powerpc64/fpu/s_truncf.S: Likewise. * sysdep/powerpc/powerpc64/power5+/fpu/s_trunc.S: Likewise. * sysdep/powerpc/powerpc64/power5+/fpu/s_truncf.S: Likewise. --- sysdeps/powerpc/fpu/round_to_integer.h | 1 + sysdeps/powerpc/fpu/s_trunc.c | 35 ++++++++ sysdeps/powerpc/fpu/s_truncf.c | 35 ++++++++ sysdeps/powerpc/powerpc32/fpu/s_trunc.S | 83 ------------------- sysdeps/powerpc/powerpc32/fpu/s_truncf.S | 83 ------------------- .../power4/fpu/multiarch/s_trunc-power5+.S | 33 -------- .../power4/fpu/multiarch/s_trunc-power5+.c | 3 + .../power4/fpu/multiarch/s_trunc-ppc32.S | 31 ------- .../power4/fpu/multiarch/s_trunc-ppc32.c | 3 + .../power4/fpu/multiarch/s_truncf-power5+.S | 26 ------ .../power4/fpu/multiarch/s_truncf-power5+.c | 3 + .../power4/fpu/multiarch/s_truncf-ppc32.S | 27 ------ .../power4/fpu/multiarch/s_truncf-ppc32.c | 3 + .../powerpc/powerpc32/power5+/fpu/s_trunc.S | 29 ------- .../powerpc/powerpc32/power5+/fpu/s_truncf.S | 30 ------- .../powerpc64/be/fpu/multiarch/Makefile | 8 +- .../powerpc64/be/fpu/multiarch/s_roundf.c | 2 - .../be/fpu/multiarch/s_trunc-power5+.c | 3 + .../be/fpu/multiarch/s_trunc-ppc64.c | 3 + .../{ => be}/fpu/multiarch/s_trunc.c | 0 .../be/fpu/multiarch/s_truncf-power5+.c | 3 + .../be/fpu/multiarch/s_truncf-ppc64.c | 3 + .../{ => be}/fpu/multiarch/s_truncf.c | 2 - .../powerpc/powerpc64/fpu/multiarch/Makefile | 2 - .../powerpc64/fpu/multiarch/s_trunc-power5+.S | 30 ------- .../powerpc64/fpu/multiarch/s_trunc-ppc64.S | 30 ------- .../fpu/multiarch/s_truncf-power5+.S | 24 ------ .../powerpc64/fpu/multiarch/s_truncf-ppc64.S | 24 ------ sysdeps/powerpc/powerpc64/fpu/s_trunc.S | 72 ---------------- sysdeps/powerpc/powerpc64/fpu/s_truncf.S | 74 ----------------- .../powerpc/powerpc64/power5+/fpu/s_trunc.S | 30 ------- .../powerpc/powerpc64/power5+/fpu/s_truncf.S | 31 ------- 32 files changed, 102 insertions(+), 664 deletions(-) create mode 100644 sysdeps/powerpc/fpu/s_trunc.c create mode 100644 sysdeps/powerpc/fpu/s_truncf.c delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_trunc.S delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_truncf.S delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-power5+.S create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-power5+.c delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-ppc32.S create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-ppc32.c delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-power5+.S create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-power5+.c delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-ppc32.S create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-ppc32.c delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_trunc.S delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_truncf.S create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc-power5+.c create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc-ppc64.c rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_trunc.c (100%) create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf-power5+.c create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf-ppc64.c rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_truncf.c (95%) delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc-power5+.S delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc-ppc64.S delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf-power5+.S delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf-ppc64.S delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_trunc.S delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_truncf.S delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_trunc.S delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_truncf.S -- 2.17.1 Reviewed-by: Gabriel F. T. Gomes diff --git a/sysdeps/powerpc/fpu/round_to_integer.h b/sysdeps/powerpc/fpu/round_to_integer.h index 3fa2b77b6d..ba2d355fb0 100644 --- a/sysdeps/powerpc/fpu/round_to_integer.h +++ b/sysdeps/powerpc/fpu/round_to_integer.h @@ -38,6 +38,7 @@ set_fenv_mode (enum round_mode mode) { case CEIL: rmode = FE_UPWARD; break; case FLOOR: rmode = FE_DOWNWARD; break; + case TRUNC: case ROUND: rmode = FE_TOWARDZERO; break; default: rmode = FE_TONEAREST; break; } diff --git a/sysdeps/powerpc/fpu/s_trunc.c b/sysdeps/powerpc/fpu/s_trunc.c new file mode 100644 index 0000000000..83caf6b9cc --- /dev/null +++ b/sysdeps/powerpc/fpu/s_trunc.c @@ -0,0 +1,35 @@ +/* Largest integral value not greater than argument. PowerPC version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, see . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +double +__trunc (double x) +{ +#ifdef _ARCH_PWR5X + return __builtin_trunc (x); +#else + return round_to_integer_double (TRUNC, x); +#endif +} +#ifndef __trunc +libm_alias_double (__trunc, trunc) +#endif diff --git a/sysdeps/powerpc/fpu/s_truncf.c b/sysdeps/powerpc/fpu/s_truncf.c new file mode 100644 index 0000000000..c9f091cf2a --- /dev/null +++ b/sysdeps/powerpc/fpu/s_truncf.c @@ -0,0 +1,35 @@ +/* Smallest integral value not less than argument. PowerPC version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, see . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +float +__truncf (float x) +{ +#ifdef _ARCH_PWR5X + return __builtin_truncf (x); +#else + return round_to_integer_float (TRUNC, x); +#endif +} +#ifndef __truncf +libm_alias_float (__trunc, trunc) +#endif diff --git a/sysdeps/powerpc/powerpc32/fpu/s_trunc.S b/sysdeps/powerpc/powerpc32/fpu/s_trunc.S deleted file mode 100644 index 31daff161f..0000000000 --- a/sysdeps/powerpc/powerpc32/fpu/s_trunc.S +++ /dev/null @@ -1,83 +0,0 @@ -/* trunc function. PowerPC32 version. - Copyright (C) 2004-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include - - .section .rodata.cst4,"aM",@progbits,4 - .align 2 -.LC0: /* 2**52 */ - .long 0x59800000 - -/* double [fp1] trunc (double x [fp1]) - IEEE 1003.1 trunc function. IEEE specifies "trunc to the integer - value, in floating format, nearest to but no larger in magnitude - then the argument." - We set "round toward Zero" mode and trunc by adding +-2**52 then - subtracting +-2**52. */ - - .section ".text" -ENTRY (__trunc) -#ifdef SHARED - mflr r11 - cfi_register(lr,r11) - SETUP_GOT_ACCESS(r9,got_label) - addis r9,r9,.LC0-got_label@ha - lfs fp13,.LC0-got_label@l(r9) - mtlr r11 - cfi_same_value (lr) -#else - lis r9,.LC0@ha - lfs fp13,.LC0@l(r9) -#endif - fabs fp0,fp1 - fsub fp12,fp13,fp13 /* generate 0.0 */ - fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */ - mffs fp11 /* Save current FPU rounding mode and - "inexact" state. */ - fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ - bnl- cr7,.L10 - mtfsfi 7,1 /* Set rounding toward 0 mode. */ - ble- cr6,.L4 - fadd fp1,fp1,fp13 /* x+= TWO52; */ - fsub fp1,fp1,fp13 /* x-= TWO52; */ - fabs fp1,fp1 /* if (x == 0.0) */ - /* x = 0.0; */ - mtfsf 0xff,fp11 /* Restore previous rounding mode and - "inexact" state. */ - blr -.L4: - bge- cr6,.L9 /* if (x < 0.0) */ - fsub fp1,fp1,fp13 /* x-= TWO52; */ - fadd fp1,fp1,fp13 /* x+= TWO52; */ - fnabs fp1,fp1 /* if (x == 0.0) */ - /* x = -0.0; */ -.L9: - mtfsf 0xff,fp11 /* Restore previous rounding mode and - "inexact" state. */ - blr -.L10: - /* Ensure sNaN input is converted to qNaN. */ - fcmpu cr7,fp1,fp1 - beqlr cr7 - fadd fp1,fp1,fp1 - blr - END (__trunc) - -libm_alias_double (__trunc, trunc) diff --git a/sysdeps/powerpc/powerpc32/fpu/s_truncf.S b/sysdeps/powerpc/powerpc32/fpu/s_truncf.S deleted file mode 100644 index 630300c5dc..0000000000 --- a/sysdeps/powerpc/powerpc32/fpu/s_truncf.S +++ /dev/null @@ -1,83 +0,0 @@ -/* truncf function. PowerPC32 version. - Copyright (C) 2004-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - - .section .rodata.cst4,"aM",@progbits,4 - .align 2 -.LC0: /* 2**23 */ - .long 0x4b000000 - -/* float [fp1] truncf (float x [fp1]) - IEEE 1003.1 trunc function. IEEE specifies "trunc to the integer - value, in floating format, nearest to but no larger in magnitude - then the argument." - We set "round toward Zero" mode and trunc by adding +-2**23 then - subtracting +-2**23. */ - - .section ".text" -ENTRY (__truncf) -#ifdef SHARED - mflr r11 - cfi_register(lr,r11) - SETUP_GOT_ACCESS(r9,got_label) - addis r9,r9,.LC0-got_label@ha - lfs fp13,.LC0-got_label@l(r9) - mtlr r11 - cfi_same_value (lr) -#else - lis r9,.LC0@ha - lfs fp13,.LC0@l(r9) -#endif - fabs fp0,fp1 - fsubs fp12,fp13,fp13 /* generate 0.0 */ - fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO23) */ - mffs fp11 /* Save current FPU rounding mode and - "inexact" state. */ - fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ - bnl- cr7,.L10 - mtfsfi 7,1 /* Set rounding toward 0 mode. */ - ble- cr6,.L4 - fadds fp1,fp1,fp13 /* x+= TWO23; */ - fsubs fp1,fp1,fp13 /* x-= TWO23; */ - fabs fp1,fp1 /* if (x == 0.0) */ - /* x = 0.0; */ - mtfsf 0xff,fp11 /* Restore previous rounding mode and - "inexact" state. */ - blr -.L4: - bge- cr6,.L9 /* if (x < 0.0) */ - fsubs fp1,fp1,fp13 /* x-= TWO23; */ - fadds fp1,fp1,fp13 /* x+= TWO23; */ - fnabs fp1,fp1 /* if (x == 0.0) */ - /* x = -0.0; */ -.L9: - mtfsf 0xff,fp11 /* Restore previous rounding mode and - "inexact" state. */ - blr -.L10: - /* Ensure sNaN input is converted to qNaN. */ - fcmpu cr7,fp1,fp1 - beqlr cr7 - fadds fp1,fp1,fp1 - blr - END (__truncf) - -libm_alias_float (__trunc, trunc) - diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-power5+.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-power5+.S deleted file mode 100644 index 3ed99c3f7e..0000000000 --- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-power5+.S +++ /dev/null @@ -1,33 +0,0 @@ -/* trunc function. PowerPC32/power5+ version. - Copyright (C) 2013-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - -#undef hidden_def -#define hidden_def(name) -#undef weak_alias -#define weak_alias(name, alias) -#undef strong_alias -#define strong_alias(name, alias) -#undef compat_symbol -#define compat_symbol(lib, name, alias, ver) - -#define __trunc __trunc_power5plus - -#include diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-power5+.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-power5+.c new file mode 100644 index 0000000000..47abda6810 --- /dev/null +++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-power5+.c @@ -0,0 +1,3 @@ +#include +#define __trunc __trunc_power5plus +#include diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-ppc32.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-ppc32.S deleted file mode 100644 index 67b87c5db1..0000000000 --- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-ppc32.S +++ /dev/null @@ -1,31 +0,0 @@ -/* trunc function. PowerPC32 default version. - Copyright (C) 2013-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - -#undef weak_alias -#define weak_alias(a,b) -#undef strong_alias -#define strong_alias(a,b) -#undef compat_symbol -#define compat_symbol(a,b,c,d) - -#define __trunc __trunc_ppc32 - -#include diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-ppc32.c new file mode 100644 index 0000000000..5b9164295f --- /dev/null +++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-ppc32.c @@ -0,0 +1,3 @@ +#include +#define __trunc __trunc_ppc32 +#include diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-power5+.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-power5+.S deleted file mode 100644 index a18af562e6..0000000000 --- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-power5+.S +++ /dev/null @@ -1,26 +0,0 @@ -/* truncf function. PowerPC32/power5+ version. - Copyright (C) 2013-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include - -#undef weak_alias -#define weak_alias(name, alias) - -#define __truncf __truncf_power5plus - -#include diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-power5+.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-power5+.c new file mode 100644 index 0000000000..b8e75d4e28 --- /dev/null +++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-power5+.c @@ -0,0 +1,3 @@ +#include +#define __truncf __truncf_power5plus +#include diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-ppc32.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-ppc32.S deleted file mode 100644 index a7bf3943f2..0000000000 --- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-ppc32.S +++ /dev/null @@ -1,27 +0,0 @@ -/* truncf function. PowerPC32 default version. - Copyright (C) 2013-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - -#undef weak_alias -#define weak_alias(a,b) - -#define __truncf __truncf_ppc32 - -#include diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-ppc32.c new file mode 100644 index 0000000000..f20c82553a --- /dev/null +++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-ppc32.c @@ -0,0 +1,3 @@ +#include +#define __truncf __truncf_ppc32 +#include diff --git a/sysdeps/powerpc/powerpc32/power5+/fpu/s_trunc.S b/sysdeps/powerpc/powerpc32/power5+/fpu/s_trunc.S deleted file mode 100644 index 37a24104e7..0000000000 --- a/sysdeps/powerpc/powerpc32/power5+/fpu/s_trunc.S +++ /dev/null @@ -1,29 +0,0 @@ -/* trunc function. PowerPC32/power5+ version. - Copyright (C) 2006-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include - - .machine "power5" -EALIGN (__trunc, 4, 0) - friz fp1, fp1 - blr - END (__trunc) - -libm_alias_double (__trunc, trunc) diff --git a/sysdeps/powerpc/powerpc32/power5+/fpu/s_truncf.S b/sysdeps/powerpc/powerpc32/power5+/fpu/s_truncf.S deleted file mode 100644 index f24c1f6cda..0000000000 --- a/sysdeps/powerpc/powerpc32/power5+/fpu/s_truncf.S +++ /dev/null @@ -1,30 +0,0 @@ -/* truncf function. PowerPC32/power5+ version. - Copyright (C) 2006-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - - .machine "power5" -EALIGN (__truncf, 4, 0) - friz fp1, fp1 /* The rounding instructions are double. */ - frsp fp1, fp1 /* But we need to set ooverflow for float. */ - blr - END (__truncf) - -libm_alias_float (__trunc, trunc) - diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile index 722f974cfb..53e600f5f6 100644 --- a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile +++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile @@ -10,7 +10,11 @@ libm-sysdep_routines += s_ceil-power5+ \ s_round-power5+ \ s_round-ppc64 \ s_roundf-power5+ \ - s_roundf-ppc64 + s_roundf-ppc64 \ + s_trunc-power5+ \ + s_trunc-ppc64 \ + s_truncf-power5+ \ + s_truncf-ppc64 CFLAGS-s_ceil-power5+.c = -mcpu=power5+ CFLAGS-s_ceilf-power5+.c = -mcpu=power5+ @@ -18,4 +22,6 @@ CFLAGS-s_floor-power5+.c = -mcpu=power5+ CFLAGS-s_floorf-power5+.c = -mcpu=power5+ CFLAGS-s_round-power5+.c = -mcpu=power5+ CFLAGS-s_roundf-power5+.c = -mcpu=power5+ +CFLAGS-s_trunc-power5+.c = -mcpu=power5+ +CFLAGS-s_truncf-power5+.c = -mcpu=power5+ endif diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf.c index 640bca5a7a..db6a17c5b2 100644 --- a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf.c +++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf.c @@ -18,8 +18,6 @@ #define NO_MATH_REDIRECT #include -#include -#include #include "init-arch.h" #include diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc-power5+.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc-power5+.c new file mode 100644 index 0000000000..47abda6810 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc-power5+.c @@ -0,0 +1,3 @@ +#include +#define __trunc __trunc_power5plus +#include diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc-ppc64.c new file mode 100644 index 0000000000..21c47308fc --- /dev/null +++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc-ppc64.c @@ -0,0 +1,3 @@ +#include +#define __trunc __trunc_ppc64 +#include diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc.c similarity index 100% rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc.c rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc.c diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf-power5+.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf-power5+.c new file mode 100644 index 0000000000..b8e75d4e28 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf-power5+.c @@ -0,0 +1,3 @@ +#include +#define __truncf __truncf_power5plus +#include diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf-ppc64.c new file mode 100644 index 0000000000..aa6c6c1f98 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf-ppc64.c @@ -0,0 +1,3 @@ +#include +#define __truncf __truncf_ppc64 +#include diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf.c similarity index 95% rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf.c rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf.c index be124b2023..b6c8260b69 100644 --- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf.c +++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf.c @@ -18,8 +18,6 @@ #define NO_MATH_REDIRECT #include -#include -#include #include "init-arch.h" #include diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile index 11c39f4b35..7d469d79af 100644 --- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile +++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile @@ -15,8 +15,6 @@ sysdep_calls := s_copysign-power6 s_copysign-ppc64 \ sysdep_routines += $(sysdep_calls) libm-sysdep_routines += s_llround-power6x \ s_llround-power5+ s_llround-ppc64 \ - s_trunc-power5+ \ - s_trunc-ppc64 s_truncf-power5+ s_truncf-ppc64 \ s_llrint-power6x s_llrint-ppc64 \ s_logb-power7 s_logbf-power7 \ s_logbl-power7 s_logb-ppc64 s_logbf-ppc64 \ diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc-power5+.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc-power5+.S deleted file mode 100644 index 9ce3db48e4..0000000000 --- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc-power5+.S +++ /dev/null @@ -1,30 +0,0 @@ -/* trunc function. PowerPC64/power5+ version. - Copyright (C) 2013-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include - -#undef weak_alias -#define weak_alias(a,b) -#undef strong_alias -#define strong_alias(a,b) -#undef compat_symbol -#define compat_symbol(a,b,c,d) - -#define __trunc __trunc_power5plus - -#include diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc-ppc64.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc-ppc64.S deleted file mode 100644 index ca9d831850..0000000000 --- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc-ppc64.S +++ /dev/null @@ -1,30 +0,0 @@ -/* trunc function. PowerPC64 default version. - Copyright (C) 2013-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include - -#undef weak_alias -#define weak_alias(a,b) -#undef strong_alias -#define strong_alias(a,b) -#undef compat_symbol -#define compat_symbol(a,b,c,d) - -#define __trunc __trunc_ppc64 - -#include diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf-power5+.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf-power5+.S deleted file mode 100644 index 4e651172af..0000000000 --- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf-power5+.S +++ /dev/null @@ -1,24 +0,0 @@ -/* truncf function. PowerPC64/power5+ version. - Copyright (C) 2013-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#undef weak_alias -#define weak_alias(a,b) - -#define __truncf __truncf_power5plus - -#include diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf-ppc64.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf-ppc64.S deleted file mode 100644 index 5420eb26c7..0000000000 --- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf-ppc64.S +++ /dev/null @@ -1,24 +0,0 @@ -/* truncf function. PowerPC64 default version. - Copyright (C) 2013-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#undef weak_alias -#define weak_alias(a,b) - -#define __truncf __truncf_ppc64 - -#include diff --git a/sysdeps/powerpc/powerpc64/fpu/s_trunc.S b/sysdeps/powerpc/powerpc64/fpu/s_trunc.S deleted file mode 100644 index 628960dd27..0000000000 --- a/sysdeps/powerpc/powerpc64/fpu/s_trunc.S +++ /dev/null @@ -1,72 +0,0 @@ -/* trunc function. PowerPC64 version. - Copyright (C) 2004-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include - - .section ".toc","aw" -.LC0: /* 2**52 */ - .tc FD_43300000_0[TC],0x4330000000000000 - .section ".text" - -/* double [fp1] trunc (double x [fp1]) - IEEE 1003.1 trunc function. IEEE specifies "trunc to the integer - value, in floating format, nearest to but no larger in magnitude - then the argument." - We set "round toward Zero" mode and trunc by adding +-2**52 then - subtracting +-2**52. */ - -ENTRY (__trunc, 4) - CALL_MCOUNT 0 - lfd fp13,.LC0@toc(2) - fabs fp0,fp1 - fsub fp12,fp13,fp13 /* generate 0.0 */ - fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */ - mffs fp11 /* Save current FPU rounding mode and - "inexact" state. */ - fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ - bnl- cr7,.L10 - mtfsfi 7,1 /* Set rounding toward 0 mode. */ - ble- cr6,.L4 - fadd fp1,fp1,fp13 /* x+= TWO52; */ - fsub fp1,fp1,fp13 /* x-= TWO52; */ - fabs fp1,fp1 /* if (x == 0.0) */ - /* x = 0.0; */ - mtfsf 0xff,fp11 /* Restore previous rounding mode and - "inexact" state. */ - blr -.L4: - bge- cr6,.L9 /* if (x < 0.0) */ - fsub fp1,fp1,fp13 /* x-= TWO52; */ - fadd fp1,fp1,fp13 /* x+= TWO52; */ - fnabs fp1,fp1 /* if (x == 0.0) */ - /* x = -0.0; */ -.L9: - mtfsf 0xff,fp11 /* Restore previous rounding mode and - "inexact" state. */ - blr -.L10: - /* Ensure sNaN input is converted to qNaN. */ - fcmpu cr7,fp1,fp1 - beqlr cr7 - fadd fp1,fp1,fp1 - blr - END (__trunc) - -libm_alias_double (__trunc, trunc) diff --git a/sysdeps/powerpc/powerpc64/fpu/s_truncf.S b/sysdeps/powerpc/powerpc64/fpu/s_truncf.S deleted file mode 100644 index 7b9294595a..0000000000 --- a/sysdeps/powerpc/powerpc64/fpu/s_truncf.S +++ /dev/null @@ -1,74 +0,0 @@ -/* truncf function. PowerPC64 version. - Copyright (C) 2004-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - - .section ".toc","aw" - .p2align 3 -.LC0: /* 2**23 */ - .long 0x4b000000 - .long 0x0 - .section ".text" - -/* float [fp1] truncf (float x [fp1]) - IEEE 1003.1 trunc function. IEEE specifies "trunc to the integer - value, in floating format, nearest to but no larger in magnitude - then the argument." - We set "round toward Zero" mode and trunc by adding +-2**23 then - subtracting +-2**23. */ - -ENTRY (__truncf, 4) - CALL_MCOUNT 0 - lfs fp13,.LC0@toc(2) - fabs fp0,fp1 - fsubs fp12,fp13,fp13 /* generate 0.0 */ - fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO23) */ - mffs fp11 /* Save current FPU rounding mode and - "inexact" state. */ - fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ - bnl- cr7,.L10 - mtfsfi 7,1 /* Set rounding toward 0 mode. */ - ble- cr6,.L4 - fadds fp1,fp1,fp13 /* x+= TWO23; */ - fsubs fp1,fp1,fp13 /* x-= TWO23; */ - fabs fp1,fp1 /* if (x == 0.0) */ - /* x = 0.0; */ - mtfsf 0xff,fp11 /* Restore previous rounding mode and - "inexact" state. */ - blr -.L4: - bge- cr6,.L9 /* if (x < 0.0) */ - fsubs fp1,fp1,fp13 /* x-= TWO23; */ - fadds fp1,fp1,fp13 /* x+= TWO23; */ - fnabs fp1,fp1 /* if (x == 0.0) */ - /* x = -0.0; */ -.L9: - mtfsf 0xff,fp11 /* Restore previous rounding mode and - "inexact" state. */ - blr -.L10: - /* Ensure sNaN input is converted to qNaN. */ - fcmpu cr7,fp1,fp1 - beqlr cr7 - fadds fp1,fp1,fp1 - blr - END (__truncf) - -libm_alias_float (__trunc, trunc) - diff --git a/sysdeps/powerpc/powerpc64/power5+/fpu/s_trunc.S b/sysdeps/powerpc/powerpc64/power5+/fpu/s_trunc.S deleted file mode 100644 index fbd0c318ef..0000000000 --- a/sysdeps/powerpc/powerpc64/power5+/fpu/s_trunc.S +++ /dev/null @@ -1,30 +0,0 @@ -/* trunc function. PowerPC64/power5+ version. - Copyright (C) 2006-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include - - .machine "power5" -ENTRY_TOCLESS (__trunc, 4) - CALL_MCOUNT 0 - friz fp1, fp1 - blr - END (__trunc) - -libm_alias_double (__trunc, trunc) diff --git a/sysdeps/powerpc/powerpc64/power5+/fpu/s_truncf.S b/sysdeps/powerpc/powerpc64/power5+/fpu/s_truncf.S deleted file mode 100644 index 91612aa4e9..0000000000 --- a/sysdeps/powerpc/powerpc64/power5+/fpu/s_truncf.S +++ /dev/null @@ -1,31 +0,0 @@ -/* truncf function. PowerPC64/power5+ version. - Copyright (C) 2006-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - - .machine "power5" -ENTRY_TOCLESS (__truncf, 4) - CALL_MCOUNT 0 - friz fp1, fp1 /* The rounding instructions are double. */ - frsp fp1, fp1 /* But we need to set ooverflow for float. */ - blr - END (__truncf) - -libm_alias_float (__trunc, trunc) -