Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/lib/libkern/arch/mips Use 64-bit-clean addition/subtract...



details:   https://anonhg.NetBSD.org/src/rev/80f7766834c5
branches:  trunk
changeset: 570228:80f7766834c5
user:      sekiya <sekiya%NetBSD.org@localhost>
date:      Wed Sep 29 04:45:26 2004 +0000

description:
Use 64-bit-clean addition/subtraction opcodes for pointer arithmetic iff
_LP64 is defined.

diffstat:

 sys/lib/libkern/arch/mips/memcpy.S |  52 +++++++++++++++++++++----------------
 sys/lib/libkern/arch/mips/memset.S |  28 +++++++++++++-------
 sys/lib/libkern/arch/mips/strcmp.S |  18 +++++++++---
 sys/lib/libkern/arch/mips/strlen.S |  16 ++++++++--
 4 files changed, 73 insertions(+), 41 deletions(-)

diffs (290 lines):

diff -r 490ac58b63dc -r 80f7766834c5 sys/lib/libkern/arch/mips/memcpy.S
--- a/sys/lib/libkern/arch/mips/memcpy.S        Wed Sep 29 04:45:05 2004 +0000
+++ b/sys/lib/libkern/arch/mips/memcpy.S        Wed Sep 29 04:45:26 2004 +0000
@@ -1,10 +1,18 @@
-/*     $NetBSD: memcpy.S,v 1.7 2001/10/16 15:40:53 uch Exp $   */
+/*     $NetBSD: memcpy.S,v 1.8 2004/09/29 04:45:26 sekiya Exp $        */
 /* XXXX We need to define this in a way which supports multiple architectures */
 
 #include <machine/cdefs.h>     /* Get SZREG correct */
 #include <mips/asm.h>
 #include <machine/endian.h>
 
+#if defined(_LP64)
+#define ADDU    daddu
+#define SUBU    dsubu
+#else
+#define ADDU    addu
+#define SUBU    subu    
+#endif  
+
 .set   push
 .set noreorder
 
@@ -32,7 +40,7 @@
         *      Make sure we can copy forwards.
         */
        sltu    t0,a1,a0        # t0 == a1 < a0
-       addu    a3,a1,a2        # a3 == end of source
+       ADDU    a3,a1,a2        # a3 == end of source
        sltu    t1,a0,a3        # t1 == a0 < a1+a2
        and     t2,t0,t1        # overlap -- copy backwards
        bne     t2,zero,backcopy
@@ -61,10 +69,10 @@
         */
        li      AT,-32          # BDSLOT
        and     t0,a2,AT        # count truncated to multiple of 32
-       addu    a3,a1,t0        # run fast loop up to this address
+       ADDU    a3,a1,t0        # run fast loop up to this address
        sltu    AT,a1,a3        # any work to do?
        beq     AT,zero,wordcopy
-       subu    a2,t0           # BDSLOT
+       SUBU    a2,t0           # BDSLOT
 
        /*
         *      loop body
@@ -81,13 +89,13 @@
        ld      v1,8(a1)
        ld      t0,16(a1)
        ld      t1,24(a1)
-       addu    a1,32
+       ADDU    a1,32
        sd      t3,0(a0)
        sd      v1,8(a0)
        sd      t0,16(a0)
        sd      t1,24(a0)
        bne     a1,a3,cp8
-       addu    a0,32           # BDSLOT
+       ADDU    a0,32           # BDSLOT
 
        b       wordcopy
        nop                     # BDSLOT
@@ -97,7 +105,7 @@
        lw      v1,4(a1)
        lw      t0,8(a1)
        lw      t1,12(a1)
-       addu    a1,32
+       ADDU    a1,32
        sw      t3,0(a0)
        sw      v1,4(a0)
        sw      t0,8(a0)
@@ -106,7 +114,7 @@
        lw      t0,-8(a1)
        lw      v1,-12(a1)
        lw      t3,-16(a1)
-       addu    a0,32
+       ADDU    a0,32
        sw      t1,-4(a0)
        sw      t0,-8(a0)
        sw      v1,-12(a0)
@@ -118,34 +126,34 @@
         */
 wordcopy:
        andi    t2,a2,3         # get byte count / 4
-       subu    t2,a2,t2        # t2 = number of words to copy * 4
+       SUBU    t2,a2,t2        # t2 = number of words to copy * 4
        beq     t2,zero,bytecopy
-       addu    t0,a1,t2        # BDSLOT stop at t0
-       subu    a2,a2,t2
+       ADDU    t0,a1,t2        # BDSLOT stop at t0
+       SUBU    a2,a2,t2
 1:
        lw      t3,0(a1)
-       addu    a1,4
+       ADDU    a1,4
        sw      t3,0(a0)
 #ifdef MIPS3_5900      
        nop
        nop
 #endif 
        bne     a1,t0,1b
-       addu    a0,4            # BDSLOT
+       ADDU    a0,4            # BDSLOT
 
 bytecopy:
        beq     a2,zero,copydone        # nothing left to do?
        nop
 2:
        lb      t3,0(a1)
-       addu    a1,1
+       ADDU    a1,1
        sb      t3,0(a0)
-       subu    a2,1
+       SUBU    a2,1
 #ifdef MIPS3_5900      
        nop
 #endif 
        bgtz    a2,2b
-       addu    a0,1            # BDSLOT
+       ADDU    a0,1            # BDSLOT
 
 copydone:
        j       ra
@@ -155,9 +163,9 @@
         */
 destaligned:
        andi    t0,a2,3         # t0 = bytecount mod 4
-       subu    a3,a2,t0        # number of words to transfer
+       SUBU    a3,a2,t0        # number of words to transfer
        beq     a3,zero,bytecopy
-       addu    a3,a1,a3        # BDSLOT: stop point for destaligned
+       ADDU    a3,a1,a3        # BDSLOT: stop point for destaligned
        move    a2,t0           # this many to do after we are done
 
 3:
@@ -179,18 +187,18 @@
         */
 backcopy:
        blez    a2,copydone     # nothing left to do?
-       addu    t0,a1,a2        # BDSLOT: end of source
-       addu    t1,a0,a2        # end of destination
+       ADDU    t0,a1,a2        # BDSLOT: end of source
+       ADDU    t1,a0,a2        # end of destination
 4:
        lb      t3,-1(t0)       
-       subu    t0,1
+       SUBU    t0,1
        sb      t3,-1(t1)
 #ifdef MIPS3_5900
        nop
        nop
 #endif 
        bne     t0,a1,4b
-       subu    t1,1            # BDSLOT
+       SUBU    t1,1            # BDSLOT
        j       ra
        nop
        
diff -r 490ac58b63dc -r 80f7766834c5 sys/lib/libkern/arch/mips/memset.S
--- a/sys/lib/libkern/arch/mips/memset.S        Wed Sep 29 04:45:05 2004 +0000
+++ b/sys/lib/libkern/arch/mips/memset.S        Wed Sep 29 04:45:26 2004 +0000
@@ -1,8 +1,16 @@
-/*     $NetBSD: memset.S,v 1.3 2001/10/16 15:40:53 uch Exp $   */
+/*     $NetBSD: memset.S,v 1.4 2004/09/29 04:45:26 sekiya Exp $        */
 #include <machine/cdefs.h>
 #include <mips/asm.h>
 #include <machine/endian.h>
 
+#if defined(_LP64)
+#define ADDU    daddu
+#define SUBU    dsubu
+#else   
+#define ADDU    addu    
+#define SUBU    subu
+#endif 
+
        .set    noreorder
 
 
@@ -19,19 +27,19 @@
        sll     t2, t1, 16              # shift that left 16
        or      t1, t2, t1              # or together
 
-       subu    t0, zero, a0            # compute # bytes to word align address
+       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
+       SUBU    a2, a2, t0              # subtract from remaining count
        SWHI    t1, 0(a0)               # store 1, 2, or 3 bytes to align
-       addu    a0, a0, t0
+       ADDU    a0, a0, t0
 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
+       SUBU    t0, a2, v1
+       SUBU    a2, a2, t0 
+       ADDU    t0, t0, a0              # compute ending address
 2:
-       addu    a0, a0, 4               # clear words
+       ADDU    a0, a0, 4               # clear words
 #ifdef MIPS3_5900
        nop
        nop
@@ -43,9 +51,9 @@
 
 smallclr:
        ble     a2, zero, 2f
-       addu    t0, a2, a0              # compute ending address
+       ADDU    t0, a2, a0              # compute ending address
 1:
-       addu    a0, a0, 1               # clear bytes
+       ADDU    a0, a0, 1               # clear bytes
 #ifdef MIPS3_5900      
        nop
        nop
diff -r 490ac58b63dc -r 80f7766834c5 sys/lib/libkern/arch/mips/strcmp.S
--- a/sys/lib/libkern/arch/mips/strcmp.S        Wed Sep 29 04:45:05 2004 +0000
+++ b/sys/lib/libkern/arch/mips/strcmp.S        Wed Sep 29 04:45:26 2004 +0000
@@ -1,7 +1,15 @@
-/*     $NetBSD: strcmp.S,v 1.1 1999/01/15 08:44:27 castor Exp $        */
+/*     $NetBSD: strcmp.S,v 1.2 2004/09/29 04:45:26 sekiya Exp $        */
 #include <machine/cdefs.h>
 #include <mips/asm.h>
 
+#if defined(_LP64)
+#define ADDU    daddu
+#define SUBU    dsubu
+#else   
+#define ADDU    addu    
+#define SUBU    subu
+#endif 
+
        .set noreorder
 
 /*
@@ -18,13 +26,13 @@
        lbu     t0, 1(a0)               # unroll loop
        lbu     t1, 1(a1)
        beq     t0, zero, LessOrEq      # end of first string?
-       addu    a0, a0, 2
+       ADDU    a0, a0, 2
        beq     t0, t1, 1b
-       addu    a1, a1, 2
+       ADDU    a1, a1, 2
 NotEq:
        j       ra
-       subu    v0, t0, t1
+       SUBU    v0, t0, t1
 LessOrEq:
        j       ra
-       subu    v0, zero, t1
+       SUBU    v0, zero, t1
 END(strcmp)
diff -r 490ac58b63dc -r 80f7766834c5 sys/lib/libkern/arch/mips/strlen.S
--- a/sys/lib/libkern/arch/mips/strlen.S        Wed Sep 29 04:45:05 2004 +0000
+++ b/sys/lib/libkern/arch/mips/strlen.S        Wed Sep 29 04:45:26 2004 +0000
@@ -1,19 +1,27 @@
-/*     $NetBSD: strlen.S,v 1.1 1999/01/15 08:44:27 castor Exp $        */
+/*     $NetBSD: strlen.S,v 1.2 2004/09/29 04:45:26 sekiya Exp $        */
 #include <machine/cdefs.h>
 #include <mips/asm.h>
 
+#if defined(_LP64)
+#define        ADDU    daddu
+#define SUBU   dsubu
+#else
+#define ADDU   addu
+#define SUBU   subu
+#endif
+
        .set    noreorder
 
 /*
  * strlen(str)
  */
 LEAF(strlen)
-       addu    v1, a0, 1
+       ADDU    v1, a0, 1
 1:
        lb      v0, 0(a0)               # get byte from string
-       addu    a0, a0, 1               # increment pointer
+       ADDU    a0, a0, 1               # increment pointer
        bne     v0, zero, 1b            # continue if not end
        nop
        j       ra
-       subu    v0, a0, v1              # compute length - 1 for '\0' char
+       SUBU    v0, a0, v1              # compute length - 1 for '\0' char
 END(strlen)



Home | Main Index | Thread Index | Old Index