Tizen 2.1 base
[external/gmp.git] / mpn / pa32 / hppa1_1 / udiv.asm
1 dnl  HP-PA  __udiv_qrnnd division support, used from longlong.h.
2 dnl  This version runs fast on PA 7000 and later.
3
4 dnl  Copyright 1993, 1994, 2000, 2001, 2003 Free Software Foundation, Inc.
5
6 dnl  This file is part of the GNU MP Library.
7
8 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
9 dnl  it under the terms of the GNU Lesser General Public License as published
10 dnl  by the Free Software Foundation; either version 3 of the License, or (at
11 dnl  your option) any later version.
12
13 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
14 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16 dnl  License for more details.
17
18 dnl  You should have received a copy of the GNU Lesser General Public License
19 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
20
21 include(`../config.m4')
22
23 C INPUT PARAMETERS
24 C rem_ptr       gr26
25 C n1            gr25
26 C n0            gr24
27 C d             gr23
28
29 C This file has caused a lot of trouble, since it demands PIC reference to
30 C static data, which triggers bugs in gas (at least version 2.7 through
31 C 2.11.2).  When the bug is triggered, many bogus relocs are generated.  The
32 C current solution is to stuff data right into the code, and refer it using
33 C absolute offsets.  Fragile to be sure, but nothing else seems to work.
34
35 ASM_START()
36 ifdef(`PIC',`',
37 `       RODATA
38         INT64(0000, 0x43f00000, 0x0)    C 2^64
39 ')
40
41 PROLOGUE(mpn_udiv_qrnnd)
42 C       .callinfo       frame=64,no_calls
43
44         ldo             64(%r30),%r30
45
46         stws            %r25,-16(0,%r30)        C n_hi
47         stws            %r24,-12(0,%r30)        C n_lo
48
49 ifdef(`PIC',
50 `       bl              .+20,%r31
51         dep             %r0,31,2,%r31
52         .word   0x0                             C padding for alignment
53         .word   0x43f00000, 0x0                 C 2^64
54         ldo             4(%r31),%r31',
55 `       ldil            `L'%L(0000),%r31
56         ldo             R%L(0000)(%r31),%r31')
57
58         fldds           -16(0,%r30),%fr5
59         stws            %r23,-12(0,%r30)
60         comib,<=        0,%r25,L(1)
61         fcnvxf,dbl,dbl  %fr5,%fr5
62         fldds           0(0,%r31),%fr4
63         fadd,dbl        %fr4,%fr5,%fr5
64
65 LDEF(1)
66         fcpy,sgl        %fr0,%fr6L
67         fldws           -12(0,%r30),%fr6R
68         fcnvxf,dbl,dbl  %fr6,%fr4
69
70         fdiv,dbl        %fr5,%fr4,%fr5
71
72         fcnvfx,dbl,dbl  %fr5,%fr4
73         fstws           %fr4R,-16(%r30)
74         xmpyu           %fr4R,%fr6R,%fr6
75         ldws            -16(%r30),%r28
76         fstds           %fr6,-16(0,%r30)
77         ldws            -12(0,%r30),%r21
78         ldws            -16(0,%r30),%r20
79         sub             %r24,%r21,%r22
80         subb            %r25,%r20,%r20
81         comib,=         0,%r20,L(2)
82         ldo             -64(%r30),%r30
83
84         add             %r22,%r23,%r22
85         ldo             -1(%r28),%r28
86
87 LDEF(2)
88         bv              0(%r2)
89         stws            %r22,0(0,%r26)
90
91 EPILOGUE(mpn_udiv_qrnnd)