Debian Codegraph @

mpn/x86_64/core2/aors_n.asm

raw
1 dnl Intel mpn_add_n/mpn_sub_n optimised for Conroe, Nehalem.
2
3 dnl Copyright 2006, 2007, 2011-2013 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 2
35 C AMD K10 1.93\2
36 C AMD bull 1.62\2.1
37 C AMD pile 1.6\1.7
38 C AMD steam
39 C AMD excavator
40 C AMD bobcat 2.79
41 C AMD jaguar 2.54
42 C Intel P4 10
43 C Intel core2 2
44 C Intel NHM 2
45 C Intel SBR 2
46 C Intel IBR 1.95
47 C Intel HWL 1.72
48 C Intel BWL 1.54
49 C Intel SKL 1.52
50 C Intel atom 9
51 C Intel SLM 6.5
52 C VIA nano 3
53
54 C INPUT PARAMETERS
55 define(`rp', `%rdi')
56 define(`up', `%rsi')
57 define(`vp', `%rdx')
58 define(`n', `%rcx')
59 define(`cy', `%r8')
60
61 ifdef(`OPERATION_add_n', `
62 define(ADCSBB, adc)
63 define(func, mpn_add_n)
64 define(func_nc, mpn_add_nc)')
65 ifdef(`OPERATION_sub_n', `
66 define(ADCSBB, sbb)
67 define(func, mpn_sub_n)
68 define(func_nc, mpn_sub_nc)')
69
70 MULFUNC_PROLOGUE(mpn_add_n mpn_add_nc mpn_sub_n mpn_sub_nc)
71
72 ABI_SUPPORT(DOS64)
73 ABI_SUPPORT(STD64)
74
75 ASM_START()
76 TEXT
77 ALIGN(16)
78 PROLOGUE(func)
79 FUNC_ENTRY(4)
80 xor %r8, %r8
81 L(start):
82 mov (up), %r10
83 mov (vp), %r11
84
85 lea (up,n,8), up
86 lea (vp,n,8), vp
87 lea (rp,n,8), rp
88 mov R32(n), R32(%rax)
89 neg n
90 and $3, R32(%rax)
91 je L(b00)
92 add %rax, n C clear low rcx bits for jrcxz
93 cmp $2, R32(%rax)
94 jl L(b01)
95 je L(b10)
96
97 L(b11): neg %r8 C set cy
98 jmp L(e11)
99
100 L(b00): neg %r8 C set cy
101 mov %r10, %r8
102 mov %r11, %r9
103 lea 4(n), n
104 jmp L(e00)
105
106 nop
107 nop
108 nop
109 L(b01): neg %r8 C set cy
110 jmp L(top)
111
112 L(b10): neg %r8 C set cy
113 mov %r10, %r8
114 mov %r11, %r9
115 jmp L(e10)
116
117 L(end): ADCSBB %r11, %r10
118 mov %r10, -8(rp)
119 mov R32(%rcx), R32(%rax) C clear eax, ecx contains 0
120 adc R32(%rax), R32(%rax)
121 FUNC_EXIT()
122 ret
123
124 ALIGN(16)
125 L(top): jrcxz L(end)
126 mov (up,n,8), %r8
127 mov (vp,n,8), %r9
128 lea 4(n), n
129 ADCSBB %r11, %r10
130 mov %r10, -40(rp,n,8)
131 L(e00): mov -24(up,n,8), %r10
132 mov -24(vp,n,8), %r11
133 ADCSBB %r9, %r8
134 mov %r8, -32(rp,n,8)
135 L(e11): mov -16(up,n,8), %r8
136 mov -16(vp,n,8), %r9
137 ADCSBB %r11, %r10
138 mov %r10, -24(rp,n,8)
139 L(e10): mov -8(up,n,8), %r10
140 mov -8(vp,n,8), %r11
141 ADCSBB %r9, %r8
142 mov %r8, -16(rp,n,8)
143 jmp L(top)
144 EPILOGUE()
145
146 PROLOGUE(func_nc)
147 FUNC_ENTRY(4)
148 IFDOS(` mov 56(%rsp), %r8 ')
149 jmp L(start)
150 EPILOGUE()