]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - lib/libc/ia64/gen/__umodsi3.S
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / lib / libc / ia64 / gen / __umodsi3.S
1 .file "__umodsi3.s"
2
3 //  
4 // Copyright (c) 2000, Intel Corporation
5 // All rights reserved.
6 //
7 // Contributed 2/15/2000 by Marius Cornea, John Harrison, Cristina Iordache, 
8 // Ted Kubaska, Bob Norin, and Shane Story of the Computational Software Lab, 
9 // Intel Corporation.
10 //
11 // WARRANTY DISCLAIMER
12 //
13 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
14 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
15 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
16 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS 
17 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
20 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
22 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 //
25 // Intel Corporation is the author of this code, and requests that all
26 // problem reports or change requests be submitted to it directly at
27 // http://developer.intel.com/opensource.
28 //
29
30 #include <machine/asm.h>
31 __FBSDID("$FreeBSD$");
32
33 .section .text
34
35 // 32-bit unsigned integer remainder
36
37 .proc __umodsi3#
38 .align 32
39 .global __umodsi3#
40 .align 32
41
42 __umodsi3:
43
44 { .mii
45   alloc r31=ar.pfs,2,0,0,0
46   nop.i 0
47   nop.i 0;;
48 } { .mii
49   nop.m 0
50
51   // 32-BIT UNSIGNED INTEGER REMAINDER BEGINS HERE
52
53   // general register used:
54   //    r32 - 32-bit unsigned integer dividend
55   //    r33 - 32-bit unsigned integer divisor
56   //    r8 - 32-bit unsigned integer result
57   //    r2 - scratch register
58   // floating-point registers used: f6, f7, f8, f9, f10, f11
59   // predicate registers used: p6
60
61   zxt4 r32=r32
62   zxt4 r33=r33;;
63 } { .mmb
64   setf.sig f11=r32
65   setf.sig f7=r33
66   nop.b 0;;
67 } { .mfi
68   nop.m 0
69   fcvt.xf f6=f11
70   nop.i 0
71 } { .mfi
72   // get 2's complement of b
73   sub r33=r0,r33
74   fcvt.xf f7=f7
75   mov r2 = 0x0ffdd;;
76 } { .mfi
77   setf.exp f9 = r2
78   // (1) y0
79   frcpa.s1 f8,p6=f6,f7
80   nop.i 0;;
81 }  { .mfi
82   nop.m 0
83   // (2) q0 = a * y0
84   (p6) fma.s1 f10=f6,f8,f0
85   nop.i 0
86 } { .mfi
87   nop.m 0
88   // (3) e0 = 1 - b * y0
89   (p6) fnma.s1 f8=f7,f8,f1
90   nop.i 0;;
91 } { .mfi
92   nop.m 0
93   // (4) q1 = q0 + e0 * q0
94   (p6) fma.s1 f10=f8,f10,f10
95   nop.i 0
96 } { .mfi
97   // get 2's complement of b
98   setf.sig f7=r33
99   // (5) e1 = e0 * e0 + 2^-34
100   (p6) fma.s1 f8=f8,f8,f9
101   nop.i 0;;
102 } { .mfi
103   nop.m 0
104   // (6) q2 = q1 + e1 * q1
105   (p6) fma.s1 f8=f8,f10,f10
106   nop.i 0;;
107 } { .mfi
108   nop.m 0
109   // (7) q = trunc(q2)
110   fcvt.fxu.trunc.s1 f8=f8
111   nop.i 0;;
112 }  { .mfi
113   nop.m 0
114   // (8) r = a + (-b) * q
115   xma.l f8=f8,f7,f11
116   nop.i 0;;
117 }  { .mmi
118   // remainder will be in the least significant 32 bits of r8 (if b != 0)
119   getf.sig r8=f8
120   nop.m 0
121   nop.i 0;;
122 }
123
124   // 32-BIT UNSIGNED INTEGER REMAINDER ENDS HERE
125
126 { .mmb
127   nop.m 0
128   nop.m 0
129   br.ret.sptk b0;;
130 }
131
132 .endp __umodsi3