xref: /linux/arch/sparc/lib/NG4fls.S (revision ba199dc909a20fe62270ae4e93f263987bb9d119)
1/* NG4fls.S: SPARC optimized fls and __fls for T4 and above.
2 *
3 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
4 */
5
6#include <linux/linkage.h>
7
8#define LZCNT_O0_G2	\
9	.word	0x85b002e8
10
11	.text
12	.register	%g2, #scratch
13	.register	%g3, #scratch
14
15ENTRY(NG4fls)
16	LZCNT_O0_G2	!lzcnt	%o0, %g2
17	mov	64, %g3
18	retl
19	 sub	%g3, %g2, %o0
20ENDPROC(NG4fls)
21
22ENTRY(__NG4fls)
23	brz,pn	%o0, 1f
24	LZCNT_O0_G2	!lzcnt	%o0, %g2
25	mov	63, %g3
26	sub	%g3, %g2, %o0
271:
28	retl
29	 nop
30ENDPROC(__NG4fls)
31