Update copyright notices with scripts/update-copyrights
[glibc.git] / ports / sysdeps / alpha / reml.S
blob8708cf804240b0e77d70046f708bc11201c56214
1 /* Copyright (C) 2004-2014 Free Software Foundation, Inc.
2    Contributed by Richard Henderson  <rth@twiddle.net>
3    This file is part of the GNU C Library.
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.
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.
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/>.  */
19 #include "div_libc.h"
21 /* 32-bit signed int remainder.  This is not a normal C function.  Argument
22    registers are t10 and t11, the result goes in t12.  Only t12 and AT may
23    be clobbered.
25    The FPU can handle the division for all input values except zero.
26    All we have to do is compute the remainder via multiply-and-subtract.
28    The FPCR save/restore is due to the fact that the EV6 _will_ set FPCR_INE
29    for cvttq/c even without /sui being set.  It will not, however, properly
30    raise the exception, so we don't have to worry about FPCR_INED being clear
31    and so dying by SIGFPE.  */
33 #ifndef EXTEND
34 #define EXTEND(S,D)     sextl S, D
35 #endif
37         .text
38         .align  4
39         .globl  __reml
40         .type   __reml, @funcnoplt
41         .usepv  __reml, no
43         cfi_startproc
44         cfi_return_column (RA)
45 __reml:
46         lda     sp, -FRAME(sp)
47         cfi_def_cfa_offset (FRAME)
48         CALL_MCOUNT
49         stt     $f0, 0(sp)
50         excb
51         beq     Y, DIVBYZERO
53         stt     $f1, 8(sp)
54         stt     $f2, 16(sp)
55         cfi_rel_offset ($f0, 0)
56         cfi_rel_offset ($f1, 8)
57         cfi_rel_offset ($f2, 16)
58         mf_fpcr $f2
60         EXTEND  (X, RV)
61         EXTEND  (Y, AT)
62         _ITOFT2 RV, $f0, 24, AT, $f1, 32
63         cvtqt   $f0, $f0
64         cvtqt   $f1, $f1
65         divt/c  $f0, $f1, $f0
66         cvttq/c $f0, $f0
67         excb
68         mt_fpcr $f2
69         _FTOIT  $f0, RV, 24
71         ldt     $f0, 0(sp)
72         mull    RV, Y, RV
73         ldt     $f1, 8(sp)
74         ldt     $f2, 16(sp)
75         lda     sp, FRAME(sp)
76         cfi_restore ($f0)
77         cfi_restore ($f1)
78         cfi_restore ($f2)
79         cfi_def_cfa_offset (0)
80         subl    X, RV, RV
81         ret     $31, (RA), 1
83         cfi_endproc
84         .size   __reml, .-__reml
86         DO_DIVBYZERO