Skip to contentSkip to conversation

m68k: use kernel's generic libgcc functions

PATCH In review Greg Ungerer 3 participants 4 messages Sep 13, 2023 – Oct 5, 2023 m68k architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68k: use kernel's generic libgcc functions

From: Greg Ungerer <[email protected]>

The arch/m68k/lib versions of the libgcc functions: ashldi3, ashrdi3 and lshrdi3 were taken directly from an older version of gcc. We can use the kernel's own generic lib versions of these - they are virtually identical. Switch to those and remove the m68k local ones.

---

Tested on ColdFire and on an Atari build under aranym.

 arch/m68k/Kconfig       |  3 ++
 arch/m68k/lib/Makefile  |  3 +-
 arch/m68k/lib/ashldi3.c | 61 ----------------------------------------
 arch/m68k/lib/ashrdi3.c | 62 -----------------------------------------
 arch/m68k/lib/lshrdi3.c | 61 ----------------------------------------
 5 files changed, 4 insertions(+), 186 deletions(-)
 delete mode 100644 arch/m68k/lib/ashldi3.c
 delete mode 100644 arch/m68k/lib/ashrdi3.c
 delete mode 100644 arch/m68k/lib/lshrdi3.c
arch/m68k/Kconfig +3 -0
index 3e318bf9504c..3e96486d9528 100644
@@ -19,6 +19,9 @@ config M68K
 	select GENERIC_CPU_DEVICES
 	select GENERIC_IOMAP
 	select GENERIC_IRQ_SHOW
+	select GENERIC_LIB_ASHLDI3
+	select GENERIC_LIB_ASHRDI3
+	select GENERIC_LIB_LSHRDI3
 	select HAS_IOPORT if PCI || ISA || ATARI_ROM_ISA
 	select HAVE_ARCH_SECCOMP
 	select HAVE_ARCH_SECCOMP_FILTER
arch/m68k/lib/Makefile +1 -2
index eca17f14b4d5..9158688e6cc6 100644
@@ -4,8 +4,7 @@
 # Makefile for m68k-specific library files..
 #
 
-lib-y	:= ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \
-	   memcpy.o memset.o memmove.o
+lib-y	:= muldi3.o memcpy.o memset.o memmove.o
 
 lib-$(CONFIG_MMU) += uaccess.o
 lib-$(CONFIG_CPU_HAS_NO_MULDIV64) += mulsi3.o divsi3.o udivsi3.o
arch/m68k/lib/ashldi3.c deleted +0 -61

61 lines not on this page · raw message

arch/m68k/lib/ashrdi3.c deleted +0 -62

62 lines not on this page · raw message

arch/m68k/lib/lshrdi3.c deleted +0 -61

61 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Greg,

Quoted 8 lines · Greg Ungerer

From: Greg Ungerer <[email protected]>

The arch/m68k/lib versions of the libgcc functions: ashldi3, ashrdi3 and lshrdi3 were taken directly from an older version of gcc. We can use the kernel's own generic lib versions of these - they are virtually identical. Switch to those and remove the m68k local ones.

Thanks for your patch!

i.e. will queue in the m68k for-v6.7 branch.

arch/m68k/Kconfig config M68K · line 27

Quoted 12 lines
arch/m68k/Kconfig +3 -0
@@ -19,6 +19,9 @@ config M68K
        select GENERIC_CPU_DEVICES
        select GENERIC_IOMAP
        select GENERIC_IRQ_SHOW
+       select GENERIC_LIB_ASHLDI3
+       select GENERIC_LIB_ASHRDI3
+       select GENERIC_LIB_LSHRDI3
        select HAS_IOPORT if PCI || ISA || ATARI_ROM_ISA
        select HAVE_ARCH_SECCOMP
        select HAVE_ARCH_SECCOMP_FILTER

I guess we can select GENERIC_LIB_MULDI3 if CPU_HAS_NO_MULDIV64 and clean up arch/m68k/lib/muldi3.c, too?

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#2 lore raw

Hi Geert,

Quoted 17 lines · Geert Uytterhoeven

Hi Greg,

Quoted 8 lines · Greg Ungerer

From: Greg Ungerer <[email protected]>

The arch/m68k/lib versions of the libgcc functions: ashldi3, ashrdi3 and lshrdi3 were taken directly from an older version of gcc. We can use the kernel's own generic lib versions of these - they are virtually identical. Switch to those and remove the m68k local ones.

Thanks for your patch!

i.e. will queue in the m68k for-v6.7 branch.

Quoted 15 lines

arch/m68k/Kconfig config M68K · line 27

Quoted 12 lines
arch/m68k/Kconfig +3 -0
@@ -19,6 +19,9 @@ config M68K
         select GENERIC_CPU_DEVICES
         select GENERIC_IOMAP
         select GENERIC_IRQ_SHOW
+       select GENERIC_LIB_ASHLDI3
+       select GENERIC_LIB_ASHRDI3
+       select GENERIC_LIB_LSHRDI3
         select HAS_IOPORT if PCI || ISA || ATARI_ROM_ISA
         select HAVE_ARCH_SECCOMP
         select HAVE_ARCH_SECCOMP_FILTER

I guess we can select GENERIC_LIB_MULDI3 if CPU_HAS_NO_MULDIV64 and clean up arch/m68k/lib/muldi3.c, too?

Yes, that is true.

I was hoping we might be able to do something a little more clever. The common muldi3.c is almost identical except our local macro for umul_ppmm(). But looking at the common lib/muldi3.c code it has been setup to handle an arch local definition of that. I didn't spend too much time looking at it yet, not sure where we could put that for the whole mechanism to work though.

Regards
Greg

#3 lore raw

Hi Greg,

Quoted 4 lines · Greg Ungerer
Quoted 2 lines · Geert Uytterhoeven

I guess we can select GENERIC_LIB_MULDI3 if CPU_HAS_NO_MULDIV64 and clean up arch/m68k/lib/muldi3.c, too?

Quoted 8 lines

Yes, that is true.

I was hoping we might be able to do something a little more clever. The common muldi3.c is almost identical except our local macro for umul_ppmm(). But looking at the common lib/muldi3.c code it has been setup to handle an arch local definition of that. I didn't spend too much time looking at it yet, not sure where we could put that for the whole mechanism to work though.

For floating point, there are <math-emu/soft-fp.h> and <asm/sfp-machine.h>, but abusing that for integer feels wrong.

'git grep "#\s*define\s*umul_ppmm"' shows there are already plenty of definitions for umul_ppmm(), so moving these to arch-specific header files can clean that up in the process.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds