Module Name:    src
Committed By:   uwe
Date:           Fri Aug  5 01:59:40 UTC 2011

Modified Files:
        src/sys/lib/libkern/arch/sh3: sdivsi3.S udivsi3.S

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/lib/libkern/arch/sh3/sdivsi3.S
cvs rdiff -u -r1.10 -r1.11 src/sys/lib/libkern/arch/sh3/udivsi3.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/lib/libkern/arch/sh3/sdivsi3.S
diff -u src/sys/lib/libkern/arch/sh3/sdivsi3.S:1.11 src/sys/lib/libkern/arch/sh3/sdivsi3.S:1.12
--- src/sys/lib/libkern/arch/sh3/sdivsi3.S:1.11	Thu Jul 14 09:48:03 2011
+++ src/sys/lib/libkern/arch/sh3/sdivsi3.S	Fri Aug  5 01:59:39 2011
@@ -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

Index: src/sys/lib/libkern/arch/sh3/udivsi3.S
diff -u src/sys/lib/libkern/arch/sh3/udivsi3.S:1.10 src/sys/lib/libkern/arch/sh3/udivsi3.S:1.11
--- src/sys/lib/libkern/arch/sh3/udivsi3.S:1.10	Thu Jul 14 09:48:04 2011
+++ src/sys/lib/libkern/arch/sh3/udivsi3.S	Fri Aug  5 01:59:39 2011
@@ -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.
- *
- * 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:
+ * 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.
  *
- * . this function cannot have _PROF_PROLOGUE
- * . this function cannot be called via PLT
+ * See the definition of "udivsi3_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)
  */
 
 
@@ -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

Reply via email to