Deleted Added
full compact
ffs.S (137342) ffs.S (137463)
1/* $NetBSD: ffs.S,v 1.3 2003/04/05 23:27:15 bjh21 Exp $ */
2/*
3 * Copyright (c) 2001 Christopher Gilbert
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 15 unchanged lines hidden (view full) ---

24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <machine/asm.h>
1/* $NetBSD: ffs.S,v 1.3 2003/04/05 23:27:15 bjh21 Exp $ */
2/*
3 * Copyright (c) 2001 Christopher Gilbert
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 15 unchanged lines hidden (view full) ---

24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <machine/asm.h>
32__FBSDID("$FreeBSD: head/sys/libkern/arm/ffs.S 137342 2004-11-07 16:53:29Z cognet $");
32__FBSDID("$FreeBSD: head/sys/libkern/arm/ffs.S 137463 2004-11-09 16:47:47Z cognet $");
33
34
35/*
36 * ffs - find first set bit, this algorithm isolates the first set
37 * bit, then multiplies the number by 0x0450fbaf which leaves the top
38 * 6 bits as an index into the table. This algorithm should be a win
39 * over the checking each bit in turn as per the C compiled version.
40 *

--- 18 unchanged lines hidden (view full) ---

59 adrne r2, .L_ffs_table
60 orrne r0, r0, r0, lsl #4 /* r0 = X * 0x11 */
61 orrne r0, r0, r0, lsl #6 /* r0 = X * 0x451 */
62 rsbne r0, r0, r0, lsl #16 /* r0 = X * 0x0450fbaf */
63
64 /* now lookup in table indexed on top 6 bits of r0 */
65 ldrneb r0, [ r2, r0, lsr #26 ]
66
33
34
35/*
36 * ffs - find first set bit, this algorithm isolates the first set
37 * bit, then multiplies the number by 0x0450fbaf which leaves the top
38 * 6 bits as an index into the table. This algorithm should be a win
39 * over the checking each bit in turn as per the C compiled version.
40 *

--- 18 unchanged lines hidden (view full) ---

59 adrne r2, .L_ffs_table
60 orrne r0, r0, r0, lsl #4 /* r0 = X * 0x11 */
61 orrne r0, r0, r0, lsl #6 /* r0 = X * 0x451 */
62 rsbne r0, r0, r0, lsl #16 /* r0 = X * 0x0450fbaf */
63
64 /* now lookup in table indexed on top 6 bits of r0 */
65 ldrneb r0, [ r2, r0, lsr #26 ]
66
67 mov pc, lr
67 RET
68.text;
69.type .L_ffs_table, _ASM_TYPE_OBJECT;
70.L_ffs_table:
71/* 0 1 2 3 4 5 6 7 */
72 .byte 0, 1, 2, 13, 3, 7, 0, 14 /* 0- 7 */
73 .byte 4, 0, 8, 0, 0, 0, 0, 15 /* 8-15 */
74 .byte 11, 5, 0, 0, 9, 0, 0, 26 /* 16-23 */
75 .byte 0, 0, 0, 0, 0, 22, 28, 16 /* 24-31 */
76 .byte 32, 12, 6, 0, 0, 0, 0, 0 /* 32-39 */
77 .byte 10, 0, 0, 25, 0, 0, 21, 27 /* 40-47 */
78 .byte 31, 0, 0, 0, 0, 24, 0, 20 /* 48-55 */
79 .byte 30, 0, 23, 19, 29, 18, 17, 0 /* 56-63 */
80#else
81 clzne r0, r0
82 rsbne r0, r0, #32
68.text;
69.type .L_ffs_table, _ASM_TYPE_OBJECT;
70.L_ffs_table:
71/* 0 1 2 3 4 5 6 7 */
72 .byte 0, 1, 2, 13, 3, 7, 0, 14 /* 0- 7 */
73 .byte 4, 0, 8, 0, 0, 0, 0, 15 /* 8-15 */
74 .byte 11, 5, 0, 0, 9, 0, 0, 26 /* 16-23 */
75 .byte 0, 0, 0, 0, 0, 22, 28, 16 /* 24-31 */
76 .byte 32, 12, 6, 0, 0, 0, 0, 0 /* 32-39 */
77 .byte 10, 0, 0, 25, 0, 0, 21, 27 /* 40-47 */
78 .byte 31, 0, 0, 0, 0, 24, 0, 20 /* 48-55 */
79 .byte 30, 0, 23, 19, 29, 18, 17, 0 /* 56-63 */
80#else
81 clzne r0, r0
82 rsbne r0, r0, #32
83 mov pc, lr
83 RET
84#endif
84#endif