Tizen 2.1 base
[external/gmp.git] / mpn / pa64 / aors_n.asm
1 dnl  HP-PA 2.0 mpn_add_n, mpn_sub_n
2
3 dnl  Copyright 1997, 2000, 2002, 2003, 2009 Free Software Foundation, Inc.
4
5 dnl  This file is part of the GNU MP Library.
6
7 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl  it under the terms of the GNU Lesser General Public License as published
9 dnl  by the Free Software Foundation; either version 3 of the License, or (at
10 dnl  your option) any later version.
11
12 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
13 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15 dnl  License for more details.
16
17 dnl  You should have received a copy of the GNU Lesser General Public License
18 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
19
20
21 dnl  This runs at 2 cycles/limb on PA8000 and 1.6875 cycles/limb on PA8500.  It
22 dnl  should be possible to reach the cache bandwidth 1.5 cycles/limb at least
23 dnl  with PA8500.  The problem now is stalling of the first ADD,DC after LDO,
24 dnl  where the processor gets confused about where carry comes from.
25
26 include(`../config.m4')
27
28 dnl INPUT PARAMETERS
29 define(`rp',`%r26')
30 define(`up',`%r25')
31 define(`vp',`%r24')
32 define(`n',`%r23')
33
34 ifdef(`OPERATION_add_n', `
35         define(ADCSBC,        `add,dc')
36         define(INITCY,        `addi -1,%r22,%r0')
37         define(func,          mpn_add_n)
38         define(func_nc,       mpn_add_nc)')
39 ifdef(`OPERATION_sub_n', `
40         define(ADCSBC,        `sub,db')
41         define(INITCY,        `subi 0,%r22,%r0')
42         define(func,          mpn_sub_n)
43         define(func_nc,       mpn_sub_nc)')
44
45 MULFUNC_PROLOGUE(mpn_add_n mpn_add_nc mpn_sub_n mpn_sub_nc)
46
47 ifdef(`HAVE_ABI_2_0w',
48 `       .level  2.0w
49 ',`     .level  2.0
50 ')
51 PROLOGUE(func_nc)
52         b       L(com)
53         nop
54 EPILOGUE()
55 PROLOGUE(func)
56         ldi             0, %r22
57 LDEF(com)
58         sub             %r0, n, %r21
59         depw,z          %r21, 30, 3, %r28       C r28 = 2 * (-n & 7)
60         depw,z          %r21, 28, 3, %r21       C r21 = 8 * (-n & 7)
61         sub             up, %r21, up            C offset up
62         sub             vp, %r21, vp            C offset vp
63         sub             rp, %r21, rp            C offset rp
64         blr             %r28, %r0               C branch into loop
65         INITCY
66
67 LDEF(loop)
68         ldd             0(up), %r20
69         ldd             0(vp), %r31
70         ADCSBC          %r20, %r31, %r20
71         std             %r20, 0(rp)
72 LDEF(7) ldd             8(up), %r21
73         ldd             8(vp), %r19
74         ADCSBC          %r21, %r19, %r21
75         std             %r21, 8(rp)
76 LDEF(6) ldd             16(up), %r20
77         ldd             16(vp), %r31
78         ADCSBC          %r20, %r31, %r20
79         std             %r20, 16(rp)
80 LDEF(5) ldd             24(up), %r21
81         ldd             24(vp), %r19
82         ADCSBC          %r21, %r19, %r21
83         std             %r21, 24(rp)
84 LDEF(4) ldd             32(up), %r20
85         ldd             32(vp), %r31
86         ADCSBC          %r20, %r31, %r20
87         std             %r20, 32(rp)
88 LDEF(3) ldd             40(up), %r21
89         ldd             40(vp), %r19
90         ADCSBC          %r21, %r19, %r21
91         std             %r21, 40(rp)
92 LDEF(2) ldd             48(up), %r20
93         ldd             48(vp), %r31
94         ADCSBC          %r20, %r31, %r20
95         std             %r20, 48(rp)
96 LDEF(1) ldd             56(up), %r21
97         ldd             56(vp), %r19
98         ADCSBC          %r21, %r19, %r21
99         ldo             64(up), up
100         std             %r21, 56(rp)
101         ldo             64(vp), vp
102         addib,>         -8, n, L(loop)
103         ldo             64(rp), rp
104
105         add,dc          %r0, %r0, %r29
106 ifdef(`OPERATION_sub_n',`
107         subi            1, %r29, %r29
108 ')
109         bve             (%r2)
110 ifdef(`HAVE_ABI_2_0w',
111 `       copy            %r29, %r28
112 ',`     ldi             0, %r28
113 ')
114 EPILOGUE()