aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-12-09 04:07:09 -0500
committerDavid S. Miller <davem@davemloft.net>2008-12-09 04:07:09 -0500
commitae984d72e0632782dd98c3fcf469b9045ad0d449 (patch)
treecd1f09781fffee44c72218d354aa23d9bd069e52 /arch/sparc
parent5c03d590910a6ccddc144b382b0ecdb122c349f3 (diff)
sparc: Unify strlen assembler.
Use the new asm/asm.h header to help commonize the strlen assembler between 32-bit and 64-bit While we're here, use proper linux/linkage.h macros instead of by-hand stuff. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc')
-rw-r--r--arch/sparc/lib/Makefile2
-rw-r--r--arch/sparc/lib/strlen.S (renamed from arch/sparc/lib/strlen_64.S)40
-rw-r--r--arch/sparc/lib/strlen_32.S81
3 files changed, 21 insertions, 102 deletions
diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
index 05ae5c945e35..0db2c61a0f78 100644
--- a/arch/sparc/lib/Makefile
+++ b/arch/sparc/lib/Makefile
@@ -6,7 +6,7 @@ ccflags-y := -Werror
6 6
7lib-$(CONFIG_SPARC32) += mul.o rem.o sdiv.o udiv.o umul.o urem.o ashrdi3.o 7lib-$(CONFIG_SPARC32) += mul.o rem.o sdiv.o udiv.o umul.o urem.o ashrdi3.o
8lib-$(CONFIG_SPARC32) += memcpy.o memset.o 8lib-$(CONFIG_SPARC32) += memcpy.o memset.o
9lib-y += strlen_$(BITS).o 9lib-y += strlen.o
10lib-y += checksum_$(BITS).o 10lib-y += checksum_$(BITS).o
11lib-$(CONFIG_SPARC32) += blockops.o 11lib-$(CONFIG_SPARC32) += blockops.o
12lib-y += memscan_$(BITS).o memcmp_$(BITS).o strncmp_$(BITS).o 12lib-y += memscan_$(BITS).o memcmp_$(BITS).o strncmp_$(BITS).o
diff --git a/arch/sparc/lib/strlen_64.S b/arch/sparc/lib/strlen.S
index e9ba1920d818..536f83507fbf 100644
--- a/arch/sparc/lib/strlen_64.S
+++ b/arch/sparc/lib/strlen.S
@@ -1,37 +1,38 @@
1/* strlen.S: Sparc64 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, 1997 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 .align 32 14 .text
12 .globl strlen 15ENTRY(strlen)
13 .type strlen,#function
14strlen:
15 mov %o0, %o1 16 mov %o0, %o1
16 andcc %o0, 3, %g0 17 andcc %o0, 3, %g0
17 be,pt %icc, 9f 18 BRANCH32(be, pt, 9f)
18 sethi %hi(HI_MAGIC), %o4 19 sethi %hi(HI_MAGIC), %o4
19 ldub [%o0], %o5 20 ldub [%o0], %o5
20 brz,pn %o5, 11f 21 BRANCH_REG_ZERO(pn, %o5, 11f)
21 add %o0, 1, %o0 22 add %o0, 1, %o0
22 andcc %o0, 3, %g0 23 andcc %o0, 3, %g0
23 be,pn %icc, 4f 24 BRANCH32(be, pn, 4f)
24 or %o4, %lo(HI_MAGIC), %o3 25 or %o4, %lo(HI_MAGIC), %o3
25 ldub [%o0], %o5 26 ldub [%o0], %o5
26 brz,pn %o5, 12f 27 BRANCH_REG_ZERO(pn, %o5, 12f)
27 add %o0, 1, %o0 28 add %o0, 1, %o0
28 andcc %o0, 3, %g0 29 andcc %o0, 3, %g0
29 be,pt %icc, 5f 30 BRANCH32(be, pt, 5f)
30 sethi %hi(LO_MAGIC), %o4 31 sethi %hi(LO_MAGIC), %o4
31 ldub [%o0], %o5 32 ldub [%o0], %o5
32 brz,pn %o5, 13f 33 BRANCH_REG_ZERO(pn, %o5, 13f)
33 add %o0, 1, %o0 34 add %o0, 1, %o0
34 ba,pt %icc, 8f 35 BRANCH32(ba, pt, 8f)
35 or %o4, %lo(LO_MAGIC), %o2 36 or %o4, %lo(LO_MAGIC), %o2
369: 379:
37 or %o4, %lo(HI_MAGIC), %o3 38 or %o4, %lo(HI_MAGIC), %o3
@@ -44,24 +45,24 @@ strlen:
442: 452:
45 sub %o5, %o2, %o4 46 sub %o5, %o2, %o4
46 andcc %o4, %o3, %g0 47 andcc %o4, %o3, %g0
47 be,pt %icc, 8b 48 BRANCH32(be, pt, 8b)
48 add %o0, 4, %o0 49 add %o0, 4, %o0
49 50
50 /* Check every byte. */ 51 /* Check every byte. */
51 srl %o5, 24, %g7 52 srl %o5, 24, %g7
52 andcc %g7, 0xff, %g0 53 andcc %g7, 0xff, %g0
53 be,pn %icc, 1f 54 BRANCH32(be, pn, 1f)
54 add %o0, -4, %o4 55 add %o0, -4, %o4
55 srl %o5, 16, %g7 56 srl %o5, 16, %g7
56 andcc %g7, 0xff, %g0 57 andcc %g7, 0xff, %g0
57 be,pn %icc, 1f 58 BRANCH32(be, pn, 1f)
58 add %o4, 1, %o4 59 add %o4, 1, %o4
59 srl %o5, 8, %g7 60 srl %o5, 8, %g7
60 andcc %g7, 0xff, %g0 61 andcc %g7, 0xff, %g0
61 be,pn %icc, 1f 62 BRANCH32(be, pn, 1f)
62 add %o4, 1, %o4 63 add %o4, 1, %o4
63 andcc %o5, 0xff, %g0 64 andcc %o5, 0xff, %g0
64 bne,a,pt %icc, 2b 65 BRANCH32_ANNUL(bne, pt, 2b)
65 ld [%o0], %o5 66 ld [%o0], %o5
66 add %o4, 1, %o4 67 add %o4, 1, %o4
671: 681:
@@ -76,5 +77,4 @@ strlen:
7613: 7713:
77 retl 78 retl
78 mov 2, %o0 79 mov 2, %o0
79 80ENDPROC(strlen)
80 .size strlen, .-strlen
diff --git a/arch/sparc/lib/strlen_32.S b/arch/sparc/lib/strlen_32.S
deleted file mode 100644
index ed9a763368cd..000000000000
--- a/arch/sparc/lib/strlen_32.S
+++ /dev/null
@@ -1,81 +0,0 @@
1/* strlen.S: Sparc 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 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
6 */
7
8#define LO_MAGIC 0x01010101
9#define HI_MAGIC 0x80808080
10
110:
12 ldub [%o0], %o5
13 cmp %o5, 0
14 be 1f
15 add %o0, 1, %o0
16 andcc %o0, 3, %g0
17 be 4f
18 or %o4, %lo(HI_MAGIC), %o3
19 ldub [%o0], %o5
20 cmp %o5, 0
21 be 2f
22 add %o0, 1, %o0
23 andcc %o0, 3, %g0
24 be 5f
25 sethi %hi(LO_MAGIC), %o4
26 ldub [%o0], %o5
27 cmp %o5, 0
28 be 3f
29 add %o0, 1, %o0
30 b 8f
31 or %o4, %lo(LO_MAGIC), %o2
321:
33 retl
34 mov 0, %o0
352:
36 retl
37 mov 1, %o0
383:
39 retl
40 mov 2, %o0
41
42 .align 4
43 .global strlen
44strlen:
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
504:
51 sethi %hi(LO_MAGIC), %o4
525:
53 or %o4, %lo(LO_MAGIC), %o2
548:
55 ld [%o0], %o5
562:
57 sub %o5, %o2, %o4
58 andcc %o4, %o3, %g0
59 be 8b
60 add %o0, 4, %o0
61
62 /* Check every byte. */
63 srl %o5, 24, %g5
64 andcc %g5, 0xff, %g0
65 be 1f
66 add %o0, -4, %o4
67 srl %o5, 16, %g5
68 andcc %g5, 0xff, %g0
69 be 1f
70 add %o4, 1, %o4
71 srl %o5, 8, %g5
72 andcc %g5, 0xff, %g0
73 be 1f
74 add %o4, 1, %o4
75 andcc %o5, 0xff, %g0
76 bne,a 2b
77 ld [%o0], %o5
78 add %o4, 1, %o4
791:
80 retl
81 sub %o4, %o1, %o0