diff options
author | David S. Miller <davem@davemloft.net> | 2011-08-02 23:23:34 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-08-03 00:28:53 -0400 |
commit | 56d205cc5c0a3032a605121d4253e111193bf923 (patch) | |
tree | 1e37a74fd6df18ec35a9d6a1f70eca2e649e4afb /arch/sparc/lib | |
parent | ea5e7447ea9d555558e0f13798f5143dd51a915a (diff) |
sparc: Use popc when possible for ffs/__ffs/ffz.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/lib')
-rw-r--r-- | arch/sparc/lib/Makefile | 2 | ||||
-rw-r--r-- | arch/sparc/lib/ffs.S | 84 |
2 files changed, 85 insertions, 1 deletions
diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile index 11c850a9b66f..a3fc4375a150 100644 --- a/arch/sparc/lib/Makefile +++ b/arch/sparc/lib/Makefile | |||
@@ -37,7 +37,7 @@ lib-$(CONFIG_SPARC64) += GENmemcpy.o GENcopy_from_user.o GENcopy_to_user.o | |||
37 | lib-$(CONFIG_SPARC64) += GENpatch.o GENpage.o GENbzero.o | 37 | lib-$(CONFIG_SPARC64) += GENpatch.o GENpage.o GENbzero.o |
38 | 38 | ||
39 | lib-$(CONFIG_SPARC64) += copy_in_user.o user_fixup.o memmove.o | 39 | lib-$(CONFIG_SPARC64) += copy_in_user.o user_fixup.o memmove.o |
40 | lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o | 40 | lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o |
41 | 41 | ||
42 | obj-y += iomap.o | 42 | obj-y += iomap.o |
43 | obj-$(CONFIG_SPARC32) += atomic32.o | 43 | obj-$(CONFIG_SPARC32) += atomic32.o |
diff --git a/arch/sparc/lib/ffs.S b/arch/sparc/lib/ffs.S new file mode 100644 index 000000000000..b39389f69899 --- /dev/null +++ b/arch/sparc/lib/ffs.S | |||
@@ -0,0 +1,84 @@ | |||
1 | #include <linux/linkage.h> | ||
2 | |||
3 | .register %g2,#scratch | ||
4 | |||
5 | .text | ||
6 | .align 32 | ||
7 | |||
8 | ENTRY(ffs) | ||
9 | brnz,pt %o0, 1f | ||
10 | mov 1, %o1 | ||
11 | retl | ||
12 | clr %o0 | ||
13 | nop | ||
14 | nop | ||
15 | ENTRY(__ffs) | ||
16 | sllx %o0, 32, %g1 /* 1 */ | ||
17 | srlx %o0, 32, %g2 | ||
18 | |||
19 | clr %o1 /* 2 */ | ||
20 | movrz %g1, %g2, %o0 | ||
21 | |||
22 | movrz %g1, 32, %o1 /* 3 */ | ||
23 | 1: clr %o2 | ||
24 | |||
25 | sllx %o0, (64 - 16), %g1 /* 4 */ | ||
26 | srlx %o0, 16, %g2 | ||
27 | |||
28 | movrz %g1, %g2, %o0 /* 5 */ | ||
29 | clr %o3 | ||
30 | |||
31 | movrz %g1, 16, %o2 /* 6 */ | ||
32 | clr %o4 | ||
33 | |||
34 | and %o0, 0xff, %g1 /* 7 */ | ||
35 | srlx %o0, 8, %g2 | ||
36 | |||
37 | movrz %g1, %g2, %o0 /* 8 */ | ||
38 | clr %o5 | ||
39 | |||
40 | movrz %g1, 8, %o3 /* 9 */ | ||
41 | add %o2, %o1, %o2 | ||
42 | |||
43 | and %o0, 0xf, %g1 /* 10 */ | ||
44 | srlx %o0, 4, %g2 | ||
45 | |||
46 | movrz %g1, %g2, %o0 /* 11 */ | ||
47 | add %o2, %o3, %o2 | ||
48 | |||
49 | movrz %g1, 4, %o4 /* 12 */ | ||
50 | |||
51 | and %o0, 0x3, %g1 /* 13 */ | ||
52 | srlx %o0, 2, %g2 | ||
53 | |||
54 | movrz %g1, %g2, %o0 /* 14 */ | ||
55 | add %o2, %o4, %o2 | ||
56 | |||
57 | movrz %g1, 2, %o5 /* 15 */ | ||
58 | |||
59 | and %o0, 0x1, %g1 /* 16 */ | ||
60 | |||
61 | add %o2, %o5, %o2 /* 17 */ | ||
62 | xor %g1, 0x1, %g1 | ||
63 | |||
64 | retl /* 18 */ | ||
65 | add %o2, %g1, %o0 | ||
66 | ENDPROC(ffs) | ||
67 | ENDPROC(__ffs) | ||
68 | |||
69 | .section .popc_6insn_patch, "ax" | ||
70 | .word ffs | ||
71 | brz,pn %o0, 98f | ||
72 | neg %o0, %g1 | ||
73 | xnor %o0, %g1, %o1 | ||
74 | popc %o1, %o0 | ||
75 | 98: retl | ||
76 | nop | ||
77 | .word __ffs | ||
78 | neg %o0, %g1 | ||
79 | xnor %o0, %g1, %o1 | ||
80 | popc %o1, %o0 | ||
81 | retl | ||
82 | sub %o0, 1, %o0 | ||
83 | nop | ||
84 | .previous | ||