]>
Commit | Line | Data |
---|---|---|
04067002 | 1 | /* llround function. POWER6x PowerPC64 version. |
b168057a | 2 | Copyright (C) 2006-2015 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> | |
9c84384c | 21 | |
04067002 | 22 | /* long long [r3] llround (float x [fp1]) |
9c84384c | 23 | IEEE 1003.1 llround function. IEEE specifies "round to the nearest |
04067002 UD |
24 | integer value, rounding halfway cases away from zero, regardless of |
25 | the current rounding mode." However PowerPC Architecture defines | |
9c84384c JM |
26 | "round to Nearest" as "Choose the best approximation. In case of a |
27 | tie, choose the one that is even (least significant bit o).". | |
04067002 UD |
28 | So we pre-round using the V2.02 Floating Round to Integer Nearest |
29 | instruction before we use Floating Convert to Integer Word with | |
30 | round to zero instruction. */ | |
31 | ||
32 | .machine "power6" | |
33 | ENTRY (__llround) | |
34 | CALL_MCOUNT 0 | |
9c84384c | 35 | frin fp2,fp1 /* Round to nearest +-0.5. */ |
04067002 UD |
36 | fctidz fp3,fp2 /* Convert To Integer DW round toward 0. */ |
37 | mftgpr r3,fp3 /* Transfer integer to R3. */ | |
38 | blr | |
39 | END (__llround) | |
40 | ||
41 | strong_alias (__llround, __lround) | |
42 | weak_alias (__llround, llround) | |
43 | weak_alias (__lround, lround) | |
44 | ||
45 | #ifdef NO_LONG_DOUBLE | |
46 | weak_alias (__llround, llroundl) | |
47 | strong_alias (__llround, __llroundl) | |
48 | weak_alias (__lround, lroundl) | |
49 | strong_alias (__lround, __lroundl) | |
50 | #endif | |
51 | #if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) | |
52 | compat_symbol (libm, __llround, llroundl, GLIBC_2_1) | |
53 | compat_symbol (libm, __lround, lroundl, GLIBC_2_1) | |
54 | #endif |