xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/x86_64/bdiv_dbm1c.asm (revision b2c35e17b976cf7ccd7250c86c6f5e95090ed636)
1dnl  x86_64 mpn_bdiv_dbm1.
2
3dnl  Copyright 2008, 2011, 2012 Free Software Foundation, Inc.
4
5dnl  This file is part of the GNU MP Library.
6dnl
7dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8dnl  it under the terms of either:
9dnl
10dnl    * the GNU Lesser General Public License as published by the Free
11dnl      Software Foundation; either version 3 of the License, or (at your
12dnl      option) any later version.
13dnl
14dnl  or
15dnl
16dnl    * the GNU General Public License as published by the Free Software
17dnl      Foundation; either version 2 of the License, or (at your option) any
18dnl      later version.
19dnl
20dnl  or both in parallel, as here.
21dnl
22dnl  The GNU MP Library is distributed in the hope that it will be useful, but
23dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25dnl  for more details.
26dnl
27dnl  You should have received copies of the GNU General Public License and the
28dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
29dnl  see https://www.gnu.org/licenses/.
30
31include(`../config.m4')
32
33C	     cycles/limb
34C AMD K8,K9	 2.25
35C AMD K10	 2.25
36C Intel P4	12.5
37C Intel core2	 4
38C Intel NHM	 3.75
39C Intel SBR	 3.6
40C Intel atom	20
41C VIA nano	 4
42
43C TODO
44C  * Optimise feed-in code.
45
46C INPUT PARAMETERS
47define(`qp',	  `%rdi')
48define(`up',	  `%rsi')
49define(`n_param', `%rdx')
50define(`bd',	  `%rcx')
51define(`cy',	  `%r8')
52
53define(`n',       `%r9')
54
55ABI_SUPPORT(DOS64)
56ABI_SUPPORT(STD64)
57
58ASM_START()
59	TEXT
60	ALIGN(16)
61PROLOGUE(mpn_bdiv_dbm1c)
62	FUNC_ENTRY(4)
63IFDOS(`	mov	56(%rsp), %r8	')
64	mov	(up), %rax
65	mov	n_param, n
66	mov	R32(n_param), R32(%r11)
67	mul	bd
68	lea	(up,n,8), up
69	lea	(qp,n,8), qp
70	neg	n
71	and	$3, R32(%r11)
72	jz	L(lo0)
73	lea	-4(n,%r11), n
74	cmp	$2, R32(%r11)
75	jc	L(lo1)
76	jz	L(lo2)
77	jmp	L(lo3)
78
79	ALIGN(16)
80L(top):	mov	(up,n,8), %rax
81	mul	bd
82L(lo0):	sub	%rax, %r8
83	mov	%r8, (qp,n,8)
84	sbb	%rdx, %r8
85	mov	8(up,n,8), %rax
86	mul	bd
87L(lo3):	sub	%rax, %r8
88	mov	%r8, 8(qp,n,8)
89	sbb	%rdx, %r8
90	mov	16(up,n,8), %rax
91	mul	bd
92L(lo2):	sub	%rax, %r8
93	mov	%r8, 16(qp,n,8)
94	sbb	%rdx, %r8
95	mov	24(up,n,8), %rax
96	mul	bd
97L(lo1):	sub	%rax, %r8
98	mov	%r8, 24(qp,n,8)
99	sbb	%rdx, %r8
100	add	$4, n
101	jnz	L(top)
102
103	mov	%r8, %rax
104	FUNC_EXIT()
105	ret
106EPILOGUE()
107