Module Name: src
Committed By: matt
Date: Sun Aug 16 03:02:47 UTC 2009
Modified Files:
src/common/lib/libc/arch/mips/gen [matt-nb5-mips64]: byte_swap_2.S
byte_swap_4.S
src/common/lib/libc/arch/mips/string [matt-nb5-mips64]: bcopy.S ffs.S
memset.S strcmp.S strlen.S
Log Message:
First pass at making ABI agnostic. Generates same O32 code.
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.40.1 src/common/lib/libc/arch/mips/gen/byte_swap_2.S \
src/common/lib/libc/arch/mips/gen/byte_swap_4.S
cvs rdiff -u -r1.2 -r1.2.40.1 src/common/lib/libc/arch/mips/string/bcopy.S
cvs rdiff -u -r1.1 -r1.1.40.1 src/common/lib/libc/arch/mips/string/ffs.S \
src/common/lib/libc/arch/mips/string/memset.S \
src/common/lib/libc/arch/mips/string/strcmp.S \
src/common/lib/libc/arch/mips/string/strlen.S
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/common/lib/libc/arch/mips/gen/byte_swap_2.S
diff -u src/common/lib/libc/arch/mips/gen/byte_swap_2.S:1.2 src/common/lib/libc/arch/mips/gen/byte_swap_2.S:1.2.40.1
--- src/common/lib/libc/arch/mips/gen/byte_swap_2.S:1.2 Wed Feb 8 21:52:36 2006
+++ src/common/lib/libc/arch/mips/gen/byte_swap_2.S Sun Aug 16 03:02:47 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: byte_swap_2.S,v 1.2 2006/02/08 21:52:36 simonb Exp $ */
+/* $NetBSD: byte_swap_2.S,v 1.2.40.1 2009/08/16 03:02:47 matt Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -35,8 +35,8 @@
#include <mips/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
- ASMSTR("from: @(#)htons.s 8.1 (Berkeley) 6/4/93")
- ASMSTR("$NetBSD: byte_swap_2.S,v 1.2 2006/02/08 21:52:36 simonb Exp $")
+ /* RCSID("from: @(#)htons.s 8.1 (Berkeley) 6/4/93") */
+ RCSID("$NetBSD: byte_swap_2.S,v 1.2.40.1 2009/08/16 03:02:47 matt Exp $")
#endif /* LIBC_SCCS and not lint */
#undef _LOCORE
Index: src/common/lib/libc/arch/mips/gen/byte_swap_4.S
diff -u src/common/lib/libc/arch/mips/gen/byte_swap_4.S:1.2 src/common/lib/libc/arch/mips/gen/byte_swap_4.S:1.2.40.1
--- src/common/lib/libc/arch/mips/gen/byte_swap_4.S:1.2 Wed Feb 8 21:52:36 2006
+++ src/common/lib/libc/arch/mips/gen/byte_swap_4.S Sun Aug 16 03:02:47 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: byte_swap_4.S,v 1.2 2006/02/08 21:52:36 simonb Exp $ */
+/* $NetBSD: byte_swap_4.S,v 1.2.40.1 2009/08/16 03:02:47 matt Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -35,8 +35,8 @@
#include <mips/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
- ASMSTR("from: @(#)htonl.s 8.1 (Berkeley) 6/4/93")
- ASMSTR("$NetBSD: byte_swap_4.S,v 1.2 2006/02/08 21:52:36 simonb Exp $")
+ /* RCSID("from: @(#)htonl.s 8.1 (Berkeley) 6/4/93") */
+ RCSID("$NetBSD: byte_swap_4.S,v 1.2.40.1 2009/08/16 03:02:47 matt Exp $")
#endif /* LIBC_SCCS and not lint */
#undef _LOCORE
Index: src/common/lib/libc/arch/mips/string/bcopy.S
diff -u src/common/lib/libc/arch/mips/string/bcopy.S:1.2 src/common/lib/libc/arch/mips/string/bcopy.S:1.2.40.1
--- src/common/lib/libc/arch/mips/string/bcopy.S:1.2 Tue Dec 27 11:23:53 2005
+++ src/common/lib/libc/arch/mips/string/bcopy.S Sun Aug 16 03:02:47 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: bcopy.S,v 1.2 2005/12/27 11:23:53 tsutsui Exp $ */
+/* $NetBSD: bcopy.S,v 1.2.40.1 2009/08/16 03:02:47 matt Exp $ */
/*
* Mach Operating System
@@ -43,14 +43,10 @@
#if defined(LIBC_SCCS) && !defined(lint)
- ASMSTR("from: @(#)mips_bcopy.s 2.2 CMU 18/06/93")
- ASMSTR("$NetBSD: bcopy.S,v 1.2 2005/12/27 11:23:53 tsutsui Exp $")
+ /* RCSID("from: @(#)mips_bcopy.s 2.2 CMU 18/06/93") */
+ RCSID("$NetBSD: bcopy.S,v 1.2.40.1 2009/08/16 03:02:47 matt Exp $")
#endif /* LIBC_SCCS and not lint */
-#ifdef __ABICALLS__
- .abicalls
-#endif
-
/*
* bcopy(caddr_t src, caddr_t dst, unsigned int len)
*
@@ -103,71 +99,120 @@
* copy is alignable. eg if src and dest are both
* on a halfword boundary.
*/
- andi t1,DSTREG,3 # get last 3 bits of dest
- bne t1,zero,3f
- andi t0,SRCREG,3 # get last 3 bits of src
- bne t0,zero,5f
+#if 1
+ andi t1,DSTREG,(SZREG-1) # get last bits of dest
+ bne t1,zero,3f # dest unaligned
+ andi t0,SRCREG,(SZREG-1) # get last bits of src
+ bne t0,zero,5f
+#else
+ andi t1,DSTREG,(SZREG-1) # get last bits of dest
+ andi t0,SRCREG,(SZREG-1) # get last bits of src
+ beq t1,t0,97f # aligned on non-word
+ nop;
+ bne t1,zero,3f # dest unaligned
+ nop
+ b 5f # source unaligned
+ nop
+
+97:
+ sltiu t1,SIZEREG,SZREG
+ bne t1,zero,3f
+ nop
+ subu t2,zero,t2 # t2 = -t0
+ andi t2,t2,(SZREG-1) # t2 &= (SZREG-1)
+ # t0 + t2 == SZREG
+ PTR_SUBU SIZEREG,SIZEREG,t2 # retreat to word boundary
+ PTR_ADDU DSTREG,DSTREG,t2 # advance to word boundary
+ PTR_ADDU SRCREG,SRCREG,t2 # advance to word boundary
+ REG_L a3,-SZREG(DSTREG)
+ REG_L v1,-SZREG(SRCREG)
+ sll t0,t0,3 # bits to clear in dest
+ sll t1,t1,3 # bits to clear in source
+/*
+ * DST = 01 23 45 67 BE: 01234567 LE: 67452301
+ * 01000000 00000001
+ * SRC = 89 ab cd ef BE: 89abcdef LE: efcdab89
+ * 00abcdef efcdab00
+ * 01abcdef
+ */
+#if _BYTE_ORDER == _BIG_ENDIAN
+ REG_SRLV a3,a3,t1 # clear lsb dest bits
+ REG_SLLV a3,a3,t1
+ REG_SLLV v1,v1,t0 # clear msb source bits
+ REG_SRLV v1,v1,t0
+#endif
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+ REG_SLLV a3,a3,t1 # clear msb dest bits
+ REG_SRLV a3,a3,t1
+ REG_SRLV v1,v1,t0 # clear lsb source bits
+ REG_SLLV v1,v1,t0
+#endif
+ or a3,a3,v1 # merge
+ REG_S a3,-SZREG(DSTREG) # and save
+99:
+#endif
/*
* Forward aligned->aligned copy, 8*4 bytes at a time.
*/
- li AT,-32
- and t0,SIZEREG,AT # count truncated to multiple of 32 */
- addu a3,SRCREG,t0 # run fast loop up to this address
- sltu AT,SRCREG,a3 # any work to do?
- beq AT,zero,2f
- subu SIZEREG,t0
+98:
+ li AT,-(SZREG*8)
+ and t0,SIZEREG,AT # count truncated to multiples
+ PTR_ADDU a3,SRCREG,t0 # run fast loop up to this addr
+ sltu AT,SRCREG,a3 # any work to do?
+ beq AT,zero,2f
+ PTR_SUBU SIZEREG,t0
/*
* loop body
*/
1: # cp
- lw t3,0(SRCREG)
- lw v1,4(SRCREG)
- lw t0,8(SRCREG)
- lw t1,12(SRCREG)
- addu SRCREG,32
- sw t3,0(DSTREG)
- sw v1,4(DSTREG)
- sw t0,8(DSTREG)
- sw t1,12(DSTREG)
- lw t1,-4(SRCREG)
- lw t0,-8(SRCREG)
- lw v1,-12(SRCREG)
- lw t3,-16(SRCREG)
- addu DSTREG,32
- sw t1,-4(DSTREG)
- sw t0,-8(DSTREG)
- sw v1,-12(DSTREG)
- bne SRCREG,a3,1b
- sw t3,-16(DSTREG)
+ REG_L t3,(0*SZREG)(SRCREG)
+ REG_L v1,(1*SZREG)(SRCREG)
+ REG_L t0,(2*SZREG)(SRCREG)
+ REG_L t1,(3*SZREG)(SRCREG)
+ PTR_ADDU SRCREG,SZREG*8
+ REG_S t3,(0*SZREG)(DSTREG)
+ REG_S v1,(1*SZREG)(DSTREG)
+ REG_S t0,(2*SZREG)(DSTREG)
+ REG_S t1,(3*SZREG)(DSTREG)
+ REG_L t3,(-4*SZREG)(SRCREG)
+ REG_L v1,(-3*SZREG)(SRCREG)
+ REG_L t0,(-2*SZREG)(SRCREG)
+ REG_L t1,(-1*SZREG)(SRCREG)
+ PTR_ADDU DSTREG,SZREG*8
+ REG_S t1,(-1*SZREG)(DSTREG)
+ REG_S t0,(-2*SZREG)(DSTREG)
+ REG_S v1,(-3*SZREG)(DSTREG)
+ bne SRCREG,a3,1b
+ REG_S t3,(-4*SZREG)(DSTREG)
/*
* Copy a word at a time, no loop unrolling.
*/
2: # wordcopy
- andi t2,SIZEREG,3 # get byte count / 4
- subu t2,SIZEREG,t2 # t2 = number of words to copy * 4
- beq t2,zero,3f
- addu t0,SRCREG,t2 # stop at t0
- subu SIZEREG,SIZEREG,t2
+ andi t2,SIZEREG,(SZREG-1) # get byte count / SZREG
+ xor t2,SIZEREG,t2 # t2 = words to copy * SZREG
+ beq t2,zero,3f
+ PTR_ADDU t0,SRCREG,t2 # stop at t0
+ PTR_SUBU SIZEREG,SIZEREG,t2
1:
- lw t3,0(SRCREG)
- addu SRCREG,4
- sw t3,0(DSTREG)
- bne SRCREG,t0,1b
- addu DSTREG,4
+ REG_L t3,0(SRCREG)
+ PTR_ADDU SRCREG,SZREG
+ REG_S t3,0(DSTREG)
+ bne SRCREG,t0,1b
+ PTR_ADDU DSTREG,SZREG
3: # bytecopy
- beq SIZEREG,zero,4f # nothing left to do?
+ beq SIZEREG,zero,4f # nothing left to do?
nop
1:
- lb t3,0(SRCREG)
- addu SRCREG,1
- sb t3,0(DSTREG)
- subu SIZEREG,1
- bgtz SIZEREG,1b
- addu DSTREG,1
+ lb t3,0(SRCREG)
+ PTR_ADDU SRCREG,1
+ sb t3,0(DSTREG)
+ PTR_SUBU SIZEREG,1
+ bgtz SIZEREG,1b
+ PTR_ADDU DSTREG,1
4: # copydone
j ra
@@ -177,91 +222,91 @@
* Copy from unaligned source to aligned dest.
*/
5: # destaligned
- andi t0,SIZEREG,3 # t0 = bytecount mod 4
- subu a3,SIZEREG,t0 # number of words to transfer
- beq a3,zero,3b
+ andi t0,SIZEREG,(SZREG-1) # t0 = bytecount mod SZREG
+ PTR_SUBU a3,SIZEREG,t0 # number of words to transfer
+ beq a3,zero,3b
nop
- move SIZEREG,t0 # this many to do after we are done
- addu a3,SRCREG,a3 # stop point
+ move SIZEREG,t0 # this many to do after we are done
+ PTR_ADDU a3,SRCREG,a3 # stop point
1:
- LWHI t3,0(SRCREG)
- LWLO t3,3(SRCREG)
- addi SRCREG,4
- sw t3,0(DSTREG)
- bne SRCREG,a3,1b
- addi DSTREG,4
+ LWHI t3,0(SRCREG)
+ LWLO t3,3(SRCREG)
+ PTR_ADDI SRCREG,SZREG
+ sw t3,0(DSTREG)
+ bne SRCREG,a3,1b
+ PTR_ADDI DSTREG,SZREG
- j 3b
+ j 3b
nop
6: # backcopy -- based on above
- addu SRCREG,SIZEREG
- addu DSTREG,SIZEREG
- andi t1,DSTREG,3 # get last 3 bits of dest
- bne t1,zero,3f
- andi t0,SRCREG,3 # get last 3 bits of src
- bne t0,zero,5f
+ PTR_ADDU SRCREG,SIZEREG
+ PTR_ADDU DSTREG,SIZEREG
+ andi t1,DSTREG,3 # get last 3 bits of dest
+ bne t1,zero,3f
+ andi t0,SRCREG,3 # get last 3 bits of src
+ bne t0,zero,5f
/*
* Forward aligned->aligned copy, 8*4 bytes at a time.
*/
- li AT,-32
- and t0,SIZEREG,AT # count truncated to multiple of 32
- beq t0,zero,2f # any work to do?
- subu SIZEREG,t0
- subu a3,SRCREG,t0
+ li AT,(-8*SZREG)
+ and t0,SIZEREG,AT # count truncated to multiple of 32
+ beq t0,zero,2f # any work to do?
+ PTR_SUBU SIZEREG,t0
+ PTR_SUBU a3,SRCREG,t0
/*
* loop body
*/
1: # cp
- lw t3,-16(SRCREG)
- lw v1,-12(SRCREG)
- lw t0,-8(SRCREG)
- lw t1,-4(SRCREG)
- subu SRCREG,32
- sw t3,-16(DSTREG)
- sw v1,-12(DSTREG)
- sw t0,-8(DSTREG)
- sw t1,-4(DSTREG)
- lw t1,12(SRCREG)
- lw t0,8(SRCREG)
- lw v1,4(SRCREG)
- lw t3,0(SRCREG)
- subu DSTREG,32
- sw t1,12(DSTREG)
- sw t0,8(DSTREG)
- sw v1,4(DSTREG)
- bne SRCREG,a3,1b
- sw t3,0(DSTREG)
+ REG_L t3,(-4*SZREG)(SRCREG)
+ REG_L v1,(-3*SZREG)(SRCREG)
+ REG_L t0,(-2*SZREG)(SRCREG)
+ REG_L t1,(-1*SZREG)(SRCREG)
+ PTR_SUBU SRCREG,8*SZREG
+ REG_S t3,(-4*SZREG)(DSTREG)
+ REG_S v1,(-3*SZREG)(DSTREG)
+ REG_S t0,(-2*SZREG)(DSTREG)
+ REG_S t1,(-1*SZREG)(DSTREG)
+ REG_L t3,(0*SZREG)(SRCREG)
+ REG_L v1,(1*SZREG)(SRCREG)
+ REG_L t0,(2*SZREG)(SRCREG)
+ REG_L t1,(3*SZREG)(SRCREG)
+ PTR_SUBU DSTREG,8*SZREG
+ REG_S t1,(3*SZREG)(DSTREG)
+ REG_S t0,(2*SZREG)(DSTREG)
+ REG_S v1,(1*SZREG)(DSTREG)
+ bne SRCREG,a3,1b
+ REG_S t3,(0*SZREG)(DSTREG)
/*
* Copy a word at a time, no loop unrolling.
*/
2: # wordcopy
- andi t2,SIZEREG,3 # get byte count / 4
- subu t2,SIZEREG,t2 # t2 = number of words to copy * 4
- beq t2,zero,3f
- subu t0,SRCREG,t2 # stop at t0
- subu SIZEREG,SIZEREG,t2
+ andi t2,SIZEREG,SZREG-1 # get byte count / 4
+ xor t2,SIZEREG,t2 # t2 = number of words to copy
+ beq t2,zero,3f
+ PTR_SUBU t0,SRCREG,t2 # stop at t0
+ PTR_SUBU SIZEREG,SIZEREG,t2
1:
- lw t3,-4(SRCREG)
- subu SRCREG,4
- sw t3,-4(DSTREG)
- bne SRCREG,t0,1b
- subu DSTREG,4
+ REG_L t3,-SZREG(SRCREG)
+ PTR_SUBU SRCREG,SZREG
+ REG_S t3,-SZREG(DSTREG)
+ bne SRCREG,t0,1b
+ PTR_SUBU DSTREG,SZREG
3: # bytecopy
- beq SIZEREG,zero,4f # nothing left to do?
+ beq SIZEREG,zero,4f # nothing left to do?
nop
1:
- lb t3,-1(SRCREG)
- subu SRCREG,1
- sb t3,-1(DSTREG)
- subu SIZEREG,1
- bgtz SIZEREG,1b
- subu DSTREG,1
+ lb t3,-1(SRCREG)
+ PTR_SUBU SRCREG,1
+ sb t3,-1(DSTREG)
+ PTR_SUBU SIZEREG,1
+ bgtz SIZEREG,1b
+ PTR_SUBU DSTREG,1
4: # copydone
j ra
@@ -271,22 +316,22 @@
* Copy from unaligned source to aligned dest.
*/
5: # destaligned
- andi t0,SIZEREG,3 # t0 = bytecount mod 4
- subu a3,SIZEREG,t0 # number of words to transfer
- beq a3,zero,3b
+ andi t0,SIZEREG,3 # t0 = bytecount mod 4
+ PTR_SUBU a3,SIZEREG,t0 # number of words to transfer
+ beq a3,zero,3b
nop
- move SIZEREG,t0 # this many to do after we are done
- subu a3,SRCREG,a3 # stop point
+ move SIZEREG,t0 # this many to do after we are done
+ PTR_SUBU a3,SRCREG,a3 # stop point
1:
- LWHI t3,-4(SRCREG)
- LWLO t3,-1(SRCREG)
- subu SRCREG,4
- sw t3,-4(DSTREG)
- bne SRCREG,a3,1b
- subu DSTREG,4
+ LWHI t3,-4(SRCREG)
+ LWLO t3,-1(SRCREG)
+ PTR_SUBU SRCREG,4
+ sw t3,-4(DSTREG)
+ bne SRCREG,a3,1b
+ PTR_SUBU DSTREG,4
- j 3b
+ j 3b
nop
.set reorder
Index: src/common/lib/libc/arch/mips/string/ffs.S
diff -u src/common/lib/libc/arch/mips/string/ffs.S:1.1 src/common/lib/libc/arch/mips/string/ffs.S:1.1.40.1
--- src/common/lib/libc/arch/mips/string/ffs.S:1.1 Tue Dec 20 19:28:49 2005
+++ src/common/lib/libc/arch/mips/string/ffs.S Sun Aug 16 03:02:47 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
+/* $NetBSD: ffs.S,v 1.1.40.1 2009/08/16 03:02:47 matt Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -35,14 +35,10 @@
#include <mips/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
- ASMSTR("from: @(#)ffs.s 8.1 (Berkeley) 6/4/93")
- ASMSTR("$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+ /* RCSID("from: @(#)ffs.s 8.1 (Berkeley) 6/4/93") */
+ RCSID("$NetBSD: ffs.S,v 1.1.40.1 2009/08/16 03:02:47 matt Exp $")
#endif /* LIBC_SCCS and not lint */
-#ifdef __ABICALLS__
- .abicalls
-#endif
-
/* bit = ffs(value) */
LEAF(ffs)
Index: src/common/lib/libc/arch/mips/string/memset.S
diff -u src/common/lib/libc/arch/mips/string/memset.S:1.1 src/common/lib/libc/arch/mips/string/memset.S:1.1.40.1
--- src/common/lib/libc/arch/mips/string/memset.S:1.1 Tue Dec 20 19:28:50 2005
+++ src/common/lib/libc/arch/mips/string/memset.S Sun Aug 16 03:02:47 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: memset.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */
+/* $NetBSD: memset.S,v 1.1.40.1 2009/08/16 03:02:47 matt Exp $ */
#include <machine/cdefs.h>
#include <mips/asm.h>
@@ -8,44 +8,82 @@
#include <machine/endian.h>
+#if defined(SYSLIBC_SCCS) && !defined(lint)
+ RCSID("$NetBSD: memset.S,v 1.1.40.1 2009/08/16 03:02:47 matt Exp $")
+#endif /* SYSLIBC_SCCS and not lint */
+
.set noreorder
/*
* memset(void *s1, int c, int len)
*/
LEAF(memset)
- blt a2, 12, smallclr # small amount to clear?
- move v0, a0 # save s1 for result
+ blt a2, 12, smallclr # small amount to clear?
+ move v0, a0 # save s1 for result
+
+ sll t1, a1, 8 # compute c << 8 in t1
+ or t1, t1, a1 # compute c << 8 | c in t1
+ sll t2, t1, 16 # shift that left 16
+ or t1, t2, t1 # or together
+#if SZREG == 8
+ dsll32 t2, t1, 0 # shift that left 32
+ or t1, t2, t1 # or together
+#endif
- sll t1, a1, 8 # compute c << 8 in t1
- or t1, t1, a1 # compute c << 8 | c in 11
- sll t2, t1, 16 # shift that left 16
- or t1, t2, t1 # or together
-
- subu t0, zero, a0 # compute # bytes to word align address
- and t0, t0, 3
- beq t0, zero, 1f # skip if word aligned
- subu a2, a2, t0 # subtract from remaining count
- SWHI t1, 0(a0) # store 1, 2, or 3 bytes to align
- addu a0, a0, t0
+ subu t0, zero, a0 # compute # bytes to word align address
+ and t0, t0, SZREG-1
+ beq t0, zero, 1f # skip if word aligned
+ PTR_SUBU a2, a2, t0 # subtract from remaining count
+#if 1
+ SWHI t1, 0(a0) # store 1, 2, or 3 bytes to align
+ PTR_ADDU a0, a0, t0
+#if SZREG == 8
+ sltui t0, t0, 4 # did we need to store more than 3?
+ bne t0, zero, 1f # nope,
+ nop
+ sw t1, -4(a0) # store remaining 4 bytes
+#endif
+#else
+/*
+ *
+ */
+ andi t2, a0, SZREG-1 # v0 + t0 = SZREG
+ PTR_ADDU a0, a0, t0 # advance to word boundary
+ REG_L a3, -SZREG(a0) # load previous word
+ sll t2, t2, 3 # convert byte count to bit count
+ sll t0, t0, 3 # convert byte count to bit count
+#if _BYTE_ORDER == _BIG_ENDIAN
+ REG_SLLV v1, t1, t2 # clear msb bits of fill
+ REG_SRLV v1, v1, t2
+ REG_SRLV a3, a3, t0 # clear lsb bits of source
+ REG_SLLV a3, a3, t0
+#elif _BYTE_ORDER == _LITTLE_ENDIAN
+ REG_SRLV v1, t1, t2 # clear lsb bits of fill
+ REG_SLLV v1, v1, t2
+ REG_SLLV a3, a3, t0 # clear msb bits of source
+ REG_SRLV a3, a3, t0
+#endif
+ or a3, a3, v1 # merge source and fill
+ REG_S a3, -SZREG(a0) # store it
+#endif /* 0 */
1:
- and v1, a2, 3 # compute number of whole words left
- subu t0, a2, v1
- subu a2, a2, t0
- addu t0, t0, a0 # compute ending address
+ and v1, a2, SZREG-1 # compute number of whole words left
+ PTR_SUBU t0, a2, v1
+ PTR_SUBU a2, a2, t0
+ PTR_ADDU t0, t0, a0 # compute ending address
2:
- addu a0, a0, 4 # clear words
- bne a0, t0, 2b # unrolling loop does not help
- sw t1, -4(a0) # since we are limited by memory speed
+ PTR_ADDU a0, a0, SZREG # clear words
+ bne a0, t0, 2b # unrolling loop does not help
+ REG_S t1, -SZREG(a0) # since we are limited by memory speed
smallclr:
- ble a2, zero, 2f
- addu t0, a2, a0 # compute ending address
+ ble a2, zero, 2f
+ PTR_ADDU t0, a2, a0 # compute ending address
1:
- addu a0, a0, 1 # clear bytes
- bne a0, t0, 1b
- sb a1, -1(a0)
+ PTR_ADDU a0, a0, 1 # clear bytes
+ bne a0, t0, 1b
+ sb a1, -1(a0)
2:
- j ra
+ j ra
nop
END(memset)
Index: src/common/lib/libc/arch/mips/string/strcmp.S
diff -u src/common/lib/libc/arch/mips/string/strcmp.S:1.1 src/common/lib/libc/arch/mips/string/strcmp.S:1.1.40.1
--- src/common/lib/libc/arch/mips/string/strcmp.S:1.1 Tue Dec 20 19:28:50 2005
+++ src/common/lib/libc/arch/mips/string/strcmp.S Sun Aug 16 03:02:47 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */
+/* $NetBSD: strcmp.S,v 1.1.40.1 2009/08/16 03:02:47 matt Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -35,14 +35,10 @@
#include <mips/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
- ASMSTR("from: @(#)strcmp.s 8.1 (Berkeley) 6/4/93")
- ASMSTR("$NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
+ /* RCSID("from: @(#)strcmp.s 8.1 (Berkeley) 6/4/93") */
+ RCSID("$NetBSD: strcmp.S,v 1.1.40.1 2009/08/16 03:02:47 matt Exp $")
#endif /* LIBC_SCCS and not lint */
-#ifdef __ABICALLS__
- .abicalls
-#endif
-
/*
* NOTE: this version assumes unsigned chars in order to be "8 bit clean".
*/
@@ -54,9 +50,9 @@
bne t0, t1, NotEq
lbu t0, 1(a0) # unroll loop
lbu t1, 1(a1)
- add a0, a0, 2
+ PTR_ADD a0, a0, 2
beq t0, zero, LessOrEq # end of first string?
- add a1, a1, 2
+ PTR_ADD a1, a1, 2
beq t0, t1, 1b
NotEq:
subu v0, t0, t1
Index: src/common/lib/libc/arch/mips/string/strlen.S
diff -u src/common/lib/libc/arch/mips/string/strlen.S:1.1 src/common/lib/libc/arch/mips/string/strlen.S:1.1.40.1
--- src/common/lib/libc/arch/mips/string/strlen.S:1.1 Tue Dec 20 19:28:50 2005
+++ src/common/lib/libc/arch/mips/string/strlen.S Sun Aug 16 03:02:47 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: strlen.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */
+/* $NetBSD: strlen.S,v 1.1.40.1 2009/08/16 03:02:47 matt Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -35,20 +35,16 @@
#include <mips/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
- ASMSTR("from: @(#)strlen.s 8.1 (Berkeley) 6/4/93")
- ASMSTR("$NetBSD: strlen.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
+ /* RCSID("from: @(#)strlen.s 8.1 (Berkeley) 6/4/93") */
+ RCSID("$NetBSD: strlen.S,v 1.1.40.1 2009/08/16 03:02:47 matt Exp $")
#endif /* LIBC_SCCS and not lint */
-#ifdef __ABICALLS__
- .abicalls
-#endif
-
LEAF(strlen)
- addu v1, a0, 1
+ PTR_ADDU v1, a0, 1
1:
- lb v0, 0(a0) # get byte from string
- addu a0, a0, 1 # increment pointer
- bne v0, zero, 1b # continue if not end
- subu v0, a0, v1 # compute length - 1 for '\0' char
- j ra
+ lb v0, 0(a0) # get byte from string
+ PTR_ADDU a0, a0, 1 # increment pointer
+ bne v0, zero, 1b # continue if not end
+ PTR_SUBU v0, a0, v1 # compute length - 1 for '\0' char
+ j ra
END(strlen)