4 // Copyright (c) 2000, Intel Corporation
5 // All rights reserved.
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,
11 // WARRANTY DISCLAIMER
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.
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.
30 #include <machine/asm.h>
31 __FBSDID("$FreeBSD$");
35 // 64-bit unsigned integer remainder
45 alloc r31=ar.pfs,3,0,0,0
50 // 64-BIT UNSIGNED INTEGER REMAINDER BEGINS HERE
52 // general register used:
53 // r32 - 64-bit unsigned integer dividend
54 // r33 - 64-bit unsigned integer divisor
55 // r8 - 64-bit unsigned integer result
56 // floating-point registers used: f6, f7, f8, f9, f10, f11, f12
57 // predicate registers used: p6
59 setf.sig f12=r32 // holds an in integer form
63 // get 2's complement of b
81 (p6) fma.s1 f10=f6,f8,f0
86 // e0 = 1 - b * y0 in f9
87 (p6) fnma.s1 f9=f7,f8,f1
92 // q1 = q0 + e0 * q0 in f10
93 (p6) fma.s1 f10=f9,f10,f10
98 // e1 = e0 * e0 in f11
99 (p6) fma.s1 f11=f9,f9,f0
104 // y1 = y0 + e0 * y0 in f8
105 (p6) fma.s1 f8=f9,f8,f8
110 // q2 = q1 + e1 * q1 in f9
111 (p6) fma.s1 f9=f11,f10,f10
116 // y2 = y1 + e1 * y1 in f8
117 (p6) fma.s1 f8=f11,f8,f8
122 // r2 = a - b * q2 in f10
123 (p6) fnma.s1 f10=f7,f9,f6
129 // q3 = q2 + r2 * y2 in f8
130 (p6) fma.s1 f8=f10,f8,f9
134 // (11) q = trunc(q3)
135 fcvt.fxu.trunc.s1 f8=f8
139 // (12) r = a + (-b) * q
148 // 64-BIT UNSIGNED INTEGER REMAINDER ENDS HERE