Debian Codegraph @

mpn/x86_64/core2/aorsmul_1.asm

raw
1 dnl x86-64 mpn_addmul_1 and mpn_submul_1, optimized for "Core 2".
2
3 dnl Copyright 2003-2005, 2007-2009, 2011, 2012 Free Software Foundation, Inc.
4
5 dnl This file is part of the GNU MP Library.
6 dnl
7 dnl The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl it under the terms of either:
9 dnl
10 dnl * the GNU Lesser General Public License as published by the Free
11 dnl Software Foundation; either version 3 of the License, or (at your
12 dnl option) any later version.
13 dnl
14 dnl or
15 dnl
16 dnl * the GNU General Public License as published by the Free Software
17 dnl Foundation; either version 2 of the License, or (at your option) any
18 dnl later version.
19 dnl
20 dnl or both in parallel, as here.
21 dnl
22 dnl The GNU MP Library is distributed in the hope that it will be useful, but
23 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 dnl for more details.
26 dnl
27 dnl You should have received copies of the GNU General Public License and the
28 dnl GNU Lesser General Public License along with the GNU MP Library. If not,
29 dnl see https://www.gnu.org/licenses/.
30
31 include(`../config.m4')
32
33 C cycles/limb
34 C AMD K8,K9 4.52
35 C AMD K10 4.01
36 C AMD bull 4.98
37 C AMD pile 4.83
38 C AMD steam
39 C AMD excavator
40 C AMD bobcat 5.56
41 C AMD jaguar 5.54
42 C Intel P4 16.3 17.3
43 C Intel core2 4.32 4.61
44 C Intel NHM 5.08
45 C Intel SBR 4.04
46 C Intel IBR 3.95
47 C Intel HWL 3.66
48 C Intel BWL 2.87
49 C Intel SKL 2.79
50 C Intel atom 20.6
51 C Intel SLM 7.6
52 C VIA nano 5.25
53
54 C INPUT PARAMETERS
55 define(`rp', `%rdi')
56 define(`up', `%rsi')
57 define(`n', `%rdx')
58 define(`v0', `%rcx')
59
60 ifdef(`OPERATION_addmul_1',`
61 define(`ADDSUB', `add')
62 define(`func', `mpn_addmul_1')
63 define(`func_1c', `mpn_addmul_1c')
64 ')
65 ifdef(`OPERATION_submul_1',`
66 define(`ADDSUB', `sub')
67 define(`func', `mpn_submul_1')
68 define(`func_1c', `mpn_submul_1c')
69 ')
70
71 MULFUNC_PROLOGUE(mpn_addmul_1 mpn_addmul_1c mpn_submul_1 mpn_submul_1c)
72
73 ABI_SUPPORT(DOS64)
74 ABI_SUPPORT(STD64)
75
76 C For DOS, on the stack we have four saved registers, return address,
77 C space for four register arguments, and finally the carry input.
78
79 IFDOS(` define(`carry_in', `72(%rsp)')') dnl
80 IFSTD(` define(`carry_in', `%r8')') dnl
81
82 ASM_START()
83 TEXT
84 ALIGN(16)
85 PROLOGUE(func_1c)
86 FUNC_ENTRY(4)
87 push %rbx
88 push %rbp
89 lea (%rdx), %rbx
90 neg %rbx
91
92 mov (up), %rax
93 mov (rp), %r10
94
95 lea -16(rp,%rdx,8), rp
96 lea (up,%rdx,8), up
97 mul %rcx
98 add carry_in, %rax
99 adc $0, %rdx
100 jmp L(start_nc)
101 EPILOGUE()
102
103 ALIGN(16)
104 PROLOGUE(func)
105 FUNC_ENTRY(4)
106 push %rbx
107 push %rbp
108 lea (%rdx), %rbx
109 neg %rbx
110
111 mov (up), %rax
112 mov (rp), %r10
113
114 lea -16(rp,%rdx,8), rp
115 lea (up,%rdx,8), up
116 mul %rcx
117
118 L(start_nc):
119 test $1, R8(%rbx)
120 jnz L(odd)
121
122 lea (%rax), %r11
123 mov 8(up,%rbx,8), %rax
124 lea (%rdx), %rbp
125 mul %rcx
126 add $2, %rbx
127 jz L(n2)
128
129 lea (%rax), %r8
130 mov (up,%rbx,8), %rax
131 lea (%rdx), %r9
132 jmp L(mid)
133
134 ALIGN(8)
135 L(odd): inc %rbx
136 jz L(n1)
137
138 lea (%rax), %r8
139 mov (up,%rbx,8), %rax
140 lea (%rdx), %r9
141 mul %rcx
142 lea (%rax), %r11
143 mov 8(up,%rbx,8), %rax
144 lea (%rdx), %rbp
145 jmp L(e)
146
147 ALIGN(16)
148 L(top): mul %rcx
149 ADDSUB %r8, %r10
150 lea (%rax), %r8
151 mov (up,%rbx,8), %rax
152 adc %r9, %r11
153 mov %r10, -8(rp,%rbx,8)
154 mov (rp,%rbx,8), %r10
155 lea (%rdx), %r9
156 adc $0, %rbp
157 L(mid): mul %rcx
158 ADDSUB %r11, %r10
159 lea (%rax), %r11
160 mov 8(up,%rbx,8), %rax
161 adc %rbp, %r8
162 mov %r10, (rp,%rbx,8)
163 mov 8(rp,%rbx,8), %r10
164 lea (%rdx), %rbp
165 adc $0, %r9
166 L(e): add $2, %rbx
167 js L(top)
168
169 mul %rcx
170 ADDSUB %r8, %r10
171 adc %r9, %r11
172 mov %r10, -8(rp)
173 adc %rbx, %rbp C rbx = 0
174 L(n2): mov (rp), %r10
175 ADDSUB %r11, %r10
176 adc %rbp, %rax
177 mov %r10, (rp)
178 adc %rbx, %rdx C rbx = 0
179 L(n1): mov 8(rp), %r10
180 ADDSUB %rax, %r10
181 mov %r10, 8(rp)
182 mov R32(%rbx), R32(%rax) C rbx = 0
183 adc %rdx, %rax
184 pop %rbp
185 pop %rbx
186 FUNC_EXIT()
187 ret
188 EPILOGUE()