Blame sysdeps/s390/fpu/s_llrintf.c

Packit Service 26e3ff
/* llrintf() - S390 version.
Packit Service 26e3ff
   Copyright (C) 2019 Free Software Foundation, Inc.
Packit Service 26e3ff
Packit Service 26e3ff
   This file is part of the GNU C Library.
Packit Service 26e3ff
Packit Service 26e3ff
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 26e3ff
   modify it under the terms of the GNU Lesser General Public License as
Packit Service 26e3ff
   published by the Free Software Foundation; either version 2.1 of the
Packit Service 26e3ff
   License, or (at your option) any later version.
Packit Service 26e3ff
Packit Service 26e3ff
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 26e3ff
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 26e3ff
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 26e3ff
   Lesser General Public License for more details.
Packit Service 26e3ff
Packit Service 26e3ff
   You should have received a copy of the GNU Lesser General Public
Packit Service 26e3ff
   License along with the GNU C Library; if not, see
Packit Service 26e3ff
   <https://www.gnu.org/licenses/>.  */
Packit Service 26e3ff
Packit Service 26e3ff
#if defined __s390x__ && defined HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
Packit Service 26e3ff
/* We only support s390x as on s390 a long long int refers to a register pair
Packit Service 26e3ff
   of two 4byte registers instead of a 8byte register which is produced by the
Packit Service 26e3ff
   instruction.
Packit Service 26e3ff
   Note: On s390 this instruction would only be used if build with -mzarch.  */
Packit Service 26e3ff
# include <math.h>
Packit Service 26e3ff
# include <libm-alias-float.h>
Packit Service 26e3ff
Packit Service 26e3ff
long long int
Packit Service 26e3ff
__llrintf (float x)
Packit Service 26e3ff
{
Packit Service 26e3ff
  long long int y;
Packit Service 26e3ff
  /* The z196 zarch "convert to fixed" (cgebra) instruction is rounding
Packit Service 26e3ff
     according to current rounding mode (M3-field: 0).
Packit Service 26e3ff
     First convert x with suppressed inexact exception and check if the
Packit Service 26e3ff
     resulting value is beyond the target limits (indicated by cc=3;
Packit Service 26e3ff
     Note: a nan is also indicated by cc=3).
Packit Service 26e3ff
     If the resulting value is within the target limits, redo
Packit Service 26e3ff
     without suppressing the inexact exception.  */
Packit Service 26e3ff
  __asm__ ("cgebra %0,0,%1,4 \n\t"
Packit Service 26e3ff
	   "jo 1f \n\t"
Packit Service 26e3ff
	   "cgebra %0,0,%1,0 \n\t"
Packit Service 26e3ff
	   "1:"
Packit Service 26e3ff
	   : "=&d" (y) : "f" (x) : "cc");
Packit Service 26e3ff
  return y;
Packit Service 26e3ff
}
Packit Service 26e3ff
libm_alias_float (__llrint, llrint)
Packit Service 26e3ff
Packit Service 26e3ff
#else
Packit Service 26e3ff
# include <sysdeps/ieee754/flt-32/s_llrintf.c>
Packit Service 26e3ff
#endif