1dnl  Alpha mpn_invert_limb -- Invert a normalized limb.
2
3dnl  Copyright 1996, 2000-2003, 2007, 2011, 2013 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 EV4:     ?
35C EV5:   137/140  (with BWX/without BWX)
36C EV6:    71/72   (with BWX/without BWX)
37
38C This was compiler generated, with minimal manual edits.  Surely several
39C cycles could be cut with some thought.
40
41ASM_START()
42PROLOGUE(mpn_invert_limb,gp)
43	LEA(	r2, approx_tab)
44	srl	r16, 54, r1
45	srl	r16, 24, r4
46	and	r16, 1, r5
47	bic	r1, 1, r7
48	lda	r4, 1(r4)
49	srl	r16, 1, r3
50	addq	r7, r2, r1
51ifelse(bwx_available_p,1,`
52	ldwu	r0, -512(r1)
53',`
54	ldq_u	r0, -512(r1)
55	extwl	r0, r7, r0
56')
57	addq	r3, r5, r3
58	mull	r0, r0, r1
59	sll	r0, 11, r0
60	mulq	r1, r4, r1
61	srl	r1, 40, r1
62	subq	r0, r1, r0
63	lda	r0, -1(r0)
64	mulq	r0, r0, r2
65	sll	r0, 60, r1
66	sll	r0, 13, r0
67	mulq	r2, r4, r2
68	subq	r1, r2, r1
69	srl	r1, 47, r1
70	addq	r0, r1, r0
71	mulq	r0, r3, r3
72	srl	r0, 1, r1
73	cmoveq	r5, 0, r1
74	subq	r1, r3, r1
75	umulh	r1, r0, r3
76	sll	r0, 31, r0
77	srl	r3, 1, r1
78	addq	r0, r1, r0
79	mulq	r0, r16, r2
80	umulh	r0, r16, r3
81	addq	r2, r16, r1
82	addq	r3, r16, r16
83	cmpult	r1, r2, r1
84	addq	r16, r1, r3
85	subq	r0, r3, r0
86	ret	r31, (r26), 1
87EPILOGUE()
88DATASTART(approx_tab,8)
89forloop(i,256,512-1,dnl
90`	.word	eval(0x7fd00/i)
91')dnl
92	SIZE(approx_tab, 512)
93	TYPE(approx_tab, object)
94DATAEND()
95ASM_END()
96