diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/sparc64/lib/strlen.S |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/sparc64/lib/strlen.S')
-rw-r--r-- | arch/sparc64/lib/strlen.S | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/arch/sparc64/lib/strlen.S b/arch/sparc64/lib/strlen.S new file mode 100644 index 000000000000..e9ba1920d818 --- /dev/null +++ b/arch/sparc64/lib/strlen.S | |||
@@ -0,0 +1,80 @@ | |||
1 | /* strlen.S: Sparc64 optimized strlen code | ||
2 | * Hand optimized from GNU libc's strlen | ||
3 | * Copyright (C) 1991,1996 Free Software Foundation | ||
4 | * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) | ||
5 | * Copyright (C) 1996, 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) | ||
6 | */ | ||
7 | |||
8 | #define LO_MAGIC 0x01010101 | ||
9 | #define HI_MAGIC 0x80808080 | ||
10 | |||
11 | .align 32 | ||
12 | .globl strlen | ||
13 | .type strlen,#function | ||
14 | strlen: | ||
15 | mov %o0, %o1 | ||
16 | andcc %o0, 3, %g0 | ||
17 | be,pt %icc, 9f | ||
18 | sethi %hi(HI_MAGIC), %o4 | ||
19 | ldub [%o0], %o5 | ||
20 | brz,pn %o5, 11f | ||
21 | add %o0, 1, %o0 | ||
22 | andcc %o0, 3, %g0 | ||
23 | be,pn %icc, 4f | ||
24 | or %o4, %lo(HI_MAGIC), %o3 | ||
25 | ldub [%o0], %o5 | ||
26 | brz,pn %o5, 12f | ||
27 | add %o0, 1, %o0 | ||
28 | andcc %o0, 3, %g0 | ||
29 | be,pt %icc, 5f | ||
30 | sethi %hi(LO_MAGIC), %o4 | ||
31 | ldub [%o0], %o5 | ||
32 | brz,pn %o5, 13f | ||
33 | add %o0, 1, %o0 | ||
34 | ba,pt %icc, 8f | ||
35 | or %o4, %lo(LO_MAGIC), %o2 | ||
36 | 9: | ||
37 | or %o4, %lo(HI_MAGIC), %o3 | ||
38 | 4: | ||
39 | sethi %hi(LO_MAGIC), %o4 | ||
40 | 5: | ||
41 | or %o4, %lo(LO_MAGIC), %o2 | ||
42 | 8: | ||
43 | ld [%o0], %o5 | ||
44 | 2: | ||
45 | sub %o5, %o2, %o4 | ||
46 | andcc %o4, %o3, %g0 | ||
47 | be,pt %icc, 8b | ||
48 | add %o0, 4, %o0 | ||
49 | |||
50 | /* Check every byte. */ | ||
51 | srl %o5, 24, %g7 | ||
52 | andcc %g7, 0xff, %g0 | ||
53 | be,pn %icc, 1f | ||
54 | add %o0, -4, %o4 | ||
55 | srl %o5, 16, %g7 | ||
56 | andcc %g7, 0xff, %g0 | ||
57 | be,pn %icc, 1f | ||
58 | add %o4, 1, %o4 | ||
59 | srl %o5, 8, %g7 | ||
60 | andcc %g7, 0xff, %g0 | ||
61 | be,pn %icc, 1f | ||
62 | add %o4, 1, %o4 | ||
63 | andcc %o5, 0xff, %g0 | ||
64 | bne,a,pt %icc, 2b | ||
65 | ld [%o0], %o5 | ||
66 | add %o4, 1, %o4 | ||
67 | 1: | ||
68 | retl | ||
69 | sub %o4, %o1, %o0 | ||
70 | 11: | ||
71 | retl | ||
72 | mov 0, %o0 | ||
73 | 12: | ||
74 | retl | ||
75 | mov 1, %o0 | ||
76 | 13: | ||
77 | retl | ||
78 | mov 2, %o0 | ||
79 | |||
80 | .size strlen, .-strlen | ||