]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/powerpc/powerpc32/power5+/fpu/s_lround.S
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / powerpc / powerpc32 / power5+ / fpu / s_lround.S
1 /* lround function. POWER5+, PowerPC32 version.
2 Copyright (C) 2006-2015 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 #include <sysdep.h>
19 #include <math_ldbl_opt.h>
20
21 /* long [r3] lround (float x [fp1])
22 IEEE 1003.1 lround function. IEEE specifies "round to the nearest
23 integer value, rounding halfway cases away from zero, regardless of
24 the current rounding mode." However PowerPC Architecture defines
25 "round to Nearest" as "Choose the best approximation. In case of a
26 tie, choose the one that is even (least significant bit o).".
27 So we pre-round using the V2.02 Floating Round to Integer Nearest
28 instruction before we use the Floating Convert to Integer Word with
29 round to zero instruction. */
30
31 .machine "power5"
32 ENTRY (__lround)
33 stwu r1,-16(r1)
34 cfi_adjust_cfa_offset (16)
35 frin fp2,fp1
36 fctiwz fp3,fp2 /* Convert To Integer Word lround toward 0. */
37 stfd fp3,8(r1)
38 nop /* Ensure the following load is in a different dispatch */
39 nop /* group to avoid pipe stall on POWER4&5. */
40 nop
41 lwz r3,8+LOWORD(r1)
42 addi r1,r1,16
43 blr
44 END (__lround)
45
46 weak_alias (__lround, lround)
47
48 strong_alias (__lround, __lroundf)
49 weak_alias (__lround, lroundf)
50
51 #ifdef NO_LONG_DOUBLE
52 weak_alias (__lround, lroundl)
53 strong_alias (__lround, __lroundl)
54 #endif
55 #if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
56 compat_symbol (libm, __lround, lroundl, GLIBC_2_1)
57 #endif