Remove support in configure for unsupported architectures
[glibc.git] / sysdeps / ia64 / fpu / e_sqrtl.S
blob6a5735d45a1e6faa8616122faad5d9770e8cda34
1 .file "sqrtl.s"
4 // Copyright (c) 2000 - 2003, Intel Corporation
5 // All rights reserved.
6 //
7 // Contributed 2000 by the Intel Numerics Group, Intel Corporation
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are
11 // met:
13 // * Redistributions of source code must retain the above copyright
14 // notice, this list of conditions and the following disclaimer.
16 // * Redistributions in binary form must reproduce the above copyright
17 // notice, this list of conditions and the following disclaimer in the
18 // documentation and/or other materials provided with the distribution.
20 // * The name of Intel Corporation may not be used to endorse or promote
21 // products derived from this software without specific prior written
22 // permission.
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS 
28 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
30 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
31 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
32 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
33 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
34 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
35 // 
36 // Intel Corporation is the author of this code, and requests that all
37 // problem reports or change requests be submitted to it directly at 
38 // http://www.intel.com/software/products/opensource/libraries/num.htm.
40 //********************************************************************
42 // History:
43 // 02/02/00 (hand-optimized)
44 // 04/04/00 Unwind support added
45 // 08/15/00 Bundle added after call to __libm_error_support to properly
46 //          set [the previously overwritten] GR_Parameter_RESULT.
47 // 05/20/02 Cleaned up namespace and sf0 syntax
48 // 02/10/03 Reordered header: .section, .global, .proc, .align
50 //********************************************************************
52 // Function:   Combined sqrtl(x), where
53 //                         _
54 //             sqrtl(x) = |x, for double-extended precision x values
56 //********************************************************************
58 // Resources Used:
60 //    Floating-Point Registers: f8  (Input and Return Value)
61 //                              f7 -f14
63 //    General Purpose Registers:
64 //      r32-r36 (Locals)
65 //      r37-r40 (Used to pass arguments to error handling routine)
67 //    Predicate Registers:      p6, p7, p8
69 //********************************************************************
71 // IEEE Special Conditions:
73 //    All faults and exceptions should be raised correctly.
74 //    sqrtl(QNaN) = QNaN
75 //    sqrtl(SNaN) = QNaN
76 //    sqrtl(+/-0) = +/-0
77 //    sqrtl(negative) = QNaN and error handling is called
79 //********************************************************************
81 // Implementation:
83 //  Modified Newton-Raphson Algorithm
85 //********************************************************************
87 GR_SAVE_PFS         = r33
88 GR_SAVE_B0          = r34
89 GR_SAVE_GP          = r35
90 GR_Parameter_X      = r37
91 GR_Parameter_Y      = r38
92 GR_Parameter_RESULT = r39
93 GR_Parameter_TAG    = r40
95 FR_X                = f15
96 FR_Y                = f0
97 FR_RESULT           = f8
99 .section .text
100 GLOBAL_IEEE754_ENTRY(sqrtl)
101 { .mlx
102 alloc r32= ar.pfs,0,5,4,0
103   // exponent of +1/2 in r2
104   movl r2 = 0x0fffe;;
105 } { .mfi
106   // +1/2 in f10
107   setf.exp f12 = r2
108   // Step (1)
109   // y0 = 1/sqrt(a) in f7
110   frsqrta.s0 f7,p6=f8
111   nop.i 0;;
112 } { .mfi
113   nop.m 0
114   // Step (2)
115   // H0 = +1/2 * y0 in f9
116   (p6) fma.s1 f9=f12,f7,f0
117   nop.i 0
118 } { .mfi
119   nop.m 0
120   // Step (3)
121   // S0 = a * y0 in f7
122   (p6) fma.s1 f7=f8,f7,f0
123   nop.i 0;;
124 } { .mfi
125   nop.m 0
126   // Make copy input x 
127   mov f13=f8 
128   nop.i 0
129 } { .mfi
130   nop.m 0
131   fclass.m.unc p7,p8 = f8,0x3A
132   nop.i 0;;
133 } { .mfi
134   nop.m 0
135   // Step (4)
136   // d0 = 1/2 - S0 * H0 in f10
137   (p6) fnma.s1 f10=f7,f9,f12
138   nop.i 0;;
140 { .mfi
141   nop.m 0
142        mov f15=f8
143   nop.i 0;;
144 } { .mfi
145   nop.m 0
146   // Step (5)
147   // H1 = H0 + d0 * H0 in f9
148   (p6) fma.s1 f9=f10,f9,f9
149   nop.i 0
150 } { .mfi
151   nop.m 0
152   // Step (6)
153   // S1 = S0 + d0 * S0 in f7
154   (p6) fma.s1 f7=f10,f7,f7
155   nop.i 0;;
156 } { .mfi
157   nop.m 0
158   // Step (7)
159   // d1 = 1/2 - S1 * H1 in f10
160   (p6) fnma.s1 f10=f7,f9,f12
161   nop.i 0;;
162 } { .mfi
163   nop.m 0
164   // Step (8)
165   // H2 = H1 + d1 * H1 in f9
166   (p6) fma.s1 f9=f10,f9,f9
167   nop.i 0
168 } { .mfi
169   nop.m 0
170   // Step (9)
171   // S2 = S1 + d1 * S1 in f7
172   (p6) fma.s1 f7=f10,f7,f7
173   nop.i 0;;
174 } { .mfi
175   nop.m 0
176   // Step (10)
177   // d2 = 1/2 - S2 * H2 in f10
178   (p6) fnma.s1 f10=f7,f9,f12
179   nop.i 0
180 } { .mfi
181   nop.m 0
182   // Step (11)
183   // e2 = a - S2 * S2 in f12
184   (p6) fnma.s1 f12=f7,f7,f8
185   nop.i 0;;
186 } { .mfi
187   nop.m 0
188   // Step (12)
189   // S3 = S2 + d2 * S2 in f7
190   (p6) fma.s1 f7=f12,f9,f7
191   nop.i 0
192 } { .mfi
193   nop.m 0
194   // Step (13)
195   // H3 = H2 + d2 * H2 in f9
196   (p6) fma.s1 f9=f10,f9,f9
197   nop.i 0;;
198 } { .mfi
199   nop.m 0
200   // Step (14)
201   // e3 = a - S3 * S3 in f12
202   (p6) fnma.s1 f12=f7,f7,f8
203   nop.i 0;;
204 } { .mfb
205   nop.m 0
206   // Step (15)
207   // S = S3 + e3 * H3 in f7
208   (p6) fma.s0 f8=f12,f9,f7
209   (p6) br.ret.sptk b0 ;;
211 { .mfb
212        mov GR_Parameter_TAG    = 48
213        mov   f8 = f7
214   (p8) br.ret.sptk b0 ;;
217 // This branch includes all those special values that are not negative,
218 // with the result equal to frcpa(x)
222 // END DOUBLE EXTENDED PRECISION MINIMUM LATENCY SQUARE ROOT ALGORITHM
223 GLOBAL_IEEE754_END(sqrtl)
225 LOCAL_LIBM_ENTRY(__libm_error_region)
226 .prologue
227 { .mfi
228         add   GR_Parameter_Y=-32,sp             // Parameter 2 value
229         nop.f 0
230 .save   ar.pfs,GR_SAVE_PFS
231         mov  GR_SAVE_PFS=ar.pfs                 // Save ar.pfs
233 { .mfi
234 .fframe 64
235         add sp=-64,sp                           // Create new stack
236         nop.f 0
237         mov GR_SAVE_GP=gp                       // Save gp
239 { .mmi
240         stfe [GR_Parameter_Y] = FR_Y,16         // Save Parameter 2 on stack
241         add GR_Parameter_X = 16,sp              // Parameter 1 address
242 .save   b0, GR_SAVE_B0
243         mov GR_SAVE_B0=b0                       // Save b0
245 .body
246 { .mib
247         stfe [GR_Parameter_X] = FR_X            // Store Parameter 1 on stack
248         add   GR_Parameter_RESULT = 0,GR_Parameter_Y
249         nop.b 0                                 // Parameter 3 address
251 { .mib
252         stfe [GR_Parameter_Y] = FR_RESULT      // Store Parameter 3 on stack
253         add   GR_Parameter_Y = -16,GR_Parameter_Y
254         br.call.sptk b0=__libm_error_support#  // Call error handling function
256 { .mmi
257         nop.m 0
258         nop.m 0
259         add   GR_Parameter_RESULT = 48,sp
261 { .mmi
262         ldfe  f8 = [GR_Parameter_RESULT]       // Get return result off stack
263 .restore sp
264         add   sp = 64,sp                       // Restore stack pointer
265         mov   b0 = GR_SAVE_B0                  // Restore return address
267 { .mib
268         mov   gp = GR_SAVE_GP                  // Restore gp
269         mov   ar.pfs = GR_SAVE_PFS             // Restore ar.pfs
270         br.ret.sptk     b0                     // Return
273 LOCAL_LIBM_END(__libm_error_region#)
274 .type   __libm_error_support#,@function
275 .global __libm_error_support#