]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/powerpc/powerpc32/power4/fpu/w_sqrtf_compat.S
Obsolete matherr, _LIB_VERSION, libieee.a.
[thirdparty/glibc.git] / sysdeps / powerpc / powerpc32 / power4 / fpu / w_sqrtf_compat.S
1 /* sqrtf function. PowerPC32 version.
2 Copyright (C) 2007-2017 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 <math-svid-compat.h>
22
23 /* float [fp1] sqrts (float x [fp1])
24 Power4 (ISA V2.0) and above implement sqrt in hardware (not optional).
25 The fsqrts instruction generates the correct value for all inputs and
26 sets the appropriate floating point exceptions. Extended checking is
27 only needed to set errno (via __kernel_standard) if the input value
28 is negative.
29
30 The fsqrts will set FPCC and FU (Floating Point Unordered or NaN
31 to indicated that the input value was negative or NaN. Use Move to
32 Condition Register from FPSCR to copy the FPCC field to cr1. The
33 branch on summary overflow transfers control to w_sqrt to process
34 any error conditions. Otherwise we can return the result directly.
35
36 This part of the function is a leaf routine, so no need to stack a
37 frame or execute prologue/epilogue code. This means it is safe to
38 transfer directly to w_sqrt as long as the input value (f1) is
39 preserved. Putting the sqrt result into f2 (float parameter 2)
40 allows passing both the input value and sqrt result into the extended
41 wrapper so there is no need to recompute.
42
43 This tactic avoids the overhead of stacking a frame for the normal
44 (non-error) case. Until gcc supports prologue shrink-wrapping
45 this is the best we can do. */
46
47 .section ".text"
48 .machine power4
49 EALIGN (__sqrtf, 5, 0)
50 fsqrts fp2,fp1
51 mcrfs cr1,4
52 bso- cr1,.Lw_sqrtf
53 fmr fp1,fp2
54 blr
55 .align 4
56 .Lw_sqrtf:
57 mflr r0
58 stwu r1,-16(r1)
59 cfi_adjust_cfa_offset(16)
60 fmr fp12,fp2
61 stw r0,20(r1)
62 stw r30,8(r1)
63 cfi_offset(lr,20-16)
64 cfi_offset(r30,8-16)
65 #ifdef SHARED
66 SETUP_GOT_ACCESS(r30,got_label)
67 addis r30,r30,_GLOBAL_OFFSET_TABLE_-got_label@ha
68 addi r30,r30,_GLOBAL_OFFSET_TABLE_-got_label@l
69 lwz r9,_LIB_VERSION@got(30)
70 lwz r0,0(r9)
71 #else
72 lis r9,_LIB_VERSION@ha
73 lwz r0,_LIB_VERSION@l(r9)
74 #endif
75 /* if (_LIB_VERSION == _IEEE_) return z; */
76 cmpwi cr7,r0,-1
77 beq- cr7,.L4
78 /* if (x != x, 0) return z; !isnan */
79 fcmpu cr7,fp1,fp1
80 bne- cr7,.L4
81 /* if (x < 0.0)
82 return __kernel_standard (x, x, 126) */
83 fmr fp2,fp1
84 fabs fp0,fp1
85 li r3,126
86 fcmpu cr7,1,0
87 bne- cr7,.L11
88 .L4:
89 lwz r0,20(r1)
90 fmr fp1,fp12
91 lwz r30,8(r1)
92 addi r1,r1,16
93 mtlr r0
94 blr
95 .L11:
96 bl __kernel_standard@plt
97 fmr fp12,fp1
98 b .L4
99 END (__sqrtf)
100
101 weak_alias (__sqrtf, sqrtf)