]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/alpha/reml.S
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / sysdeps / alpha / reml.S
CommitLineData
04277e02 1/* Copyright (C) 2004-2019 Free Software Foundation, Inc.
08e3c578
RH
2 Contributed by Richard Henderson <rth@twiddle.net>
3 This file is part of the GNU C Library.
a424e418 4
08e3c578
RH
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
ab84e3ff 16 License along with the GNU C Library. If not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
08e3c578
RH
18
19#include "div_libc.h"
20
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.
24
25 The FPU can handle the division for all input values except zero.
a61c91b0
RH
26 All we have to do is compute the remainder via multiply-and-subtract.
27
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. */
08e3c578
RH
32
33#ifndef EXTEND
34#define EXTEND(S,D) sextl S, D
35#endif
36
37 .text
38 .align 4
39 .globl __reml
685896ef 40 .type __reml, @funcnoplt
08e3c578
RH
41 .usepv __reml, no
42
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)
a61c91b0 50 excb
08e3c578 51 beq Y, DIVBYZERO
a61c91b0
RH
52
53 stt $f1, 8(sp)
54 stt $f2, 16(sp)
08e3c578
RH
55 cfi_rel_offset ($f0, 0)
56 cfi_rel_offset ($f1, 8)
a61c91b0
RH
57 cfi_rel_offset ($f2, 16)
58 mf_fpcr $f2
08e3c578
RH
59
60 EXTEND (X, RV)
61 EXTEND (Y, AT)
a61c91b0 62 _ITOFT2 RV, $f0, 24, AT, $f1, 32
08e3c578
RH
63 cvtqt $f0, $f0
64 cvtqt $f1, $f1
08e3c578
RH
65 divt/c $f0, $f1, $f0
66 cvttq/c $f0, $f0
a61c91b0
RH
67 excb
68 mt_fpcr $f2
69 _FTOIT $f0, RV, 24
08e3c578
RH
70
71 ldt $f0, 0(sp)
72 mull RV, Y, RV
73 ldt $f1, 8(sp)
a61c91b0 74 ldt $f2, 16(sp)
08e3c578
RH
75 lda sp, FRAME(sp)
76 cfi_restore ($f0)
77 cfi_restore ($f1)
a61c91b0 78 cfi_restore ($f2)
08e3c578 79 cfi_def_cfa_offset (0)
08e3c578
RH
80 subl X, RV, RV
81 ret $31, (RA), 1
82
83 cfi_endproc
84 .size __reml, .-__reml
85
86 DO_DIVBYZERO