xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/alpha/cntlz.asm (revision ce54336801cf28877c3414aa2fcb251dddd543a2)
1dnl  Alpha auxiliary for longlong.h's count_leading_zeros
2
3dnl  Copyright 1997, 2000, 2002 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
33
34ASM_START()
35EXTERN(__clz_tab)
36PROLOGUE(mpn_count_leading_zeros,gp)
37	cmpbge	r31,  r16, r1
38	LEA(r3,__clz_tab)
39	sra	r1,   1,   r1
40	xor	r1,   127, r1
41	srl	r16,  1,   r16
42	addq	r1,   r3,  r1
43	ldq_u	r0,   0(r1)
44	lda	r2,   64
45	extbl	r0,   r1,   r0
46	s8subl	r0,   8,    r0
47	srl	r16,  r0,   r16
48	addq	r16,  r3,   r16
49	ldq_u	r1,   0(r16)
50	extbl	r1,   r16,  r1
51	subq	r2,   r1,   r2
52	subq	r2,   r0,   r0
53	ret	r31,  (r26),1
54EPILOGUE(mpn_count_leading_zeros)
55ASM_END()
56