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/sh3 Reword the comment about "millicode...



details:   https://anonhg.NetBSD.org/src/rev/ba670a5081c5
branches:  trunk
changeset: 767973:ba670a5081c5
user:      uwe <uwe%NetBSD.org@localhost>
date:      Fri Aug 05 01:59:39 2011 +0000

description:
Reword the comment about "millicode" nature of these functions and add
it to sdivsi3.S too.

Remove !_KERNEL code left over from the days when we shared these
files with userland.

Use .L prefix for local label.

diffstat:

 sys/lib/libkern/arch/sh3/sdivsi3.S |  52 ++++++++++++++--------------------
 sys/lib/libkern/arch/sh3/udivsi3.S |  57 +++++++++----------------------------
 2 files changed, 35 insertions(+), 74 deletions(-)

diffs (172 lines):

diff -r 4ead8df84b4a -r ba670a5081c5 sys/lib/libkern/arch/sh3/sdivsi3.S
--- a/sys/lib/libkern/arch/sh3/sdivsi3.S        Fri Aug 05 00:26:16 2011 +0000
+++ b/sys/lib/libkern/arch/sh3/sdivsi3.S        Fri Aug 05 01:59:39 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sdivsi3.S,v 1.11 2011/07/14 09:48:03 mrg Exp $ */
+/*     $NetBSD: sdivsi3.S,v 1.12 2011/08/05 01:59:39 uwe Exp $ */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -36,9 +36,26 @@
 
 #include <machine/asm.h>
 #if defined(LIBC_SCCS)
-       RCSID("$NetBSD: sdivsi3.S,v 1.11 2011/07/14 09:48:03 mrg Exp $")
+       RCSID("$NetBSD: sdivsi3.S,v 1.12 2011/08/05 01:59:39 uwe Exp $")
 #endif
 
+/*
+ * IMPOTANT: This function is special.
+ *
+ * This function is an auxiliary "millicode" function that is
+ * referenced by the code generated by gcc for signed integer
+ * division.  But gcc does NOT treat a call to this function as an
+ * ordinary function call - it can clobber only R1, R2 and R3.
+ *
+ * See the definition of "divsi3_i1" in gcc/config/sh/sh.md
+ *
+ * As the consequence this function cannot be called via any
+ * indirection that assumes normal calling convention:
+ *
+ * . cannot have _PROF_PROLOGUE
+ * . cannot be called via PLT (not relevant for kernel)
+ */
+
 
 #ifdef __ELF__
        .hidden __sdivsi3
@@ -51,7 +68,7 @@
        mov     r5, r1
 
        tst     r1, r1
-       bt      div_by_zero
+       bt      .L_div_by_zero
 
        mov     #0, r2
        div0s   r2, r0
@@ -70,33 +87,6 @@
        rts
         addc   r2, r0
 
-div_by_zero:
-#ifdef _KERNEL
+.L_div_by_zero:
        rts
         mov    #0, r0
-#else
-       mov.l   r14, @-r15
-       sts.l   pr, @-r15
-       mov     r15, r14
-
-       mov.l   L_raise, r1
-#ifdef PIC
-1:     bsrf    r1
-#else
-       jsr     @r1
-#endif
-        mov    #8, r4          /* delay slot.  8 <- SIGFPE. */
-       mov     #0, r0
-
-       lds.l   @r15+, pr
-       rts
-        mov.l  @r15+, r14
-
-       .align  2
-L_raise:
-#ifdef PIC
-       .long   _C_LABEL(raise)-(1b+4)
-#else
-       .long   _C_LABEL(raise)
-#endif
-#endif
diff -r 4ead8df84b4a -r ba670a5081c5 sys/lib/libkern/arch/sh3/udivsi3.S
--- a/sys/lib/libkern/arch/sh3/udivsi3.S        Fri Aug 05 00:26:16 2011 +0000
+++ b/sys/lib/libkern/arch/sh3/udivsi3.S        Fri Aug 05 01:59:39 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: udivsi3.S,v 1.10 2011/07/14 09:48:04 mrg Exp $ */
+/*     $NetBSD: udivsi3.S,v 1.11 2011/08/05 01:59:39 uwe Exp $ */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -36,26 +36,24 @@
 
 #include <machine/asm.h>
 #if defined(LIBC_SCCS)
-       RCSID("$NetBSD: udivsi3.S,v 1.10 2011/07/14 09:48:04 mrg Exp $")
+       RCSID("$NetBSD: udivsi3.S,v 1.11 2011/08/05 01:59:39 uwe Exp $")
 #endif
 
 /*
  * IMPOTANT: This function is special.
  *
- * This function is an auxiliary function that is referenced by the
- * code generated by gcc for integer division.  But gcc does NOT treat
- * a call to this function as an ordinary function call w.r.t. the set
- * of register this call clobbers.  See the definition of "udivsi3_i1"
- * in gcc/config/sh/sh.md.
+ * This function is an auxiliary "millicode" function that is
+ * referenced by the code generated by gcc for unsigned integer
+ * division.  But gcc does NOT treat a call to this function as an
+ * ordinary function call - it can clobber only R4.
  *
- * Any call to this function MUST NOT clobber any registers besides r4
- * and r0, where the result is returned.  At the time of the call the
- * r4 contains the first argument, so we are only left with r0, and we
- * cannot do anything meaningful using only one register.  The
- * consequences are:
+ * See the definition of "udivsi3_i1" in gcc/config/sh/sh.md
  *
- * . this function cannot have _PROF_PROLOGUE
- * . this function cannot be called via PLT
+ * As the consequence this function cannot be called via any
+ * indirection that assumes normal calling convention:
+ *
+ * . cannot have _PROF_PROLOGUE
+ * . cannot be called via PLT (not relevant for kernel)
  */
 
 
@@ -67,7 +65,7 @@
 /* r0 <= r4 / r5 */
 NENTRY(__udivsi3)
        tst     r5, r5
-       bt      div_by_zero
+       bt      .L_div_by_zero
 
        mov     #0, r0
        div0u
@@ -83,33 +81,6 @@
        rts
         mov    r4, r0
 
-div_by_zero:
-#ifdef _KERNEL
+.L_div_by_zero:
        rts
         mov    #0, r0
-#else
-       mov.l   r14, @-r15
-       sts.l   pr, @-r15
-       mov     r15, r14
-
-       mov.l   L_raise, r1
-#ifdef PIC
-1:     bsrf    r1
-#else
-       jsr     @r1
-#endif
-        mov    #8, r4          /* delay slot.  8 <- SIGFPE. */
-       mov     #0, r0
-
-       lds.l   @r15+, pr
-       rts
-        mov.l  @r15+, r14
-
-       .align  2
-L_raise:
-#ifdef PIC
-       .long   _C_LABEL(raise)-(1b+4)
-#else
-       .long   _C_LABEL(raise)
-#endif
-#endif



Home | Main Index | Thread Index | Old Index