166633Sdfr.file "__modsi3.s" 266633Sdfr 366633Sdfr// $FreeBSD$ 4139815Simp 5139815Simp//- 666633Sdfr// Copyright (c) 2000, Intel Corporation 766633Sdfr// All rights reserved. 866633Sdfr// 966633Sdfr// Contributed 2/15/2000 by Marius Cornea, John Harrison, Cristina Iordache, 1066633Sdfr// Ted Kubaska, Bob Norin, and Shane Story of the Computational Software Lab, 1166633Sdfr// Intel Corporation. 1266633Sdfr// 1366633Sdfr// WARRANTY DISCLAIMER 1466633Sdfr// 1566633Sdfr// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1666633Sdfr// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1766633Sdfr// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1866633Sdfr// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS 1966633Sdfr// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 2066633Sdfr// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 2166633Sdfr// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 2266633Sdfr// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 2366633Sdfr// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING 2466633Sdfr// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 2566633Sdfr// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2666633Sdfr// 2766633Sdfr// Intel Corporation is the author of this code, and requests that all 2866633Sdfr// problem reports or change requests be submitted to it directly at 2966633Sdfr// http://developer.intel.com/opensource. 3066633Sdfr// 3166633Sdfr 3266633Sdfr.section .text 3366633Sdfr 3466633Sdfr// 32-bit signed integer remainder 3566633Sdfr 3666633Sdfr.proc __modsi3# 3766633Sdfr.align 32 3866633Sdfr.global __modsi3# 3966633Sdfr.align 32 4066633Sdfr 4166633Sdfr__modsi3: 4266633Sdfr 4366633Sdfr{ .mii 4466633Sdfr alloc r31=ar.pfs,2,0,0,0 4566633Sdfr nop.i 0 4666633Sdfr nop.i 0;; 4766633Sdfr} { .mii 4866633Sdfr nop.m 0 4966633Sdfr 5066633Sdfr // 32-BIT SIGNED INTEGER REMAINDER BEGINS HERE 5166633Sdfr 5266633Sdfr // general register used: 5366633Sdfr // r32 - 32-bit signed integer dividend 5466633Sdfr // r33 - 32-bit signed integer divisor 5566633Sdfr // r8 - 32-bit signed integer result 5666633Sdfr // r2 - scratch register 5766633Sdfr // floating-point registers used: f6, f7, f8, f9, f10, f11 5866633Sdfr // predicate registers used: p6 5966633Sdfr 6066633Sdfr sxt4 r32=r32 6166633Sdfr sxt4 r33=r33;; 6266633Sdfr} { .mmb 6366633Sdfr setf.sig f11=r32 6466633Sdfr setf.sig f7=r33 6566633Sdfr nop.b 0;; 6666633Sdfr} { .mfi 6766633Sdfr // get 2's complement of b 6866633Sdfr sub r33=r0,r33 6966633Sdfr fcvt.xf f6=f11 7066633Sdfr nop.i 0 7166633Sdfr} { .mfi 7266633Sdfr nop.m 0 7366633Sdfr fcvt.xf f7=f7 7466633Sdfr mov r2 = 0x0ffdd;; 7566633Sdfr} { .mfi 7666633Sdfr setf.exp f9 = r2 7766633Sdfr // (1) y0 7866633Sdfr frcpa.s1 f8,p6=f6,f7 7966633Sdfr nop.i 0;; 8066633Sdfr} { .mfi 8166633Sdfr nop.m 0 8266633Sdfr // (2) q0 = a * y0 8366633Sdfr (p6) fma.s1 f10=f6,f8,f0 8466633Sdfr nop.i 0 8566633Sdfr} { .mfi 8666633Sdfr nop.m 0 8766633Sdfr // (3) e0 = 1 - b * y0 8866633Sdfr (p6) fnma.s1 f8=f7,f8,f1 8966633Sdfr nop.i 0;; 9066633Sdfr} { .mfi 9166633Sdfr // 2's complement of b 9266633Sdfr setf.sig f7=r33 9366633Sdfr // (4) q1 = q0 + e0 * q0 9466633Sdfr (p6) fma.s1 f10=f8,f10,f10 9566633Sdfr nop.i 0 9666633Sdfr} { .mfi 9766633Sdfr nop.m 0 9866633Sdfr // (5) e1 = e0 * e0 + 2^-34 9966633Sdfr (p6) fma.s1 f8=f8,f8,f9 10066633Sdfr nop.i 0;; 10166633Sdfr} { .mfi 10266633Sdfr nop.m 0 10366633Sdfr // (6) q2 = q1 + e1 * q1 10466633Sdfr (p6) fma.s1 f8=f8,f10,f10 10566633Sdfr nop.i 0;; 10666633Sdfr} { .mfi 10766633Sdfr nop.m 0 10866633Sdfr // (7) q = trunc(q2) 10966633Sdfr fcvt.fx.trunc.s1 f8=f8 11066633Sdfr nop.i 0;; 11166633Sdfr} { .mfi 11266633Sdfr nop.m 0 11366633Sdfr // (8) r = a + (-b) * q 11466633Sdfr xma.l f8=f8,f7,f11 11566633Sdfr nop.i 0;; 11666633Sdfr} { .mmi 11766633Sdfr // remainder will be in the least significant 32 bits of r8 (if b != 0) 11866633Sdfr getf.sig r8=f8 11966633Sdfr nop.m 0 12066633Sdfr nop.i 0;; 12166633Sdfr} 12266633Sdfr 12366633Sdfr // 32-BIT SIGNED INTEGER REMAINDER ENDS HERE 12466633Sdfr 12566633Sdfr{ .mmb 12666633Sdfr nop.m 0 12766633Sdfr nop.m 0 12866633Sdfr br.ret.sptk b0;; 12966633Sdfr} 13066633Sdfr 13166633Sdfr.endp __modsi3 132