Blame sysdeps/s390/fpu/s_lrintl.c

Packit Service c4d75d
/* lrintl() - S390 version.
Packit Service c4d75d
   Copyright (C) 2019 Free Software Foundation, Inc.
Packit Service c4d75d
Packit Service c4d75d
   This file is part of the GNU C Library.
Packit Service c4d75d
Packit Service c4d75d
   The GNU C Library is free software; you can redistribute it and/or
Packit Service c4d75d
   modify it under the terms of the GNU Lesser General Public License as
Packit Service c4d75d
   published by the Free Software Foundation; either version 2.1 of the
Packit Service c4d75d
   License, or (at your option) any later version.
Packit Service c4d75d
Packit Service c4d75d
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service c4d75d
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service c4d75d
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service c4d75d
   Lesser General Public License for more details.
Packit Service c4d75d
Packit Service c4d75d
   You should have received a copy of the GNU Lesser General Public
Packit Service c4d75d
   License along with the GNU C Library; if not, see
Packit Service c4d75d
   <https://www.gnu.org/licenses/>.  */
Packit Service c4d75d
Packit Service c4d75d
#ifdef HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
Packit Service c4d75d
# include <math.h>
Packit Service c4d75d
# include <math_private.h>
Packit Service c4d75d
# include <libm-alias-ldouble.h>
Packit Service c4d75d
Packit Service c4d75d
/* The sizeof (long int) differs between s390x (8byte) and s390 (4byte).
Packit Service c4d75d
   Thus we need different instructions as the target size is encoded there.
Packit Service c4d75d
   Note: On s390 this instruction is only used if build with -mzarch.  */
Packit Service c4d75d
# ifdef __s390x__
Packit Service c4d75d
#  define INSN "cgxbra"
Packit Service c4d75d
# else
Packit Service c4d75d
#  define INSN "cfxbra"
Packit Service c4d75d
# endif
Packit Service c4d75d
Packit Service c4d75d
long int
Packit Service c4d75d
__lrintl (_Float128 x)
Packit Service c4d75d
{
Packit Service c4d75d
  long int y;
Packit Service c4d75d
  /* The z196 zarch "convert to fixed" (cgxbra) instruction is rounding
Packit Service c4d75d
     according to current rounding mode (M3-field: 0).
Packit Service c4d75d
     First convert x with suppressed inexact exception and check if the
Packit Service c4d75d
     resulting value is beyond the target limits (indicated by cc=3;
Packit Service c4d75d
     Note: a nan is also indicated by cc=3).
Packit Service c4d75d
     If the resulting value is within the target limits, redo
Packit Service c4d75d
     without suppressing the inexact exception.  */
Packit Service c4d75d
  __asm__ (INSN " %0,0,%1,4 \n\t"
Packit Service c4d75d
	   "jo 1f \n\t"
Packit Service c4d75d
	   INSN " %0,0,%1,0 \n\t"
Packit Service c4d75d
	   "1:"
Packit Service c4d75d
	   : "=&d" (y) : "f" (x) : "cc");
Packit Service c4d75d
  return y;
Packit Service c4d75d
}
Packit Service c4d75d
libm_alias_ldouble (__lrint, lrint)
Packit Service c4d75d
Packit Service c4d75d
#else
Packit Service c4d75d
# include <sysdeps/ieee754/ldbl-128/s_lrintl.c>
Packit Service c4d75d
#endif