Skip to contentSkip to conversation

m68k: use kernel's generic muldi3 libgcc function

PATCH Superseded Greg Ungerer 1 participant 1 message Oct 30, 2023 m68k architecture

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68k: use kernel's generic muldi3 libgcc function

From: Greg Ungerer <[email protected]>

Use the kernels own generic lib/muldi3.c implementation of muldi3 for 68K machines. Some 68K CPUs support 64bit multiplies so move the arch specific umul_ppmm() macro into a header file that is included by lib/muldi3.c. That way it can take advantage of the single instruction when available.

There is currently no arch specific compiler.h header for m68k, so create one for the umul_ppmm() macro. Then remove the old arch/m68k/lib/muldi3.c file that is no longer required.

---
 arch/m68k/Kconfig                |  2 +
 arch/m68k/include/asm/compiler.h | 22 ++++++++
 arch/m68k/lib/Makefile           |  2 +-
 arch/m68k/lib/muldi3.c           | 96 --------------------------------
 4 files changed, 25 insertions(+), 97 deletions(-)
 create mode 100644 arch/m68k/include/asm/compiler.h
 delete mode 100644 arch/m68k/lib/muldi3.c

Geert: this is a follow up to our discussion at

       https://lore.kernel.org/all/[email protected]/T/
arch/m68k/Kconfig +2 -0
index 3e96486d9528..6aa85096e1ee 100644
@@ -22,7 +22,9 @@ config M68K
 	select GENERIC_LIB_ASHLDI3
 	select GENERIC_LIB_ASHRDI3
 	select GENERIC_LIB_LSHRDI3
+	select GENERIC_LIB_MULDI3
 	select HAS_IOPORT if PCI || ISA || ATARI_ROM_ISA
+	select HAVE_ARCH_COMPILER_H
 	select HAVE_ARCH_SECCOMP
 	select HAVE_ARCH_SECCOMP_FILTER
 	select HAVE_ASM_MODVERSIONS
arch/m68k/include/asm/compiler.h new file +22 -0
new file mode 100644
index 000000000000..4abd3c6fc0e2
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_M68K_COMPILER_H
+#define __ASM_M68K_COMPILER_H
+
+#ifndef CONFIG_CPU_HAS_NO_MULDIV64
+
+/*
+ * For those 68K CPUs that support 64bit multiply define umul_ppm()
+ * for the common muldi3 libgcc helper function (in lib/muldi3.c).
+ * CPUs that don't have it (like the original 68000 and ColdFire)
+ * will fallback to using the C-coded version of umul_ppmm().
+ */
+#define umul_ppmm(w1, w0, u, v)				\
+	__asm__ ("mulu%.l %3,%1:%0"			\
+		 : "=d" ((unsigned long)(w0)),		\
+		   "=d" ((unsigned long)(w1))		\
+		 : "%0" ((unsigned long)(u)),		\
+		   "dmi" ((unsigned long)(v)))
+
+#endif /* !CONFIG_CPU_HAS_NO_MULDIV64 */
+
+#endif /* __ASM_M68K_COMPILER_H */
arch/m68k/lib/Makefile +1 -1
index 9158688e6cc6..15278a95259e 100644
@@ -4,7 +4,7 @@
 # Makefile for m68k-specific library files..
 #
 
-lib-y	:= muldi3.o memcpy.o memset.o memmove.o
+lib-y	:= 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/muldi3.c deleted +0 -96

96 lines not on this page · raw message

Signature · 1 line
2.25.1