]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/powerpc/powerpc64/power6x/fpu/s_llround.S
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / powerpc / powerpc64 / power6x / fpu / s_llround.S
1 /* llround function. POWER6x PowerPC64 version.
2 Copyright (C) 2006-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19 #include <sysdep.h>
20 #include <math_ldbl_opt.h>
21 #include <libm-alias-float.h>
22 #include <libm-alias-double.h>
23
24 /* long long [r3] llround (float x [fp1])
25 IEEE 1003.1 llround function. IEEE specifies "round to the nearest
26 integer value, rounding halfway cases away from zero, regardless of
27 the current rounding mode." However PowerPC Architecture defines
28 "round to Nearest" as "Choose the best approximation. In case of a
29 tie, choose the one that is even (least significant bit o).".
30 So we pre-round using the V2.02 Floating Round to Integer Nearest
31 instruction before we use Floating Convert to Integer Word with
32 round to zero instruction. */
33
34 .machine "power6"
35 ENTRY_TOCLESS (__llround)
36 CALL_MCOUNT 0
37 frin fp2,fp1 /* Round to nearest +-0.5. */
38 fctidz fp3,fp2 /* Convert To Integer DW round toward 0. */
39 mftgpr r3,fp3 /* Transfer integer to R3. */
40 blr
41 END (__llround)
42
43 strong_alias (__llround, __lround)
44 libm_alias_double (__llround, llround)
45 libm_alias_double (__lround, lround)
46 /* The double version also works for single-precision as both float and
47 double parameters are passed in 64bit FPRs and both versions are expected
48 to return [long] long type. */
49 strong_alias (__llround, __llroundf)
50 libm_alias_float (__llround, llround)
51 strong_alias (__lround, __lroundf)
52 libm_alias_float (__lround, lround)