Skip to contentSkip to conversation

sparc32: Kill off software 32-bit multiply/divide routines.

PATCH In review David Miller 2 participants 2 messages May 15, 2012 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore

David Miller

author maintainer
#0 lore raw

PATCH 2/2 sparc32: Kill off software 32-bit multiply/divide routines.

For the explicit calls to .udiv/.umul in assembler, I made a mechanical (read as: safe) transformation. I didn't attempt to make any simplifications.

In particular, __ndelay and __udelay can be simplified significantly. Some of the %y reads are unnecessary and these routines have no need any longer for allocating a register window, they can be leaf functions.

---
 arch/sparc/kernel/entry.S    |   27 +--
 arch/sparc/kernel/head_32.S  |   45 -----
 arch/sparc/kernel/kernel.h   |    3 -
 arch/sparc/kernel/module.c   |   21 +--
 arch/sparc/kernel/muldiv.c   |  238 --------------------------
 arch/sparc/kernel/traps_32.c |    2 -
 arch/sparc/lib/Makefile      |    2 +-
 arch/sparc/lib/divdi3.S      |    4 +-
 arch/sparc/lib/ksyms.c       |   17 --
 arch/sparc/lib/mul.S         |  137 ---------------
 arch/sparc/lib/muldi3.S      |    4 +-
 arch/sparc/lib/rem.S         |  384 ------------------------------------------
 arch/sparc/lib/sdiv.S        |  381 -----------------------------------------
 arch/sparc/lib/udiv.S        |  357 ---------------------------------------
 arch/sparc/lib/udivdi3.S     |    3 +-
 arch/sparc/lib/umul.S        |  171 -------------------
 arch/sparc/lib/urem.S        |  357 ---------------------------------------
 17 files changed, 24 insertions(+), 2129 deletions(-)
 delete mode 100644 arch/sparc/kernel/muldiv.c
 delete mode 100644 arch/sparc/lib/mul.S
 delete mode 100644 arch/sparc/lib/rem.S
 delete mode 100644 arch/sparc/lib/sdiv.S
 delete mode 100644 arch/sparc/lib/udiv.S
 delete mode 100644 arch/sparc/lib/umul.S
 delete mode 100644 arch/sparc/lib/urem.S
arch/sparc/kernel/entry.S +16 -11
index 773f3f0..3f3976e 100644
@@ -1161,11 +1161,13 @@ fpload:
 	.globl	__ndelay
 __ndelay:
 	save	%sp, -STACKFRAME_SZ, %sp
-	mov	%i0, %o0
-	call	.umul			! round multiplier up so large ns ok
-	 mov	0x1ae, %o1		! 2**32 / (1 000 000 000 / HZ)
-	call	.umul
-	 mov	%i1, %o1		! udelay_val
+	mov	%i0, %o0		! round multiplier up so large ns ok
+	mov	0x1ae, %o1		! 2**32 / (1 000 000 000 / HZ)
+	umul	%o0, %o1, %o0
+	rd	%y, %o1
+	mov	%i1, %o1		! udelay_val
+	umul	%o0, %o1, %o0
+	rd	%y, %o1
 	ba	delay_continue
 	 mov	%o1, %o0		! >>32 later for better resolution
 
@@ -1174,18 +1176,21 @@ __udelay:
 	save	%sp, -STACKFRAME_SZ, %sp
 	mov	%i0, %o0
 	sethi	%hi(0x10c7), %o1	! round multiplier up so large us ok
-	call	.umul
-	 or	%o1, %lo(0x10c7), %o1	! 2**32 / 1 000 000
-	call	.umul
-	 mov	%i1, %o1		! udelay_val
+	or	%o1, %lo(0x10c7), %o1	! 2**32 / 1 000 000
+	umul	%o0, %o1, %o0
+	rd	%y, %o1
+	mov	%i1, %o1		! udelay_val
+	umul	%o0, %o1, %o0
+	rd	%y, %o1
 	sethi	%hi(0x028f4b62), %l0	! Add in rounding constant * 2**32,
 	or	%g0, %lo(0x028f4b62), %l0
 	addcc	%o0, %l0, %o0		! 2**32 * 0.009 999
 	bcs,a	3f
 	 add	%o1, 0x01, %o1
 3:
-	call	.umul
-	 mov	HZ, %o0			! >>32 earlier for wider range
+	mov	HZ, %o0			! >>32 earlier for wider range
+	umul	%o0, %o1, %o0
+	rd	%y, %o1
 
 delay_continue:
 	cmp	%o0, 0x0
arch/sparc/kernel/head_32.S +0 -45

51 lines not on this page · raw message

arch/sparc/kernel/kernel.h +0 -3
index 1c1a7d3..a86372d 100644
@@ -32,9 +32,6 @@ extern void cpu_probe(void);
 /* traps_32.c */
 extern void handle_hw_divzero(struct pt_regs *regs, unsigned long pc,
                               unsigned long npc, unsigned long psr);
-/* muldiv.c */
-extern int do_user_muldiv (struct pt_regs *, unsigned long);
-
 /* irq_32.c */
 extern struct irqaction static_irqaction[];
 extern int static_irq_count;
arch/sparc/kernel/module.c +1 -20
index 276359e..15e0a16 100644
@@ -32,26 +32,11 @@ static void *module_map(unsigned long size)
 				GFP_KERNEL, PAGE_KERNEL, -1,
 				__builtin_return_address(0));
 }
-
-static char *dot2underscore(char *name)
-{
-	return name;
-}
 #else
 static void *module_map(unsigned long size)
 {
 	return vmalloc(size);
 }
-
-/* Replace references to .func with _Func */
-static char *dot2underscore(char *name)
-{
-	if (name[0] = '.') {
-		name[0] = '_';
-                name[1] = toupper(name[1]);
-	}
-	return name;
-}
 #endif /* CONFIG_SPARC64 */
 
 void *module_alloc(unsigned long size)
@@ -93,12 +78,8 @@ int module_frob_arch_sections(Elf_Ehdr *hdr,
 
 	for (i = 1; i < sechdrs[symidx].sh_size / sizeof(Elf_Sym); i++) {
 		if (sym[i].st_shndx = SHN_UNDEF) {
-			if (ELF_ST_TYPE(sym[i].st_info) = STT_REGISTER) {
+			if (ELF_ST_TYPE(sym[i].st_info) = STT_REGISTER)
 				sym[i].st_shndx = SHN_ABS;
-			} else {
-				char *name = strtab + sym[i].st_name;
-				dot2underscore(name);
-			}
 		}
 	}
 	return 0;
arch/sparc/kernel/muldiv.c deleted +0 -238

238 lines not on this page · raw message

arch/sparc/kernel/traps_32.c +0 -2
index d2de213..a5785ea 100644
@@ -120,8 +120,6 @@ void do_illegal_instruction(struct pt_regs *regs, unsigned long pc, unsigned lon
 	printk("Ill instr. at pc=%08lx instruction is %08lx\n",
 	       regs->pc, *(unsigned long *)regs->pc);
 #endif
-	if (!do_user_muldiv (regs, pc))
-		return;
 
 	info.si_signo = SIGILL;
 	info.si_errno = 0;
arch/sparc/lib/Makefile +1 -1
index 33d8d85..ead6df2 100644
@@ -4,7 +4,7 @@
 asflags-y := -ansi -DST_DIV0=0x02
 ccflags-y := -Werror
 
-lib-$(CONFIG_SPARC32) += mul.o rem.o sdiv.o udiv.o umul.o urem.o ashrdi3.o
+lib-$(CONFIG_SPARC32) += ashrdi3.o
 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
 lib-y                 += strlen.o
 lib-y                 += checksum_$(BITS).o
arch/sparc/lib/divdi3.S +2 -2
index d74bc09..9614b48 100644
@@ -19,7 +19,6 @@ Boston, MA 02111-1307, USA.  */
 
 	.text
 	.align 4
-	.global .udiv
 	.globl __divdi3
 __divdi3:
 	save %sp,-104,%sp
@@ -83,8 +82,9 @@ __divdi3:
 	bne .LL85
 	mov %i0,%o2
 	mov 1,%o0
-	call .udiv,0
 	mov 0,%o1
+	wr %g0, 0, %y
+	udiv %o0, %o1, %o0
 	mov %o0,%o4
 	mov %i0,%o2
 .LL85:
arch/sparc/lib/ksyms.c +0 -17
index 1bc8972..2dc3087 100644
@@ -61,16 +61,6 @@ extern void ___rw_read_try(void);
 extern void ___rw_read_exit(void);
 extern void ___rw_write_enter(void);
 
-/* Alias functions whose names begin with "." and export the aliases.
- * The module references will be fixed up by module_frob_arch_sections.
- */
-extern int _Div(int, int);
-extern int _Mul(int, int);
-extern int _Rem(int, int);
-extern unsigned _Udiv(unsigned, unsigned);
-extern unsigned _Umul(unsigned, unsigned);
-extern unsigned _Urem(unsigned, unsigned);
-
 /* Networking helper routines. */
 EXPORT_SYMBOL(__csum_partial_copy_sparc_generic);
 
@@ -95,13 +85,6 @@ EXPORT_SYMBOL(__ashldi3);
 EXPORT_SYMBOL(__lshrdi3);
 EXPORT_SYMBOL(__muldi3);
 EXPORT_SYMBOL(__divdi3);
-
-EXPORT_SYMBOL(_Rem);
-EXPORT_SYMBOL(_Urem);
-EXPORT_SYMBOL(_Mul);
-EXPORT_SYMBOL(_Umul);
-EXPORT_SYMBOL(_Div);
-EXPORT_SYMBOL(_Udiv);
 #endif
 
 /*
arch/sparc/lib/mul.S deleted +0 -137

137 lines not on this page · raw message

arch/sparc/lib/muldi3.S +2 -2
index 7f17872..9794939 100644
@@ -63,12 +63,12 @@ __muldi3:
 	rd  %y, %o1
 	mov  %o1, %l3
 	mov  %i1, %o0
-	call  .umul
 	mov  %i2, %o1
+	umul %o0, %o1, %o0
 	mov  %o0, %l0
 	mov  %i0, %o0
-	call  .umul
 	mov  %i3, %o1
+	umul %o0, %o1, %o0
 	add  %l0, %o0, %l0
 	mov  %l2, %i0
 	add  %l2, %l0, %i0
arch/sparc/lib/rem.S deleted +0 -384

384 lines not on this page · raw message

arch/sparc/lib/sdiv.S deleted +0 -381

381 lines not on this page · raw message

arch/sparc/lib/udiv.S deleted +0 -357

357 lines not on this page · raw message

arch/sparc/lib/udivdi3.S +2 -1
index b430f1f..24e0a35 100644
@@ -60,8 +60,9 @@ __udivdi3:
 	bne .LL77
 	mov %i0,%o2
 	mov 1,%o0
-	call .udiv,0
 	mov 0,%o1
+	wr %g0, 0, %y
+	udiv %o0, %o1, %o0
 	mov %o0,%o3
 	mov %i0,%o2
 .LL77:
arch/sparc/lib/umul.S deleted +0 -171

171 lines not on this page · raw message

arch/sparc/lib/urem.S deleted +0 -357

357 lines not on this page · raw message

Signature · 1 line
1.7.10
#1 lore raw
Quoted 11 lines · David Miller

For the explicit calls to .udiv/.umul in assembler, I made a mechanical (read as: safe) transformation. I didn't attempt to make any simplifications.

In particular, __ndelay and __udelay can be simplified significantly. Some of the %y reads are unnecessary and these routines have no need any longer for allocating a register window, they can be leaf functions.

This was exactly what I hoped to see with Cypress dropped - great!

Sam