]>
Commit | Line | Data |
---|---|---|
04067002 | 1 | /* llround function. POWER5+, PowerPC64 version. |
688903eb | 2 | Copyright (C) 2006-2018 Free Software Foundation, Inc. |
04067002 UD |
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 | |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
04067002 UD |
18 | |
19 | #include <sysdep.h> | |
20 | #include <math_ldbl_opt.h> | |
216933b2 | 21 | #include <libm-alias-float.h> |
d17542d2 | 22 | #include <libm-alias-double.h> |
9c84384c | 23 | |
04067002 | 24 | /* long long [r3] llround (float x [fp1]) |
9c84384c | 25 | IEEE 1003.1 llround function. IEEE specifies "round to the nearest |
04067002 UD |
26 | integer value, rounding halfway cases away from zero, regardless of |
27 | the current rounding mode." However PowerPC Architecture defines | |
9c84384c JM |
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).". | |
04067002 UD |
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 "power5" | |
d5b41185 | 35 | ENTRY_TOCLESS (__llround, 4) |
04067002 | 36 | CALL_MCOUNT 0 |
9c84384c | 37 | frin fp2, fp1 /* Round to nearest +-0.5. */ |
04067002 UD |
38 | fctidz fp3, fp2 /* Convert To Integer DW round toward 0. */ |
39 | stfd fp3, -16(r1) | |
40 | nop /* Insure the following load is in a different dispatch group */ | |
41 | nop /* to avoid pipe stall on POWER4&5. */ | |
42 | nop | |
43 | ld r3, -16(r1) | |
44 | blr | |
45 | END (__llround) | |
46 | ||
47 | strong_alias (__llround, __lround) | |
d17542d2 JM |
48 | libm_alias_double (__llround, llround) |
49 | libm_alias_double (__lround, lround) | |
001b09a6 RS |
50 | /* The double version also works for single-precision as both float and |
51 | double parameters are passed in 64bit FPRs and both versions are expected | |
52 | to return [long] long type. */ | |
53 | strong_alias (__llround, __llroundf) | |
216933b2 | 54 | libm_alias_float (__llround, llround) |
001b09a6 | 55 | strong_alias (__lround, __lroundf) |
216933b2 | 56 | libm_alias_float (__lround, lround) |