sparc32: Kill off software 32-bit multiply/divide routines.
David Miller
maintainerPATCH 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
@@ -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
@@ -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
@@ -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
@@ -120,8 +120,6 @@ void do_illegal_instruction(struct pt_regs *regs, unsigned long pc, unsigned lonprintk ("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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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,
__ndelayand__udelaycan 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.Signed-off-by David S. Miller <[email protected]>
This was exactly what I hoped to see with Cypress dropped - great!
Sam