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.
6
7dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8dnl  it under the terms of the GNU Lesser General Public License as published
9dnl  by the Free Software Foundation; either version 3 of the License, or (at
10dnl  your option) any later version.
11
12dnl  The GNU MP Library is distributed in the hope that it will be useful, but
13dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15dnl  License for more details.
16
17dnl  You should have received a copy of the GNU Lesser General Public License
18dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
19
20include(`../config.m4')
21
22
23ASM_START()
24EXTERN(__clz_tab)
25PROLOGUE(mpn_count_leading_zeros,gp)
26	cmpbge	r31,  r16, r1
27	LEA(r3,__clz_tab)
28	sra	r1,   1,   r1
29	xor	r1,   127, r1
30	srl	r16,  1,   r16
31	addq	r1,   r3,  r1
32	ldq_u	r0,   0(r1)
33	lda	r2,   64
34	extbl	r0,   r1,   r0
35	s8subl	r0,   8,    r0
36	srl	r16,  r0,   r16
37	addq	r16,  r3,   r16
38	ldq_u	r1,   0(r16)
39	extbl	r1,   r16,  r1
40	subq	r2,   r1,   r2
41	subq	r2,   r0,   r0
42	ret	r31,  (r26),1
43EPILOGUE(mpn_count_leading_zeros)
44ASM_END()
45