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