diff options
Diffstat (limited to 'arch/sparc/lib/strlen.S')
-rw-r--r-- | arch/sparc/lib/strlen.S | 79 |
1 files changed, 39 insertions, 40 deletions
diff --git a/arch/sparc/lib/strlen.S b/arch/sparc/lib/strlen.S index ed9a763368cd..536f83507fbf 100644 --- a/arch/sparc/lib/strlen.S +++ b/arch/sparc/lib/strlen.S | |||
@@ -1,51 +1,40 @@ | |||
1 | /* strlen.S: Sparc optimized strlen code | 1 | /* strlen.S: Sparc optimized strlen code |
2 | * Hand optimized from GNU libc's strlen | 2 | * Hand optimized from GNU libc's strlen |
3 | * Copyright (C) 1991,1996 Free Software Foundation | 3 | * Copyright (C) 1991,1996 Free Software Foundation |
4 | * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) | 4 | * Copyright (C) 1996,2008 David S. Miller (davem@davemloft.net) |
5 | * Copyright (C) 1996 Jakub Jelinek (jj@sunsite.mff.cuni.cz) | 5 | * Copyright (C) 1996, 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include <linux/linkage.h> | ||
9 | #include <asm/asm.h> | ||
10 | |||
8 | #define LO_MAGIC 0x01010101 | 11 | #define LO_MAGIC 0x01010101 |
9 | #define HI_MAGIC 0x80808080 | 12 | #define HI_MAGIC 0x80808080 |
10 | 13 | ||
11 | 0: | 14 | .text |
15 | ENTRY(strlen) | ||
16 | mov %o0, %o1 | ||
17 | andcc %o0, 3, %g0 | ||
18 | BRANCH32(be, pt, 9f) | ||
19 | sethi %hi(HI_MAGIC), %o4 | ||
12 | ldub [%o0], %o5 | 20 | ldub [%o0], %o5 |
13 | cmp %o5, 0 | 21 | BRANCH_REG_ZERO(pn, %o5, 11f) |
14 | be 1f | ||
15 | add %o0, 1, %o0 | 22 | add %o0, 1, %o0 |
16 | andcc %o0, 3, %g0 | 23 | andcc %o0, 3, %g0 |
17 | be 4f | 24 | BRANCH32(be, pn, 4f) |
18 | or %o4, %lo(HI_MAGIC), %o3 | 25 | or %o4, %lo(HI_MAGIC), %o3 |
19 | ldub [%o0], %o5 | 26 | ldub [%o0], %o5 |
20 | cmp %o5, 0 | 27 | BRANCH_REG_ZERO(pn, %o5, 12f) |
21 | be 2f | ||
22 | add %o0, 1, %o0 | 28 | add %o0, 1, %o0 |
23 | andcc %o0, 3, %g0 | 29 | andcc %o0, 3, %g0 |
24 | be 5f | 30 | BRANCH32(be, pt, 5f) |
25 | sethi %hi(LO_MAGIC), %o4 | 31 | sethi %hi(LO_MAGIC), %o4 |
26 | ldub [%o0], %o5 | 32 | ldub [%o0], %o5 |
27 | cmp %o5, 0 | 33 | BRANCH_REG_ZERO(pn, %o5, 13f) |
28 | be 3f | ||
29 | add %o0, 1, %o0 | 34 | add %o0, 1, %o0 |
30 | b 8f | 35 | BRANCH32(ba, pt, 8f) |
31 | or %o4, %lo(LO_MAGIC), %o2 | 36 | or %o4, %lo(LO_MAGIC), %o2 |
32 | 1: | 37 | 9: |
33 | retl | ||
34 | mov 0, %o0 | ||
35 | 2: | ||
36 | retl | ||
37 | mov 1, %o0 | ||
38 | 3: | ||
39 | retl | ||
40 | mov 2, %o0 | ||
41 | |||
42 | .align 4 | ||
43 | .global strlen | ||
44 | strlen: | ||
45 | mov %o0, %o1 | ||
46 | andcc %o0, 3, %g0 | ||
47 | bne 0b | ||
48 | sethi %hi(HI_MAGIC), %o4 | ||
49 | or %o4, %lo(HI_MAGIC), %o3 | 38 | or %o4, %lo(HI_MAGIC), %o3 |
50 | 4: | 39 | 4: |
51 | sethi %hi(LO_MAGIC), %o4 | 40 | sethi %hi(LO_MAGIC), %o4 |
@@ -56,26 +45,36 @@ strlen: | |||
56 | 2: | 45 | 2: |
57 | sub %o5, %o2, %o4 | 46 | sub %o5, %o2, %o4 |
58 | andcc %o4, %o3, %g0 | 47 | andcc %o4, %o3, %g0 |
59 | be 8b | 48 | BRANCH32(be, pt, 8b) |
60 | add %o0, 4, %o0 | 49 | add %o0, 4, %o0 |
61 | 50 | ||
62 | /* Check every byte. */ | 51 | /* Check every byte. */ |
63 | srl %o5, 24, %g5 | 52 | srl %o5, 24, %g7 |
64 | andcc %g5, 0xff, %g0 | 53 | andcc %g7, 0xff, %g0 |
65 | be 1f | 54 | BRANCH32(be, pn, 1f) |
66 | add %o0, -4, %o4 | 55 | add %o0, -4, %o4 |
67 | srl %o5, 16, %g5 | 56 | srl %o5, 16, %g7 |
68 | andcc %g5, 0xff, %g0 | 57 | andcc %g7, 0xff, %g0 |
69 | be 1f | 58 | BRANCH32(be, pn, 1f) |
70 | add %o4, 1, %o4 | 59 | add %o4, 1, %o4 |
71 | srl %o5, 8, %g5 | 60 | srl %o5, 8, %g7 |
72 | andcc %g5, 0xff, %g0 | 61 | andcc %g7, 0xff, %g0 |
73 | be 1f | 62 | BRANCH32(be, pn, 1f) |
74 | add %o4, 1, %o4 | 63 | add %o4, 1, %o4 |
75 | andcc %o5, 0xff, %g0 | 64 | andcc %o5, 0xff, %g0 |
76 | bne,a 2b | 65 | BRANCH32_ANNUL(bne, pt, 2b) |
77 | ld [%o0], %o5 | 66 | ld [%o0], %o5 |
78 | add %o4, 1, %o4 | 67 | add %o4, 1, %o4 |
79 | 1: | 68 | 1: |
80 | retl | 69 | retl |
81 | sub %o4, %o1, %o0 | 70 | sub %o4, %o1, %o0 |
71 | 11: | ||
72 | retl | ||
73 | mov 0, %o0 | ||
74 | 12: | ||
75 | retl | ||
76 | mov 1, %o0 | ||
77 | 13: | ||
78 | retl | ||
79 | mov 2, %o0 | ||
80 | ENDPROC(strlen) | ||