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