* Unify the various copies of libgcc into lib
@ 2017-05-23 22:05 Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
` (26 more replies)
0 siblings, 27 replies; 93+ messages in thread
From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw)
To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem,
linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch
I'm in the process of submitting the RISC-V Linux port, and someone noticed
that we were adding copies of some libgcc emulation routines that were the same
as some of the other ports. This prompted me to go through and check all the
ports for libgcc.h and to merge the versions that were functionally identical.
The only difference in libgcc.h was that there was a #define for little vs big
endian. The differences in the emulation routines were all just whitespace.
This patch set comes in two parts:
* Patch 1 adds new copies of all the C files copied from libgcc, as well as
moving libgcc.h to include/lib (that's a new folder, which probably means
it's the wrong place to put it, but I couldn't find anything better). There
are Kconfig entries for each of these library functions so architectures can
select them one at a time.
* The rest of the patches convert each architecture over to the new system.
Unless I screwed something up, this patch set shouldn't actually change any
functionality. Unfortunately I don't actually have all these cross compilers
setup so I can't actually test any of this, but I did convert the RISC-V port
over to using this system and it appears to be OK there so at least this isn't
completely broken.
^ permalink raw reply [flat|nested] 93+ messages in thread* Unify the various copies of libgcc into lib 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` [PATCH 1/7] lib: Add shared copies of some GCC library routines Palmer Dabbelt ` (25 subsequent siblings) 26 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch I'm in the process of submitting the RISC-V Linux port, and someone noticed that we were adding copies of some libgcc emulation routines that were the same as some of the other ports. This prompted me to go through and check all the ports for libgcc.h and to merge the versions that were functionally identical. The only difference in libgcc.h was that there was a #define for little vs big endian. The differences in the emulation routines were all just whitespace. This patch set comes in two parts: * Patch 1 adds new copies of all the C files copied from libgcc, as well as moving libgcc.h to include/lib (that's a new folder, which probably means it's the wrong place to put it, but I couldn't find anything better). There are Kconfig entries for each of these library functions so architectures can select them one at a time. * The rest of the patches convert each architecture over to the new system. Unless I screwed something up, this patch set shouldn't actually change any functionality. Unfortunately I don't actually have all these cross compilers setup so I can't actually test any of this, but I did convert the RISC-V port over to using this system and it appears to be OK there so at least this isn't completely broken. ^ permalink raw reply [flat|nested] 93+ messages in thread
* [PATCH 1/7] lib: Add shared copies of some GCC library routines 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt ` (24 subsequent siblings) 26 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt Many ports (m32r, microblaze, mips, parisc, score, and sparc) use functionally identical copies of various GCC library routine files, which came up as we were submitting the RISC-V port (which also uses some of these). This patch adds a new copy of these library routine files, which are functionally identical to the various other copies. These are availiable via Kconfig as CONFIG_LIB_$ROUTINE, which currently isn't used anywhere. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- include/lib/libgcc.h | 44 ++++++++++++++++++++++++++++++++ lib/Kconfig | 18 +++++++++++++ lib/Makefile | 8 ++++++ lib/ashldi3.c | 45 ++++++++++++++++++++++++++++++++ lib/ashrdi3.c | 46 +++++++++++++++++++++++++++++++++ lib/cmpdi2.c | 42 ++++++++++++++++++++++++++++++ lib/lshrdi3.c | 45 ++++++++++++++++++++++++++++++++ lib/muldi3.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/ucmpdi2.c | 35 +++++++++++++++++++++++++ 9 files changed, 355 insertions(+) create mode 100644 include/lib/libgcc.h create mode 100644 lib/ashldi3.c create mode 100644 lib/ashrdi3.c create mode 100644 lib/cmpdi2.c create mode 100644 lib/lshrdi3.c create mode 100644 lib/muldi3.c create mode 100644 lib/ucmpdi2.c diff --git a/include/lib/libgcc.h b/include/lib/libgcc.h new file mode 100644 index 000000000000..a5397e34e005 --- /dev/null +++ b/include/lib/libgcc.h @@ -0,0 +1,44 @@ +/* + * include/lib/libgcc.h + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + + +#ifndef __LIB_LIBGCC_H +#define __LIB_LIBGCC_H + +#include <asm/byteorder.h> + +typedef int word_type __attribute__ ((mode (__word__))); + +#ifdef __BIG_ENDIAN +struct DWstruct { + int high, low; +}; +#elif defined(__LITTLE_ENDIAN) +struct DWstruct { + int low, high; +}; +#else +#error I feel sick. +#endif + +typedef union { + struct DWstruct s; + long long ll; +} DWunion; + +#endif /* __ASM_LIBGCC_H */ diff --git a/lib/Kconfig b/lib/Kconfig index 0c8b78a9ae2e..24c08ae53c20 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -565,3 +565,21 @@ config PRIME_NUMBERS tristate endmenu + +config LIB_ASHLDI3 + def_bool n + +config LIB_ASHRDI3 + def_bool n + +config LIB_LSHRDI3 + def_bool n + +config LIB_MULDI3 + def_bool n + +config LIB_CMPDI2 + def_bool n + +config LIB_UCMPDI2 + def_bool n diff --git a/lib/Makefile b/lib/Makefile index 0166fbc0fa81..d111c6d9224a 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -243,3 +243,11 @@ UBSAN_SANITIZE_ubsan.o := n obj-$(CONFIG_SBITMAP) += sbitmap.o obj-$(CONFIG_PARMAN) += parman.o + +# GCC library routines +obj-$(CONFIG_LIB_ASHLDI3) += ashldi3.o +obj-$(CONFIG_LIB_ASHRDI3) += ashrdi3.o +obj-$(CONFIG_LIB_LSHRDI3) += lshrdi3.o +obj-$(CONFIG_LIB_MULDI3) += multi3.o +obj-$(CONFIG_LIB_CMPDI2) += cmpdi2.o +obj-$(CONFIG_LIB_UCMPDI2) += ucmpdi2.o diff --git a/lib/ashldi3.c b/lib/ashldi3.c new file mode 100644 index 000000000000..5a4c731546b0 --- /dev/null +++ b/lib/ashldi3.c @@ -0,0 +1,45 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + + +#include <linux/export.h> + +#include <lib/libgcc.h> + +long long __ashldi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + w.s.low = 0; + w.s.high = (unsigned int) uu.s.low << -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.low >> bm; + + w.s.low = (unsigned int) uu.s.low << b; + w.s.high = ((unsigned int) uu.s.high << b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__ashldi3); diff --git a/lib/ashrdi3.c b/lib/ashrdi3.c new file mode 100644 index 000000000000..31b34ca7252c --- /dev/null +++ b/lib/ashrdi3.c @@ -0,0 +1,46 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> + +#include <lib/libgcc.h> + +long long __ashrdi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + /* w.s.high = 1..1 or 0..0 */ + w.s.high = + uu.s.high >> 31; + w.s.low = uu.s.high >> -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.high << bm; + + w.s.high = uu.s.high >> b; + w.s.low = ((unsigned int) uu.s.low >> b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__ashrdi3); diff --git a/lib/cmpdi2.c b/lib/cmpdi2.c new file mode 100644 index 000000000000..a0d7701d9386 --- /dev/null +++ b/lib/cmpdi2.c @@ -0,0 +1,42 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> + +#include <lib/libgcc.h> + +word_type __cmpdi2(long long a, long long b) +{ + const DWunion au = { + .ll = a + }; + const DWunion bu = { + .ll = b + }; + + if (au.s.high < bu.s.high) + return 0; + else if (au.s.high > bu.s.high) + return 2; + + if ((unsigned int) au.s.low < (unsigned int) bu.s.low) + return 0; + else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) + return 2; + + return 1; +} +EXPORT_SYMBOL(__cmpdi2); diff --git a/lib/lshrdi3.c b/lib/lshrdi3.c new file mode 100644 index 000000000000..c5a5c23b2e92 --- /dev/null +++ b/lib/lshrdi3.c @@ -0,0 +1,45 @@ +/* + * lib/lshrdi3.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/module.h> +#include <lib/libgcc.h> + +long long __lshrdi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + w.s.high = 0; + w.s.low = (unsigned int) uu.s.high >> -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.high << bm; + + w.s.high = (unsigned int) uu.s.high >> b; + w.s.low = ((unsigned int) uu.s.low >> b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__lshrdi3); diff --git a/lib/muldi3.c b/lib/muldi3.c new file mode 100644 index 000000000000..b361dca557af --- /dev/null +++ b/lib/muldi3.c @@ -0,0 +1,72 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> +#include <lib/libgcc.h> + +#define W_TYPE_SIZE 32 + +#define __ll_B ((unsigned long) 1 << (W_TYPE_SIZE / 2)) +#define __ll_lowpart(t) ((unsigned long) (t) & (__ll_B - 1)) +#define __ll_highpart(t) ((unsigned long) (t) >> (W_TYPE_SIZE / 2)) + +/* If we still don't have umul_ppmm, define it using plain C. */ +#if !defined(umul_ppmm) +#define umul_ppmm(w1, w0, u, v) \ + do { \ + unsigned long __x0, __x1, __x2, __x3; \ + unsigned short __ul, __vl, __uh, __vh; \ + \ + __ul = __ll_lowpart(u); \ + __uh = __ll_highpart(u); \ + __vl = __ll_lowpart(v); \ + __vh = __ll_highpart(v); \ + \ + __x0 = (unsigned long) __ul * __vl; \ + __x1 = (unsigned long) __ul * __vh; \ + __x2 = (unsigned long) __uh * __vl; \ + __x3 = (unsigned long) __uh * __vh; \ + \ + __x1 += __ll_highpart(__x0); /* this can't give carry */\ + __x1 += __x2; /* but this indeed can */ \ + if (__x1 < __x2) /* did we get it? */ \ + __x3 += __ll_B; /* yes, add it in the proper pos */ \ + \ + (w1) = __x3 + __ll_highpart(__x1); \ + (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0);\ + } while (0) +#endif + +#if !defined(__umulsidi3) +#define __umulsidi3(u, v) ({ \ + DWunion __w; \ + umul_ppmm(__w.s.high, __w.s.low, u, v); \ + __w.ll; \ + }) +#endif + +long long __muldi3(long long u, long long v) +{ + const DWunion uu = {.ll = u}; + const DWunion vv = {.ll = v}; + DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)}; + + w.s.high += ((unsigned long) uu.s.low * (unsigned long) vv.s.high + + (unsigned long) uu.s.high * (unsigned long) vv.s.low); + + return w.ll; +} +EXPORT_SYMBOL(__muldi3); diff --git a/lib/ucmpdi2.c b/lib/ucmpdi2.c new file mode 100644 index 000000000000..49a53505c8e3 --- /dev/null +++ b/lib/ucmpdi2.c @@ -0,0 +1,35 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/module.h> +#include <lib/libgcc.h> + +word_type __ucmpdi2(unsigned long long a, unsigned long long b) +{ + const DWunion au = {.ll = a}; + const DWunion bu = {.ll = b}; + + if ((unsigned int) au.s.high < (unsigned int) bu.s.high) + return 0; + else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) + return 2; + if ((unsigned int) au.s.low < (unsigned int) bu.s.low) + return 0; + else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) + return 2; + return 1; +} +EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 1/7] lib: Add shared copies of some GCC library routines 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` [PATCH 1/7] lib: Add shared copies of some GCC library routines Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-24 8:52 ` Matt Redfearn 2017-05-23 22:05 ` [PATCH 2/7] m32r: Use lib/ucmpdi2.c Palmer Dabbelt ` (23 subsequent siblings) 26 siblings, 2 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt Many ports (m32r, microblaze, mips, parisc, score, and sparc) use functionally identical copies of various GCC library routine files, which came up as we were submitting the RISC-V port (which also uses some of these). This patch adds a new copy of these library routine files, which are functionally identical to the various other copies. These are availiable via Kconfig as CONFIG_LIB_$ROUTINE, which currently isn't used anywhere. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- include/lib/libgcc.h | 44 ++++++++++++++++++++++++++++++++ lib/Kconfig | 18 +++++++++++++ lib/Makefile | 8 ++++++ lib/ashldi3.c | 45 ++++++++++++++++++++++++++++++++ lib/ashrdi3.c | 46 +++++++++++++++++++++++++++++++++ lib/cmpdi2.c | 42 ++++++++++++++++++++++++++++++ lib/lshrdi3.c | 45 ++++++++++++++++++++++++++++++++ lib/muldi3.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/ucmpdi2.c | 35 +++++++++++++++++++++++++ 9 files changed, 355 insertions(+) create mode 100644 include/lib/libgcc.h create mode 100644 lib/ashldi3.c create mode 100644 lib/ashrdi3.c create mode 100644 lib/cmpdi2.c create mode 100644 lib/lshrdi3.c create mode 100644 lib/muldi3.c create mode 100644 lib/ucmpdi2.c diff --git a/include/lib/libgcc.h b/include/lib/libgcc.h new file mode 100644 index 000000000000..a5397e34e005 --- /dev/null +++ b/include/lib/libgcc.h @@ -0,0 +1,44 @@ +/* + * include/lib/libgcc.h + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + + +#ifndef __LIB_LIBGCC_H +#define __LIB_LIBGCC_H + +#include <asm/byteorder.h> + +typedef int word_type __attribute__ ((mode (__word__))); + +#ifdef __BIG_ENDIAN +struct DWstruct { + int high, low; +}; +#elif defined(__LITTLE_ENDIAN) +struct DWstruct { + int low, high; +}; +#else +#error I feel sick. +#endif + +typedef union { + struct DWstruct s; + long long ll; +} DWunion; + +#endif /* __ASM_LIBGCC_H */ diff --git a/lib/Kconfig b/lib/Kconfig index 0c8b78a9ae2e..24c08ae53c20 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -565,3 +565,21 @@ config PRIME_NUMBERS tristate endmenu + +config LIB_ASHLDI3 + def_bool n + +config LIB_ASHRDI3 + def_bool n + +config LIB_LSHRDI3 + def_bool n + +config LIB_MULDI3 + def_bool n + +config LIB_CMPDI2 + def_bool n + +config LIB_UCMPDI2 + def_bool n diff --git a/lib/Makefile b/lib/Makefile index 0166fbc0fa81..d111c6d9224a 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -243,3 +243,11 @@ UBSAN_SANITIZE_ubsan.o := n obj-$(CONFIG_SBITMAP) += sbitmap.o obj-$(CONFIG_PARMAN) += parman.o + +# GCC library routines +obj-$(CONFIG_LIB_ASHLDI3) += ashldi3.o +obj-$(CONFIG_LIB_ASHRDI3) += ashrdi3.o +obj-$(CONFIG_LIB_LSHRDI3) += lshrdi3.o +obj-$(CONFIG_LIB_MULDI3) += multi3.o +obj-$(CONFIG_LIB_CMPDI2) += cmpdi2.o +obj-$(CONFIG_LIB_UCMPDI2) += ucmpdi2.o diff --git a/lib/ashldi3.c b/lib/ashldi3.c new file mode 100644 index 000000000000..5a4c731546b0 --- /dev/null +++ b/lib/ashldi3.c @@ -0,0 +1,45 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + + +#include <linux/export.h> + +#include <lib/libgcc.h> + +long long __ashldi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + w.s.low = 0; + w.s.high = (unsigned int) uu.s.low << -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.low >> bm; + + w.s.low = (unsigned int) uu.s.low << b; + w.s.high = ((unsigned int) uu.s.high << b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__ashldi3); diff --git a/lib/ashrdi3.c b/lib/ashrdi3.c new file mode 100644 index 000000000000..31b34ca7252c --- /dev/null +++ b/lib/ashrdi3.c @@ -0,0 +1,46 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> + +#include <lib/libgcc.h> + +long long __ashrdi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + /* w.s.high = 1..1 or 0..0 */ + w.s.high = + uu.s.high >> 31; + w.s.low = uu.s.high >> -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.high << bm; + + w.s.high = uu.s.high >> b; + w.s.low = ((unsigned int) uu.s.low >> b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__ashrdi3); diff --git a/lib/cmpdi2.c b/lib/cmpdi2.c new file mode 100644 index 000000000000..a0d7701d9386 --- /dev/null +++ b/lib/cmpdi2.c @@ -0,0 +1,42 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> + +#include <lib/libgcc.h> + +word_type __cmpdi2(long long a, long long b) +{ + const DWunion au = { + .ll = a + }; + const DWunion bu = { + .ll = b + }; + + if (au.s.high < bu.s.high) + return 0; + else if (au.s.high > bu.s.high) + return 2; + + if ((unsigned int) au.s.low < (unsigned int) bu.s.low) + return 0; + else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) + return 2; + + return 1; +} +EXPORT_SYMBOL(__cmpdi2); diff --git a/lib/lshrdi3.c b/lib/lshrdi3.c new file mode 100644 index 000000000000..c5a5c23b2e92 --- /dev/null +++ b/lib/lshrdi3.c @@ -0,0 +1,45 @@ +/* + * lib/lshrdi3.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/module.h> +#include <lib/libgcc.h> + +long long __lshrdi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + w.s.high = 0; + w.s.low = (unsigned int) uu.s.high >> -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.high << bm; + + w.s.high = (unsigned int) uu.s.high >> b; + w.s.low = ((unsigned int) uu.s.low >> b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__lshrdi3); diff --git a/lib/muldi3.c b/lib/muldi3.c new file mode 100644 index 000000000000..b361dca557af --- /dev/null +++ b/lib/muldi3.c @@ -0,0 +1,72 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> +#include <lib/libgcc.h> + +#define W_TYPE_SIZE 32 + +#define __ll_B ((unsigned long) 1 << (W_TYPE_SIZE / 2)) +#define __ll_lowpart(t) ((unsigned long) (t) & (__ll_B - 1)) +#define __ll_highpart(t) ((unsigned long) (t) >> (W_TYPE_SIZE / 2)) + +/* If we still don't have umul_ppmm, define it using plain C. */ +#if !defined(umul_ppmm) +#define umul_ppmm(w1, w0, u, v) \ + do { \ + unsigned long __x0, __x1, __x2, __x3; \ + unsigned short __ul, __vl, __uh, __vh; \ + \ + __ul = __ll_lowpart(u); \ + __uh = __ll_highpart(u); \ + __vl = __ll_lowpart(v); \ + __vh = __ll_highpart(v); \ + \ + __x0 = (unsigned long) __ul * __vl; \ + __x1 = (unsigned long) __ul * __vh; \ + __x2 = (unsigned long) __uh * __vl; \ + __x3 = (unsigned long) __uh * __vh; \ + \ + __x1 += __ll_highpart(__x0); /* this can't give carry */\ + __x1 += __x2; /* but this indeed can */ \ + if (__x1 < __x2) /* did we get it? */ \ + __x3 += __ll_B; /* yes, add it in the proper pos */ \ + \ + (w1) = __x3 + __ll_highpart(__x1); \ + (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0);\ + } while (0) +#endif + +#if !defined(__umulsidi3) +#define __umulsidi3(u, v) ({ \ + DWunion __w; \ + umul_ppmm(__w.s.high, __w.s.low, u, v); \ + __w.ll; \ + }) +#endif + +long long __muldi3(long long u, long long v) +{ + const DWunion uu = {.ll = u}; + const DWunion vv = {.ll = v}; + DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)}; + + w.s.high += ((unsigned long) uu.s.low * (unsigned long) vv.s.high + + (unsigned long) uu.s.high * (unsigned long) vv.s.low); + + return w.ll; +} +EXPORT_SYMBOL(__muldi3); diff --git a/lib/ucmpdi2.c b/lib/ucmpdi2.c new file mode 100644 index 000000000000..49a53505c8e3 --- /dev/null +++ b/lib/ucmpdi2.c @@ -0,0 +1,35 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/module.h> +#include <lib/libgcc.h> + +word_type __ucmpdi2(unsigned long long a, unsigned long long b) +{ + const DWunion au = {.ll = a}; + const DWunion bu = {.ll = b}; + + if ((unsigned int) au.s.high < (unsigned int) bu.s.high) + return 0; + else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) + return 2; + if ((unsigned int) au.s.low < (unsigned int) bu.s.low) + return 0; + else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) + return 2; + return 1; +} +EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 1/7] lib: Add shared copies of some GCC library routines 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-24 8:52 ` Matt Redfearn 1 sibling, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt Many ports (m32r, microblaze, mips, parisc, score, and sparc) use functionally identical copies of various GCC library routine files, which came up as we were submitting the RISC-V port (which also uses some of these). This patch adds a new copy of these library routine files, which are functionally identical to the various other copies. These are availiable via Kconfig as CONFIG_LIB_$ROUTINE, which currently isn't used anywhere. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- include/lib/libgcc.h | 44 ++++++++++++++++++++++++++++++++ lib/Kconfig | 18 +++++++++++++ lib/Makefile | 8 ++++++ lib/ashldi3.c | 45 ++++++++++++++++++++++++++++++++ lib/ashrdi3.c | 46 +++++++++++++++++++++++++++++++++ lib/cmpdi2.c | 42 ++++++++++++++++++++++++++++++ lib/lshrdi3.c | 45 ++++++++++++++++++++++++++++++++ lib/muldi3.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/ucmpdi2.c | 35 +++++++++++++++++++++++++ 9 files changed, 355 insertions(+) create mode 100644 include/lib/libgcc.h create mode 100644 lib/ashldi3.c create mode 100644 lib/ashrdi3.c create mode 100644 lib/cmpdi2.c create mode 100644 lib/lshrdi3.c create mode 100644 lib/muldi3.c create mode 100644 lib/ucmpdi2.c diff --git a/include/lib/libgcc.h b/include/lib/libgcc.h new file mode 100644 index 000000000000..a5397e34e005 --- /dev/null +++ b/include/lib/libgcc.h @@ -0,0 +1,44 @@ +/* + * include/lib/libgcc.h + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + + +#ifndef __LIB_LIBGCC_H +#define __LIB_LIBGCC_H + +#include <asm/byteorder.h> + +typedef int word_type __attribute__ ((mode (__word__))); + +#ifdef __BIG_ENDIAN +struct DWstruct { + int high, low; +}; +#elif defined(__LITTLE_ENDIAN) +struct DWstruct { + int low, high; +}; +#else +#error I feel sick. +#endif + +typedef union { + struct DWstruct s; + long long ll; +} DWunion; + +#endif /* __ASM_LIBGCC_H */ diff --git a/lib/Kconfig b/lib/Kconfig index 0c8b78a9ae2e..24c08ae53c20 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -565,3 +565,21 @@ config PRIME_NUMBERS tristate endmenu + +config LIB_ASHLDI3 + def_bool n + +config LIB_ASHRDI3 + def_bool n + +config LIB_LSHRDI3 + def_bool n + +config LIB_MULDI3 + def_bool n + +config LIB_CMPDI2 + def_bool n + +config LIB_UCMPDI2 + def_bool n diff --git a/lib/Makefile b/lib/Makefile index 0166fbc0fa81..d111c6d9224a 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -243,3 +243,11 @@ UBSAN_SANITIZE_ubsan.o := n obj-$(CONFIG_SBITMAP) += sbitmap.o obj-$(CONFIG_PARMAN) += parman.o + +# GCC library routines +obj-$(CONFIG_LIB_ASHLDI3) += ashldi3.o +obj-$(CONFIG_LIB_ASHRDI3) += ashrdi3.o +obj-$(CONFIG_LIB_LSHRDI3) += lshrdi3.o +obj-$(CONFIG_LIB_MULDI3) += multi3.o +obj-$(CONFIG_LIB_CMPDI2) += cmpdi2.o +obj-$(CONFIG_LIB_UCMPDI2) += ucmpdi2.o diff --git a/lib/ashldi3.c b/lib/ashldi3.c new file mode 100644 index 000000000000..5a4c731546b0 --- /dev/null +++ b/lib/ashldi3.c @@ -0,0 +1,45 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + + +#include <linux/export.h> + +#include <lib/libgcc.h> + +long long __ashldi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + w.s.low = 0; + w.s.high = (unsigned int) uu.s.low << -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.low >> bm; + + w.s.low = (unsigned int) uu.s.low << b; + w.s.high = ((unsigned int) uu.s.high << b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__ashldi3); diff --git a/lib/ashrdi3.c b/lib/ashrdi3.c new file mode 100644 index 000000000000..31b34ca7252c --- /dev/null +++ b/lib/ashrdi3.c @@ -0,0 +1,46 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> + +#include <lib/libgcc.h> + +long long __ashrdi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + /* w.s.high = 1..1 or 0..0 */ + w.s.high = + uu.s.high >> 31; + w.s.low = uu.s.high >> -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.high << bm; + + w.s.high = uu.s.high >> b; + w.s.low = ((unsigned int) uu.s.low >> b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__ashrdi3); diff --git a/lib/cmpdi2.c b/lib/cmpdi2.c new file mode 100644 index 000000000000..a0d7701d9386 --- /dev/null +++ b/lib/cmpdi2.c @@ -0,0 +1,42 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> + +#include <lib/libgcc.h> + +word_type __cmpdi2(long long a, long long b) +{ + const DWunion au = { + .ll = a + }; + const DWunion bu = { + .ll = b + }; + + if (au.s.high < bu.s.high) + return 0; + else if (au.s.high > bu.s.high) + return 2; + + if ((unsigned int) au.s.low < (unsigned int) bu.s.low) + return 0; + else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) + return 2; + + return 1; +} +EXPORT_SYMBOL(__cmpdi2); diff --git a/lib/lshrdi3.c b/lib/lshrdi3.c new file mode 100644 index 000000000000..c5a5c23b2e92 --- /dev/null +++ b/lib/lshrdi3.c @@ -0,0 +1,45 @@ +/* + * lib/lshrdi3.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/module.h> +#include <lib/libgcc.h> + +long long __lshrdi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + w.s.high = 0; + w.s.low = (unsigned int) uu.s.high >> -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.high << bm; + + w.s.high = (unsigned int) uu.s.high >> b; + w.s.low = ((unsigned int) uu.s.low >> b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__lshrdi3); diff --git a/lib/muldi3.c b/lib/muldi3.c new file mode 100644 index 000000000000..b361dca557af --- /dev/null +++ b/lib/muldi3.c @@ -0,0 +1,72 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> +#include <lib/libgcc.h> + +#define W_TYPE_SIZE 32 + +#define __ll_B ((unsigned long) 1 << (W_TYPE_SIZE / 2)) +#define __ll_lowpart(t) ((unsigned long) (t) & (__ll_B - 1)) +#define __ll_highpart(t) ((unsigned long) (t) >> (W_TYPE_SIZE / 2)) + +/* If we still don't have umul_ppmm, define it using plain C. */ +#if !defined(umul_ppmm) +#define umul_ppmm(w1, w0, u, v) \ + do { \ + unsigned long __x0, __x1, __x2, __x3; \ + unsigned short __ul, __vl, __uh, __vh; \ + \ + __ul = __ll_lowpart(u); \ + __uh = __ll_highpart(u); \ + __vl = __ll_lowpart(v); \ + __vh = __ll_highpart(v); \ + \ + __x0 = (unsigned long) __ul * __vl; \ + __x1 = (unsigned long) __ul * __vh; \ + __x2 = (unsigned long) __uh * __vl; \ + __x3 = (unsigned long) __uh * __vh; \ + \ + __x1 += __ll_highpart(__x0); /* this can't give carry */\ + __x1 += __x2; /* but this indeed can */ \ + if (__x1 < __x2) /* did we get it? */ \ + __x3 += __ll_B; /* yes, add it in the proper pos */ \ + \ + (w1) = __x3 + __ll_highpart(__x1); \ + (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0);\ + } while (0) +#endif + +#if !defined(__umulsidi3) +#define __umulsidi3(u, v) ({ \ + DWunion __w; \ + umul_ppmm(__w.s.high, __w.s.low, u, v); \ + __w.ll; \ + }) +#endif + +long long __muldi3(long long u, long long v) +{ + const DWunion uu = {.ll = u}; + const DWunion vv = {.ll = v}; + DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)}; + + w.s.high += ((unsigned long) uu.s.low * (unsigned long) vv.s.high + + (unsigned long) uu.s.high * (unsigned long) vv.s.low); + + return w.ll; +} +EXPORT_SYMBOL(__muldi3); diff --git a/lib/ucmpdi2.c b/lib/ucmpdi2.c new file mode 100644 index 000000000000..49a53505c8e3 --- /dev/null +++ b/lib/ucmpdi2.c @@ -0,0 +1,35 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/module.h> +#include <lib/libgcc.h> + +word_type __ucmpdi2(unsigned long long a, unsigned long long b) +{ + const DWunion au = {.ll = a}; + const DWunion bu = {.ll = b}; + + if ((unsigned int) au.s.high < (unsigned int) bu.s.high) + return 0; + else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) + return 2; + if ((unsigned int) au.s.low < (unsigned int) bu.s.low) + return 0; + else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) + return 2; + return 1; +} +EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* Re: [PATCH 1/7] lib: Add shared copies of some GCC library routines 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-24 8:52 ` Matt Redfearn 2017-05-24 8:52 ` Matt Redfearn 2017-06-03 2:18 ` Palmer Dabbelt 1 sibling, 2 replies; 93+ messages in thread From: Matt Redfearn @ 2017-05-24 8:52 UTC (permalink / raw) To: Palmer Dabbelt, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Hi Palmer On 23/05/17 23:05, Palmer Dabbelt wrote: > Many ports (m32r, microblaze, mips, parisc, score, and sparc) use > functionally identical copies of various GCC library routine files, > which came up as we were submitting the RISC-V port (which also uses > some of these). > > This patch adds a new copy of these library routine files, which are > functionally identical to the various other copies. These are > availiable via Kconfig as CONFIG_LIB_$ROUTINE, which currently isn't > used anywhere. Note that, on MIPS, we had to mark the compiler intrinsics as notrace (see commit aedcfbe06558a9f53002e82d5be64c6c94687726) because if the compiler requires the intrinsic in the ftrace path, it then tries to trace itself leading to infinite recursion and stack overflow. So I'd suggest you mark the generic versions notrace as well. Thanks, Matt > > Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> > --- > include/lib/libgcc.h | 44 ++++++++++++++++++++++++++++++++ > lib/Kconfig | 18 +++++++++++++ > lib/Makefile | 8 ++++++ > lib/ashldi3.c | 45 ++++++++++++++++++++++++++++++++ > lib/ashrdi3.c | 46 +++++++++++++++++++++++++++++++++ > lib/cmpdi2.c | 42 ++++++++++++++++++++++++++++++ > lib/lshrdi3.c | 45 ++++++++++++++++++++++++++++++++ > lib/muldi3.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > lib/ucmpdi2.c | 35 +++++++++++++++++++++++++ > 9 files changed, 355 insertions(+) > create mode 100644 include/lib/libgcc.h > create mode 100644 lib/ashldi3.c > create mode 100644 lib/ashrdi3.c > create mode 100644 lib/cmpdi2.c > create mode 100644 lib/lshrdi3.c > create mode 100644 lib/muldi3.c > create mode 100644 lib/ucmpdi2.c > > diff --git a/include/lib/libgcc.h b/include/lib/libgcc.h > new file mode 100644 > index 000000000000..a5397e34e005 > --- /dev/null > +++ b/include/lib/libgcc.h > @@ -0,0 +1,44 @@ > +/* > + * include/lib/libgcc.h > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, see the file COPYING, or write > + * to the Free Software Foundation, Inc. > + */ > + > + > +#ifndef __LIB_LIBGCC_H > +#define __LIB_LIBGCC_H > + > +#include <asm/byteorder.h> > + > +typedef int word_type __attribute__ ((mode (__word__))); > + > +#ifdef __BIG_ENDIAN > +struct DWstruct { > + int high, low; > +}; > +#elif defined(__LITTLE_ENDIAN) > +struct DWstruct { > + int low, high; > +}; > +#else > +#error I feel sick. > +#endif > + > +typedef union { > + struct DWstruct s; > + long long ll; > +} DWunion; > + > +#endif /* __ASM_LIBGCC_H */ > diff --git a/lib/Kconfig b/lib/Kconfig > index 0c8b78a9ae2e..24c08ae53c20 100644 > --- a/lib/Kconfig > +++ b/lib/Kconfig > @@ -565,3 +565,21 @@ config PRIME_NUMBERS > tristate > > endmenu > + > +config LIB_ASHLDI3 > + def_bool n > + > +config LIB_ASHRDI3 > + def_bool n > + > +config LIB_LSHRDI3 > + def_bool n > + > +config LIB_MULDI3 > + def_bool n > + > +config LIB_CMPDI2 > + def_bool n > + > +config LIB_UCMPDI2 > + def_bool n > diff --git a/lib/Makefile b/lib/Makefile > index 0166fbc0fa81..d111c6d9224a 100644 > --- a/lib/Makefile > +++ b/lib/Makefile > @@ -243,3 +243,11 @@ UBSAN_SANITIZE_ubsan.o := n > obj-$(CONFIG_SBITMAP) += sbitmap.o > > obj-$(CONFIG_PARMAN) += parman.o > + > +# GCC library routines > +obj-$(CONFIG_LIB_ASHLDI3) += ashldi3.o > +obj-$(CONFIG_LIB_ASHRDI3) += ashrdi3.o > +obj-$(CONFIG_LIB_LSHRDI3) += lshrdi3.o > +obj-$(CONFIG_LIB_MULDI3) += multi3.o > +obj-$(CONFIG_LIB_CMPDI2) += cmpdi2.o > +obj-$(CONFIG_LIB_UCMPDI2) += ucmpdi2.o > diff --git a/lib/ashldi3.c b/lib/ashldi3.c > new file mode 100644 > index 000000000000..5a4c731546b0 > --- /dev/null > +++ b/lib/ashldi3.c > @@ -0,0 +1,45 @@ > +/* > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, see the file COPYING, or write > + * to the Free Software Foundation, Inc. > + */ > + > + > +#include <linux/export.h> > + > +#include <lib/libgcc.h> > + > +long long __ashldi3(long long u, word_type b) > +{ > + DWunion uu, w; > + word_type bm; > + > + if (b == 0) > + return u; > + > + uu.ll = u; > + bm = 32 - b; > + > + if (bm <= 0) { > + w.s.low = 0; > + w.s.high = (unsigned int) uu.s.low << -bm; > + } else { > + const unsigned int carries = (unsigned int) uu.s.low >> bm; > + > + w.s.low = (unsigned int) uu.s.low << b; > + w.s.high = ((unsigned int) uu.s.high << b) | carries; > + } > + > + return w.ll; > +} > +EXPORT_SYMBOL(__ashldi3); > diff --git a/lib/ashrdi3.c b/lib/ashrdi3.c > new file mode 100644 > index 000000000000..31b34ca7252c > --- /dev/null > +++ b/lib/ashrdi3.c > @@ -0,0 +1,46 @@ > +/* > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, see the file COPYING, or write > + * to the Free Software Foundation, Inc. > + */ > + > +#include <linux/export.h> > + > +#include <lib/libgcc.h> > + > +long long __ashrdi3(long long u, word_type b) > +{ > + DWunion uu, w; > + word_type bm; > + > + if (b == 0) > + return u; > + > + uu.ll = u; > + bm = 32 - b; > + > + if (bm <= 0) { > + /* w.s.high = 1..1 or 0..0 */ > + w.s.high = > + uu.s.high >> 31; > + w.s.low = uu.s.high >> -bm; > + } else { > + const unsigned int carries = (unsigned int) uu.s.high << bm; > + > + w.s.high = uu.s.high >> b; > + w.s.low = ((unsigned int) uu.s.low >> b) | carries; > + } > + > + return w.ll; > +} > +EXPORT_SYMBOL(__ashrdi3); > diff --git a/lib/cmpdi2.c b/lib/cmpdi2.c > new file mode 100644 > index 000000000000..a0d7701d9386 > --- /dev/null > +++ b/lib/cmpdi2.c > @@ -0,0 +1,42 @@ > +/* > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, see the file COPYING, or write > + * to the Free Software Foundation, Inc. > + */ > + > +#include <linux/export.h> > + > +#include <lib/libgcc.h> > + > +word_type __cmpdi2(long long a, long long b) > +{ > + const DWunion au = { > + .ll = a > + }; > + const DWunion bu = { > + .ll = b > + }; > + > + if (au.s.high < bu.s.high) > + return 0; > + else if (au.s.high > bu.s.high) > + return 2; > + > + if ((unsigned int) au.s.low < (unsigned int) bu.s.low) > + return 0; > + else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) > + return 2; > + > + return 1; > +} > +EXPORT_SYMBOL(__cmpdi2); > diff --git a/lib/lshrdi3.c b/lib/lshrdi3.c > new file mode 100644 > index 000000000000..c5a5c23b2e92 > --- /dev/null > +++ b/lib/lshrdi3.c > @@ -0,0 +1,45 @@ > +/* > + * lib/lshrdi3.c > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, see the file COPYING, or write > + * to the Free Software Foundation, Inc. > + */ > + > +#include <linux/module.h> > +#include <lib/libgcc.h> > + > +long long __lshrdi3(long long u, word_type b) > +{ > + DWunion uu, w; > + word_type bm; > + > + if (b == 0) > + return u; > + > + uu.ll = u; > + bm = 32 - b; > + > + if (bm <= 0) { > + w.s.high = 0; > + w.s.low = (unsigned int) uu.s.high >> -bm; > + } else { > + const unsigned int carries = (unsigned int) uu.s.high << bm; > + > + w.s.high = (unsigned int) uu.s.high >> b; > + w.s.low = ((unsigned int) uu.s.low >> b) | carries; > + } > + > + return w.ll; > +} > +EXPORT_SYMBOL(__lshrdi3); > diff --git a/lib/muldi3.c b/lib/muldi3.c > new file mode 100644 > index 000000000000..b361dca557af > --- /dev/null > +++ b/lib/muldi3.c > @@ -0,0 +1,72 @@ > +/* > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, see the file COPYING, or write > + * to the Free Software Foundation, Inc. > + */ > + > +#include <linux/export.h> > +#include <lib/libgcc.h> > + > +#define W_TYPE_SIZE 32 > + > +#define __ll_B ((unsigned long) 1 << (W_TYPE_SIZE / 2)) > +#define __ll_lowpart(t) ((unsigned long) (t) & (__ll_B - 1)) > +#define __ll_highpart(t) ((unsigned long) (t) >> (W_TYPE_SIZE / 2)) > + > +/* If we still don't have umul_ppmm, define it using plain C. */ > +#if !defined(umul_ppmm) > +#define umul_ppmm(w1, w0, u, v) \ > + do { \ > + unsigned long __x0, __x1, __x2, __x3; \ > + unsigned short __ul, __vl, __uh, __vh; \ > + \ > + __ul = __ll_lowpart(u); \ > + __uh = __ll_highpart(u); \ > + __vl = __ll_lowpart(v); \ > + __vh = __ll_highpart(v); \ > + \ > + __x0 = (unsigned long) __ul * __vl; \ > + __x1 = (unsigned long) __ul * __vh; \ > + __x2 = (unsigned long) __uh * __vl; \ > + __x3 = (unsigned long) __uh * __vh; \ > + \ > + __x1 += __ll_highpart(__x0); /* this can't give carry */\ > + __x1 += __x2; /* but this indeed can */ \ > + if (__x1 < __x2) /* did we get it? */ \ > + __x3 += __ll_B; /* yes, add it in the proper pos */ \ > + \ > + (w1) = __x3 + __ll_highpart(__x1); \ > + (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0);\ > + } while (0) > +#endif > + > +#if !defined(__umulsidi3) > +#define __umulsidi3(u, v) ({ \ > + DWunion __w; \ > + umul_ppmm(__w.s.high, __w.s.low, u, v); \ > + __w.ll; \ > + }) > +#endif > + > +long long __muldi3(long long u, long long v) > +{ > + const DWunion uu = {.ll = u}; > + const DWunion vv = {.ll = v}; > + DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)}; > + > + w.s.high += ((unsigned long) uu.s.low * (unsigned long) vv.s.high > + + (unsigned long) uu.s.high * (unsigned long) vv.s.low); > + > + return w.ll; > +} > +EXPORT_SYMBOL(__muldi3); > diff --git a/lib/ucmpdi2.c b/lib/ucmpdi2.c > new file mode 100644 > index 000000000000..49a53505c8e3 > --- /dev/null > +++ b/lib/ucmpdi2.c > @@ -0,0 +1,35 @@ > +/* > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, see the file COPYING, or write > + * to the Free Software Foundation, Inc. > + */ > + > +#include <linux/module.h> > +#include <lib/libgcc.h> > + > +word_type __ucmpdi2(unsigned long long a, unsigned long long b) > +{ > + const DWunion au = {.ll = a}; > + const DWunion bu = {.ll = b}; > + > + if ((unsigned int) au.s.high < (unsigned int) bu.s.high) > + return 0; > + else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) > + return 2; > + if ((unsigned int) au.s.low < (unsigned int) bu.s.low) > + return 0; > + else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) > + return 2; > + return 1; > +} > +EXPORT_SYMBOL(__ucmpdi2); ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 1/7] lib: Add shared copies of some GCC library routines 2017-05-24 8:52 ` Matt Redfearn @ 2017-05-24 8:52 ` Matt Redfearn 2017-06-03 2:18 ` Palmer Dabbelt 1 sibling, 0 replies; 93+ messages in thread From: Matt Redfearn @ 2017-05-24 8:52 UTC (permalink / raw) To: Palmer Dabbelt, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Hi Palmer On 23/05/17 23:05, Palmer Dabbelt wrote: > Many ports (m32r, microblaze, mips, parisc, score, and sparc) use > functionally identical copies of various GCC library routine files, > which came up as we were submitting the RISC-V port (which also uses > some of these). > > This patch adds a new copy of these library routine files, which are > functionally identical to the various other copies. These are > availiable via Kconfig as CONFIG_LIB_$ROUTINE, which currently isn't > used anywhere. Note that, on MIPS, we had to mark the compiler intrinsics as notrace (see commit aedcfbe06558a9f53002e82d5be64c6c94687726) because if the compiler requires the intrinsic in the ftrace path, it then tries to trace itself leading to infinite recursion and stack overflow. So I'd suggest you mark the generic versions notrace as well. Thanks, Matt > > Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> > --- > include/lib/libgcc.h | 44 ++++++++++++++++++++++++++++++++ > lib/Kconfig | 18 +++++++++++++ > lib/Makefile | 8 ++++++ > lib/ashldi3.c | 45 ++++++++++++++++++++++++++++++++ > lib/ashrdi3.c | 46 +++++++++++++++++++++++++++++++++ > lib/cmpdi2.c | 42 ++++++++++++++++++++++++++++++ > lib/lshrdi3.c | 45 ++++++++++++++++++++++++++++++++ > lib/muldi3.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > lib/ucmpdi2.c | 35 +++++++++++++++++++++++++ > 9 files changed, 355 insertions(+) > create mode 100644 include/lib/libgcc.h > create mode 100644 lib/ashldi3.c > create mode 100644 lib/ashrdi3.c > create mode 100644 lib/cmpdi2.c > create mode 100644 lib/lshrdi3.c > create mode 100644 lib/muldi3.c > create mode 100644 lib/ucmpdi2.c > > diff --git a/include/lib/libgcc.h b/include/lib/libgcc.h > new file mode 100644 > index 000000000000..a5397e34e005 > --- /dev/null > +++ b/include/lib/libgcc.h > @@ -0,0 +1,44 @@ > +/* > + * include/lib/libgcc.h > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, see the file COPYING, or write > + * to the Free Software Foundation, Inc. > + */ > + > + > +#ifndef __LIB_LIBGCC_H > +#define __LIB_LIBGCC_H > + > +#include <asm/byteorder.h> > + > +typedef int word_type __attribute__ ((mode (__word__))); > + > +#ifdef __BIG_ENDIAN > +struct DWstruct { > + int high, low; > +}; > +#elif defined(__LITTLE_ENDIAN) > +struct DWstruct { > + int low, high; > +}; > +#else > +#error I feel sick. > +#endif > + > +typedef union { > + struct DWstruct s; > + long long ll; > +} DWunion; > + > +#endif /* __ASM_LIBGCC_H */ > diff --git a/lib/Kconfig b/lib/Kconfig > index 0c8b78a9ae2e..24c08ae53c20 100644 > --- a/lib/Kconfig > +++ b/lib/Kconfig > @@ -565,3 +565,21 @@ config PRIME_NUMBERS > tristate > > endmenu > + > +config LIB_ASHLDI3 > + def_bool n > + > +config LIB_ASHRDI3 > + def_bool n > + > +config LIB_LSHRDI3 > + def_bool n > + > +config LIB_MULDI3 > + def_bool n > + > +config LIB_CMPDI2 > + def_bool n > + > +config LIB_UCMPDI2 > + def_bool n > diff --git a/lib/Makefile b/lib/Makefile > index 0166fbc0fa81..d111c6d9224a 100644 > --- a/lib/Makefile > +++ b/lib/Makefile > @@ -243,3 +243,11 @@ UBSAN_SANITIZE_ubsan.o := n > obj-$(CONFIG_SBITMAP) += sbitmap.o > > obj-$(CONFIG_PARMAN) += parman.o > + > +# GCC library routines > +obj-$(CONFIG_LIB_ASHLDI3) += ashldi3.o > +obj-$(CONFIG_LIB_ASHRDI3) += ashrdi3.o > +obj-$(CONFIG_LIB_LSHRDI3) += lshrdi3.o > +obj-$(CONFIG_LIB_MULDI3) += multi3.o > +obj-$(CONFIG_LIB_CMPDI2) += cmpdi2.o > +obj-$(CONFIG_LIB_UCMPDI2) += ucmpdi2.o > diff --git a/lib/ashldi3.c b/lib/ashldi3.c > new file mode 100644 > index 000000000000..5a4c731546b0 > --- /dev/null > +++ b/lib/ashldi3.c > @@ -0,0 +1,45 @@ > +/* > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, see the file COPYING, or write > + * to the Free Software Foundation, Inc. > + */ > + > + > +#include <linux/export.h> > + > +#include <lib/libgcc.h> > + > +long long __ashldi3(long long u, word_type b) > +{ > + DWunion uu, w; > + word_type bm; > + > + if (b == 0) > + return u; > + > + uu.ll = u; > + bm = 32 - b; > + > + if (bm <= 0) { > + w.s.low = 0; > + w.s.high = (unsigned int) uu.s.low << -bm; > + } else { > + const unsigned int carries = (unsigned int) uu.s.low >> bm; > + > + w.s.low = (unsigned int) uu.s.low << b; > + w.s.high = ((unsigned int) uu.s.high << b) | carries; > + } > + > + return w.ll; > +} > +EXPORT_SYMBOL(__ashldi3); > diff --git a/lib/ashrdi3.c b/lib/ashrdi3.c > new file mode 100644 > index 000000000000..31b34ca7252c > --- /dev/null > +++ b/lib/ashrdi3.c > @@ -0,0 +1,46 @@ > +/* > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, see the file COPYING, or write > + * to the Free Software Foundation, Inc. > + */ > + > +#include <linux/export.h> > + > +#include <lib/libgcc.h> > + > +long long __ashrdi3(long long u, word_type b) > +{ > + DWunion uu, w; > + word_type bm; > + > + if (b == 0) > + return u; > + > + uu.ll = u; > + bm = 32 - b; > + > + if (bm <= 0) { > + /* w.s.high = 1..1 or 0..0 */ > + w.s.high = > + uu.s.high >> 31; > + w.s.low = uu.s.high >> -bm; > + } else { > + const unsigned int carries = (unsigned int) uu.s.high << bm; > + > + w.s.high = uu.s.high >> b; > + w.s.low = ((unsigned int) uu.s.low >> b) | carries; > + } > + > + return w.ll; > +} > +EXPORT_SYMBOL(__ashrdi3); > diff --git a/lib/cmpdi2.c b/lib/cmpdi2.c > new file mode 100644 > index 000000000000..a0d7701d9386 > --- /dev/null > +++ b/lib/cmpdi2.c > @@ -0,0 +1,42 @@ > +/* > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, see the file COPYING, or write > + * to the Free Software Foundation, Inc. > + */ > + > +#include <linux/export.h> > + > +#include <lib/libgcc.h> > + > +word_type __cmpdi2(long long a, long long b) > +{ > + const DWunion au = { > + .ll = a > + }; > + const DWunion bu = { > + .ll = b > + }; > + > + if (au.s.high < bu.s.high) > + return 0; > + else if (au.s.high > bu.s.high) > + return 2; > + > + if ((unsigned int) au.s.low < (unsigned int) bu.s.low) > + return 0; > + else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) > + return 2; > + > + return 1; > +} > +EXPORT_SYMBOL(__cmpdi2); > diff --git a/lib/lshrdi3.c b/lib/lshrdi3.c > new file mode 100644 > index 000000000000..c5a5c23b2e92 > --- /dev/null > +++ b/lib/lshrdi3.c > @@ -0,0 +1,45 @@ > +/* > + * lib/lshrdi3.c > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, see the file COPYING, or write > + * to the Free Software Foundation, Inc. > + */ > + > +#include <linux/module.h> > +#include <lib/libgcc.h> > + > +long long __lshrdi3(long long u, word_type b) > +{ > + DWunion uu, w; > + word_type bm; > + > + if (b == 0) > + return u; > + > + uu.ll = u; > + bm = 32 - b; > + > + if (bm <= 0) { > + w.s.high = 0; > + w.s.low = (unsigned int) uu.s.high >> -bm; > + } else { > + const unsigned int carries = (unsigned int) uu.s.high << bm; > + > + w.s.high = (unsigned int) uu.s.high >> b; > + w.s.low = ((unsigned int) uu.s.low >> b) | carries; > + } > + > + return w.ll; > +} > +EXPORT_SYMBOL(__lshrdi3); > diff --git a/lib/muldi3.c b/lib/muldi3.c > new file mode 100644 > index 000000000000..b361dca557af > --- /dev/null > +++ b/lib/muldi3.c > @@ -0,0 +1,72 @@ > +/* > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, see the file COPYING, or write > + * to the Free Software Foundation, Inc. > + */ > + > +#include <linux/export.h> > +#include <lib/libgcc.h> > + > +#define W_TYPE_SIZE 32 > + > +#define __ll_B ((unsigned long) 1 << (W_TYPE_SIZE / 2)) > +#define __ll_lowpart(t) ((unsigned long) (t) & (__ll_B - 1)) > +#define __ll_highpart(t) ((unsigned long) (t) >> (W_TYPE_SIZE / 2)) > + > +/* If we still don't have umul_ppmm, define it using plain C. */ > +#if !defined(umul_ppmm) > +#define umul_ppmm(w1, w0, u, v) \ > + do { \ > + unsigned long __x0, __x1, __x2, __x3; \ > + unsigned short __ul, __vl, __uh, __vh; \ > + \ > + __ul = __ll_lowpart(u); \ > + __uh = __ll_highpart(u); \ > + __vl = __ll_lowpart(v); \ > + __vh = __ll_highpart(v); \ > + \ > + __x0 = (unsigned long) __ul * __vl; \ > + __x1 = (unsigned long) __ul * __vh; \ > + __x2 = (unsigned long) __uh * __vl; \ > + __x3 = (unsigned long) __uh * __vh; \ > + \ > + __x1 += __ll_highpart(__x0); /* this can't give carry */\ > + __x1 += __x2; /* but this indeed can */ \ > + if (__x1 < __x2) /* did we get it? */ \ > + __x3 += __ll_B; /* yes, add it in the proper pos */ \ > + \ > + (w1) = __x3 + __ll_highpart(__x1); \ > + (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0);\ > + } while (0) > +#endif > + > +#if !defined(__umulsidi3) > +#define __umulsidi3(u, v) ({ \ > + DWunion __w; \ > + umul_ppmm(__w.s.high, __w.s.low, u, v); \ > + __w.ll; \ > + }) > +#endif > + > +long long __muldi3(long long u, long long v) > +{ > + const DWunion uu = {.ll = u}; > + const DWunion vv = {.ll = v}; > + DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)}; > + > + w.s.high += ((unsigned long) uu.s.low * (unsigned long) vv.s.high > + + (unsigned long) uu.s.high * (unsigned long) vv.s.low); > + > + return w.ll; > +} > +EXPORT_SYMBOL(__muldi3); > diff --git a/lib/ucmpdi2.c b/lib/ucmpdi2.c > new file mode 100644 > index 000000000000..49a53505c8e3 > --- /dev/null > +++ b/lib/ucmpdi2.c > @@ -0,0 +1,35 @@ > +/* > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, see the file COPYING, or write > + * to the Free Software Foundation, Inc. > + */ > + > +#include <linux/module.h> > +#include <lib/libgcc.h> > + > +word_type __ucmpdi2(unsigned long long a, unsigned long long b) > +{ > + const DWunion au = {.ll = a}; > + const DWunion bu = {.ll = b}; > + > + if ((unsigned int) au.s.high < (unsigned int) bu.s.high) > + return 0; > + else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) > + return 2; > + if ((unsigned int) au.s.low < (unsigned int) bu.s.low) > + return 0; > + else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) > + return 2; > + return 1; > +} > +EXPORT_SYMBOL(__ucmpdi2); ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 1/7] lib: Add shared copies of some GCC library routines 2017-05-24 8:52 ` Matt Redfearn 2017-05-24 8:52 ` Matt Redfearn @ 2017-06-03 2:18 ` Palmer Dabbelt 2017-06-03 2:18 ` Palmer Dabbelt 1 sibling, 1 reply; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-03 2:18 UTC (permalink / raw) To: matt.redfearn Cc: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch On Wed, 24 May 2017 01:52:13 PDT (-0700), matt.redfearn@imgtec.com wrote: > Hi Palmer > > > On 23/05/17 23:05, Palmer Dabbelt wrote: >> Many ports (m32r, microblaze, mips, parisc, score, and sparc) use >> functionally identical copies of various GCC library routine files, >> which came up as we were submitting the RISC-V port (which also uses >> some of these). >> >> This patch adds a new copy of these library routine files, which are >> functionally identical to the various other copies. These are >> availiable via Kconfig as CONFIG_LIB_$ROUTINE, which currently isn't >> used anywhere. > > Note that, on MIPS, we had to mark the compiler intrinsics as notrace > (see commit aedcfbe06558a9f53002e82d5be64c6c94687726) because if the > compiler requires the intrinsic in the ftrace path, it then tries to > trace itself leading to infinite recursion and stack overflow. So I'd > suggest you mark the generic versions notrace as well. Sorry, I didn't notice that. I got a bit swamped responding to the RISC-V port's code reviews, but assuming nobody has merged any of this I'll submit a v2 patch set that fixes this (and some other errors I believe I introduced) once I get through all my email. Thanks! ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 1/7] lib: Add shared copies of some GCC library routines 2017-06-03 2:18 ` Palmer Dabbelt @ 2017-06-03 2:18 ` Palmer Dabbelt 0 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-03 2:18 UTC (permalink / raw) To: matt.redfearn Cc: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch On Wed, 24 May 2017 01:52:13 PDT (-0700), matt.redfearn@imgtec.com wrote: > Hi Palmer > > > On 23/05/17 23:05, Palmer Dabbelt wrote: >> Many ports (m32r, microblaze, mips, parisc, score, and sparc) use >> functionally identical copies of various GCC library routine files, >> which came up as we were submitting the RISC-V port (which also uses >> some of these). >> >> This patch adds a new copy of these library routine files, which are >> functionally identical to the various other copies. These are >> availiable via Kconfig as CONFIG_LIB_$ROUTINE, which currently isn't >> used anywhere. > > Note that, on MIPS, we had to mark the compiler intrinsics as notrace > (see commit aedcfbe06558a9f53002e82d5be64c6c94687726) because if the > compiler requires the intrinsic in the ftrace path, it then tries to > trace itself leading to infinite recursion and stack overflow. So I'd > suggest you mark the generic versions notrace as well. Sorry, I didn't notice that. I got a bit swamped responding to the RISC-V port's code reviews, but assuming nobody has merged any of this I'll submit a v2 patch set that fixes this (and some other errors I believe I introduced) once I get through all my email. Thanks! ^ permalink raw reply [flat|nested] 93+ messages in thread
* [PATCH 2/7] m32r: Use lib/ucmpdi2.c 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (2 preceding siblings ...) 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt ` (22 subsequent siblings) 26 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/m32r/Kconfig | 1 + arch/m32r/lib/Makefile | 3 +-- arch/m32r/lib/libgcc.h | 23 ----------------------- arch/m32r/lib/ucmpdi2.c | 17 ----------------- 4 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 arch/m32r/lib/libgcc.h delete mode 100644 arch/m32r/lib/ucmpdi2.c diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index 95474460b367..2fbe3aa3e0c4 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig @@ -19,6 +19,7 @@ config M32R select HAVE_DEBUG_STACKOVERFLOW select CPU_NO_EFFICIENT_FFS select DMA_NOOP_OPS + select LIB_UCMPDI3 config SBUS bool diff --git a/arch/m32r/lib/Makefile b/arch/m32r/lib/Makefile index 5889eb9610b5..0a753a833bbf 100644 --- a/arch/m32r/lib/Makefile +++ b/arch/m32r/lib/Makefile @@ -3,5 +3,4 @@ # lib-y := checksum.o ashxdi3.o memset.o memcpy.o \ - delay.o strlen.o usercopy.o csum_partial_copy.o \ - ucmpdi2.o + delay.o strlen.o usercopy.o csum_partial_copy.o diff --git a/arch/m32r/lib/libgcc.h b/arch/m32r/lib/libgcc.h deleted file mode 100644 index 267aa435bc35..000000000000 --- a/arch/m32r/lib/libgcc.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/m32r/lib/ucmpdi2.c b/arch/m32r/lib/ucmpdi2.c deleted file mode 100644 index 9d3c682c89b5..000000000000 --- a/arch/m32r/lib/ucmpdi2.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "libgcc.h" - -int __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int)au.s.high < (unsigned int)bu.s.high) - return 0; - else if ((unsigned int)au.s.high > (unsigned int)bu.s.high) - return 2; - if ((unsigned int)au.s.low < (unsigned int)bu.s.low) - return 0; - else if ((unsigned int)au.s.low > (unsigned int)bu.s.low) - return 2; - return 1; -} -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 2/7] m32r: Use lib/ucmpdi2.c 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (3 preceding siblings ...) 2017-05-23 22:05 ` [PATCH 2/7] m32r: Use lib/ucmpdi2.c Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt ` (21 subsequent siblings) 26 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/m32r/Kconfig | 1 + arch/m32r/lib/Makefile | 3 +-- arch/m32r/lib/libgcc.h | 23 ----------------------- arch/m32r/lib/ucmpdi2.c | 17 ----------------- 4 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 arch/m32r/lib/libgcc.h delete mode 100644 arch/m32r/lib/ucmpdi2.c diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index 95474460b367..2fbe3aa3e0c4 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig @@ -19,6 +19,7 @@ config M32R select HAVE_DEBUG_STACKOVERFLOW select CPU_NO_EFFICIENT_FFS select DMA_NOOP_OPS + select LIB_UCMPDI3 config SBUS bool diff --git a/arch/m32r/lib/Makefile b/arch/m32r/lib/Makefile index 5889eb9610b5..0a753a833bbf 100644 --- a/arch/m32r/lib/Makefile +++ b/arch/m32r/lib/Makefile @@ -3,5 +3,4 @@ # lib-y := checksum.o ashxdi3.o memset.o memcpy.o \ - delay.o strlen.o usercopy.o csum_partial_copy.o \ - ucmpdi2.o + delay.o strlen.o usercopy.o csum_partial_copy.o diff --git a/arch/m32r/lib/libgcc.h b/arch/m32r/lib/libgcc.h deleted file mode 100644 index 267aa435bc35..000000000000 --- a/arch/m32r/lib/libgcc.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/m32r/lib/ucmpdi2.c b/arch/m32r/lib/ucmpdi2.c deleted file mode 100644 index 9d3c682c89b5..000000000000 --- a/arch/m32r/lib/ucmpdi2.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "libgcc.h" - -int __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int)au.s.high < (unsigned int)bu.s.high) - return 0; - else if ((unsigned int)au.s.high > (unsigned int)bu.s.high) - return 2; - if ((unsigned int)au.s.low < (unsigned int)bu.s.low) - return 0; - else if ((unsigned int)au.s.low > (unsigned int)bu.s.low) - return 2; - return 1; -} -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 2/7] m32r: Use lib/ucmpdi2.c 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (4 preceding siblings ...) 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt ` (20 subsequent siblings) 26 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/m32r/Kconfig | 1 + arch/m32r/lib/Makefile | 3 +-- arch/m32r/lib/libgcc.h | 23 ----------------------- arch/m32r/lib/ucmpdi2.c | 17 ----------------- 4 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 arch/m32r/lib/libgcc.h delete mode 100644 arch/m32r/lib/ucmpdi2.c diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index 95474460b367..2fbe3aa3e0c4 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig @@ -19,6 +19,7 @@ config M32R select HAVE_DEBUG_STACKOVERFLOW select CPU_NO_EFFICIENT_FFS select DMA_NOOP_OPS + select LIB_UCMPDI3 config SBUS bool diff --git a/arch/m32r/lib/Makefile b/arch/m32r/lib/Makefile index 5889eb9610b5..0a753a833bbf 100644 --- a/arch/m32r/lib/Makefile +++ b/arch/m32r/lib/Makefile @@ -3,5 +3,4 @@ # lib-y := checksum.o ashxdi3.o memset.o memcpy.o \ - delay.o strlen.o usercopy.o csum_partial_copy.o \ - ucmpdi2.o + delay.o strlen.o usercopy.o csum_partial_copy.o diff --git a/arch/m32r/lib/libgcc.h b/arch/m32r/lib/libgcc.h deleted file mode 100644 index 267aa435bc35..000000000000 --- a/arch/m32r/lib/libgcc.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/m32r/lib/ucmpdi2.c b/arch/m32r/lib/ucmpdi2.c deleted file mode 100644 index 9d3c682c89b5..000000000000 --- a/arch/m32r/lib/ucmpdi2.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "libgcc.h" - -int __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int)au.s.high < (unsigned int)bu.s.high) - return 0; - else if ((unsigned int)au.s.high > (unsigned int)bu.s.high) - return 2; - if ((unsigned int)au.s.low < (unsigned int)bu.s.low) - return 0; - else if ((unsigned int)au.s.low > (unsigned int)bu.s.low) - return 2; - return 1; -} -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 2/7] m32r: Use lib/ucmpdi2.c 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (5 preceding siblings ...) 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` [PATCH 3/7] microblaze: Use libgcc files from lib/ Palmer Dabbelt ` (19 subsequent siblings) 26 siblings, 1 reply; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/m32r/Kconfig | 1 + arch/m32r/lib/Makefile | 3 +-- arch/m32r/lib/libgcc.h | 23 ----------------------- arch/m32r/lib/ucmpdi2.c | 17 ----------------- 4 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 arch/m32r/lib/libgcc.h delete mode 100644 arch/m32r/lib/ucmpdi2.c diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index 95474460b367..2fbe3aa3e0c4 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig @@ -19,6 +19,7 @@ config M32R select HAVE_DEBUG_STACKOVERFLOW select CPU_NO_EFFICIENT_FFS select DMA_NOOP_OPS + select LIB_UCMPDI3 config SBUS bool diff --git a/arch/m32r/lib/Makefile b/arch/m32r/lib/Makefile index 5889eb9610b5..0a753a833bbf 100644 --- a/arch/m32r/lib/Makefile +++ b/arch/m32r/lib/Makefile @@ -3,5 +3,4 @@ # lib-y := checksum.o ashxdi3.o memset.o memcpy.o \ - delay.o strlen.o usercopy.o csum_partial_copy.o \ - ucmpdi2.o + delay.o strlen.o usercopy.o csum_partial_copy.o diff --git a/arch/m32r/lib/libgcc.h b/arch/m32r/lib/libgcc.h deleted file mode 100644 index 267aa435bc35..000000000000 --- a/arch/m32r/lib/libgcc.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/m32r/lib/ucmpdi2.c b/arch/m32r/lib/ucmpdi2.c deleted file mode 100644 index 9d3c682c89b5..000000000000 --- a/arch/m32r/lib/ucmpdi2.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "libgcc.h" - -int __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int)au.s.high < (unsigned int)bu.s.high) - return 0; - else if ((unsigned int)au.s.high > (unsigned int)bu.s.high) - return 2; - if ((unsigned int)au.s.low < (unsigned int)bu.s.low) - return 0; - else if ((unsigned int)au.s.low > (unsigned int)bu.s.low) - return 2; - return 1; -} -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 2/7] m32r: Use lib/ucmpdi2.c 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 0 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/m32r/Kconfig | 1 + arch/m32r/lib/Makefile | 3 +-- arch/m32r/lib/libgcc.h | 23 ----------------------- arch/m32r/lib/ucmpdi2.c | 17 ----------------- 4 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 arch/m32r/lib/libgcc.h delete mode 100644 arch/m32r/lib/ucmpdi2.c diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index 95474460b367..2fbe3aa3e0c4 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig @@ -19,6 +19,7 @@ config M32R select HAVE_DEBUG_STACKOVERFLOW select CPU_NO_EFFICIENT_FFS select DMA_NOOP_OPS + select LIB_UCMPDI3 config SBUS bool diff --git a/arch/m32r/lib/Makefile b/arch/m32r/lib/Makefile index 5889eb9610b5..0a753a833bbf 100644 --- a/arch/m32r/lib/Makefile +++ b/arch/m32r/lib/Makefile @@ -3,5 +3,4 @@ # lib-y := checksum.o ashxdi3.o memset.o memcpy.o \ - delay.o strlen.o usercopy.o csum_partial_copy.o \ - ucmpdi2.o + delay.o strlen.o usercopy.o csum_partial_copy.o diff --git a/arch/m32r/lib/libgcc.h b/arch/m32r/lib/libgcc.h deleted file mode 100644 index 267aa435bc35..000000000000 --- a/arch/m32r/lib/libgcc.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/m32r/lib/ucmpdi2.c b/arch/m32r/lib/ucmpdi2.c deleted file mode 100644 index 9d3c682c89b5..000000000000 --- a/arch/m32r/lib/ucmpdi2.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "libgcc.h" - -int __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int)au.s.high < (unsigned int)bu.s.high) - return 0; - else if ((unsigned int)au.s.high > (unsigned int)bu.s.high) - return 2; - if ((unsigned int)au.s.low < (unsigned int)bu.s.low) - return 0; - else if ((unsigned int)au.s.low > (unsigned int)bu.s.low) - return 2; - return 1; -} -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 3/7] microblaze: Use libgcc files from lib/ 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (6 preceding siblings ...) 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt ` (18 subsequent siblings) 26 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/microblaze/Kconfig | 6 +++++ arch/microblaze/lib/Makefile | 3 +-- arch/microblaze/lib/ashldi3.c | 28 --------------------- arch/microblaze/lib/ashrdi3.c | 30 ----------------------- arch/microblaze/lib/cmpdi2.c | 26 -------------------- arch/microblaze/lib/libgcc.h | 32 ------------------------ arch/microblaze/lib/lshrdi3.c | 28 --------------------- arch/microblaze/lib/muldi3.c | 57 ------------------------------------------- arch/microblaze/lib/ucmpdi2.c | 20 --------------- 9 files changed, 7 insertions(+), 223 deletions(-) delete mode 100644 arch/microblaze/lib/ashldi3.c delete mode 100644 arch/microblaze/lib/ashrdi3.c delete mode 100644 arch/microblaze/lib/cmpdi2.c delete mode 100644 arch/microblaze/lib/libgcc.h delete mode 100644 arch/microblaze/lib/lshrdi3.c delete mode 100644 arch/microblaze/lib/muldi3.c delete mode 100644 arch/microblaze/lib/ucmpdi2.c diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index 85885a501dce..cc88ea3d18a7 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig @@ -34,6 +34,12 @@ config MICROBLAZE select TRACING_SUPPORT select VIRT_TO_BUS select CPU_NO_EFFICIENT_FFS + select LIB_ASHLDI3 + select LIB_ASHRDI3 + select LIB_CMPDI2 + select LIB_LSHRDI3 + select LIB_MULDI3 + select LIB_UCMPDI3 config SWAP def_bool n diff --git a/arch/microblaze/lib/Makefile b/arch/microblaze/lib/Makefile index 70c7ae6a3fb5..c9a4d537e2fd 100644 --- a/arch/microblaze/lib/Makefile +++ b/arch/microblaze/lib/Makefile @@ -19,5 +19,4 @@ endif lib-y += uaccess_old.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o cmpdi2.o divsi3.o lshrdi3.o modsi3.o -obj-y += muldi3.o mulsi3.o ucmpdi2.o udivsi3.o umodsi3.o +obj-y += divsi3.o modsi3.o mulsi3.o udivsi3.o umodsi3.o diff --git a/arch/microblaze/lib/ashldi3.c b/arch/microblaze/lib/ashldi3.c deleted file mode 100644 index 1af904cd972d..000000000000 --- a/arch/microblaze/lib/ashldi3.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/microblaze/lib/ashrdi3.c b/arch/microblaze/lib/ashrdi3.c deleted file mode 100644 index 32c334c05d04..000000000000 --- a/arch/microblaze/lib/ashrdi3.c +++ /dev/null @@ -1,30 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/microblaze/lib/cmpdi2.c b/arch/microblaze/lib/cmpdi2.c deleted file mode 100644 index 67abc9ac1bd4..000000000000 --- a/arch/microblaze/lib/cmpdi2.c +++ /dev/null @@ -1,26 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/microblaze/lib/libgcc.h b/arch/microblaze/lib/libgcc.h deleted file mode 100644 index ab077ef7e14b..000000000000 --- a/arch/microblaze/lib/libgcc.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -extern long long __ashldi3(long long u, word_type b); -extern long long __ashrdi3(long long u, word_type b); -extern word_type __cmpdi2(long long a, long long b); -extern long long __lshrdi3(long long u, word_type b); -extern long long __muldi3(long long u, long long v); -extern word_type __ucmpdi2(unsigned long long a, unsigned long long b); - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/microblaze/lib/lshrdi3.c b/arch/microblaze/lib/lshrdi3.c deleted file mode 100644 index adcb253f11c8..000000000000 --- a/arch/microblaze/lib/lshrdi3.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/microblaze/lib/muldi3.c b/arch/microblaze/lib/muldi3.c deleted file mode 100644 index a3f9a03acdcd..000000000000 --- a/arch/microblaze/lib/muldi3.c +++ /dev/null @@ -1,57 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -#define W_TYPE_SIZE 32 - -#define __ll_B ((unsigned long) 1 << (W_TYPE_SIZE / 2)) -#define __ll_lowpart(t) ((unsigned long) (t) & (__ll_B - 1)) -#define __ll_highpart(t) ((unsigned long) (t) >> (W_TYPE_SIZE / 2)) - -/* If we still don't have umul_ppmm, define it using plain C. */ -#if !defined(umul_ppmm) -#define umul_ppmm(w1, w0, u, v) \ - do { \ - unsigned long __x0, __x1, __x2, __x3; \ - unsigned short __ul, __vl, __uh, __vh; \ - \ - __ul = __ll_lowpart(u); \ - __uh = __ll_highpart(u); \ - __vl = __ll_lowpart(v); \ - __vh = __ll_highpart(v); \ - \ - __x0 = (unsigned long) __ul * __vl; \ - __x1 = (unsigned long) __ul * __vh; \ - __x2 = (unsigned long) __uh * __vl; \ - __x3 = (unsigned long) __uh * __vh; \ - \ - __x1 += __ll_highpart(__x0); /* this can't give carry */\ - __x1 += __x2; /* but this indeed can */ \ - if (__x1 < __x2) /* did we get it? */ \ - __x3 += __ll_B; /* yes, add it in the proper pos */ \ - \ - (w1) = __x3 + __ll_highpart(__x1); \ - (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0);\ - } while (0) -#endif - -#if !defined(__umulsidi3) -#define __umulsidi3(u, v) ({ \ - DWunion __w; \ - umul_ppmm(__w.s.high, __w.s.low, u, v); \ - __w.ll; \ - }) -#endif - -long long __muldi3(long long u, long long v) -{ - const DWunion uu = {.ll = u}; - const DWunion vv = {.ll = v}; - DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)}; - - w.s.high += ((unsigned long) uu.s.low * (unsigned long) vv.s.high - + (unsigned long) uu.s.high * (unsigned long) vv.s.low); - - return w.ll; -} -EXPORT_SYMBOL(__muldi3); diff --git a/arch/microblaze/lib/ucmpdi2.c b/arch/microblaze/lib/ucmpdi2.c deleted file mode 100644 index d05f1585121c..000000000000 --- a/arch/microblaze/lib/ucmpdi2.c +++ /dev/null @@ -1,20 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 3/7] microblaze: Use libgcc files from lib/ 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (7 preceding siblings ...) 2017-05-23 22:05 ` [PATCH 3/7] microblaze: Use libgcc files from lib/ Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-24 11:22 ` kbuild test robot 2017-05-23 22:05 ` Palmer Dabbelt ` (17 subsequent siblings) 26 siblings, 2 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/microblaze/Kconfig | 6 +++++ arch/microblaze/lib/Makefile | 3 +-- arch/microblaze/lib/ashldi3.c | 28 --------------------- arch/microblaze/lib/ashrdi3.c | 30 ----------------------- arch/microblaze/lib/cmpdi2.c | 26 -------------------- arch/microblaze/lib/libgcc.h | 32 ------------------------ arch/microblaze/lib/lshrdi3.c | 28 --------------------- arch/microblaze/lib/muldi3.c | 57 ------------------------------------------- arch/microblaze/lib/ucmpdi2.c | 20 --------------- 9 files changed, 7 insertions(+), 223 deletions(-) delete mode 100644 arch/microblaze/lib/ashldi3.c delete mode 100644 arch/microblaze/lib/ashrdi3.c delete mode 100644 arch/microblaze/lib/cmpdi2.c delete mode 100644 arch/microblaze/lib/libgcc.h delete mode 100644 arch/microblaze/lib/lshrdi3.c delete mode 100644 arch/microblaze/lib/muldi3.c delete mode 100644 arch/microblaze/lib/ucmpdi2.c diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index 85885a501dce..cc88ea3d18a7 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig @@ -34,6 +34,12 @@ config MICROBLAZE select TRACING_SUPPORT select VIRT_TO_BUS select CPU_NO_EFFICIENT_FFS + select LIB_ASHLDI3 + select LIB_ASHRDI3 + select LIB_CMPDI2 + select LIB_LSHRDI3 + select LIB_MULDI3 + select LIB_UCMPDI3 config SWAP def_bool n diff --git a/arch/microblaze/lib/Makefile b/arch/microblaze/lib/Makefile index 70c7ae6a3fb5..c9a4d537e2fd 100644 --- a/arch/microblaze/lib/Makefile +++ b/arch/microblaze/lib/Makefile @@ -19,5 +19,4 @@ endif lib-y += uaccess_old.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o cmpdi2.o divsi3.o lshrdi3.o modsi3.o -obj-y += muldi3.o mulsi3.o ucmpdi2.o udivsi3.o umodsi3.o +obj-y += divsi3.o modsi3.o mulsi3.o udivsi3.o umodsi3.o diff --git a/arch/microblaze/lib/ashldi3.c b/arch/microblaze/lib/ashldi3.c deleted file mode 100644 index 1af904cd972d..000000000000 --- a/arch/microblaze/lib/ashldi3.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/microblaze/lib/ashrdi3.c b/arch/microblaze/lib/ashrdi3.c deleted file mode 100644 index 32c334c05d04..000000000000 --- a/arch/microblaze/lib/ashrdi3.c +++ /dev/null @@ -1,30 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/microblaze/lib/cmpdi2.c b/arch/microblaze/lib/cmpdi2.c deleted file mode 100644 index 67abc9ac1bd4..000000000000 --- a/arch/microblaze/lib/cmpdi2.c +++ /dev/null @@ -1,26 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/microblaze/lib/libgcc.h b/arch/microblaze/lib/libgcc.h deleted file mode 100644 index ab077ef7e14b..000000000000 --- a/arch/microblaze/lib/libgcc.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -extern long long __ashldi3(long long u, word_type b); -extern long long __ashrdi3(long long u, word_type b); -extern word_type __cmpdi2(long long a, long long b); -extern long long __lshrdi3(long long u, word_type b); -extern long long __muldi3(long long u, long long v); -extern word_type __ucmpdi2(unsigned long long a, unsigned long long b); - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/microblaze/lib/lshrdi3.c b/arch/microblaze/lib/lshrdi3.c deleted file mode 100644 index adcb253f11c8..000000000000 --- a/arch/microblaze/lib/lshrdi3.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/microblaze/lib/muldi3.c b/arch/microblaze/lib/muldi3.c deleted file mode 100644 index a3f9a03acdcd..000000000000 --- a/arch/microblaze/lib/muldi3.c +++ /dev/null @@ -1,57 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -#define W_TYPE_SIZE 32 - -#define __ll_B ((unsigned long) 1 << (W_TYPE_SIZE / 2)) -#define __ll_lowpart(t) ((unsigned long) (t) & (__ll_B - 1)) -#define __ll_highpart(t) ((unsigned long) (t) >> (W_TYPE_SIZE / 2)) - -/* If we still don't have umul_ppmm, define it using plain C. */ -#if !defined(umul_ppmm) -#define umul_ppmm(w1, w0, u, v) \ - do { \ - unsigned long __x0, __x1, __x2, __x3; \ - unsigned short __ul, __vl, __uh, __vh; \ - \ - __ul = __ll_lowpart(u); \ - __uh = __ll_highpart(u); \ - __vl = __ll_lowpart(v); \ - __vh = __ll_highpart(v); \ - \ - __x0 = (unsigned long) __ul * __vl; \ - __x1 = (unsigned long) __ul * __vh; \ - __x2 = (unsigned long) __uh * __vl; \ - __x3 = (unsigned long) __uh * __vh; \ - \ - __x1 += __ll_highpart(__x0); /* this can't give carry */\ - __x1 += __x2; /* but this indeed can */ \ - if (__x1 < __x2) /* did we get it? */ \ - __x3 += __ll_B; /* yes, add it in the proper pos */ \ - \ - (w1) = __x3 + __ll_highpart(__x1); \ - (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0);\ - } while (0) -#endif - -#if !defined(__umulsidi3) -#define __umulsidi3(u, v) ({ \ - DWunion __w; \ - umul_ppmm(__w.s.high, __w.s.low, u, v); \ - __w.ll; \ - }) -#endif - -long long __muldi3(long long u, long long v) -{ - const DWunion uu = {.ll = u}; - const DWunion vv = {.ll = v}; - DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)}; - - w.s.high += ((unsigned long) uu.s.low * (unsigned long) vv.s.high - + (unsigned long) uu.s.high * (unsigned long) vv.s.low); - - return w.ll; -} -EXPORT_SYMBOL(__muldi3); diff --git a/arch/microblaze/lib/ucmpdi2.c b/arch/microblaze/lib/ucmpdi2.c deleted file mode 100644 index d05f1585121c..000000000000 --- a/arch/microblaze/lib/ucmpdi2.c +++ /dev/null @@ -1,20 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 3/7] microblaze: Use libgcc files from lib/ 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-24 11:22 ` kbuild test robot 1 sibling, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/microblaze/Kconfig | 6 +++++ arch/microblaze/lib/Makefile | 3 +-- arch/microblaze/lib/ashldi3.c | 28 --------------------- arch/microblaze/lib/ashrdi3.c | 30 ----------------------- arch/microblaze/lib/cmpdi2.c | 26 -------------------- arch/microblaze/lib/libgcc.h | 32 ------------------------ arch/microblaze/lib/lshrdi3.c | 28 --------------------- arch/microblaze/lib/muldi3.c | 57 ------------------------------------------- arch/microblaze/lib/ucmpdi2.c | 20 --------------- 9 files changed, 7 insertions(+), 223 deletions(-) delete mode 100644 arch/microblaze/lib/ashldi3.c delete mode 100644 arch/microblaze/lib/ashrdi3.c delete mode 100644 arch/microblaze/lib/cmpdi2.c delete mode 100644 arch/microblaze/lib/libgcc.h delete mode 100644 arch/microblaze/lib/lshrdi3.c delete mode 100644 arch/microblaze/lib/muldi3.c delete mode 100644 arch/microblaze/lib/ucmpdi2.c diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index 85885a501dce..cc88ea3d18a7 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig @@ -34,6 +34,12 @@ config MICROBLAZE select TRACING_SUPPORT select VIRT_TO_BUS select CPU_NO_EFFICIENT_FFS + select LIB_ASHLDI3 + select LIB_ASHRDI3 + select LIB_CMPDI2 + select LIB_LSHRDI3 + select LIB_MULDI3 + select LIB_UCMPDI3 config SWAP def_bool n diff --git a/arch/microblaze/lib/Makefile b/arch/microblaze/lib/Makefile index 70c7ae6a3fb5..c9a4d537e2fd 100644 --- a/arch/microblaze/lib/Makefile +++ b/arch/microblaze/lib/Makefile @@ -19,5 +19,4 @@ endif lib-y += uaccess_old.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o cmpdi2.o divsi3.o lshrdi3.o modsi3.o -obj-y += muldi3.o mulsi3.o ucmpdi2.o udivsi3.o umodsi3.o +obj-y += divsi3.o modsi3.o mulsi3.o udivsi3.o umodsi3.o diff --git a/arch/microblaze/lib/ashldi3.c b/arch/microblaze/lib/ashldi3.c deleted file mode 100644 index 1af904cd972d..000000000000 --- a/arch/microblaze/lib/ashldi3.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/microblaze/lib/ashrdi3.c b/arch/microblaze/lib/ashrdi3.c deleted file mode 100644 index 32c334c05d04..000000000000 --- a/arch/microblaze/lib/ashrdi3.c +++ /dev/null @@ -1,30 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/microblaze/lib/cmpdi2.c b/arch/microblaze/lib/cmpdi2.c deleted file mode 100644 index 67abc9ac1bd4..000000000000 --- a/arch/microblaze/lib/cmpdi2.c +++ /dev/null @@ -1,26 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/microblaze/lib/libgcc.h b/arch/microblaze/lib/libgcc.h deleted file mode 100644 index ab077ef7e14b..000000000000 --- a/arch/microblaze/lib/libgcc.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -extern long long __ashldi3(long long u, word_type b); -extern long long __ashrdi3(long long u, word_type b); -extern word_type __cmpdi2(long long a, long long b); -extern long long __lshrdi3(long long u, word_type b); -extern long long __muldi3(long long u, long long v); -extern word_type __ucmpdi2(unsigned long long a, unsigned long long b); - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/microblaze/lib/lshrdi3.c b/arch/microblaze/lib/lshrdi3.c deleted file mode 100644 index adcb253f11c8..000000000000 --- a/arch/microblaze/lib/lshrdi3.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/microblaze/lib/muldi3.c b/arch/microblaze/lib/muldi3.c deleted file mode 100644 index a3f9a03acdcd..000000000000 --- a/arch/microblaze/lib/muldi3.c +++ /dev/null @@ -1,57 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -#define W_TYPE_SIZE 32 - -#define __ll_B ((unsigned long) 1 << (W_TYPE_SIZE / 2)) -#define __ll_lowpart(t) ((unsigned long) (t) & (__ll_B - 1)) -#define __ll_highpart(t) ((unsigned long) (t) >> (W_TYPE_SIZE / 2)) - -/* If we still don't have umul_ppmm, define it using plain C. */ -#if !defined(umul_ppmm) -#define umul_ppmm(w1, w0, u, v) \ - do { \ - unsigned long __x0, __x1, __x2, __x3; \ - unsigned short __ul, __vl, __uh, __vh; \ - \ - __ul = __ll_lowpart(u); \ - __uh = __ll_highpart(u); \ - __vl = __ll_lowpart(v); \ - __vh = __ll_highpart(v); \ - \ - __x0 = (unsigned long) __ul * __vl; \ - __x1 = (unsigned long) __ul * __vh; \ - __x2 = (unsigned long) __uh * __vl; \ - __x3 = (unsigned long) __uh * __vh; \ - \ - __x1 += __ll_highpart(__x0); /* this can't give carry */\ - __x1 += __x2; /* but this indeed can */ \ - if (__x1 < __x2) /* did we get it? */ \ - __x3 += __ll_B; /* yes, add it in the proper pos */ \ - \ - (w1) = __x3 + __ll_highpart(__x1); \ - (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0);\ - } while (0) -#endif - -#if !defined(__umulsidi3) -#define __umulsidi3(u, v) ({ \ - DWunion __w; \ - umul_ppmm(__w.s.high, __w.s.low, u, v); \ - __w.ll; \ - }) -#endif - -long long __muldi3(long long u, long long v) -{ - const DWunion uu = {.ll = u}; - const DWunion vv = {.ll = v}; - DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)}; - - w.s.high += ((unsigned long) uu.s.low * (unsigned long) vv.s.high - + (unsigned long) uu.s.high * (unsigned long) vv.s.low); - - return w.ll; -} -EXPORT_SYMBOL(__muldi3); diff --git a/arch/microblaze/lib/ucmpdi2.c b/arch/microblaze/lib/ucmpdi2.c deleted file mode 100644 index d05f1585121c..000000000000 --- a/arch/microblaze/lib/ucmpdi2.c +++ /dev/null @@ -1,20 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* Re: [PATCH 3/7] microblaze: Use libgcc files from lib/ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-24 11:22 ` kbuild test robot 2017-05-24 11:22 ` kbuild test robot 1 sibling, 1 reply; 93+ messages in thread From: kbuild test robot @ 2017-05-24 11:22 UTC (permalink / raw) Cc: kbuild-all, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch, Palmer Dabbelt [-- Attachment #1: Type: text/plain, Size: 1018 bytes --] Hi Palmer, [auto build test ERROR on linus/master] [also build test ERROR on v4.12-rc2 next-20170524] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Palmer-Dabbelt/lib-Add-shared-copies-of-some-GCC-library-routines/20170524-170717 config: microblaze-mmu_defconfig (attached as .config) compiler: microblaze-linux-gcc (GCC) 6.2.0 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=microblaze All errors (new ones prefixed by >>): >> make[2]: *** No rule to make target 'lib/multi3.o', needed by 'lib/built-in.o'. make[2]: Target '__build' not remade because of errors. --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 12869 bytes --] ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 3/7] microblaze: Use libgcc files from lib/ 2017-05-24 11:22 ` kbuild test robot @ 2017-05-24 11:22 ` kbuild test robot 0 siblings, 0 replies; 93+ messages in thread From: kbuild test robot @ 2017-05-24 11:22 UTC (permalink / raw) To: Palmer Dabbelt Cc: kbuild-all, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch [-- Attachment #1: Type: text/plain, Size: 1018 bytes --] Hi Palmer, [auto build test ERROR on linus/master] [also build test ERROR on v4.12-rc2 next-20170524] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Palmer-Dabbelt/lib-Add-shared-copies-of-some-GCC-library-routines/20170524-170717 config: microblaze-mmu_defconfig (attached as .config) compiler: microblaze-linux-gcc (GCC) 6.2.0 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=microblaze All errors (new ones prefixed by >>): >> make[2]: *** No rule to make target 'lib/multi3.o', needed by 'lib/built-in.o'. make[2]: Target '__build' not remade because of errors. --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 12869 bytes --] ^ permalink raw reply [flat|nested] 93+ messages in thread
* [PATCH 3/7] microblaze: Use libgcc files from lib/ 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (8 preceding siblings ...) 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` [PATCH 4/7] mips: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c Palmer Dabbelt ` (16 subsequent siblings) 26 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/microblaze/Kconfig | 6 +++++ arch/microblaze/lib/Makefile | 3 +-- arch/microblaze/lib/ashldi3.c | 28 --------------------- arch/microblaze/lib/ashrdi3.c | 30 ----------------------- arch/microblaze/lib/cmpdi2.c | 26 -------------------- arch/microblaze/lib/libgcc.h | 32 ------------------------ arch/microblaze/lib/lshrdi3.c | 28 --------------------- arch/microblaze/lib/muldi3.c | 57 ------------------------------------------- arch/microblaze/lib/ucmpdi2.c | 20 --------------- 9 files changed, 7 insertions(+), 223 deletions(-) delete mode 100644 arch/microblaze/lib/ashldi3.c delete mode 100644 arch/microblaze/lib/ashrdi3.c delete mode 100644 arch/microblaze/lib/cmpdi2.c delete mode 100644 arch/microblaze/lib/libgcc.h delete mode 100644 arch/microblaze/lib/lshrdi3.c delete mode 100644 arch/microblaze/lib/muldi3.c delete mode 100644 arch/microblaze/lib/ucmpdi2.c diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index 85885a501dce..cc88ea3d18a7 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig @@ -34,6 +34,12 @@ config MICROBLAZE select TRACING_SUPPORT select VIRT_TO_BUS select CPU_NO_EFFICIENT_FFS + select LIB_ASHLDI3 + select LIB_ASHRDI3 + select LIB_CMPDI2 + select LIB_LSHRDI3 + select LIB_MULDI3 + select LIB_UCMPDI3 config SWAP def_bool n diff --git a/arch/microblaze/lib/Makefile b/arch/microblaze/lib/Makefile index 70c7ae6a3fb5..c9a4d537e2fd 100644 --- a/arch/microblaze/lib/Makefile +++ b/arch/microblaze/lib/Makefile @@ -19,5 +19,4 @@ endif lib-y += uaccess_old.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o cmpdi2.o divsi3.o lshrdi3.o modsi3.o -obj-y += muldi3.o mulsi3.o ucmpdi2.o udivsi3.o umodsi3.o +obj-y += divsi3.o modsi3.o mulsi3.o udivsi3.o umodsi3.o diff --git a/arch/microblaze/lib/ashldi3.c b/arch/microblaze/lib/ashldi3.c deleted file mode 100644 index 1af904cd972d..000000000000 --- a/arch/microblaze/lib/ashldi3.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/microblaze/lib/ashrdi3.c b/arch/microblaze/lib/ashrdi3.c deleted file mode 100644 index 32c334c05d04..000000000000 --- a/arch/microblaze/lib/ashrdi3.c +++ /dev/null @@ -1,30 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/microblaze/lib/cmpdi2.c b/arch/microblaze/lib/cmpdi2.c deleted file mode 100644 index 67abc9ac1bd4..000000000000 --- a/arch/microblaze/lib/cmpdi2.c +++ /dev/null @@ -1,26 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/microblaze/lib/libgcc.h b/arch/microblaze/lib/libgcc.h deleted file mode 100644 index ab077ef7e14b..000000000000 --- a/arch/microblaze/lib/libgcc.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -extern long long __ashldi3(long long u, word_type b); -extern long long __ashrdi3(long long u, word_type b); -extern word_type __cmpdi2(long long a, long long b); -extern long long __lshrdi3(long long u, word_type b); -extern long long __muldi3(long long u, long long v); -extern word_type __ucmpdi2(unsigned long long a, unsigned long long b); - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/microblaze/lib/lshrdi3.c b/arch/microblaze/lib/lshrdi3.c deleted file mode 100644 index adcb253f11c8..000000000000 --- a/arch/microblaze/lib/lshrdi3.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/microblaze/lib/muldi3.c b/arch/microblaze/lib/muldi3.c deleted file mode 100644 index a3f9a03acdcd..000000000000 --- a/arch/microblaze/lib/muldi3.c +++ /dev/null @@ -1,57 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -#define W_TYPE_SIZE 32 - -#define __ll_B ((unsigned long) 1 << (W_TYPE_SIZE / 2)) -#define __ll_lowpart(t) ((unsigned long) (t) & (__ll_B - 1)) -#define __ll_highpart(t) ((unsigned long) (t) >> (W_TYPE_SIZE / 2)) - -/* If we still don't have umul_ppmm, define it using plain C. */ -#if !defined(umul_ppmm) -#define umul_ppmm(w1, w0, u, v) \ - do { \ - unsigned long __x0, __x1, __x2, __x3; \ - unsigned short __ul, __vl, __uh, __vh; \ - \ - __ul = __ll_lowpart(u); \ - __uh = __ll_highpart(u); \ - __vl = __ll_lowpart(v); \ - __vh = __ll_highpart(v); \ - \ - __x0 = (unsigned long) __ul * __vl; \ - __x1 = (unsigned long) __ul * __vh; \ - __x2 = (unsigned long) __uh * __vl; \ - __x3 = (unsigned long) __uh * __vh; \ - \ - __x1 += __ll_highpart(__x0); /* this can't give carry */\ - __x1 += __x2; /* but this indeed can */ \ - if (__x1 < __x2) /* did we get it? */ \ - __x3 += __ll_B; /* yes, add it in the proper pos */ \ - \ - (w1) = __x3 + __ll_highpart(__x1); \ - (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0);\ - } while (0) -#endif - -#if !defined(__umulsidi3) -#define __umulsidi3(u, v) ({ \ - DWunion __w; \ - umul_ppmm(__w.s.high, __w.s.low, u, v); \ - __w.ll; \ - }) -#endif - -long long __muldi3(long long u, long long v) -{ - const DWunion uu = {.ll = u}; - const DWunion vv = {.ll = v}; - DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)}; - - w.s.high += ((unsigned long) uu.s.low * (unsigned long) vv.s.high - + (unsigned long) uu.s.high * (unsigned long) vv.s.low); - - return w.ll; -} -EXPORT_SYMBOL(__muldi3); diff --git a/arch/microblaze/lib/ucmpdi2.c b/arch/microblaze/lib/ucmpdi2.c deleted file mode 100644 index d05f1585121c..000000000000 --- a/arch/microblaze/lib/ucmpdi2.c +++ /dev/null @@ -1,20 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 4/7] mips: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (9 preceding siblings ...) 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt ` (15 subsequent siblings) 26 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/mips/Kconfig | 1 + arch/mips/lib/Makefile | 2 +- arch/mips/lib/ashldi3.c | 2 +- arch/mips/lib/ashrdi3.c | 2 +- arch/mips/lib/cmpdi2.c | 2 +- arch/mips/lib/libgcc.h | 25 ------------------------- arch/mips/lib/lshrdi3.c | 2 +- arch/mips/lib/ucmpdi2.c | 21 --------------------- 8 files changed, 6 insertions(+), 51 deletions(-) delete mode 100644 arch/mips/lib/libgcc.h delete mode 100644 arch/mips/lib/ucmpdi2.c diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 2828ecde133d..b106e6165db0 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -70,6 +70,7 @@ config MIPS select HAVE_EXIT_THREAD select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_COPY_THREAD_TLS + select LIB_UCMPDI3 menu "Machine selection" diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile index 0344e575f522..e38dbafea074 100644 --- a/arch/mips/lib/Makefile +++ b/arch/mips/lib/Makefile @@ -15,4 +15,4 @@ obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o +obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c index c3e22053d13e..b3d706155fce 100644 --- a/arch/mips/lib/ashldi3.c +++ b/arch/mips/lib/ashldi3.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> long long notrace __ashldi3(long long u, word_type b) { diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c index 17456024873d..bca87aca6f5c 100644 --- a/arch/mips/lib/ashrdi3.c +++ b/arch/mips/lib/ashrdi3.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> long long notrace __ashrdi3(long long u, word_type b) { diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c index 9d849d8743c9..774b109921b5 100644 --- a/arch/mips/lib/cmpdi2.c +++ b/arch/mips/lib/cmpdi2.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> word_type notrace __cmpdi2(long long a, long long b) { diff --git a/arch/mips/lib/libgcc.h b/arch/mips/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/mips/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c index 221167c1be55..ceb1a5c14bc8 100644 --- a/arch/mips/lib/lshrdi3.c +++ b/arch/mips/lib/lshrdi3.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> long long notrace __lshrdi3(long long u, word_type b) { diff --git a/arch/mips/lib/ucmpdi2.c b/arch/mips/lib/ucmpdi2.c deleted file mode 100644 index 08067fa538f2..000000000000 --- a/arch/mips/lib/ucmpdi2.c +++ /dev/null @@ -1,21 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type notrace __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} - -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 4/7] mips: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (10 preceding siblings ...) 2017-05-23 22:05 ` [PATCH 4/7] mips: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt ` (3 more replies) 2017-05-23 22:05 ` Palmer Dabbelt ` (14 subsequent siblings) 26 siblings, 4 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/mips/Kconfig | 1 + arch/mips/lib/Makefile | 2 +- arch/mips/lib/ashldi3.c | 2 +- arch/mips/lib/ashrdi3.c | 2 +- arch/mips/lib/cmpdi2.c | 2 +- arch/mips/lib/libgcc.h | 25 ------------------------- arch/mips/lib/lshrdi3.c | 2 +- arch/mips/lib/ucmpdi2.c | 21 --------------------- 8 files changed, 6 insertions(+), 51 deletions(-) delete mode 100644 arch/mips/lib/libgcc.h delete mode 100644 arch/mips/lib/ucmpdi2.c diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 2828ecde133d..b106e6165db0 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -70,6 +70,7 @@ config MIPS select HAVE_EXIT_THREAD select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_COPY_THREAD_TLS + select LIB_UCMPDI3 menu "Machine selection" diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile index 0344e575f522..e38dbafea074 100644 --- a/arch/mips/lib/Makefile +++ b/arch/mips/lib/Makefile @@ -15,4 +15,4 @@ obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o +obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c index c3e22053d13e..b3d706155fce 100644 --- a/arch/mips/lib/ashldi3.c +++ b/arch/mips/lib/ashldi3.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> long long notrace __ashldi3(long long u, word_type b) { diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c index 17456024873d..bca87aca6f5c 100644 --- a/arch/mips/lib/ashrdi3.c +++ b/arch/mips/lib/ashrdi3.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> long long notrace __ashrdi3(long long u, word_type b) { diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c index 9d849d8743c9..774b109921b5 100644 --- a/arch/mips/lib/cmpdi2.c +++ b/arch/mips/lib/cmpdi2.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> word_type notrace __cmpdi2(long long a, long long b) { diff --git a/arch/mips/lib/libgcc.h b/arch/mips/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/mips/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c index 221167c1be55..ceb1a5c14bc8 100644 --- a/arch/mips/lib/lshrdi3.c +++ b/arch/mips/lib/lshrdi3.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> long long notrace __lshrdi3(long long u, word_type b) { diff --git a/arch/mips/lib/ucmpdi2.c b/arch/mips/lib/ucmpdi2.c deleted file mode 100644 index 08067fa538f2..000000000000 --- a/arch/mips/lib/ucmpdi2.c +++ /dev/null @@ -1,21 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type notrace __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} - -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 4/7] mips: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-24 9:01 ` Matt Redfearn ` (2 subsequent siblings) 3 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/mips/Kconfig | 1 + arch/mips/lib/Makefile | 2 +- arch/mips/lib/ashldi3.c | 2 +- arch/mips/lib/ashrdi3.c | 2 +- arch/mips/lib/cmpdi2.c | 2 +- arch/mips/lib/libgcc.h | 25 ------------------------- arch/mips/lib/lshrdi3.c | 2 +- arch/mips/lib/ucmpdi2.c | 21 --------------------- 8 files changed, 6 insertions(+), 51 deletions(-) delete mode 100644 arch/mips/lib/libgcc.h delete mode 100644 arch/mips/lib/ucmpdi2.c diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 2828ecde133d..b106e6165db0 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -70,6 +70,7 @@ config MIPS select HAVE_EXIT_THREAD select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_COPY_THREAD_TLS + select LIB_UCMPDI3 menu "Machine selection" diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile index 0344e575f522..e38dbafea074 100644 --- a/arch/mips/lib/Makefile +++ b/arch/mips/lib/Makefile @@ -15,4 +15,4 @@ obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o +obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c index c3e22053d13e..b3d706155fce 100644 --- a/arch/mips/lib/ashldi3.c +++ b/arch/mips/lib/ashldi3.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> long long notrace __ashldi3(long long u, word_type b) { diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c index 17456024873d..bca87aca6f5c 100644 --- a/arch/mips/lib/ashrdi3.c +++ b/arch/mips/lib/ashrdi3.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> long long notrace __ashrdi3(long long u, word_type b) { diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c index 9d849d8743c9..774b109921b5 100644 --- a/arch/mips/lib/cmpdi2.c +++ b/arch/mips/lib/cmpdi2.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> word_type notrace __cmpdi2(long long a, long long b) { diff --git a/arch/mips/lib/libgcc.h b/arch/mips/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/mips/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c index 221167c1be55..ceb1a5c14bc8 100644 --- a/arch/mips/lib/lshrdi3.c +++ b/arch/mips/lib/lshrdi3.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> long long notrace __lshrdi3(long long u, word_type b) { diff --git a/arch/mips/lib/ucmpdi2.c b/arch/mips/lib/ucmpdi2.c deleted file mode 100644 index 08067fa538f2..000000000000 --- a/arch/mips/lib/ucmpdi2.c +++ /dev/null @@ -1,21 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type notrace __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} - -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* Re: [PATCH 4/7] mips: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-24 9:01 ` Matt Redfearn 2017-05-24 9:01 ` Matt Redfearn 2017-06-03 2:18 ` Palmer Dabbelt 2017-05-24 11:39 ` kbuild test robot 2017-05-24 11:50 ` kbuild test robot 3 siblings, 2 replies; 93+ messages in thread From: Matt Redfearn @ 2017-05-24 9:01 UTC (permalink / raw) To: Palmer Dabbelt, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Hi Palmer, On 23/05/17 23:05, Palmer Dabbelt wrote: > These files are functionally identical to the shared copies that I > recently added. > > Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> > --- > arch/mips/Kconfig | 1 + > arch/mips/lib/Makefile | 2 +- > arch/mips/lib/ashldi3.c | 2 +- > arch/mips/lib/ashrdi3.c | 2 +- > arch/mips/lib/cmpdi2.c | 2 +- > arch/mips/lib/libgcc.h | 25 ------------------------- > arch/mips/lib/lshrdi3.c | 2 +- > arch/mips/lib/ucmpdi2.c | 21 --------------------- > 8 files changed, 6 insertions(+), 51 deletions(-) > delete mode 100644 arch/mips/lib/libgcc.h > delete mode 100644 arch/mips/lib/ucmpdi2.c > > diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig > index 2828ecde133d..b106e6165db0 100644 > --- a/arch/mips/Kconfig > +++ b/arch/mips/Kconfig > @@ -70,6 +70,7 @@ config MIPS > select HAVE_EXIT_THREAD > select HAVE_REGS_AND_STACK_ACCESS_API > select HAVE_COPY_THREAD_TLS > + select LIB_UCMPDI3 > > menu "Machine selection" > > diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile > index 0344e575f522..e38dbafea074 100644 > --- a/arch/mips/lib/Makefile > +++ b/arch/mips/lib/Makefile > @@ -15,4 +15,4 @@ obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o > obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o > > # libgcc-style stuff needed in the kernel > -obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o > +obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o > diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c > index c3e22053d13e..b3d706155fce 100644 > --- a/arch/mips/lib/ashldi3.c > +++ b/arch/mips/lib/ashldi3.c > @@ -1,6 +1,6 @@ > #include <linux/export.h> > > -#include "libgcc.h" > +#include <lib/libgcc.h> > > long long notrace __ashldi3(long long u, word_type b) > { > diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c > index 17456024873d..bca87aca6f5c 100644 > --- a/arch/mips/lib/ashrdi3.c > +++ b/arch/mips/lib/ashrdi3.c > @@ -1,6 +1,6 @@ > #include <linux/export.h> > > -#include "libgcc.h" > +#include <lib/libgcc.h> > > long long notrace __ashrdi3(long long u, word_type b) > { > diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c > index 9d849d8743c9..774b109921b5 100644 > --- a/arch/mips/lib/cmpdi2.c > +++ b/arch/mips/lib/cmpdi2.c > @@ -1,6 +1,6 @@ > #include <linux/export.h> > > -#include "libgcc.h" > +#include <lib/libgcc.h> > > word_type notrace __cmpdi2(long long a, long long b) > { > diff --git a/arch/mips/lib/libgcc.h b/arch/mips/lib/libgcc.h > deleted file mode 100644 > index 05909d58e2fe..000000000000 > --- a/arch/mips/lib/libgcc.h > +++ /dev/null > @@ -1,25 +0,0 @@ > -#ifndef __ASM_LIBGCC_H > -#define __ASM_LIBGCC_H > - > -#include <asm/byteorder.h> > - > -typedef int word_type __attribute__ ((mode (__word__))); > - > -#ifdef __BIG_ENDIAN > -struct DWstruct { > - int high, low; > -}; > -#elif defined(__LITTLE_ENDIAN) > -struct DWstruct { > - int low, high; > -}; > -#else > -#error I feel sick. > -#endif > - > -typedef union { > - struct DWstruct s; > - long long ll; > -} DWunion; > - > -#endif /* __ASM_LIBGCC_H */ > diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c > index 221167c1be55..ceb1a5c14bc8 100644 > --- a/arch/mips/lib/lshrdi3.c > +++ b/arch/mips/lib/lshrdi3.c > @@ -1,6 +1,6 @@ > #include <linux/export.h> > > -#include "libgcc.h" > +#include <lib/libgcc.h> > > long long notrace __lshrdi3(long long u, word_type b) > { > diff --git a/arch/mips/lib/ucmpdi2.c b/arch/mips/lib/ucmpdi2.c > deleted file mode 100644 > index 08067fa538f2..000000000000 > --- a/arch/mips/lib/ucmpdi2.c > +++ /dev/null > @@ -1,21 +0,0 @@ > -#include <linux/export.h> > - > -#include "libgcc.h" > - > -word_type notrace __ucmpdi2(unsigned long long a, unsigned long long b) > -{ > - const DWunion au = {.ll = a}; > - const DWunion bu = {.ll = b}; > - > - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) > - return 0; > - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) > - return 2; > - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) > - return 0; > - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) > - return 2; > - return 1; > -} > - > -EXPORT_SYMBOL(__ucmpdi2); This patch doesn't quite match the subject, since it only removes the mips specific implementation of __ucmpdi2. The following patch removes all of the intrinsics that you added to lib/ from arch/mips/lib. I've built & boot tested this on a MIPS pistachio platform. Note that this patch will require rebasing on linux-next, since it will conflict with other changes in arch/mips/Kconfig Thanks, Matt [PATCH] MIPS: Use generic libgcc intrinsics These routines in arch/mips/lib/ are functionally identical to those recently added to lib/ so remove them and select the generic ones. Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com> --- arch/mips/Kconfig | 5 +++++ arch/mips/lib/Makefile | 2 +- arch/mips/lib/ashldi3.c | 29 ----------------------------- arch/mips/lib/ashrdi3.c | 31 ------------------------------- arch/mips/lib/cmpdi2.c | 27 --------------------------- arch/mips/lib/libgcc.h | 25 ------------------------- arch/mips/lib/lshrdi3.c | 29 ----------------------------- arch/mips/lib/ucmpdi2.c | 21 --------------------- 8 files changed, 6 insertions(+), 163 deletions(-) delete mode 100644 arch/mips/lib/ashldi3.c delete mode 100644 arch/mips/lib/ashrdi3.c delete mode 100644 arch/mips/lib/cmpdi2.c delete mode 100644 arch/mips/lib/libgcc.h delete mode 100644 arch/mips/lib/lshrdi3.c delete mode 100644 arch/mips/lib/ucmpdi2.c diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 2828ecde133d..808626394e8d 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -70,6 +70,11 @@ config MIPS select HAVE_EXIT_THREAD select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_COPY_THREAD_TLS + select LIB_ASHLDI3 + select LIB_ASHRDI3 + select LIB_CMPDI2 + select LIB_LSHRDI3 + select LIB_UCMPDI2 menu "Machine selection" diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile index 0344e575f522..814e739d6f86 100644 --- a/arch/mips/lib/Makefile +++ b/arch/mips/lib/Makefile @@ -15,4 +15,4 @@ obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o +obj-y += bswapsi.o bswapdi.o diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c deleted file mode 100644 index c3e22053d13e..000000000000 --- a/arch/mips/lib/ashldi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c deleted file mode 100644 index 17456024873d..000000000000 --- a/arch/mips/lib/ashrdi3.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c deleted file mode 100644 index 9d849d8743c9..000000000000 --- a/arch/mips/lib/cmpdi2.c +++ /dev/null @@ -1,27 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type notrace __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} - -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/mips/lib/libgcc.h b/arch/mips/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/mips/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c deleted file mode 100644 index 221167c1be55..000000000000 --- a/arch/mips/lib/lshrdi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/mips/lib/ucmpdi2.c b/arch/mips/lib/ucmpdi2.c deleted file mode 100644 index 08067fa538f2..000000000000 --- a/arch/mips/lib/ucmpdi2.c +++ /dev/null @@ -1,21 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type notrace __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} - -EXPORT_SYMBOL(__ucmpdi2); -- 2.7.4 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* Re: [PATCH 4/7] mips: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c 2017-05-24 9:01 ` Matt Redfearn @ 2017-05-24 9:01 ` Matt Redfearn 2017-06-03 2:18 ` Palmer Dabbelt 1 sibling, 0 replies; 93+ messages in thread From: Matt Redfearn @ 2017-05-24 9:01 UTC (permalink / raw) To: Palmer Dabbelt, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Hi Palmer, On 23/05/17 23:05, Palmer Dabbelt wrote: > These files are functionally identical to the shared copies that I > recently added. > > Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> > --- > arch/mips/Kconfig | 1 + > arch/mips/lib/Makefile | 2 +- > arch/mips/lib/ashldi3.c | 2 +- > arch/mips/lib/ashrdi3.c | 2 +- > arch/mips/lib/cmpdi2.c | 2 +- > arch/mips/lib/libgcc.h | 25 ------------------------- > arch/mips/lib/lshrdi3.c | 2 +- > arch/mips/lib/ucmpdi2.c | 21 --------------------- > 8 files changed, 6 insertions(+), 51 deletions(-) > delete mode 100644 arch/mips/lib/libgcc.h > delete mode 100644 arch/mips/lib/ucmpdi2.c > > diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig > index 2828ecde133d..b106e6165db0 100644 > --- a/arch/mips/Kconfig > +++ b/arch/mips/Kconfig > @@ -70,6 +70,7 @@ config MIPS > select HAVE_EXIT_THREAD > select HAVE_REGS_AND_STACK_ACCESS_API > select HAVE_COPY_THREAD_TLS > + select LIB_UCMPDI3 > > menu "Machine selection" > > diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile > index 0344e575f522..e38dbafea074 100644 > --- a/arch/mips/lib/Makefile > +++ b/arch/mips/lib/Makefile > @@ -15,4 +15,4 @@ obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o > obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o > > # libgcc-style stuff needed in the kernel > -obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o > +obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o > diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c > index c3e22053d13e..b3d706155fce 100644 > --- a/arch/mips/lib/ashldi3.c > +++ b/arch/mips/lib/ashldi3.c > @@ -1,6 +1,6 @@ > #include <linux/export.h> > > -#include "libgcc.h" > +#include <lib/libgcc.h> > > long long notrace __ashldi3(long long u, word_type b) > { > diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c > index 17456024873d..bca87aca6f5c 100644 > --- a/arch/mips/lib/ashrdi3.c > +++ b/arch/mips/lib/ashrdi3.c > @@ -1,6 +1,6 @@ > #include <linux/export.h> > > -#include "libgcc.h" > +#include <lib/libgcc.h> > > long long notrace __ashrdi3(long long u, word_type b) > { > diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c > index 9d849d8743c9..774b109921b5 100644 > --- a/arch/mips/lib/cmpdi2.c > +++ b/arch/mips/lib/cmpdi2.c > @@ -1,6 +1,6 @@ > #include <linux/export.h> > > -#include "libgcc.h" > +#include <lib/libgcc.h> > > word_type notrace __cmpdi2(long long a, long long b) > { > diff --git a/arch/mips/lib/libgcc.h b/arch/mips/lib/libgcc.h > deleted file mode 100644 > index 05909d58e2fe..000000000000 > --- a/arch/mips/lib/libgcc.h > +++ /dev/null > @@ -1,25 +0,0 @@ > -#ifndef __ASM_LIBGCC_H > -#define __ASM_LIBGCC_H > - > -#include <asm/byteorder.h> > - > -typedef int word_type __attribute__ ((mode (__word__))); > - > -#ifdef __BIG_ENDIAN > -struct DWstruct { > - int high, low; > -}; > -#elif defined(__LITTLE_ENDIAN) > -struct DWstruct { > - int low, high; > -}; > -#else > -#error I feel sick. > -#endif > - > -typedef union { > - struct DWstruct s; > - long long ll; > -} DWunion; > - > -#endif /* __ASM_LIBGCC_H */ > diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c > index 221167c1be55..ceb1a5c14bc8 100644 > --- a/arch/mips/lib/lshrdi3.c > +++ b/arch/mips/lib/lshrdi3.c > @@ -1,6 +1,6 @@ > #include <linux/export.h> > > -#include "libgcc.h" > +#include <lib/libgcc.h> > > long long notrace __lshrdi3(long long u, word_type b) > { > diff --git a/arch/mips/lib/ucmpdi2.c b/arch/mips/lib/ucmpdi2.c > deleted file mode 100644 > index 08067fa538f2..000000000000 > --- a/arch/mips/lib/ucmpdi2.c > +++ /dev/null > @@ -1,21 +0,0 @@ > -#include <linux/export.h> > - > -#include "libgcc.h" > - > -word_type notrace __ucmpdi2(unsigned long long a, unsigned long long b) > -{ > - const DWunion au = {.ll = a}; > - const DWunion bu = {.ll = b}; > - > - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) > - return 0; > - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) > - return 2; > - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) > - return 0; > - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) > - return 2; > - return 1; > -} > - > -EXPORT_SYMBOL(__ucmpdi2); This patch doesn't quite match the subject, since it only removes the mips specific implementation of __ucmpdi2. The following patch removes all of the intrinsics that you added to lib/ from arch/mips/lib. I've built & boot tested this on a MIPS pistachio platform. Note that this patch will require rebasing on linux-next, since it will conflict with other changes in arch/mips/Kconfig Thanks, Matt [PATCH] MIPS: Use generic libgcc intrinsics These routines in arch/mips/lib/ are functionally identical to those recently added to lib/ so remove them and select the generic ones. Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com> --- arch/mips/Kconfig | 5 +++++ arch/mips/lib/Makefile | 2 +- arch/mips/lib/ashldi3.c | 29 ----------------------------- arch/mips/lib/ashrdi3.c | 31 ------------------------------- arch/mips/lib/cmpdi2.c | 27 --------------------------- arch/mips/lib/libgcc.h | 25 ------------------------- arch/mips/lib/lshrdi3.c | 29 ----------------------------- arch/mips/lib/ucmpdi2.c | 21 --------------------- 8 files changed, 6 insertions(+), 163 deletions(-) delete mode 100644 arch/mips/lib/ashldi3.c delete mode 100644 arch/mips/lib/ashrdi3.c delete mode 100644 arch/mips/lib/cmpdi2.c delete mode 100644 arch/mips/lib/libgcc.h delete mode 100644 arch/mips/lib/lshrdi3.c delete mode 100644 arch/mips/lib/ucmpdi2.c diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 2828ecde133d..808626394e8d 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -70,6 +70,11 @@ config MIPS select HAVE_EXIT_THREAD select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_COPY_THREAD_TLS + select LIB_ASHLDI3 + select LIB_ASHRDI3 + select LIB_CMPDI2 + select LIB_LSHRDI3 + select LIB_UCMPDI2 menu "Machine selection" diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile index 0344e575f522..814e739d6f86 100644 --- a/arch/mips/lib/Makefile +++ b/arch/mips/lib/Makefile @@ -15,4 +15,4 @@ obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o +obj-y += bswapsi.o bswapdi.o diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c deleted file mode 100644 index c3e22053d13e..000000000000 --- a/arch/mips/lib/ashldi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c deleted file mode 100644 index 17456024873d..000000000000 --- a/arch/mips/lib/ashrdi3.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c deleted file mode 100644 index 9d849d8743c9..000000000000 --- a/arch/mips/lib/cmpdi2.c +++ /dev/null @@ -1,27 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type notrace __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} - -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/mips/lib/libgcc.h b/arch/mips/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/mips/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c deleted file mode 100644 index 221167c1be55..000000000000 --- a/arch/mips/lib/lshrdi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/mips/lib/ucmpdi2.c b/arch/mips/lib/ucmpdi2.c deleted file mode 100644 index 08067fa538f2..000000000000 --- a/arch/mips/lib/ucmpdi2.c +++ /dev/null @@ -1,21 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type notrace __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} - -EXPORT_SYMBOL(__ucmpdi2); -- 2.7.4 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* Re: [PATCH 4/7] mips: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c 2017-05-24 9:01 ` Matt Redfearn 2017-05-24 9:01 ` Matt Redfearn @ 2017-06-03 2:18 ` Palmer Dabbelt 1 sibling, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-03 2:18 UTC (permalink / raw) To: matt.redfearn Cc: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch On Wed, 24 May 2017 02:01:39 PDT (-0700), matt.redfearn@imgtec.com wrote: > Hi Palmer, > This patch doesn't quite match the subject, since it only removes the > mips specific implementation of __ucmpdi2. The following patch removes > all of the intrinsics that you added to lib/ from arch/mips/lib. I've > built & boot tested this on a MIPS pistachio platform. > Note that this patch will require rebasing on linux-next, since it will > conflict with other changes in arch/mips/Kconfig > > Thanks, > Matt > > [PATCH] MIPS: Use generic libgcc intrinsics > > These routines in arch/mips/lib/ are functionally identical to those > recently added to lib/ so remove them and select the generic ones. > > Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com> > --- > arch/mips/Kconfig | 5 +++++ > arch/mips/lib/Makefile | 2 +- > arch/mips/lib/ashldi3.c | 29 ----------------------------- > arch/mips/lib/ashrdi3.c | 31 ------------------------------- > arch/mips/lib/cmpdi2.c | 27 --------------------------- > arch/mips/lib/libgcc.h | 25 ------------------------- > arch/mips/lib/lshrdi3.c | 29 ----------------------------- > arch/mips/lib/ucmpdi2.c | 21 --------------------- > 8 files changed, 6 insertions(+), 163 deletions(-) > delete mode 100644 arch/mips/lib/ashldi3.c > delete mode 100644 arch/mips/lib/ashrdi3.c > delete mode 100644 arch/mips/lib/cmpdi2.c > delete mode 100644 arch/mips/lib/libgcc.h > delete mode 100644 arch/mips/lib/lshrdi3.c > delete mode 100644 arch/mips/lib/ucmpdi2.c Sorry about that, I'll take your version and submit a v2. ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 4/7] mips: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-24 9:01 ` Matt Redfearn @ 2017-05-24 11:39 ` kbuild test robot 2017-05-24 11:39 ` kbuild test robot 2017-05-24 11:50 ` kbuild test robot 3 siblings, 1 reply; 93+ messages in thread From: kbuild test robot @ 2017-05-24 11:39 UTC (permalink / raw) Cc: kbuild-all, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch, Palmer Dabbelt [-- Attachment #1: Type: text/plain, Size: 1126 bytes --] Hi Palmer, [auto build test ERROR on linus/master] [also build test ERROR on v4.12-rc2] [cannot apply to next-20170524] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Palmer-Dabbelt/lib-Add-shared-copies-of-some-GCC-library-routines/20170524-170717 config: mips-jz4740 (attached as .config) compiler: mips-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=mips All errors (new ones prefixed by >>): kernel/built-in.o: In function `perf_swevent_init': >> core.c:(.text+0x75da8): undefined reference to `__ucmpdi2' drivers/built-in.o: In function `drm_getcap': >> drm_ioctl.c:(.text+0x5d864): undefined reference to `__ucmpdi2' --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 19912 bytes --] ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 4/7] mips: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c 2017-05-24 11:39 ` kbuild test robot @ 2017-05-24 11:39 ` kbuild test robot 0 siblings, 0 replies; 93+ messages in thread From: kbuild test robot @ 2017-05-24 11:39 UTC (permalink / raw) To: Palmer Dabbelt Cc: kbuild-all, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch [-- Attachment #1: Type: text/plain, Size: 1126 bytes --] Hi Palmer, [auto build test ERROR on linus/master] [also build test ERROR on v4.12-rc2] [cannot apply to next-20170524] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Palmer-Dabbelt/lib-Add-shared-copies-of-some-GCC-library-routines/20170524-170717 config: mips-jz4740 (attached as .config) compiler: mips-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=mips All errors (new ones prefixed by >>): kernel/built-in.o: In function `perf_swevent_init': >> core.c:(.text+0x75da8): undefined reference to `__ucmpdi2' drivers/built-in.o: In function `drm_getcap': >> drm_ioctl.c:(.text+0x5d864): undefined reference to `__ucmpdi2' --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 19912 bytes --] ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 4/7] mips: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c 2017-05-23 22:05 ` Palmer Dabbelt ` (2 preceding siblings ...) 2017-05-24 11:39 ` kbuild test robot @ 2017-05-24 11:50 ` kbuild test robot 2017-05-24 11:50 ` kbuild test robot 3 siblings, 1 reply; 93+ messages in thread From: kbuild test robot @ 2017-05-24 11:50 UTC (permalink / raw) Cc: kbuild-all, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch, Palmer Dabbelt [-- Attachment #1: Type: text/plain, Size: 945 bytes --] Hi Palmer, [auto build test ERROR on linus/master] [also build test ERROR on v4.12-rc2] [cannot apply to next-20170524] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Palmer-Dabbelt/lib-Add-shared-copies-of-some-GCC-library-routines/20170524-170717 config: mips-defconfig (attached as .config) compiler: mips-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=mips All errors (new ones prefixed by >>): >> ERROR: "__ucmpdi2" [fs/xfs/xfs.ko] undefined! --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 13771 bytes --] ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 4/7] mips: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c 2017-05-24 11:50 ` kbuild test robot @ 2017-05-24 11:50 ` kbuild test robot 0 siblings, 0 replies; 93+ messages in thread From: kbuild test robot @ 2017-05-24 11:50 UTC (permalink / raw) To: Palmer Dabbelt Cc: kbuild-all, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch [-- Attachment #1: Type: text/plain, Size: 945 bytes --] Hi Palmer, [auto build test ERROR on linus/master] [also build test ERROR on v4.12-rc2] [cannot apply to next-20170524] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Palmer-Dabbelt/lib-Add-shared-copies-of-some-GCC-library-routines/20170524-170717 config: mips-defconfig (attached as .config) compiler: mips-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=mips All errors (new ones prefixed by >>): >> ERROR: "__ucmpdi2" [fs/xfs/xfs.ko] undefined! --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 13771 bytes --] ^ permalink raw reply [flat|nested] 93+ messages in thread
* [PATCH 4/7] mips: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (11 preceding siblings ...) 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt ` (13 subsequent siblings) 26 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/mips/Kconfig | 1 + arch/mips/lib/Makefile | 2 +- arch/mips/lib/ashldi3.c | 2 +- arch/mips/lib/ashrdi3.c | 2 +- arch/mips/lib/cmpdi2.c | 2 +- arch/mips/lib/libgcc.h | 25 ------------------------- arch/mips/lib/lshrdi3.c | 2 +- arch/mips/lib/ucmpdi2.c | 21 --------------------- 8 files changed, 6 insertions(+), 51 deletions(-) delete mode 100644 arch/mips/lib/libgcc.h delete mode 100644 arch/mips/lib/ucmpdi2.c diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 2828ecde133d..b106e6165db0 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -70,6 +70,7 @@ config MIPS select HAVE_EXIT_THREAD select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_COPY_THREAD_TLS + select LIB_UCMPDI3 menu "Machine selection" diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile index 0344e575f522..e38dbafea074 100644 --- a/arch/mips/lib/Makefile +++ b/arch/mips/lib/Makefile @@ -15,4 +15,4 @@ obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o +obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c index c3e22053d13e..b3d706155fce 100644 --- a/arch/mips/lib/ashldi3.c +++ b/arch/mips/lib/ashldi3.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> long long notrace __ashldi3(long long u, word_type b) { diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c index 17456024873d..bca87aca6f5c 100644 --- a/arch/mips/lib/ashrdi3.c +++ b/arch/mips/lib/ashrdi3.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> long long notrace __ashrdi3(long long u, word_type b) { diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c index 9d849d8743c9..774b109921b5 100644 --- a/arch/mips/lib/cmpdi2.c +++ b/arch/mips/lib/cmpdi2.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> word_type notrace __cmpdi2(long long a, long long b) { diff --git a/arch/mips/lib/libgcc.h b/arch/mips/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/mips/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c index 221167c1be55..ceb1a5c14bc8 100644 --- a/arch/mips/lib/lshrdi3.c +++ b/arch/mips/lib/lshrdi3.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> long long notrace __lshrdi3(long long u, word_type b) { diff --git a/arch/mips/lib/ucmpdi2.c b/arch/mips/lib/ucmpdi2.c deleted file mode 100644 index 08067fa538f2..000000000000 --- a/arch/mips/lib/ucmpdi2.c +++ /dev/null @@ -1,21 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type notrace __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} - -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 4/7] mips: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (12 preceding siblings ...) 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` [PATCH 5/7] score: " Palmer Dabbelt ` (12 subsequent siblings) 26 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/mips/Kconfig | 1 + arch/mips/lib/Makefile | 2 +- arch/mips/lib/ashldi3.c | 2 +- arch/mips/lib/ashrdi3.c | 2 +- arch/mips/lib/cmpdi2.c | 2 +- arch/mips/lib/libgcc.h | 25 ------------------------- arch/mips/lib/lshrdi3.c | 2 +- arch/mips/lib/ucmpdi2.c | 21 --------------------- 8 files changed, 6 insertions(+), 51 deletions(-) delete mode 100644 arch/mips/lib/libgcc.h delete mode 100644 arch/mips/lib/ucmpdi2.c diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 2828ecde133d..b106e6165db0 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -70,6 +70,7 @@ config MIPS select HAVE_EXIT_THREAD select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_COPY_THREAD_TLS + select LIB_UCMPDI3 menu "Machine selection" diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile index 0344e575f522..e38dbafea074 100644 --- a/arch/mips/lib/Makefile +++ b/arch/mips/lib/Makefile @@ -15,4 +15,4 @@ obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o +obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c index c3e22053d13e..b3d706155fce 100644 --- a/arch/mips/lib/ashldi3.c +++ b/arch/mips/lib/ashldi3.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> long long notrace __ashldi3(long long u, word_type b) { diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c index 17456024873d..bca87aca6f5c 100644 --- a/arch/mips/lib/ashrdi3.c +++ b/arch/mips/lib/ashrdi3.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> long long notrace __ashrdi3(long long u, word_type b) { diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c index 9d849d8743c9..774b109921b5 100644 --- a/arch/mips/lib/cmpdi2.c +++ b/arch/mips/lib/cmpdi2.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> word_type notrace __cmpdi2(long long a, long long b) { diff --git a/arch/mips/lib/libgcc.h b/arch/mips/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/mips/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c index 221167c1be55..ceb1a5c14bc8 100644 --- a/arch/mips/lib/lshrdi3.c +++ b/arch/mips/lib/lshrdi3.c @@ -1,6 +1,6 @@ #include <linux/export.h> -#include "libgcc.h" +#include <lib/libgcc.h> long long notrace __lshrdi3(long long u, word_type b) { diff --git a/arch/mips/lib/ucmpdi2.c b/arch/mips/lib/ucmpdi2.c deleted file mode 100644 index 08067fa538f2..000000000000 --- a/arch/mips/lib/ucmpdi2.c +++ /dev/null @@ -1,21 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type notrace __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} - -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 5/7] score: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (13 preceding siblings ...) 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` [PATCH 6/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c Palmer Dabbelt ` (11 subsequent siblings) 26 siblings, 1 reply; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/score/Kconfig | 5 +++++ arch/score/lib/Makefile | 3 --- arch/score/lib/ashldi3.c | 46 ---------------------------------------------- arch/score/lib/ashrdi3.c | 48 ------------------------------------------------ arch/score/lib/cmpdi2.c | 44 -------------------------------------------- arch/score/lib/libgcc.h | 37 ------------------------------------- arch/score/lib/lshrdi3.c | 47 ----------------------------------------------- arch/score/lib/ucmpdi2.c | 38 -------------------------------------- 8 files changed, 5 insertions(+), 263 deletions(-) delete mode 100644 arch/score/lib/ashldi3.c delete mode 100644 arch/score/lib/ashrdi3.c delete mode 100644 arch/score/lib/cmpdi2.c delete mode 100644 arch/score/lib/libgcc.h delete mode 100644 arch/score/lib/lshrdi3.c delete mode 100644 arch/score/lib/ucmpdi2.c diff --git a/arch/score/Kconfig b/arch/score/Kconfig index 507d63181389..5959a981061c 100644 --- a/arch/score/Kconfig +++ b/arch/score/Kconfig @@ -15,6 +15,11 @@ config SCORE select MODULES_USE_ELF_REL select CLONE_BACKWARDS select CPU_NO_EFFICIENT_FFS + select LIB_ASHLDI3 + select LIB_ASHRDI3 + select LIB_CMPDI2 + select LIB_LSHRDI3 + select LIB_UCMPDI2 choice prompt "System type" diff --git a/arch/score/lib/Makefile b/arch/score/lib/Makefile index 553e30e81faf..ea3f3aba8c71 100644 --- a/arch/score/lib/Makefile +++ b/arch/score/lib/Makefile @@ -3,6 +3,3 @@ # lib-y += string.o checksum.o checksum_copy.o - -# libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o cmpdi2.o lshrdi3.o ucmpdi2.o diff --git a/arch/score/lib/ashldi3.c b/arch/score/lib/ashldi3.c deleted file mode 100644 index 15691a910431..000000000000 --- a/arch/score/lib/ashldi3.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * arch/score/lib/ashldi3.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/score/lib/ashrdi3.c b/arch/score/lib/ashrdi3.c deleted file mode 100644 index d9814a5d8d30..000000000000 --- a/arch/score/lib/ashrdi3.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * arch/score/lib/ashrdi3.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/score/lib/cmpdi2.c b/arch/score/lib/cmpdi2.c deleted file mode 100644 index 1ed5290c66ed..000000000000 --- a/arch/score/lib/cmpdi2.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * arch/score/lib/cmpdi2.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/score/lib/libgcc.h b/arch/score/lib/libgcc.h deleted file mode 100644 index 0f12543d9f31..000000000000 --- a/arch/score/lib/libgcc.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * arch/score/lib/libgcc.h - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__((mode(__word__))); - -struct DWstruct { - int low, high; -}; - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/score/lib/lshrdi3.c b/arch/score/lib/lshrdi3.c deleted file mode 100644 index ce21175fd791..000000000000 --- a/arch/score/lib/lshrdi3.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * arch/score/lib/lshrdi3.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include <linux/module.h> -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/score/lib/ucmpdi2.c b/arch/score/lib/ucmpdi2.c deleted file mode 100644 index b15241e0b079..000000000000 --- a/arch/score/lib/ucmpdi2.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * arch/score/lib/ucmpdi2.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 5/7] score: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c 2017-05-23 22:05 ` [PATCH 5/7] score: " Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 0 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/score/Kconfig | 5 +++++ arch/score/lib/Makefile | 3 --- arch/score/lib/ashldi3.c | 46 ---------------------------------------------- arch/score/lib/ashrdi3.c | 48 ------------------------------------------------ arch/score/lib/cmpdi2.c | 44 -------------------------------------------- arch/score/lib/libgcc.h | 37 ------------------------------------- arch/score/lib/lshrdi3.c | 47 ----------------------------------------------- arch/score/lib/ucmpdi2.c | 38 -------------------------------------- 8 files changed, 5 insertions(+), 263 deletions(-) delete mode 100644 arch/score/lib/ashldi3.c delete mode 100644 arch/score/lib/ashrdi3.c delete mode 100644 arch/score/lib/cmpdi2.c delete mode 100644 arch/score/lib/libgcc.h delete mode 100644 arch/score/lib/lshrdi3.c delete mode 100644 arch/score/lib/ucmpdi2.c diff --git a/arch/score/Kconfig b/arch/score/Kconfig index 507d63181389..5959a981061c 100644 --- a/arch/score/Kconfig +++ b/arch/score/Kconfig @@ -15,6 +15,11 @@ config SCORE select MODULES_USE_ELF_REL select CLONE_BACKWARDS select CPU_NO_EFFICIENT_FFS + select LIB_ASHLDI3 + select LIB_ASHRDI3 + select LIB_CMPDI2 + select LIB_LSHRDI3 + select LIB_UCMPDI2 choice prompt "System type" diff --git a/arch/score/lib/Makefile b/arch/score/lib/Makefile index 553e30e81faf..ea3f3aba8c71 100644 --- a/arch/score/lib/Makefile +++ b/arch/score/lib/Makefile @@ -3,6 +3,3 @@ # lib-y += string.o checksum.o checksum_copy.o - -# libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o cmpdi2.o lshrdi3.o ucmpdi2.o diff --git a/arch/score/lib/ashldi3.c b/arch/score/lib/ashldi3.c deleted file mode 100644 index 15691a910431..000000000000 --- a/arch/score/lib/ashldi3.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * arch/score/lib/ashldi3.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/score/lib/ashrdi3.c b/arch/score/lib/ashrdi3.c deleted file mode 100644 index d9814a5d8d30..000000000000 --- a/arch/score/lib/ashrdi3.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * arch/score/lib/ashrdi3.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/score/lib/cmpdi2.c b/arch/score/lib/cmpdi2.c deleted file mode 100644 index 1ed5290c66ed..000000000000 --- a/arch/score/lib/cmpdi2.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * arch/score/lib/cmpdi2.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/score/lib/libgcc.h b/arch/score/lib/libgcc.h deleted file mode 100644 index 0f12543d9f31..000000000000 --- a/arch/score/lib/libgcc.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * arch/score/lib/libgcc.h - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__((mode(__word__))); - -struct DWstruct { - int low, high; -}; - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/score/lib/lshrdi3.c b/arch/score/lib/lshrdi3.c deleted file mode 100644 index ce21175fd791..000000000000 --- a/arch/score/lib/lshrdi3.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * arch/score/lib/lshrdi3.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include <linux/module.h> -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/score/lib/ucmpdi2.c b/arch/score/lib/ucmpdi2.c deleted file mode 100644 index b15241e0b079..000000000000 --- a/arch/score/lib/ucmpdi2.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * arch/score/lib/ucmpdi2.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 6/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (14 preceding siblings ...) 2017-05-23 22:05 ` [PATCH 5/7] score: " Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt ` (10 subsequent siblings) 26 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/sh/Kconfig | 3 +++ arch/sh/lib/Makefile | 4 +--- arch/sh/lib/ashldi3.c | 29 ----------------------------- arch/sh/lib/ashrdi3.c | 31 ------------------------------- arch/sh/lib/libgcc.h | 25 ------------------------- arch/sh/lib/lshrdi3.c | 29 ----------------------------- 6 files changed, 4 insertions(+), 117 deletions(-) delete mode 100644 arch/sh/lib/ashldi3.c delete mode 100644 arch/sh/lib/ashrdi3.c delete mode 100644 arch/sh/lib/libgcc.h delete mode 100644 arch/sh/lib/lshrdi3.c diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index ee086958b2b2..f991632f31ba 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -48,6 +48,9 @@ config SUPERH select HAVE_ARCH_AUDITSYSCALL select HAVE_FUTEX_CMPXCHG if FUTEX select HAVE_NMI + select LIB_ASHLDI3 + select LIB_ASHRDI3 + select LIB_LSHRDI3 help The SuperH is a RISC processor targeted for use in embedded systems and consumer electronics; it was also used in the Sega Dreamcast diff --git a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile index 3baff31e58cf..8caae109a728 100644 --- a/arch/sh/lib/Makefile +++ b/arch/sh/lib/Makefile @@ -6,9 +6,7 @@ lib-y = delay.o memmove.o memchr.o \ checksum.o strlen.o div64.o div64-generic.o # Extracted from libgcc -obj-y += movmem.o ashldi3.o ashrdi3.o lshrdi3.o \ - ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o \ - udiv_qrnnd.o +obj-y += movmem.o ashlsi3.o ashrsi3.o ashiftrt.o udiv_qrnnd.o udivsi3-y := udivsi3_i4i-Os.o diff --git a/arch/sh/lib/ashldi3.c b/arch/sh/lib/ashldi3.c deleted file mode 100644 index beb80f316095..000000000000 --- a/arch/sh/lib/ashldi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/sh/lib/ashrdi3.c b/arch/sh/lib/ashrdi3.c deleted file mode 100644 index c884a912b660..000000000000 --- a/arch/sh/lib/ashrdi3.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/sh/lib/libgcc.h b/arch/sh/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/sh/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sh/lib/lshrdi3.c b/arch/sh/lib/lshrdi3.c deleted file mode 100644 index dcf8d6810b7c..000000000000 --- a/arch/sh/lib/lshrdi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__lshrdi3); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 6/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (15 preceding siblings ...) 2017-05-23 22:05 ` [PATCH 6/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt ` (9 subsequent siblings) 26 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/sh/Kconfig | 3 +++ arch/sh/lib/Makefile | 4 +--- arch/sh/lib/ashldi3.c | 29 ----------------------------- arch/sh/lib/ashrdi3.c | 31 ------------------------------- arch/sh/lib/libgcc.h | 25 ------------------------- arch/sh/lib/lshrdi3.c | 29 ----------------------------- 6 files changed, 4 insertions(+), 117 deletions(-) delete mode 100644 arch/sh/lib/ashldi3.c delete mode 100644 arch/sh/lib/ashrdi3.c delete mode 100644 arch/sh/lib/libgcc.h delete mode 100644 arch/sh/lib/lshrdi3.c diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index ee086958b2b2..f991632f31ba 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -48,6 +48,9 @@ config SUPERH select HAVE_ARCH_AUDITSYSCALL select HAVE_FUTEX_CMPXCHG if FUTEX select HAVE_NMI + select LIB_ASHLDI3 + select LIB_ASHRDI3 + select LIB_LSHRDI3 help The SuperH is a RISC processor targeted for use in embedded systems and consumer electronics; it was also used in the Sega Dreamcast diff --git a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile index 3baff31e58cf..8caae109a728 100644 --- a/arch/sh/lib/Makefile +++ b/arch/sh/lib/Makefile @@ -6,9 +6,7 @@ lib-y = delay.o memmove.o memchr.o \ checksum.o strlen.o div64.o div64-generic.o # Extracted from libgcc -obj-y += movmem.o ashldi3.o ashrdi3.o lshrdi3.o \ - ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o \ - udiv_qrnnd.o +obj-y += movmem.o ashlsi3.o ashrsi3.o ashiftrt.o udiv_qrnnd.o udivsi3-y := udivsi3_i4i-Os.o diff --git a/arch/sh/lib/ashldi3.c b/arch/sh/lib/ashldi3.c deleted file mode 100644 index beb80f316095..000000000000 --- a/arch/sh/lib/ashldi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/sh/lib/ashrdi3.c b/arch/sh/lib/ashrdi3.c deleted file mode 100644 index c884a912b660..000000000000 --- a/arch/sh/lib/ashrdi3.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/sh/lib/libgcc.h b/arch/sh/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/sh/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sh/lib/lshrdi3.c b/arch/sh/lib/lshrdi3.c deleted file mode 100644 index dcf8d6810b7c..000000000000 --- a/arch/sh/lib/lshrdi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__lshrdi3); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 6/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (16 preceding siblings ...) 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt ` (8 subsequent siblings) 26 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/sh/Kconfig | 3 +++ arch/sh/lib/Makefile | 4 +--- arch/sh/lib/ashldi3.c | 29 ----------------------------- arch/sh/lib/ashrdi3.c | 31 ------------------------------- arch/sh/lib/libgcc.h | 25 ------------------------- arch/sh/lib/lshrdi3.c | 29 ----------------------------- 6 files changed, 4 insertions(+), 117 deletions(-) delete mode 100644 arch/sh/lib/ashldi3.c delete mode 100644 arch/sh/lib/ashrdi3.c delete mode 100644 arch/sh/lib/libgcc.h delete mode 100644 arch/sh/lib/lshrdi3.c diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index ee086958b2b2..f991632f31ba 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -48,6 +48,9 @@ config SUPERH select HAVE_ARCH_AUDITSYSCALL select HAVE_FUTEX_CMPXCHG if FUTEX select HAVE_NMI + select LIB_ASHLDI3 + select LIB_ASHRDI3 + select LIB_LSHRDI3 help The SuperH is a RISC processor targeted for use in embedded systems and consumer electronics; it was also used in the Sega Dreamcast diff --git a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile index 3baff31e58cf..8caae109a728 100644 --- a/arch/sh/lib/Makefile +++ b/arch/sh/lib/Makefile @@ -6,9 +6,7 @@ lib-y = delay.o memmove.o memchr.o \ checksum.o strlen.o div64.o div64-generic.o # Extracted from libgcc -obj-y += movmem.o ashldi3.o ashrdi3.o lshrdi3.o \ - ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o \ - udiv_qrnnd.o +obj-y += movmem.o ashlsi3.o ashrsi3.o ashiftrt.o udiv_qrnnd.o udivsi3-y := udivsi3_i4i-Os.o diff --git a/arch/sh/lib/ashldi3.c b/arch/sh/lib/ashldi3.c deleted file mode 100644 index beb80f316095..000000000000 --- a/arch/sh/lib/ashldi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/sh/lib/ashrdi3.c b/arch/sh/lib/ashrdi3.c deleted file mode 100644 index c884a912b660..000000000000 --- a/arch/sh/lib/ashrdi3.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/sh/lib/libgcc.h b/arch/sh/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/sh/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sh/lib/lshrdi3.c b/arch/sh/lib/lshrdi3.c deleted file mode 100644 index dcf8d6810b7c..000000000000 --- a/arch/sh/lib/lshrdi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__lshrdi3); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 6/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (17 preceding siblings ...) 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt ` (2 more replies) 2017-05-23 22:05 ` [PATCH 7/7] sparc: Use lib/{cmpdi2,ucmpdi2}.c Palmer Dabbelt ` (7 subsequent siblings) 26 siblings, 3 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/sh/Kconfig | 3 +++ arch/sh/lib/Makefile | 4 +--- arch/sh/lib/ashldi3.c | 29 ----------------------------- arch/sh/lib/ashrdi3.c | 31 ------------------------------- arch/sh/lib/libgcc.h | 25 ------------------------- arch/sh/lib/lshrdi3.c | 29 ----------------------------- 6 files changed, 4 insertions(+), 117 deletions(-) delete mode 100644 arch/sh/lib/ashldi3.c delete mode 100644 arch/sh/lib/ashrdi3.c delete mode 100644 arch/sh/lib/libgcc.h delete mode 100644 arch/sh/lib/lshrdi3.c diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index ee086958b2b2..f991632f31ba 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -48,6 +48,9 @@ config SUPERH select HAVE_ARCH_AUDITSYSCALL select HAVE_FUTEX_CMPXCHG if FUTEX select HAVE_NMI + select LIB_ASHLDI3 + select LIB_ASHRDI3 + select LIB_LSHRDI3 help The SuperH is a RISC processor targeted for use in embedded systems and consumer electronics; it was also used in the Sega Dreamcast diff --git a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile index 3baff31e58cf..8caae109a728 100644 --- a/arch/sh/lib/Makefile +++ b/arch/sh/lib/Makefile @@ -6,9 +6,7 @@ lib-y = delay.o memmove.o memchr.o \ checksum.o strlen.o div64.o div64-generic.o # Extracted from libgcc -obj-y += movmem.o ashldi3.o ashrdi3.o lshrdi3.o \ - ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o \ - udiv_qrnnd.o +obj-y += movmem.o ashlsi3.o ashrsi3.o ashiftrt.o udiv_qrnnd.o udivsi3-y := udivsi3_i4i-Os.o diff --git a/arch/sh/lib/ashldi3.c b/arch/sh/lib/ashldi3.c deleted file mode 100644 index beb80f316095..000000000000 --- a/arch/sh/lib/ashldi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/sh/lib/ashrdi3.c b/arch/sh/lib/ashrdi3.c deleted file mode 100644 index c884a912b660..000000000000 --- a/arch/sh/lib/ashrdi3.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/sh/lib/libgcc.h b/arch/sh/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/sh/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sh/lib/lshrdi3.c b/arch/sh/lib/lshrdi3.c deleted file mode 100644 index dcf8d6810b7c..000000000000 --- a/arch/sh/lib/lshrdi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__lshrdi3); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 6/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-24 11:22 ` kbuild test robot 2017-05-24 11:30 ` kbuild test robot 2 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/sh/Kconfig | 3 +++ arch/sh/lib/Makefile | 4 +--- arch/sh/lib/ashldi3.c | 29 ----------------------------- arch/sh/lib/ashrdi3.c | 31 ------------------------------- arch/sh/lib/libgcc.h | 25 ------------------------- arch/sh/lib/lshrdi3.c | 29 ----------------------------- 6 files changed, 4 insertions(+), 117 deletions(-) delete mode 100644 arch/sh/lib/ashldi3.c delete mode 100644 arch/sh/lib/ashrdi3.c delete mode 100644 arch/sh/lib/libgcc.h delete mode 100644 arch/sh/lib/lshrdi3.c diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index ee086958b2b2..f991632f31ba 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -48,6 +48,9 @@ config SUPERH select HAVE_ARCH_AUDITSYSCALL select HAVE_FUTEX_CMPXCHG if FUTEX select HAVE_NMI + select LIB_ASHLDI3 + select LIB_ASHRDI3 + select LIB_LSHRDI3 help The SuperH is a RISC processor targeted for use in embedded systems and consumer electronics; it was also used in the Sega Dreamcast diff --git a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile index 3baff31e58cf..8caae109a728 100644 --- a/arch/sh/lib/Makefile +++ b/arch/sh/lib/Makefile @@ -6,9 +6,7 @@ lib-y = delay.o memmove.o memchr.o \ checksum.o strlen.o div64.o div64-generic.o # Extracted from libgcc -obj-y += movmem.o ashldi3.o ashrdi3.o lshrdi3.o \ - ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o \ - udiv_qrnnd.o +obj-y += movmem.o ashlsi3.o ashrsi3.o ashiftrt.o udiv_qrnnd.o udivsi3-y := udivsi3_i4i-Os.o diff --git a/arch/sh/lib/ashldi3.c b/arch/sh/lib/ashldi3.c deleted file mode 100644 index beb80f316095..000000000000 --- a/arch/sh/lib/ashldi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/sh/lib/ashrdi3.c b/arch/sh/lib/ashrdi3.c deleted file mode 100644 index c884a912b660..000000000000 --- a/arch/sh/lib/ashrdi3.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/sh/lib/libgcc.h b/arch/sh/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/sh/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sh/lib/lshrdi3.c b/arch/sh/lib/lshrdi3.c deleted file mode 100644 index dcf8d6810b7c..000000000000 --- a/arch/sh/lib/lshrdi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__lshrdi3); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* Re: [PATCH 6/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-24 11:22 ` kbuild test robot 2017-05-24 11:22 ` kbuild test robot 2017-05-24 11:30 ` kbuild test robot 2 siblings, 1 reply; 93+ messages in thread From: kbuild test robot @ 2017-05-24 11:22 UTC (permalink / raw) Cc: kbuild-all, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch, Palmer Dabbelt [-- Attachment #1: Type: text/plain, Size: 1087 bytes --] Hi Palmer, [auto build test ERROR on linus/master] [also build test ERROR on v4.12-rc2] [cannot apply to next-20170524] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Palmer-Dabbelt/lib-Add-shared-copies-of-some-GCC-library-routines/20170524-170717 config: sh-allnoconfig (attached as .config) compiler: sh4-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=sh All errors (new ones prefixed by >>): >> make[3]: *** No rule to make target 'arch/sh/lib/ashldi3.c', needed by 'arch/sh/boot/compressed/ashldi3.c'. make[3]: Target 'arch/sh/boot/compressed/vmlinux' not remade because of errors. --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 5489 bytes --] ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 6/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c 2017-05-24 11:22 ` kbuild test robot @ 2017-05-24 11:22 ` kbuild test robot 0 siblings, 0 replies; 93+ messages in thread From: kbuild test robot @ 2017-05-24 11:22 UTC (permalink / raw) To: Palmer Dabbelt Cc: kbuild-all, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch [-- Attachment #1: Type: text/plain, Size: 1087 bytes --] Hi Palmer, [auto build test ERROR on linus/master] [also build test ERROR on v4.12-rc2] [cannot apply to next-20170524] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Palmer-Dabbelt/lib-Add-shared-copies-of-some-GCC-library-routines/20170524-170717 config: sh-allnoconfig (attached as .config) compiler: sh4-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=sh All errors (new ones prefixed by >>): >> make[3]: *** No rule to make target 'arch/sh/lib/ashldi3.c', needed by 'arch/sh/boot/compressed/ashldi3.c'. make[3]: Target 'arch/sh/boot/compressed/vmlinux' not remade because of errors. --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 5489 bytes --] ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 6/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-24 11:22 ` kbuild test robot @ 2017-05-24 11:30 ` kbuild test robot 2017-05-24 11:30 ` kbuild test robot 2 siblings, 1 reply; 93+ messages in thread From: kbuild test robot @ 2017-05-24 11:30 UTC (permalink / raw) Cc: kbuild-all, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch, Palmer Dabbelt [-- Attachment #1: Type: text/plain, Size: 1087 bytes --] Hi Palmer, [auto build test ERROR on linus/master] [also build test ERROR on v4.12-rc2] [cannot apply to next-20170524] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Palmer-Dabbelt/lib-Add-shared-copies-of-some-GCC-library-routines/20170524-170717 config: sh-titan_defconfig (attached as .config) compiler: sh4-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=sh All errors (new ones prefixed by >>): >> arch/sh/kernel/built-in.o:(___ksymtab+__lshrsi3_r0+0x0): undefined reference to `__lshrsi3_r0' >> arch/sh/kernel/built-in.o:(___ksymtab+__lshrsi3+0x0): undefined reference to `__lshrsi3' --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 16461 bytes --] ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 6/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c 2017-05-24 11:30 ` kbuild test robot @ 2017-05-24 11:30 ` kbuild test robot 0 siblings, 0 replies; 93+ messages in thread From: kbuild test robot @ 2017-05-24 11:30 UTC (permalink / raw) To: Palmer Dabbelt Cc: kbuild-all, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch [-- Attachment #1: Type: text/plain, Size: 1087 bytes --] Hi Palmer, [auto build test ERROR on linus/master] [also build test ERROR on v4.12-rc2] [cannot apply to next-20170524] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Palmer-Dabbelt/lib-Add-shared-copies-of-some-GCC-library-routines/20170524-170717 config: sh-titan_defconfig (attached as .config) compiler: sh4-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=sh All errors (new ones prefixed by >>): >> arch/sh/kernel/built-in.o:(___ksymtab+__lshrsi3_r0+0x0): undefined reference to `__lshrsi3_r0' >> arch/sh/kernel/built-in.o:(___ksymtab+__lshrsi3+0x0): undefined reference to `__lshrsi3' --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 16461 bytes --] ^ permalink raw reply [flat|nested] 93+ messages in thread
* [PATCH 7/7] sparc: Use lib/{cmpdi2,ucmpdi2}.c 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (18 preceding siblings ...) 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt ` (6 subsequent siblings) 26 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/sparc/Kconfig | 2 ++ arch/sparc/lib/Makefile | 4 ++-- arch/sparc/lib/cmpdi2.c | 27 --------------------------- arch/sparc/lib/libgcc.h | 18 ------------------ arch/sparc/lib/ucmpdi2.c | 19 ------------------- 5 files changed, 4 insertions(+), 66 deletions(-) delete mode 100644 arch/sparc/lib/cmpdi2.c delete mode 100644 arch/sparc/lib/libgcc.h delete mode 100644 arch/sparc/lib/ucmpdi2.c diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 58243b0d21c0..80ed2338812b 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -52,6 +52,8 @@ config SPARC32 select CLZ_TAB select HAVE_UID16 select OLD_SIGACTION + select LIB_CMPDI2 + select LIB_UCMPDI2 config SPARC64 def_bool 64BIT diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile index 69912d2f8b54..815b4a336aa8 100644 --- a/arch/sparc/lib/Makefile +++ b/arch/sparc/lib/Makefile @@ -14,7 +14,7 @@ lib-$(CONFIG_SPARC32) += divdi3.o udivdi3.o lib-$(CONFIG_SPARC32) += copy_user.o locks.o lib-$(CONFIG_SPARC64) += atomic_64.o lib-$(CONFIG_SPARC32) += lshrdi3.o ashldi3.o -lib-$(CONFIG_SPARC32) += muldi3.o bitext.o cmpdi2.o +lib-$(CONFIG_SPARC32) += muldi3.o bitext.o lib-$(CONFIG_SPARC64) += copy_page.o clear_page.o bzero.o lib-$(CONFIG_SPARC64) += csum_copy.o csum_copy_from_user.o csum_copy_to_user.o @@ -42,5 +42,5 @@ lib-$(CONFIG_SPARC64) += copy_in_user.o memmove.o lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o obj-$(CONFIG_SPARC64) += iomap.o -obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o +obj-$(CONFIG_SPARC32) += atomic32.o obj-$(CONFIG_SPARC64) += PeeCeeI.o diff --git a/arch/sparc/lib/cmpdi2.c b/arch/sparc/lib/cmpdi2.c deleted file mode 100644 index 8c1306437ed1..000000000000 --- a/arch/sparc/lib/cmpdi2.c +++ /dev/null @@ -1,27 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} - -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/sparc/lib/libgcc.h b/arch/sparc/lib/libgcc.h deleted file mode 100644 index b84fd797f3ea..000000000000 --- a/arch/sparc/lib/libgcc.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -struct DWstruct { - int high, low; -}; - -typedef union -{ - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sparc/lib/ucmpdi2.c b/arch/sparc/lib/ucmpdi2.c deleted file mode 100644 index 1e06ed500682..000000000000 --- a/arch/sparc/lib/ucmpdi2.c +++ /dev/null @@ -1,19 +0,0 @@ -#include <linux/module.h> -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 7/7] sparc: Use lib/{cmpdi2,ucmpdi2}.c 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (19 preceding siblings ...) 2017-05-23 22:05 ` [PATCH 7/7] sparc: Use lib/{cmpdi2,ucmpdi2}.c Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt ` (5 subsequent siblings) 26 siblings, 1 reply; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/sparc/Kconfig | 2 ++ arch/sparc/lib/Makefile | 4 ++-- arch/sparc/lib/cmpdi2.c | 27 --------------------------- arch/sparc/lib/libgcc.h | 18 ------------------ arch/sparc/lib/ucmpdi2.c | 19 ------------------- 5 files changed, 4 insertions(+), 66 deletions(-) delete mode 100644 arch/sparc/lib/cmpdi2.c delete mode 100644 arch/sparc/lib/libgcc.h delete mode 100644 arch/sparc/lib/ucmpdi2.c diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 58243b0d21c0..80ed2338812b 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -52,6 +52,8 @@ config SPARC32 select CLZ_TAB select HAVE_UID16 select OLD_SIGACTION + select LIB_CMPDI2 + select LIB_UCMPDI2 config SPARC64 def_bool 64BIT diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile index 69912d2f8b54..815b4a336aa8 100644 --- a/arch/sparc/lib/Makefile +++ b/arch/sparc/lib/Makefile @@ -14,7 +14,7 @@ lib-$(CONFIG_SPARC32) += divdi3.o udivdi3.o lib-$(CONFIG_SPARC32) += copy_user.o locks.o lib-$(CONFIG_SPARC64) += atomic_64.o lib-$(CONFIG_SPARC32) += lshrdi3.o ashldi3.o -lib-$(CONFIG_SPARC32) += muldi3.o bitext.o cmpdi2.o +lib-$(CONFIG_SPARC32) += muldi3.o bitext.o lib-$(CONFIG_SPARC64) += copy_page.o clear_page.o bzero.o lib-$(CONFIG_SPARC64) += csum_copy.o csum_copy_from_user.o csum_copy_to_user.o @@ -42,5 +42,5 @@ lib-$(CONFIG_SPARC64) += copy_in_user.o memmove.o lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o obj-$(CONFIG_SPARC64) += iomap.o -obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o +obj-$(CONFIG_SPARC32) += atomic32.o obj-$(CONFIG_SPARC64) += PeeCeeI.o diff --git a/arch/sparc/lib/cmpdi2.c b/arch/sparc/lib/cmpdi2.c deleted file mode 100644 index 8c1306437ed1..000000000000 --- a/arch/sparc/lib/cmpdi2.c +++ /dev/null @@ -1,27 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} - -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/sparc/lib/libgcc.h b/arch/sparc/lib/libgcc.h deleted file mode 100644 index b84fd797f3ea..000000000000 --- a/arch/sparc/lib/libgcc.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -struct DWstruct { - int high, low; -}; - -typedef union -{ - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sparc/lib/ucmpdi2.c b/arch/sparc/lib/ucmpdi2.c deleted file mode 100644 index 1e06ed500682..000000000000 --- a/arch/sparc/lib/ucmpdi2.c +++ /dev/null @@ -1,19 +0,0 @@ -#include <linux/module.h> -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 7/7] sparc: Use lib/{cmpdi2,ucmpdi2}.c 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 0 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/sparc/Kconfig | 2 ++ arch/sparc/lib/Makefile | 4 ++-- arch/sparc/lib/cmpdi2.c | 27 --------------------------- arch/sparc/lib/libgcc.h | 18 ------------------ arch/sparc/lib/ucmpdi2.c | 19 ------------------- 5 files changed, 4 insertions(+), 66 deletions(-) delete mode 100644 arch/sparc/lib/cmpdi2.c delete mode 100644 arch/sparc/lib/libgcc.h delete mode 100644 arch/sparc/lib/ucmpdi2.c diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 58243b0d21c0..80ed2338812b 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -52,6 +52,8 @@ config SPARC32 select CLZ_TAB select HAVE_UID16 select OLD_SIGACTION + select LIB_CMPDI2 + select LIB_UCMPDI2 config SPARC64 def_bool 64BIT diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile index 69912d2f8b54..815b4a336aa8 100644 --- a/arch/sparc/lib/Makefile +++ b/arch/sparc/lib/Makefile @@ -14,7 +14,7 @@ lib-$(CONFIG_SPARC32) += divdi3.o udivdi3.o lib-$(CONFIG_SPARC32) += copy_user.o locks.o lib-$(CONFIG_SPARC64) += atomic_64.o lib-$(CONFIG_SPARC32) += lshrdi3.o ashldi3.o -lib-$(CONFIG_SPARC32) += muldi3.o bitext.o cmpdi2.o +lib-$(CONFIG_SPARC32) += muldi3.o bitext.o lib-$(CONFIG_SPARC64) += copy_page.o clear_page.o bzero.o lib-$(CONFIG_SPARC64) += csum_copy.o csum_copy_from_user.o csum_copy_to_user.o @@ -42,5 +42,5 @@ lib-$(CONFIG_SPARC64) += copy_in_user.o memmove.o lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o obj-$(CONFIG_SPARC64) += iomap.o -obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o +obj-$(CONFIG_SPARC32) += atomic32.o obj-$(CONFIG_SPARC64) += PeeCeeI.o diff --git a/arch/sparc/lib/cmpdi2.c b/arch/sparc/lib/cmpdi2.c deleted file mode 100644 index 8c1306437ed1..000000000000 --- a/arch/sparc/lib/cmpdi2.c +++ /dev/null @@ -1,27 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} - -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/sparc/lib/libgcc.h b/arch/sparc/lib/libgcc.h deleted file mode 100644 index b84fd797f3ea..000000000000 --- a/arch/sparc/lib/libgcc.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -struct DWstruct { - int high, low; -}; - -typedef union -{ - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sparc/lib/ucmpdi2.c b/arch/sparc/lib/ucmpdi2.c deleted file mode 100644 index 1e06ed500682..000000000000 --- a/arch/sparc/lib/ucmpdi2.c +++ /dev/null @@ -1,19 +0,0 @@ -#include <linux/module.h> -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 7/7] sparc: Use lib/{cmpdi2,ucmpdi2}.c 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (20 preceding siblings ...) 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-23 22:05 ` Palmer Dabbelt ` (4 subsequent siblings) 26 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/sparc/Kconfig | 2 ++ arch/sparc/lib/Makefile | 4 ++-- arch/sparc/lib/cmpdi2.c | 27 --------------------------- arch/sparc/lib/libgcc.h | 18 ------------------ arch/sparc/lib/ucmpdi2.c | 19 ------------------- 5 files changed, 4 insertions(+), 66 deletions(-) delete mode 100644 arch/sparc/lib/cmpdi2.c delete mode 100644 arch/sparc/lib/libgcc.h delete mode 100644 arch/sparc/lib/ucmpdi2.c diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 58243b0d21c0..80ed2338812b 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -52,6 +52,8 @@ config SPARC32 select CLZ_TAB select HAVE_UID16 select OLD_SIGACTION + select LIB_CMPDI2 + select LIB_UCMPDI2 config SPARC64 def_bool 64BIT diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile index 69912d2f8b54..815b4a336aa8 100644 --- a/arch/sparc/lib/Makefile +++ b/arch/sparc/lib/Makefile @@ -14,7 +14,7 @@ lib-$(CONFIG_SPARC32) += divdi3.o udivdi3.o lib-$(CONFIG_SPARC32) += copy_user.o locks.o lib-$(CONFIG_SPARC64) += atomic_64.o lib-$(CONFIG_SPARC32) += lshrdi3.o ashldi3.o -lib-$(CONFIG_SPARC32) += muldi3.o bitext.o cmpdi2.o +lib-$(CONFIG_SPARC32) += muldi3.o bitext.o lib-$(CONFIG_SPARC64) += copy_page.o clear_page.o bzero.o lib-$(CONFIG_SPARC64) += csum_copy.o csum_copy_from_user.o csum_copy_to_user.o @@ -42,5 +42,5 @@ lib-$(CONFIG_SPARC64) += copy_in_user.o memmove.o lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o obj-$(CONFIG_SPARC64) += iomap.o -obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o +obj-$(CONFIG_SPARC32) += atomic32.o obj-$(CONFIG_SPARC64) += PeeCeeI.o diff --git a/arch/sparc/lib/cmpdi2.c b/arch/sparc/lib/cmpdi2.c deleted file mode 100644 index 8c1306437ed1..000000000000 --- a/arch/sparc/lib/cmpdi2.c +++ /dev/null @@ -1,27 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} - -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/sparc/lib/libgcc.h b/arch/sparc/lib/libgcc.h deleted file mode 100644 index b84fd797f3ea..000000000000 --- a/arch/sparc/lib/libgcc.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -struct DWstruct { - int high, low; -}; - -typedef union -{ - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sparc/lib/ucmpdi2.c b/arch/sparc/lib/ucmpdi2.c deleted file mode 100644 index 1e06ed500682..000000000000 --- a/arch/sparc/lib/ucmpdi2.c +++ /dev/null @@ -1,19 +0,0 @@ -#include <linux/module.h> -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 7/7] sparc: Use lib/{cmpdi2,ucmpdi2}.c 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (21 preceding siblings ...) 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-23 22:05 ` Palmer Dabbelt 2017-05-24 9:21 ` Unify the various copies of libgcc into lib Geert Uytterhoeven ` (3 subsequent siblings) 26 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-05-23 22:05 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/sparc/Kconfig | 2 ++ arch/sparc/lib/Makefile | 4 ++-- arch/sparc/lib/cmpdi2.c | 27 --------------------------- arch/sparc/lib/libgcc.h | 18 ------------------ arch/sparc/lib/ucmpdi2.c | 19 ------------------- 5 files changed, 4 insertions(+), 66 deletions(-) delete mode 100644 arch/sparc/lib/cmpdi2.c delete mode 100644 arch/sparc/lib/libgcc.h delete mode 100644 arch/sparc/lib/ucmpdi2.c diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 58243b0d21c0..80ed2338812b 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -52,6 +52,8 @@ config SPARC32 select CLZ_TAB select HAVE_UID16 select OLD_SIGACTION + select LIB_CMPDI2 + select LIB_UCMPDI2 config SPARC64 def_bool 64BIT diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile index 69912d2f8b54..815b4a336aa8 100644 --- a/arch/sparc/lib/Makefile +++ b/arch/sparc/lib/Makefile @@ -14,7 +14,7 @@ lib-$(CONFIG_SPARC32) += divdi3.o udivdi3.o lib-$(CONFIG_SPARC32) += copy_user.o locks.o lib-$(CONFIG_SPARC64) += atomic_64.o lib-$(CONFIG_SPARC32) += lshrdi3.o ashldi3.o -lib-$(CONFIG_SPARC32) += muldi3.o bitext.o cmpdi2.o +lib-$(CONFIG_SPARC32) += muldi3.o bitext.o lib-$(CONFIG_SPARC64) += copy_page.o clear_page.o bzero.o lib-$(CONFIG_SPARC64) += csum_copy.o csum_copy_from_user.o csum_copy_to_user.o @@ -42,5 +42,5 @@ lib-$(CONFIG_SPARC64) += copy_in_user.o memmove.o lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o obj-$(CONFIG_SPARC64) += iomap.o -obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o +obj-$(CONFIG_SPARC32) += atomic32.o obj-$(CONFIG_SPARC64) += PeeCeeI.o diff --git a/arch/sparc/lib/cmpdi2.c b/arch/sparc/lib/cmpdi2.c deleted file mode 100644 index 8c1306437ed1..000000000000 --- a/arch/sparc/lib/cmpdi2.c +++ /dev/null @@ -1,27 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} - -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/sparc/lib/libgcc.h b/arch/sparc/lib/libgcc.h deleted file mode 100644 index b84fd797f3ea..000000000000 --- a/arch/sparc/lib/libgcc.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -struct DWstruct { - int high, low; -}; - -typedef union -{ - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sparc/lib/ucmpdi2.c b/arch/sparc/lib/ucmpdi2.c deleted file mode 100644 index 1e06ed500682..000000000000 --- a/arch/sparc/lib/ucmpdi2.c +++ /dev/null @@ -1,19 +0,0 @@ -#include <linux/module.h> -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* Re: Unify the various copies of libgcc into lib 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (22 preceding siblings ...) 2017-05-23 22:05 ` Palmer Dabbelt @ 2017-05-24 9:21 ` Geert Uytterhoeven 2017-05-24 9:21 ` Geert Uytterhoeven 2017-06-03 2:59 ` Palmer Dabbelt 2017-05-24 13:49 ` David Howells ` (2 subsequent siblings) 26 siblings, 2 replies; 93+ messages in thread From: Geert Uytterhoeven @ 2017-05-24 9:21 UTC (permalink / raw) To: Palmer Dabbelt Cc: Michal Simek, Ralf Baechle, Chen Liqin, Lennox Wu, Yoshinori Sato, Rich Felker, David S. Miller, Linux MIPS Mailing List, Linux-sh list, sparclinux, linux-kernel@vger.kernel.org, Linux-Arch Hi Palmer, On Wed, May 24, 2017 at 12:05 AM, Palmer Dabbelt <palmer@dabbelt.com> wrote: > I'm in the process of submitting the RISC-V Linux port, and someone noticed > that we were adding copies of some libgcc emulation routines that were the same > as some of the other ports. This prompted me to go through and check all the > ports for libgcc.h and to merge the versions that were functionally identical. > > The only difference in libgcc.h was that there was a #define for little vs big > endian. The differences in the emulation routines were all just whitespace. > > This patch set comes in two parts: > > * Patch 1 adds new copies of all the C files copied from libgcc, as well as > moving libgcc.h to include/lib (that's a new folder, which probably means > it's the wrong place to put it, but I couldn't find anything better). There > are Kconfig entries for each of these library functions so architectures can > select them one at a time. I would call the Kconfig symbols GENERIC_* instead of LIB_*, for consistency with other generic implementations. > * The rest of the patches convert each architecture over to the new system. Thanks! For all but "[PATCH 4/7] mips: ...": Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> > Unless I screwed something up, this patch set shouldn't actually change any > functionality. Unfortunately I don't actually have all these cross compilers > setup so I can't actually test any of this, but I did convert the RISC-V port > over to using this system and it appears to be OK there so at least this isn't > completely broken. https://www.kernel.org/pub/tools/crosstool/ BTW, blackfin, h8300, m68k, and parisc have their own implementations, too. They look different, but I believe their functionality is identical. They can be converted later, though. Gr{oetje,eeting}s, Geert ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: Unify the various copies of libgcc into lib 2017-05-24 9:21 ` Unify the various copies of libgcc into lib Geert Uytterhoeven @ 2017-05-24 9:21 ` Geert Uytterhoeven 2017-06-03 2:59 ` Palmer Dabbelt 1 sibling, 0 replies; 93+ messages in thread From: Geert Uytterhoeven @ 2017-05-24 9:21 UTC (permalink / raw) To: Palmer Dabbelt Cc: Michal Simek, Ralf Baechle, Chen Liqin, Lennox Wu, Yoshinori Sato, Rich Felker, David S. Miller, Linux MIPS Mailing List, Linux-sh list, sparclinux, linux-kernel@vger.kernel.org, Linux-Arch Hi Palmer, On Wed, May 24, 2017 at 12:05 AM, Palmer Dabbelt <palmer@dabbelt.com> wrote: > I'm in the process of submitting the RISC-V Linux port, and someone noticed > that we were adding copies of some libgcc emulation routines that were the same > as some of the other ports. This prompted me to go through and check all the > ports for libgcc.h and to merge the versions that were functionally identical. > > The only difference in libgcc.h was that there was a #define for little vs big > endian. The differences in the emulation routines were all just whitespace. > > This patch set comes in two parts: > > * Patch 1 adds new copies of all the C files copied from libgcc, as well as > moving libgcc.h to include/lib (that's a new folder, which probably means > it's the wrong place to put it, but I couldn't find anything better). There > are Kconfig entries for each of these library functions so architectures can > select them one at a time. I would call the Kconfig symbols GENERIC_* instead of LIB_*, for consistency with other generic implementations. > * The rest of the patches convert each architecture over to the new system. Thanks! For all but "[PATCH 4/7] mips: ...": Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> > Unless I screwed something up, this patch set shouldn't actually change any > functionality. Unfortunately I don't actually have all these cross compilers > setup so I can't actually test any of this, but I did convert the RISC-V port > over to using this system and it appears to be OK there so at least this isn't > completely broken. https://www.kernel.org/pub/tools/crosstool/ BTW, blackfin, h8300, m68k, and parisc have their own implementations, too. They look different, but I believe their functionality is identical. They can be converted later, though. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org 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 ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: Unify the various copies of libgcc into lib 2017-05-24 9:21 ` Unify the various copies of libgcc into lib Geert Uytterhoeven 2017-05-24 9:21 ` Geert Uytterhoeven @ 2017-06-03 2:59 ` Palmer Dabbelt 2017-06-03 2:59 ` Palmer Dabbelt 1 sibling, 1 reply; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-03 2:59 UTC (permalink / raw) To: geert Cc: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, linux-kernel, linux-arch On Wed, 24 May 2017 02:21:22 PDT (-0700), geert@linux-m68k.org wrote: > Hi Palmer, > > On Wed, May 24, 2017 at 12:05 AM, Palmer Dabbelt <palmer@dabbelt.com> wrote: >> I'm in the process of submitting the RISC-V Linux port, and someone noticed >> that we were adding copies of some libgcc emulation routines that were the same >> as some of the other ports. This prompted me to go through and check all the >> ports for libgcc.h and to merge the versions that were functionally identical. >> >> The only difference in libgcc.h was that there was a #define for little vs big >> endian. The differences in the emulation routines were all just whitespace. >> >> This patch set comes in two parts: >> >> * Patch 1 adds new copies of all the C files copied from libgcc, as well as >> moving libgcc.h to include/lib (that's a new folder, which probably means >> it's the wrong place to put it, but I couldn't find anything better). There >> are Kconfig entries for each of these library functions so architectures can >> select them one at a time. > > I would call the Kconfig symbols GENERIC_* instead of LIB_*, for consistency > with other generic implementations. OK. I'll include that in my v2 patch set. >> * The rest of the patches convert each architecture over to the new system. > > Thanks! For all but "[PATCH 4/7] mips: ...": > > Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> Thanks! >> Unless I screwed something up, this patch set shouldn't actually change any >> functionality. Unfortunately I don't actually have all these cross compilers >> setup so I can't actually test any of this, but I did convert the RISC-V port >> over to using this system and it appears to be OK there so at least this isn't >> completely broken. > > https://www.kernel.org/pub/tools/crosstool/ Cool. I'll build everything before I submit a v2. ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: Unify the various copies of libgcc into lib 2017-06-03 2:59 ` Palmer Dabbelt @ 2017-06-03 2:59 ` Palmer Dabbelt 0 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-03 2:59 UTC (permalink / raw) To: geert Cc: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, linux-kernel, linux-arch On Wed, 24 May 2017 02:21:22 PDT (-0700), geert@linux-m68k.org wrote: > Hi Palmer, > > On Wed, May 24, 2017 at 12:05 AM, Palmer Dabbelt <palmer@dabbelt.com> wrote: >> I'm in the process of submitting the RISC-V Linux port, and someone noticed >> that we were adding copies of some libgcc emulation routines that were the same >> as some of the other ports. This prompted me to go through and check all the >> ports for libgcc.h and to merge the versions that were functionally identical. >> >> The only difference in libgcc.h was that there was a #define for little vs big >> endian. The differences in the emulation routines were all just whitespace. >> >> This patch set comes in two parts: >> >> * Patch 1 adds new copies of all the C files copied from libgcc, as well as >> moving libgcc.h to include/lib (that's a new folder, which probably means >> it's the wrong place to put it, but I couldn't find anything better). There >> are Kconfig entries for each of these library functions so architectures can >> select them one at a time. > > I would call the Kconfig symbols GENERIC_* instead of LIB_*, for consistency > with other generic implementations. OK. I'll include that in my v2 patch set. >> * The rest of the patches convert each architecture over to the new system. > > Thanks! For all but "[PATCH 4/7] mips: ...": > > Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> Thanks! >> Unless I screwed something up, this patch set shouldn't actually change any >> functionality. Unfortunately I don't actually have all these cross compilers >> setup so I can't actually test any of this, but I did convert the RISC-V port >> over to using this system and it appears to be OK there so at least this isn't >> completely broken. > > https://www.kernel.org/pub/tools/crosstool/ Cool. I'll build everything before I submit a v2. ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: Unify the various copies of libgcc into lib 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (23 preceding siblings ...) 2017-05-24 9:21 ` Unify the various copies of libgcc into lib Geert Uytterhoeven @ 2017-05-24 13:49 ` David Howells 2017-05-24 13:49 ` David Howells 2017-05-24 13:59 ` John Paul Adrian Glaubitz 2017-06-06 19:10 ` Unify the various copies of libgcc into lib v2 Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt 26 siblings, 2 replies; 93+ messages in thread From: David Howells @ 2017-05-24 13:49 UTC (permalink / raw) To: Palmer Dabbelt Cc: dhowells, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Palmer Dabbelt <palmer@dabbelt.com> wrote: > ... Unfortunately I don't actually have all these cross compilers setup... If you have Fedora, you have the following available as standard RPMs: gcc-aarch64-linux-gnu gcc-alpha-linux-gnu gcc-arm-linux-gnu gcc-avr32-linux-gnu gcc-bfin-linux-gnu gcc-c6x-linux-gnu gcc-cris-linux-gnu gcc-frv-linux-gnu gcc-h8300-linux-gnu gcc-hppa-linux-gnu gcc-hppa64-linux-gnu gcc-ia64-linux-gnu gcc-m32r-linux-gnu gcc-m68k-linux-gnu gcc-microblaze-linux-gnu gcc-mips64-linux-gnu gcc-mn10300-linux-gnu gcc-nios2-linux-gnu gcc-powerpc64-linux-gnu gcc-ppc64-linux-gnu gcc-s390x-linux-gnu gcc-sh-linux-gnu gcc-sparc64-linux-gnu gcc-tile-linux-gnu gcc-xtensa-linux-gnu They're built from the same sources as the gcc rpm (and the matching binutils cross rpms are built from the same sources as the binutils rpm) - it's only the spec file that's different, and they lag a bit behind the core gcc/binutils as they only get updated after those change. So in Fedora 25 these are all gcc-6 and in Fedora 26 they're all gcc-7. David ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: Unify the various copies of libgcc into lib 2017-05-24 13:49 ` David Howells @ 2017-05-24 13:49 ` David Howells 2017-05-24 13:59 ` John Paul Adrian Glaubitz 1 sibling, 0 replies; 93+ messages in thread From: David Howells @ 2017-05-24 13:49 UTC (permalink / raw) To: Palmer Dabbelt Cc: dhowells, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Palmer Dabbelt <palmer@dabbelt.com> wrote: > ... Unfortunately I don't actually have all these cross compilers setup... If you have Fedora, you have the following available as standard RPMs: gcc-aarch64-linux-gnu gcc-alpha-linux-gnu gcc-arm-linux-gnu gcc-avr32-linux-gnu gcc-bfin-linux-gnu gcc-c6x-linux-gnu gcc-cris-linux-gnu gcc-frv-linux-gnu gcc-h8300-linux-gnu gcc-hppa-linux-gnu gcc-hppa64-linux-gnu gcc-ia64-linux-gnu gcc-m32r-linux-gnu gcc-m68k-linux-gnu gcc-microblaze-linux-gnu gcc-mips64-linux-gnu gcc-mn10300-linux-gnu gcc-nios2-linux-gnu gcc-powerpc64-linux-gnu gcc-ppc64-linux-gnu gcc-s390x-linux-gnu gcc-sh-linux-gnu gcc-sparc64-linux-gnu gcc-tile-linux-gnu gcc-xtensa-linux-gnu They're built from the same sources as the gcc rpm (and the matching binutils cross rpms are built from the same sources as the binutils rpm) - it's only the spec file that's different, and they lag a bit behind the core gcc/binutils as they only get updated after those change. So in Fedora 25 these are all gcc-6 and in Fedora 26 they're all gcc-7. David ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: Unify the various copies of libgcc into lib 2017-05-24 13:49 ` David Howells 2017-05-24 13:49 ` David Howells @ 2017-05-24 13:59 ` John Paul Adrian Glaubitz 2017-05-24 13:59 ` John Paul Adrian Glaubitz 1 sibling, 1 reply; 93+ messages in thread From: John Paul Adrian Glaubitz @ 2017-05-24 13:59 UTC (permalink / raw) To: David Howells Cc: Palmer Dabbelt, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch On Wed, May 24, 2017 at 02:49:24PM +0100, David Howells wrote: > Palmer Dabbelt <palmer@dabbelt.com> wrote: > > > ... Unfortunately I don't actually have all these cross compilers setup... > > If you have Fedora, you have the following available as standard > RPMs: And if you need more than just the cross-compilers (e.g. libraries for the target architecture), I recommend a Debian Stretch or newer. Debian's Multi-Arch allows one to install libraries for the target system onto your build system. I have used that extensively in the past, for example to bootstrap GHC for various architectures [1]. Adrian > [1] https://wiki.debian.org/PortsDocs/BootstrappingGHC -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: Unify the various copies of libgcc into lib 2017-05-24 13:59 ` John Paul Adrian Glaubitz @ 2017-05-24 13:59 ` John Paul Adrian Glaubitz 0 siblings, 0 replies; 93+ messages in thread From: John Paul Adrian Glaubitz @ 2017-05-24 13:59 UTC (permalink / raw) To: David Howells Cc: Palmer Dabbelt, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch On Wed, May 24, 2017 at 02:49:24PM +0100, David Howells wrote: > Palmer Dabbelt <palmer@dabbelt.com> wrote: > > > ... Unfortunately I don't actually have all these cross compilers setup... > > If you have Fedora, you have the following available as standard > RPMs: And if you need more than just the cross-compilers (e.g. libraries for the target architecture), I recommend a Debian Stretch or newer. Debian's Multi-Arch allows one to install libraries for the target system onto your build system. I have used that extensively in the past, for example to bootstrap GHC for various architectures [1]. Adrian > [1] https://wiki.debian.org/PortsDocs/BootstrappingGHC -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 ^ permalink raw reply [flat|nested] 93+ messages in thread
* Unify the various copies of libgcc into lib v2 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (24 preceding siblings ...) 2017-05-24 13:49 ` David Howells @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt 26 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Thanks to everyone who responded to my original patch set. I believe I've responded to everyone's comments. There have been a handful of changes since the original patch set: * The Kconfig names for the routines are now GENERIC_* instead of LIB_*. This matches the existing generic implementation Kconfig names. * Tracing is disabled, which matches the MIPS behavior and seems correct globally. * I've cross compiled this to make sure it builds, and fixed all the build errors I found. * The MIPS patches actually do what they say in the commit message. I don't know of any remaining problems with this patch set, so hopefully it's ready to get merged. I'll be including patch 1 in our RISC-V submissions, but as I'm somewhat new to this I don't have a tree that anyone pulls from yet. If everyone is happy with this patch set then I'd be willing to use this as a first attempt to get patches upstream myself. [PATCH 1/7] lib: Add shared copies of some GCC library routines [PATCH 2/7] m32r: Use lib/ucmpdi2.c [PATCH 3/7] microblaze: Use libgcc files from lib/ [PATCH 4/7] score: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c [PATCH 5/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c [PATCH 6/7] sparc: Use lib/{cmpdi2,ucmpdi2}.c [PATCH 7/7] MIPS: Use generic libgcc intrinsics ^ permalink raw reply [flat|nested] 93+ messages in thread
* Unify the various copies of libgcc into lib v2 2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt ` (25 preceding siblings ...) 2017-06-06 19:10 ` Unify the various copies of libgcc into lib v2 Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` [PATCH 1/7] lib: Add shared copies of some GCC library routines Palmer Dabbelt ` (23 more replies) 26 siblings, 24 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Thanks to everyone who responded to my original patch set. I believe I've responded to everyone's comments. There have been a handful of changes since the original patch set: * The Kconfig names for the routines are now GENERIC_* instead of LIB_*. This matches the existing generic implementation Kconfig names. * Tracing is disabled, which matches the MIPS behavior and seems correct globally. * I've cross compiled this to make sure it builds, and fixed all the build errors I found. * The MIPS patches actually do what they say in the commit message. I don't know of any remaining problems with this patch set, so hopefully it's ready to get merged. I'll be including patch 1 in our RISC-V submissions, but as I'm somewhat new to this I don't have a tree that anyone pulls from yet. If everyone is happy with this patch set then I'd be willing to use this as a first attempt to get patches upstream myself. [PATCH 1/7] lib: Add shared copies of some GCC library routines [PATCH 2/7] m32r: Use lib/ucmpdi2.c [PATCH 3/7] microblaze: Use libgcc files from lib/ [PATCH 4/7] score: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c [PATCH 5/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c [PATCH 6/7] sparc: Use lib/{cmpdi2,ucmpdi2}.c [PATCH 7/7] MIPS: Use generic libgcc intrinsics ^ permalink raw reply [flat|nested] 93+ messages in thread
* [PATCH 1/7] lib: Add shared copies of some GCC library routines 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt ` (22 subsequent siblings) 23 siblings, 1 reply; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt Many ports (m32r, microblaze, mips, parisc, score, and sparc) use functionally identical copies of various GCC library routine files, which came up as we were submitting the RISC-V port (which also uses some of these). This patch adds a new copy of these library routine files, which are functionally identical to the various other copies. These are availiable via Kconfig as CONFIG_LIB_$ROUTINE, which currently isn't used anywhere. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- include/lib/libgcc.h | 44 ++++++++++++++++++++++++++++++++ lib/Kconfig | 18 +++++++++++++ lib/Makefile | 8 ++++++ lib/ashldi3.c | 45 ++++++++++++++++++++++++++++++++ lib/ashrdi3.c | 46 +++++++++++++++++++++++++++++++++ lib/cmpdi2.c | 42 ++++++++++++++++++++++++++++++ lib/lshrdi3.c | 45 ++++++++++++++++++++++++++++++++ lib/muldi3.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/ucmpdi2.c | 35 +++++++++++++++++++++++++ 9 files changed, 355 insertions(+) create mode 100644 include/lib/libgcc.h create mode 100644 lib/ashldi3.c create mode 100644 lib/ashrdi3.c create mode 100644 lib/cmpdi2.c create mode 100644 lib/lshrdi3.c create mode 100644 lib/muldi3.c create mode 100644 lib/ucmpdi2.c diff --git a/include/lib/libgcc.h b/include/lib/libgcc.h new file mode 100644 index 000000000000..a5397e34e005 --- /dev/null +++ b/include/lib/libgcc.h @@ -0,0 +1,44 @@ +/* + * include/lib/libgcc.h + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + + +#ifndef __LIB_LIBGCC_H +#define __LIB_LIBGCC_H + +#include <asm/byteorder.h> + +typedef int word_type __attribute__ ((mode (__word__))); + +#ifdef __BIG_ENDIAN +struct DWstruct { + int high, low; +}; +#elif defined(__LITTLE_ENDIAN) +struct DWstruct { + int low, high; +}; +#else +#error I feel sick. +#endif + +typedef union { + struct DWstruct s; + long long ll; +} DWunion; + +#endif /* __ASM_LIBGCC_H */ diff --git a/lib/Kconfig b/lib/Kconfig index 0c8b78a9ae2e..7a9c934d91fd 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -565,3 +565,21 @@ config PRIME_NUMBERS tristate endmenu + +config GENERIC_ASHLDI3 + def_bool n + +config GENERIC_ASHRDI3 + def_bool n + +config GENERIC_LSHRDI3 + def_bool n + +config GENERIC_MULDI3 + def_bool n + +config GENERIC_CMPDI2 + def_bool n + +config GENERIC_UCMPDI2 + def_bool n diff --git a/lib/Makefile b/lib/Makefile index 0166fbc0fa81..5f68242f7774 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -243,3 +243,11 @@ UBSAN_SANITIZE_ubsan.o := n obj-$(CONFIG_SBITMAP) += sbitmap.o obj-$(CONFIG_PARMAN) += parman.o + +# GCC library routines +obj-$(CONFIG_GENERIC_ASHLDI3) += ashldi3.o +obj-$(CONFIG_GENERIC_ASHRDI3) += ashrdi3.o +obj-$(CONFIG_GENERIC_LSHRDI3) += lshrdi3.o +obj-$(CONFIG_GENERIC_MULDI3) += muldi3.o +obj-$(CONFIG_GENERIC_CMPDI2) += cmpdi2.o +obj-$(CONFIG_GENERIC_UCMPDI2) += ucmpdi2.o diff --git a/lib/ashldi3.c b/lib/ashldi3.c new file mode 100644 index 000000000000..ff4ec63d2ab6 --- /dev/null +++ b/lib/ashldi3.c @@ -0,0 +1,45 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + + +#include <linux/export.h> + +#include <lib/libgcc.h> + +long long notrace __ashldi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + w.s.low = 0; + w.s.high = (unsigned int) uu.s.low << -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.low >> bm; + + w.s.low = (unsigned int) uu.s.low << b; + w.s.high = ((unsigned int) uu.s.high << b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__ashldi3); diff --git a/lib/ashrdi3.c b/lib/ashrdi3.c new file mode 100644 index 000000000000..2e67c97ac65a --- /dev/null +++ b/lib/ashrdi3.c @@ -0,0 +1,46 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> + +#include <lib/libgcc.h> + +long long notrace __ashrdi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + /* w.s.high = 1..1 or 0..0 */ + w.s.high = + uu.s.high >> 31; + w.s.low = uu.s.high >> -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.high << bm; + + w.s.high = uu.s.high >> b; + w.s.low = ((unsigned int) uu.s.low >> b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__ashrdi3); diff --git a/lib/cmpdi2.c b/lib/cmpdi2.c new file mode 100644 index 000000000000..6d7ebf6c2b86 --- /dev/null +++ b/lib/cmpdi2.c @@ -0,0 +1,42 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> + +#include <lib/libgcc.h> + +word_type notrace __cmpdi2(long long a, long long b) +{ + const DWunion au = { + .ll = a + }; + const DWunion bu = { + .ll = b + }; + + if (au.s.high < bu.s.high) + return 0; + else if (au.s.high > bu.s.high) + return 2; + + if ((unsigned int) au.s.low < (unsigned int) bu.s.low) + return 0; + else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) + return 2; + + return 1; +} +EXPORT_SYMBOL(__cmpdi2); diff --git a/lib/lshrdi3.c b/lib/lshrdi3.c new file mode 100644 index 000000000000..8e845f4bb65f --- /dev/null +++ b/lib/lshrdi3.c @@ -0,0 +1,45 @@ +/* + * lib/lshrdi3.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/module.h> +#include <lib/libgcc.h> + +long long notrace __lshrdi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + w.s.high = 0; + w.s.low = (unsigned int) uu.s.high >> -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.high << bm; + + w.s.high = (unsigned int) uu.s.high >> b; + w.s.low = ((unsigned int) uu.s.low >> b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__lshrdi3); diff --git a/lib/muldi3.c b/lib/muldi3.c new file mode 100644 index 000000000000..88938543e10a --- /dev/null +++ b/lib/muldi3.c @@ -0,0 +1,72 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> +#include <lib/libgcc.h> + +#define W_TYPE_SIZE 32 + +#define __ll_B ((unsigned long) 1 << (W_TYPE_SIZE / 2)) +#define __ll_lowpart(t) ((unsigned long) (t) & (__ll_B - 1)) +#define __ll_highpart(t) ((unsigned long) (t) >> (W_TYPE_SIZE / 2)) + +/* If we still don't have umul_ppmm, define it using plain C. */ +#if !defined(umul_ppmm) +#define umul_ppmm(w1, w0, u, v) \ + do { \ + unsigned long __x0, __x1, __x2, __x3; \ + unsigned short __ul, __vl, __uh, __vh; \ + \ + __ul = __ll_lowpart(u); \ + __uh = __ll_highpart(u); \ + __vl = __ll_lowpart(v); \ + __vh = __ll_highpart(v); \ + \ + __x0 = (unsigned long) __ul * __vl; \ + __x1 = (unsigned long) __ul * __vh; \ + __x2 = (unsigned long) __uh * __vl; \ + __x3 = (unsigned long) __uh * __vh; \ + \ + __x1 += __ll_highpart(__x0); /* this can't give carry */\ + __x1 += __x2; /* but this indeed can */ \ + if (__x1 < __x2) /* did we get it? */ \ + __x3 += __ll_B; /* yes, add it in the proper pos */ \ + \ + (w1) = __x3 + __ll_highpart(__x1); \ + (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0);\ + } while (0) +#endif + +#if !defined(__umulsidi3) +#define __umulsidi3(u, v) ({ \ + DWunion __w; \ + umul_ppmm(__w.s.high, __w.s.low, u, v); \ + __w.ll; \ + }) +#endif + +long long notrace __muldi3(long long u, long long v) +{ + const DWunion uu = {.ll = u}; + const DWunion vv = {.ll = v}; + DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)}; + + w.s.high += ((unsigned long) uu.s.low * (unsigned long) vv.s.high + + (unsigned long) uu.s.high * (unsigned long) vv.s.low); + + return w.ll; +} +EXPORT_SYMBOL(__muldi3); diff --git a/lib/ucmpdi2.c b/lib/ucmpdi2.c new file mode 100644 index 000000000000..49a53505c8e3 --- /dev/null +++ b/lib/ucmpdi2.c @@ -0,0 +1,35 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/module.h> +#include <lib/libgcc.h> + +word_type __ucmpdi2(unsigned long long a, unsigned long long b) +{ + const DWunion au = {.ll = a}; + const DWunion bu = {.ll = b}; + + if ((unsigned int) au.s.high < (unsigned int) bu.s.high) + return 0; + else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) + return 2; + if ((unsigned int) au.s.low < (unsigned int) bu.s.low) + return 0; + else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) + return 2; + return 1; +} +EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 1/7] lib: Add shared copies of some GCC library routines 2017-06-06 19:10 ` [PATCH 1/7] lib: Add shared copies of some GCC library routines Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 0 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt Many ports (m32r, microblaze, mips, parisc, score, and sparc) use functionally identical copies of various GCC library routine files, which came up as we were submitting the RISC-V port (which also uses some of these). This patch adds a new copy of these library routine files, which are functionally identical to the various other copies. These are availiable via Kconfig as CONFIG_LIB_$ROUTINE, which currently isn't used anywhere. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- include/lib/libgcc.h | 44 ++++++++++++++++++++++++++++++++ lib/Kconfig | 18 +++++++++++++ lib/Makefile | 8 ++++++ lib/ashldi3.c | 45 ++++++++++++++++++++++++++++++++ lib/ashrdi3.c | 46 +++++++++++++++++++++++++++++++++ lib/cmpdi2.c | 42 ++++++++++++++++++++++++++++++ lib/lshrdi3.c | 45 ++++++++++++++++++++++++++++++++ lib/muldi3.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/ucmpdi2.c | 35 +++++++++++++++++++++++++ 9 files changed, 355 insertions(+) create mode 100644 include/lib/libgcc.h create mode 100644 lib/ashldi3.c create mode 100644 lib/ashrdi3.c create mode 100644 lib/cmpdi2.c create mode 100644 lib/lshrdi3.c create mode 100644 lib/muldi3.c create mode 100644 lib/ucmpdi2.c diff --git a/include/lib/libgcc.h b/include/lib/libgcc.h new file mode 100644 index 000000000000..a5397e34e005 --- /dev/null +++ b/include/lib/libgcc.h @@ -0,0 +1,44 @@ +/* + * include/lib/libgcc.h + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + + +#ifndef __LIB_LIBGCC_H +#define __LIB_LIBGCC_H + +#include <asm/byteorder.h> + +typedef int word_type __attribute__ ((mode (__word__))); + +#ifdef __BIG_ENDIAN +struct DWstruct { + int high, low; +}; +#elif defined(__LITTLE_ENDIAN) +struct DWstruct { + int low, high; +}; +#else +#error I feel sick. +#endif + +typedef union { + struct DWstruct s; + long long ll; +} DWunion; + +#endif /* __ASM_LIBGCC_H */ diff --git a/lib/Kconfig b/lib/Kconfig index 0c8b78a9ae2e..7a9c934d91fd 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -565,3 +565,21 @@ config PRIME_NUMBERS tristate endmenu + +config GENERIC_ASHLDI3 + def_bool n + +config GENERIC_ASHRDI3 + def_bool n + +config GENERIC_LSHRDI3 + def_bool n + +config GENERIC_MULDI3 + def_bool n + +config GENERIC_CMPDI2 + def_bool n + +config GENERIC_UCMPDI2 + def_bool n diff --git a/lib/Makefile b/lib/Makefile index 0166fbc0fa81..5f68242f7774 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -243,3 +243,11 @@ UBSAN_SANITIZE_ubsan.o := n obj-$(CONFIG_SBITMAP) += sbitmap.o obj-$(CONFIG_PARMAN) += parman.o + +# GCC library routines +obj-$(CONFIG_GENERIC_ASHLDI3) += ashldi3.o +obj-$(CONFIG_GENERIC_ASHRDI3) += ashrdi3.o +obj-$(CONFIG_GENERIC_LSHRDI3) += lshrdi3.o +obj-$(CONFIG_GENERIC_MULDI3) += muldi3.o +obj-$(CONFIG_GENERIC_CMPDI2) += cmpdi2.o +obj-$(CONFIG_GENERIC_UCMPDI2) += ucmpdi2.o diff --git a/lib/ashldi3.c b/lib/ashldi3.c new file mode 100644 index 000000000000..ff4ec63d2ab6 --- /dev/null +++ b/lib/ashldi3.c @@ -0,0 +1,45 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + + +#include <linux/export.h> + +#include <lib/libgcc.h> + +long long notrace __ashldi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + w.s.low = 0; + w.s.high = (unsigned int) uu.s.low << -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.low >> bm; + + w.s.low = (unsigned int) uu.s.low << b; + w.s.high = ((unsigned int) uu.s.high << b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__ashldi3); diff --git a/lib/ashrdi3.c b/lib/ashrdi3.c new file mode 100644 index 000000000000..2e67c97ac65a --- /dev/null +++ b/lib/ashrdi3.c @@ -0,0 +1,46 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> + +#include <lib/libgcc.h> + +long long notrace __ashrdi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + /* w.s.high = 1..1 or 0..0 */ + w.s.high = + uu.s.high >> 31; + w.s.low = uu.s.high >> -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.high << bm; + + w.s.high = uu.s.high >> b; + w.s.low = ((unsigned int) uu.s.low >> b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__ashrdi3); diff --git a/lib/cmpdi2.c b/lib/cmpdi2.c new file mode 100644 index 000000000000..6d7ebf6c2b86 --- /dev/null +++ b/lib/cmpdi2.c @@ -0,0 +1,42 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> + +#include <lib/libgcc.h> + +word_type notrace __cmpdi2(long long a, long long b) +{ + const DWunion au = { + .ll = a + }; + const DWunion bu = { + .ll = b + }; + + if (au.s.high < bu.s.high) + return 0; + else if (au.s.high > bu.s.high) + return 2; + + if ((unsigned int) au.s.low < (unsigned int) bu.s.low) + return 0; + else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) + return 2; + + return 1; +} +EXPORT_SYMBOL(__cmpdi2); diff --git a/lib/lshrdi3.c b/lib/lshrdi3.c new file mode 100644 index 000000000000..8e845f4bb65f --- /dev/null +++ b/lib/lshrdi3.c @@ -0,0 +1,45 @@ +/* + * lib/lshrdi3.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/module.h> +#include <lib/libgcc.h> + +long long notrace __lshrdi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + w.s.high = 0; + w.s.low = (unsigned int) uu.s.high >> -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.high << bm; + + w.s.high = (unsigned int) uu.s.high >> b; + w.s.low = ((unsigned int) uu.s.low >> b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__lshrdi3); diff --git a/lib/muldi3.c b/lib/muldi3.c new file mode 100644 index 000000000000..88938543e10a --- /dev/null +++ b/lib/muldi3.c @@ -0,0 +1,72 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> +#include <lib/libgcc.h> + +#define W_TYPE_SIZE 32 + +#define __ll_B ((unsigned long) 1 << (W_TYPE_SIZE / 2)) +#define __ll_lowpart(t) ((unsigned long) (t) & (__ll_B - 1)) +#define __ll_highpart(t) ((unsigned long) (t) >> (W_TYPE_SIZE / 2)) + +/* If we still don't have umul_ppmm, define it using plain C. */ +#if !defined(umul_ppmm) +#define umul_ppmm(w1, w0, u, v) \ + do { \ + unsigned long __x0, __x1, __x2, __x3; \ + unsigned short __ul, __vl, __uh, __vh; \ + \ + __ul = __ll_lowpart(u); \ + __uh = __ll_highpart(u); \ + __vl = __ll_lowpart(v); \ + __vh = __ll_highpart(v); \ + \ + __x0 = (unsigned long) __ul * __vl; \ + __x1 = (unsigned long) __ul * __vh; \ + __x2 = (unsigned long) __uh * __vl; \ + __x3 = (unsigned long) __uh * __vh; \ + \ + __x1 += __ll_highpart(__x0); /* this can't give carry */\ + __x1 += __x2; /* but this indeed can */ \ + if (__x1 < __x2) /* did we get it? */ \ + __x3 += __ll_B; /* yes, add it in the proper pos */ \ + \ + (w1) = __x3 + __ll_highpart(__x1); \ + (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0);\ + } while (0) +#endif + +#if !defined(__umulsidi3) +#define __umulsidi3(u, v) ({ \ + DWunion __w; \ + umul_ppmm(__w.s.high, __w.s.low, u, v); \ + __w.ll; \ + }) +#endif + +long long notrace __muldi3(long long u, long long v) +{ + const DWunion uu = {.ll = u}; + const DWunion vv = {.ll = v}; + DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)}; + + w.s.high += ((unsigned long) uu.s.low * (unsigned long) vv.s.high + + (unsigned long) uu.s.high * (unsigned long) vv.s.low); + + return w.ll; +} +EXPORT_SYMBOL(__muldi3); diff --git a/lib/ucmpdi2.c b/lib/ucmpdi2.c new file mode 100644 index 000000000000..49a53505c8e3 --- /dev/null +++ b/lib/ucmpdi2.c @@ -0,0 +1,35 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/module.h> +#include <lib/libgcc.h> + +word_type __ucmpdi2(unsigned long long a, unsigned long long b) +{ + const DWunion au = {.ll = a}; + const DWunion bu = {.ll = b}; + + if ((unsigned int) au.s.high < (unsigned int) bu.s.high) + return 0; + else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) + return 2; + if ((unsigned int) au.s.low < (unsigned int) bu.s.low) + return 0; + else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) + return 2; + return 1; +} +EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 1/7] lib: Add shared copies of some GCC library routines 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` [PATCH 1/7] lib: Add shared copies of some GCC library routines Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt ` (21 subsequent siblings) 23 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt Many ports (m32r, microblaze, mips, parisc, score, and sparc) use functionally identical copies of various GCC library routine files, which came up as we were submitting the RISC-V port (which also uses some of these). This patch adds a new copy of these library routine files, which are functionally identical to the various other copies. These are availiable via Kconfig as CONFIG_LIB_$ROUTINE, which currently isn't used anywhere. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- include/lib/libgcc.h | 44 ++++++++++++++++++++++++++++++++ lib/Kconfig | 18 +++++++++++++ lib/Makefile | 8 ++++++ lib/ashldi3.c | 45 ++++++++++++++++++++++++++++++++ lib/ashrdi3.c | 46 +++++++++++++++++++++++++++++++++ lib/cmpdi2.c | 42 ++++++++++++++++++++++++++++++ lib/lshrdi3.c | 45 ++++++++++++++++++++++++++++++++ lib/muldi3.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/ucmpdi2.c | 35 +++++++++++++++++++++++++ 9 files changed, 355 insertions(+) create mode 100644 include/lib/libgcc.h create mode 100644 lib/ashldi3.c create mode 100644 lib/ashrdi3.c create mode 100644 lib/cmpdi2.c create mode 100644 lib/lshrdi3.c create mode 100644 lib/muldi3.c create mode 100644 lib/ucmpdi2.c diff --git a/include/lib/libgcc.h b/include/lib/libgcc.h new file mode 100644 index 000000000000..a5397e34e005 --- /dev/null +++ b/include/lib/libgcc.h @@ -0,0 +1,44 @@ +/* + * include/lib/libgcc.h + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + + +#ifndef __LIB_LIBGCC_H +#define __LIB_LIBGCC_H + +#include <asm/byteorder.h> + +typedef int word_type __attribute__ ((mode (__word__))); + +#ifdef __BIG_ENDIAN +struct DWstruct { + int high, low; +}; +#elif defined(__LITTLE_ENDIAN) +struct DWstruct { + int low, high; +}; +#else +#error I feel sick. +#endif + +typedef union { + struct DWstruct s; + long long ll; +} DWunion; + +#endif /* __ASM_LIBGCC_H */ diff --git a/lib/Kconfig b/lib/Kconfig index 0c8b78a9ae2e..7a9c934d91fd 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -565,3 +565,21 @@ config PRIME_NUMBERS tristate endmenu + +config GENERIC_ASHLDI3 + def_bool n + +config GENERIC_ASHRDI3 + def_bool n + +config GENERIC_LSHRDI3 + def_bool n + +config GENERIC_MULDI3 + def_bool n + +config GENERIC_CMPDI2 + def_bool n + +config GENERIC_UCMPDI2 + def_bool n diff --git a/lib/Makefile b/lib/Makefile index 0166fbc0fa81..5f68242f7774 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -243,3 +243,11 @@ UBSAN_SANITIZE_ubsan.o := n obj-$(CONFIG_SBITMAP) += sbitmap.o obj-$(CONFIG_PARMAN) += parman.o + +# GCC library routines +obj-$(CONFIG_GENERIC_ASHLDI3) += ashldi3.o +obj-$(CONFIG_GENERIC_ASHRDI3) += ashrdi3.o +obj-$(CONFIG_GENERIC_LSHRDI3) += lshrdi3.o +obj-$(CONFIG_GENERIC_MULDI3) += muldi3.o +obj-$(CONFIG_GENERIC_CMPDI2) += cmpdi2.o +obj-$(CONFIG_GENERIC_UCMPDI2) += ucmpdi2.o diff --git a/lib/ashldi3.c b/lib/ashldi3.c new file mode 100644 index 000000000000..ff4ec63d2ab6 --- /dev/null +++ b/lib/ashldi3.c @@ -0,0 +1,45 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + + +#include <linux/export.h> + +#include <lib/libgcc.h> + +long long notrace __ashldi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + w.s.low = 0; + w.s.high = (unsigned int) uu.s.low << -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.low >> bm; + + w.s.low = (unsigned int) uu.s.low << b; + w.s.high = ((unsigned int) uu.s.high << b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__ashldi3); diff --git a/lib/ashrdi3.c b/lib/ashrdi3.c new file mode 100644 index 000000000000..2e67c97ac65a --- /dev/null +++ b/lib/ashrdi3.c @@ -0,0 +1,46 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> + +#include <lib/libgcc.h> + +long long notrace __ashrdi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + /* w.s.high = 1..1 or 0..0 */ + w.s.high = + uu.s.high >> 31; + w.s.low = uu.s.high >> -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.high << bm; + + w.s.high = uu.s.high >> b; + w.s.low = ((unsigned int) uu.s.low >> b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__ashrdi3); diff --git a/lib/cmpdi2.c b/lib/cmpdi2.c new file mode 100644 index 000000000000..6d7ebf6c2b86 --- /dev/null +++ b/lib/cmpdi2.c @@ -0,0 +1,42 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> + +#include <lib/libgcc.h> + +word_type notrace __cmpdi2(long long a, long long b) +{ + const DWunion au = { + .ll = a + }; + const DWunion bu = { + .ll = b + }; + + if (au.s.high < bu.s.high) + return 0; + else if (au.s.high > bu.s.high) + return 2; + + if ((unsigned int) au.s.low < (unsigned int) bu.s.low) + return 0; + else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) + return 2; + + return 1; +} +EXPORT_SYMBOL(__cmpdi2); diff --git a/lib/lshrdi3.c b/lib/lshrdi3.c new file mode 100644 index 000000000000..8e845f4bb65f --- /dev/null +++ b/lib/lshrdi3.c @@ -0,0 +1,45 @@ +/* + * lib/lshrdi3.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/module.h> +#include <lib/libgcc.h> + +long long notrace __lshrdi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + w.s.high = 0; + w.s.low = (unsigned int) uu.s.high >> -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.high << bm; + + w.s.high = (unsigned int) uu.s.high >> b; + w.s.low = ((unsigned int) uu.s.low >> b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__lshrdi3); diff --git a/lib/muldi3.c b/lib/muldi3.c new file mode 100644 index 000000000000..88938543e10a --- /dev/null +++ b/lib/muldi3.c @@ -0,0 +1,72 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> +#include <lib/libgcc.h> + +#define W_TYPE_SIZE 32 + +#define __ll_B ((unsigned long) 1 << (W_TYPE_SIZE / 2)) +#define __ll_lowpart(t) ((unsigned long) (t) & (__ll_B - 1)) +#define __ll_highpart(t) ((unsigned long) (t) >> (W_TYPE_SIZE / 2)) + +/* If we still don't have umul_ppmm, define it using plain C. */ +#if !defined(umul_ppmm) +#define umul_ppmm(w1, w0, u, v) \ + do { \ + unsigned long __x0, __x1, __x2, __x3; \ + unsigned short __ul, __vl, __uh, __vh; \ + \ + __ul = __ll_lowpart(u); \ + __uh = __ll_highpart(u); \ + __vl = __ll_lowpart(v); \ + __vh = __ll_highpart(v); \ + \ + __x0 = (unsigned long) __ul * __vl; \ + __x1 = (unsigned long) __ul * __vh; \ + __x2 = (unsigned long) __uh * __vl; \ + __x3 = (unsigned long) __uh * __vh; \ + \ + __x1 += __ll_highpart(__x0); /* this can't give carry */\ + __x1 += __x2; /* but this indeed can */ \ + if (__x1 < __x2) /* did we get it? */ \ + __x3 += __ll_B; /* yes, add it in the proper pos */ \ + \ + (w1) = __x3 + __ll_highpart(__x1); \ + (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0);\ + } while (0) +#endif + +#if !defined(__umulsidi3) +#define __umulsidi3(u, v) ({ \ + DWunion __w; \ + umul_ppmm(__w.s.high, __w.s.low, u, v); \ + __w.ll; \ + }) +#endif + +long long notrace __muldi3(long long u, long long v) +{ + const DWunion uu = {.ll = u}; + const DWunion vv = {.ll = v}; + DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)}; + + w.s.high += ((unsigned long) uu.s.low * (unsigned long) vv.s.high + + (unsigned long) uu.s.high * (unsigned long) vv.s.low); + + return w.ll; +} +EXPORT_SYMBOL(__muldi3); diff --git a/lib/ucmpdi2.c b/lib/ucmpdi2.c new file mode 100644 index 000000000000..49a53505c8e3 --- /dev/null +++ b/lib/ucmpdi2.c @@ -0,0 +1,35 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/module.h> +#include <lib/libgcc.h> + +word_type __ucmpdi2(unsigned long long a, unsigned long long b) +{ + const DWunion au = {.ll = a}; + const DWunion bu = {.ll = b}; + + if ((unsigned int) au.s.high < (unsigned int) bu.s.high) + return 0; + else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) + return 2; + if ((unsigned int) au.s.low < (unsigned int) bu.s.low) + return 0; + else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) + return 2; + return 1; +} +EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 1/7] lib: Add shared copies of some GCC library routines 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` [PATCH 1/7] lib: Add shared copies of some GCC library routines Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` [PATCH 2/7] m32r: Use lib/ucmpdi2.c Palmer Dabbelt ` (20 subsequent siblings) 23 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt Many ports (m32r, microblaze, mips, parisc, score, and sparc) use functionally identical copies of various GCC library routine files, which came up as we were submitting the RISC-V port (which also uses some of these). This patch adds a new copy of these library routine files, which are functionally identical to the various other copies. These are availiable via Kconfig as CONFIG_LIB_$ROUTINE, which currently isn't used anywhere. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- include/lib/libgcc.h | 44 ++++++++++++++++++++++++++++++++ lib/Kconfig | 18 +++++++++++++ lib/Makefile | 8 ++++++ lib/ashldi3.c | 45 ++++++++++++++++++++++++++++++++ lib/ashrdi3.c | 46 +++++++++++++++++++++++++++++++++ lib/cmpdi2.c | 42 ++++++++++++++++++++++++++++++ lib/lshrdi3.c | 45 ++++++++++++++++++++++++++++++++ lib/muldi3.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/ucmpdi2.c | 35 +++++++++++++++++++++++++ 9 files changed, 355 insertions(+) create mode 100644 include/lib/libgcc.h create mode 100644 lib/ashldi3.c create mode 100644 lib/ashrdi3.c create mode 100644 lib/cmpdi2.c create mode 100644 lib/lshrdi3.c create mode 100644 lib/muldi3.c create mode 100644 lib/ucmpdi2.c diff --git a/include/lib/libgcc.h b/include/lib/libgcc.h new file mode 100644 index 000000000000..a5397e34e005 --- /dev/null +++ b/include/lib/libgcc.h @@ -0,0 +1,44 @@ +/* + * include/lib/libgcc.h + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + + +#ifndef __LIB_LIBGCC_H +#define __LIB_LIBGCC_H + +#include <asm/byteorder.h> + +typedef int word_type __attribute__ ((mode (__word__))); + +#ifdef __BIG_ENDIAN +struct DWstruct { + int high, low; +}; +#elif defined(__LITTLE_ENDIAN) +struct DWstruct { + int low, high; +}; +#else +#error I feel sick. +#endif + +typedef union { + struct DWstruct s; + long long ll; +} DWunion; + +#endif /* __ASM_LIBGCC_H */ diff --git a/lib/Kconfig b/lib/Kconfig index 0c8b78a9ae2e..7a9c934d91fd 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -565,3 +565,21 @@ config PRIME_NUMBERS tristate endmenu + +config GENERIC_ASHLDI3 + def_bool n + +config GENERIC_ASHRDI3 + def_bool n + +config GENERIC_LSHRDI3 + def_bool n + +config GENERIC_MULDI3 + def_bool n + +config GENERIC_CMPDI2 + def_bool n + +config GENERIC_UCMPDI2 + def_bool n diff --git a/lib/Makefile b/lib/Makefile index 0166fbc0fa81..5f68242f7774 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -243,3 +243,11 @@ UBSAN_SANITIZE_ubsan.o := n obj-$(CONFIG_SBITMAP) += sbitmap.o obj-$(CONFIG_PARMAN) += parman.o + +# GCC library routines +obj-$(CONFIG_GENERIC_ASHLDI3) += ashldi3.o +obj-$(CONFIG_GENERIC_ASHRDI3) += ashrdi3.o +obj-$(CONFIG_GENERIC_LSHRDI3) += lshrdi3.o +obj-$(CONFIG_GENERIC_MULDI3) += muldi3.o +obj-$(CONFIG_GENERIC_CMPDI2) += cmpdi2.o +obj-$(CONFIG_GENERIC_UCMPDI2) += ucmpdi2.o diff --git a/lib/ashldi3.c b/lib/ashldi3.c new file mode 100644 index 000000000000..ff4ec63d2ab6 --- /dev/null +++ b/lib/ashldi3.c @@ -0,0 +1,45 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + + +#include <linux/export.h> + +#include <lib/libgcc.h> + +long long notrace __ashldi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + w.s.low = 0; + w.s.high = (unsigned int) uu.s.low << -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.low >> bm; + + w.s.low = (unsigned int) uu.s.low << b; + w.s.high = ((unsigned int) uu.s.high << b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__ashldi3); diff --git a/lib/ashrdi3.c b/lib/ashrdi3.c new file mode 100644 index 000000000000..2e67c97ac65a --- /dev/null +++ b/lib/ashrdi3.c @@ -0,0 +1,46 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> + +#include <lib/libgcc.h> + +long long notrace __ashrdi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + /* w.s.high = 1..1 or 0..0 */ + w.s.high = + uu.s.high >> 31; + w.s.low = uu.s.high >> -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.high << bm; + + w.s.high = uu.s.high >> b; + w.s.low = ((unsigned int) uu.s.low >> b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__ashrdi3); diff --git a/lib/cmpdi2.c b/lib/cmpdi2.c new file mode 100644 index 000000000000..6d7ebf6c2b86 --- /dev/null +++ b/lib/cmpdi2.c @@ -0,0 +1,42 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> + +#include <lib/libgcc.h> + +word_type notrace __cmpdi2(long long a, long long b) +{ + const DWunion au = { + .ll = a + }; + const DWunion bu = { + .ll = b + }; + + if (au.s.high < bu.s.high) + return 0; + else if (au.s.high > bu.s.high) + return 2; + + if ((unsigned int) au.s.low < (unsigned int) bu.s.low) + return 0; + else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) + return 2; + + return 1; +} +EXPORT_SYMBOL(__cmpdi2); diff --git a/lib/lshrdi3.c b/lib/lshrdi3.c new file mode 100644 index 000000000000..8e845f4bb65f --- /dev/null +++ b/lib/lshrdi3.c @@ -0,0 +1,45 @@ +/* + * lib/lshrdi3.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/module.h> +#include <lib/libgcc.h> + +long long notrace __lshrdi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + w.s.high = 0; + w.s.low = (unsigned int) uu.s.high >> -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.high << bm; + + w.s.high = (unsigned int) uu.s.high >> b; + w.s.low = ((unsigned int) uu.s.low >> b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__lshrdi3); diff --git a/lib/muldi3.c b/lib/muldi3.c new file mode 100644 index 000000000000..88938543e10a --- /dev/null +++ b/lib/muldi3.c @@ -0,0 +1,72 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/export.h> +#include <lib/libgcc.h> + +#define W_TYPE_SIZE 32 + +#define __ll_B ((unsigned long) 1 << (W_TYPE_SIZE / 2)) +#define __ll_lowpart(t) ((unsigned long) (t) & (__ll_B - 1)) +#define __ll_highpart(t) ((unsigned long) (t) >> (W_TYPE_SIZE / 2)) + +/* If we still don't have umul_ppmm, define it using plain C. */ +#if !defined(umul_ppmm) +#define umul_ppmm(w1, w0, u, v) \ + do { \ + unsigned long __x0, __x1, __x2, __x3; \ + unsigned short __ul, __vl, __uh, __vh; \ + \ + __ul = __ll_lowpart(u); \ + __uh = __ll_highpart(u); \ + __vl = __ll_lowpart(v); \ + __vh = __ll_highpart(v); \ + \ + __x0 = (unsigned long) __ul * __vl; \ + __x1 = (unsigned long) __ul * __vh; \ + __x2 = (unsigned long) __uh * __vl; \ + __x3 = (unsigned long) __uh * __vh; \ + \ + __x1 += __ll_highpart(__x0); /* this can't give carry */\ + __x1 += __x2; /* but this indeed can */ \ + if (__x1 < __x2) /* did we get it? */ \ + __x3 += __ll_B; /* yes, add it in the proper pos */ \ + \ + (w1) = __x3 + __ll_highpart(__x1); \ + (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0);\ + } while (0) +#endif + +#if !defined(__umulsidi3) +#define __umulsidi3(u, v) ({ \ + DWunion __w; \ + umul_ppmm(__w.s.high, __w.s.low, u, v); \ + __w.ll; \ + }) +#endif + +long long notrace __muldi3(long long u, long long v) +{ + const DWunion uu = {.ll = u}; + const DWunion vv = {.ll = v}; + DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)}; + + w.s.high += ((unsigned long) uu.s.low * (unsigned long) vv.s.high + + (unsigned long) uu.s.high * (unsigned long) vv.s.low); + + return w.ll; +} +EXPORT_SYMBOL(__muldi3); diff --git a/lib/ucmpdi2.c b/lib/ucmpdi2.c new file mode 100644 index 000000000000..49a53505c8e3 --- /dev/null +++ b/lib/ucmpdi2.c @@ -0,0 +1,35 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <linux/module.h> +#include <lib/libgcc.h> + +word_type __ucmpdi2(unsigned long long a, unsigned long long b) +{ + const DWunion au = {.ll = a}; + const DWunion bu = {.ll = b}; + + if ((unsigned int) au.s.high < (unsigned int) bu.s.high) + return 0; + else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) + return 2; + if ((unsigned int) au.s.low < (unsigned int) bu.s.low) + return 0; + else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) + return 2; + return 1; +} +EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 2/7] m32r: Use lib/ucmpdi2.c 2017-06-06 19:10 ` Palmer Dabbelt ` (2 preceding siblings ...) 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt ` (19 subsequent siblings) 23 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/m32r/Kconfig | 1 + arch/m32r/lib/Makefile | 3 +-- arch/m32r/lib/libgcc.h | 23 ----------------------- arch/m32r/lib/ucmpdi2.c | 17 ----------------- 4 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 arch/m32r/lib/libgcc.h delete mode 100644 arch/m32r/lib/ucmpdi2.c diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index 95474460b367..756d68d4f4e1 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig @@ -19,6 +19,7 @@ config M32R select HAVE_DEBUG_STACKOVERFLOW select CPU_NO_EFFICIENT_FFS select DMA_NOOP_OPS + select GENERIC_UCMPDI3 config SBUS bool diff --git a/arch/m32r/lib/Makefile b/arch/m32r/lib/Makefile index 5889eb9610b5..0a753a833bbf 100644 --- a/arch/m32r/lib/Makefile +++ b/arch/m32r/lib/Makefile @@ -3,5 +3,4 @@ # lib-y := checksum.o ashxdi3.o memset.o memcpy.o \ - delay.o strlen.o usercopy.o csum_partial_copy.o \ - ucmpdi2.o + delay.o strlen.o usercopy.o csum_partial_copy.o diff --git a/arch/m32r/lib/libgcc.h b/arch/m32r/lib/libgcc.h deleted file mode 100644 index 267aa435bc35..000000000000 --- a/arch/m32r/lib/libgcc.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/m32r/lib/ucmpdi2.c b/arch/m32r/lib/ucmpdi2.c deleted file mode 100644 index 9d3c682c89b5..000000000000 --- a/arch/m32r/lib/ucmpdi2.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "libgcc.h" - -int __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int)au.s.high < (unsigned int)bu.s.high) - return 0; - else if ((unsigned int)au.s.high > (unsigned int)bu.s.high) - return 2; - if ((unsigned int)au.s.low < (unsigned int)bu.s.low) - return 0; - else if ((unsigned int)au.s.low > (unsigned int)bu.s.low) - return 2; - return 1; -} -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 2/7] m32r: Use lib/ucmpdi2.c 2017-06-06 19:10 ` Palmer Dabbelt ` (3 preceding siblings ...) 2017-06-06 19:10 ` [PATCH 2/7] m32r: Use lib/ucmpdi2.c Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt ` (18 subsequent siblings) 23 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/m32r/Kconfig | 1 + arch/m32r/lib/Makefile | 3 +-- arch/m32r/lib/libgcc.h | 23 ----------------------- arch/m32r/lib/ucmpdi2.c | 17 ----------------- 4 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 arch/m32r/lib/libgcc.h delete mode 100644 arch/m32r/lib/ucmpdi2.c diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index 95474460b367..756d68d4f4e1 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig @@ -19,6 +19,7 @@ config M32R select HAVE_DEBUG_STACKOVERFLOW select CPU_NO_EFFICIENT_FFS select DMA_NOOP_OPS + select GENERIC_UCMPDI3 config SBUS bool diff --git a/arch/m32r/lib/Makefile b/arch/m32r/lib/Makefile index 5889eb9610b5..0a753a833bbf 100644 --- a/arch/m32r/lib/Makefile +++ b/arch/m32r/lib/Makefile @@ -3,5 +3,4 @@ # lib-y := checksum.o ashxdi3.o memset.o memcpy.o \ - delay.o strlen.o usercopy.o csum_partial_copy.o \ - ucmpdi2.o + delay.o strlen.o usercopy.o csum_partial_copy.o diff --git a/arch/m32r/lib/libgcc.h b/arch/m32r/lib/libgcc.h deleted file mode 100644 index 267aa435bc35..000000000000 --- a/arch/m32r/lib/libgcc.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/m32r/lib/ucmpdi2.c b/arch/m32r/lib/ucmpdi2.c deleted file mode 100644 index 9d3c682c89b5..000000000000 --- a/arch/m32r/lib/ucmpdi2.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "libgcc.h" - -int __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int)au.s.high < (unsigned int)bu.s.high) - return 0; - else if ((unsigned int)au.s.high > (unsigned int)bu.s.high) - return 2; - if ((unsigned int)au.s.low < (unsigned int)bu.s.low) - return 0; - else if ((unsigned int)au.s.low > (unsigned int)bu.s.low) - return 2; - return 1; -} -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 2/7] m32r: Use lib/ucmpdi2.c 2017-06-06 19:10 ` Palmer Dabbelt ` (4 preceding siblings ...) 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` [PATCH 3/7] microblaze: Use libgcc files from lib/ Palmer Dabbelt ` (17 subsequent siblings) 23 siblings, 1 reply; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/m32r/Kconfig | 1 + arch/m32r/lib/Makefile | 3 +-- arch/m32r/lib/libgcc.h | 23 ----------------------- arch/m32r/lib/ucmpdi2.c | 17 ----------------- 4 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 arch/m32r/lib/libgcc.h delete mode 100644 arch/m32r/lib/ucmpdi2.c diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index 95474460b367..756d68d4f4e1 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig @@ -19,6 +19,7 @@ config M32R select HAVE_DEBUG_STACKOVERFLOW select CPU_NO_EFFICIENT_FFS select DMA_NOOP_OPS + select GENERIC_UCMPDI3 config SBUS bool diff --git a/arch/m32r/lib/Makefile b/arch/m32r/lib/Makefile index 5889eb9610b5..0a753a833bbf 100644 --- a/arch/m32r/lib/Makefile +++ b/arch/m32r/lib/Makefile @@ -3,5 +3,4 @@ # lib-y := checksum.o ashxdi3.o memset.o memcpy.o \ - delay.o strlen.o usercopy.o csum_partial_copy.o \ - ucmpdi2.o + delay.o strlen.o usercopy.o csum_partial_copy.o diff --git a/arch/m32r/lib/libgcc.h b/arch/m32r/lib/libgcc.h deleted file mode 100644 index 267aa435bc35..000000000000 --- a/arch/m32r/lib/libgcc.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/m32r/lib/ucmpdi2.c b/arch/m32r/lib/ucmpdi2.c deleted file mode 100644 index 9d3c682c89b5..000000000000 --- a/arch/m32r/lib/ucmpdi2.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "libgcc.h" - -int __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int)au.s.high < (unsigned int)bu.s.high) - return 0; - else if ((unsigned int)au.s.high > (unsigned int)bu.s.high) - return 2; - if ((unsigned int)au.s.low < (unsigned int)bu.s.low) - return 0; - else if ((unsigned int)au.s.low > (unsigned int)bu.s.low) - return 2; - return 1; -} -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 2/7] m32r: Use lib/ucmpdi2.c 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 0 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/m32r/Kconfig | 1 + arch/m32r/lib/Makefile | 3 +-- arch/m32r/lib/libgcc.h | 23 ----------------------- arch/m32r/lib/ucmpdi2.c | 17 ----------------- 4 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 arch/m32r/lib/libgcc.h delete mode 100644 arch/m32r/lib/ucmpdi2.c diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index 95474460b367..756d68d4f4e1 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig @@ -19,6 +19,7 @@ config M32R select HAVE_DEBUG_STACKOVERFLOW select CPU_NO_EFFICIENT_FFS select DMA_NOOP_OPS + select GENERIC_UCMPDI3 config SBUS bool diff --git a/arch/m32r/lib/Makefile b/arch/m32r/lib/Makefile index 5889eb9610b5..0a753a833bbf 100644 --- a/arch/m32r/lib/Makefile +++ b/arch/m32r/lib/Makefile @@ -3,5 +3,4 @@ # lib-y := checksum.o ashxdi3.o memset.o memcpy.o \ - delay.o strlen.o usercopy.o csum_partial_copy.o \ - ucmpdi2.o + delay.o strlen.o usercopy.o csum_partial_copy.o diff --git a/arch/m32r/lib/libgcc.h b/arch/m32r/lib/libgcc.h deleted file mode 100644 index 267aa435bc35..000000000000 --- a/arch/m32r/lib/libgcc.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/m32r/lib/ucmpdi2.c b/arch/m32r/lib/ucmpdi2.c deleted file mode 100644 index 9d3c682c89b5..000000000000 --- a/arch/m32r/lib/ucmpdi2.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "libgcc.h" - -int __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int)au.s.high < (unsigned int)bu.s.high) - return 0; - else if ((unsigned int)au.s.high > (unsigned int)bu.s.high) - return 2; - if ((unsigned int)au.s.low < (unsigned int)bu.s.low) - return 0; - else if ((unsigned int)au.s.low > (unsigned int)bu.s.low) - return 2; - return 1; -} -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 3/7] microblaze: Use libgcc files from lib/ 2017-06-06 19:10 ` Palmer Dabbelt ` (5 preceding siblings ...) 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt ` (16 subsequent siblings) 23 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/microblaze/Kconfig | 6 +++++ arch/microblaze/lib/Makefile | 3 +-- arch/microblaze/lib/ashldi3.c | 28 --------------------- arch/microblaze/lib/ashrdi3.c | 30 ----------------------- arch/microblaze/lib/cmpdi2.c | 26 -------------------- arch/microblaze/lib/libgcc.h | 32 ------------------------ arch/microblaze/lib/lshrdi3.c | 28 --------------------- arch/microblaze/lib/muldi3.c | 57 ------------------------------------------- arch/microblaze/lib/ucmpdi2.c | 20 --------------- 9 files changed, 7 insertions(+), 223 deletions(-) delete mode 100644 arch/microblaze/lib/ashldi3.c delete mode 100644 arch/microblaze/lib/ashrdi3.c delete mode 100644 arch/microblaze/lib/cmpdi2.c delete mode 100644 arch/microblaze/lib/libgcc.h delete mode 100644 arch/microblaze/lib/lshrdi3.c delete mode 100644 arch/microblaze/lib/muldi3.c delete mode 100644 arch/microblaze/lib/ucmpdi2.c diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index 85885a501dce..833487c17996 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig @@ -34,6 +34,12 @@ config MICROBLAZE select TRACING_SUPPORT select VIRT_TO_BUS select CPU_NO_EFFICIENT_FFS + select GENERIC_ASHLDI3 + select GENERIC_ASHRDI3 + select GENERIC_CMPDI2 + select GENERIC_LSHRDI3 + select GENERIC_MULDI3 + select GENERIC_UCMPDI3 config SWAP def_bool n diff --git a/arch/microblaze/lib/Makefile b/arch/microblaze/lib/Makefile index 70c7ae6a3fb5..c9a4d537e2fd 100644 --- a/arch/microblaze/lib/Makefile +++ b/arch/microblaze/lib/Makefile @@ -19,5 +19,4 @@ endif lib-y += uaccess_old.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o cmpdi2.o divsi3.o lshrdi3.o modsi3.o -obj-y += muldi3.o mulsi3.o ucmpdi2.o udivsi3.o umodsi3.o +obj-y += divsi3.o modsi3.o mulsi3.o udivsi3.o umodsi3.o diff --git a/arch/microblaze/lib/ashldi3.c b/arch/microblaze/lib/ashldi3.c deleted file mode 100644 index 1af904cd972d..000000000000 --- a/arch/microblaze/lib/ashldi3.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/microblaze/lib/ashrdi3.c b/arch/microblaze/lib/ashrdi3.c deleted file mode 100644 index 32c334c05d04..000000000000 --- a/arch/microblaze/lib/ashrdi3.c +++ /dev/null @@ -1,30 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/microblaze/lib/cmpdi2.c b/arch/microblaze/lib/cmpdi2.c deleted file mode 100644 index 67abc9ac1bd4..000000000000 --- a/arch/microblaze/lib/cmpdi2.c +++ /dev/null @@ -1,26 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/microblaze/lib/libgcc.h b/arch/microblaze/lib/libgcc.h deleted file mode 100644 index ab077ef7e14b..000000000000 --- a/arch/microblaze/lib/libgcc.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -extern long long __ashldi3(long long u, word_type b); -extern long long __ashrdi3(long long u, word_type b); -extern word_type __cmpdi2(long long a, long long b); -extern long long __lshrdi3(long long u, word_type b); -extern long long __muldi3(long long u, long long v); -extern word_type __ucmpdi2(unsigned long long a, unsigned long long b); - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/microblaze/lib/lshrdi3.c b/arch/microblaze/lib/lshrdi3.c deleted file mode 100644 index adcb253f11c8..000000000000 --- a/arch/microblaze/lib/lshrdi3.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/microblaze/lib/muldi3.c b/arch/microblaze/lib/muldi3.c deleted file mode 100644 index a3f9a03acdcd..000000000000 --- a/arch/microblaze/lib/muldi3.c +++ /dev/null @@ -1,57 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -#define W_TYPE_SIZE 32 - -#define __ll_B ((unsigned long) 1 << (W_TYPE_SIZE / 2)) -#define __ll_lowpart(t) ((unsigned long) (t) & (__ll_B - 1)) -#define __ll_highpart(t) ((unsigned long) (t) >> (W_TYPE_SIZE / 2)) - -/* If we still don't have umul_ppmm, define it using plain C. */ -#if !defined(umul_ppmm) -#define umul_ppmm(w1, w0, u, v) \ - do { \ - unsigned long __x0, __x1, __x2, __x3; \ - unsigned short __ul, __vl, __uh, __vh; \ - \ - __ul = __ll_lowpart(u); \ - __uh = __ll_highpart(u); \ - __vl = __ll_lowpart(v); \ - __vh = __ll_highpart(v); \ - \ - __x0 = (unsigned long) __ul * __vl; \ - __x1 = (unsigned long) __ul * __vh; \ - __x2 = (unsigned long) __uh * __vl; \ - __x3 = (unsigned long) __uh * __vh; \ - \ - __x1 += __ll_highpart(__x0); /* this can't give carry */\ - __x1 += __x2; /* but this indeed can */ \ - if (__x1 < __x2) /* did we get it? */ \ - __x3 += __ll_B; /* yes, add it in the proper pos */ \ - \ - (w1) = __x3 + __ll_highpart(__x1); \ - (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0);\ - } while (0) -#endif - -#if !defined(__umulsidi3) -#define __umulsidi3(u, v) ({ \ - DWunion __w; \ - umul_ppmm(__w.s.high, __w.s.low, u, v); \ - __w.ll; \ - }) -#endif - -long long __muldi3(long long u, long long v) -{ - const DWunion uu = {.ll = u}; - const DWunion vv = {.ll = v}; - DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)}; - - w.s.high += ((unsigned long) uu.s.low * (unsigned long) vv.s.high - + (unsigned long) uu.s.high * (unsigned long) vv.s.low); - - return w.ll; -} -EXPORT_SYMBOL(__muldi3); diff --git a/arch/microblaze/lib/ucmpdi2.c b/arch/microblaze/lib/ucmpdi2.c deleted file mode 100644 index d05f1585121c..000000000000 --- a/arch/microblaze/lib/ucmpdi2.c +++ /dev/null @@ -1,20 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 3/7] microblaze: Use libgcc files from lib/ 2017-06-06 19:10 ` Palmer Dabbelt ` (6 preceding siblings ...) 2017-06-06 19:10 ` [PATCH 3/7] microblaze: Use libgcc files from lib/ Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt ` (15 subsequent siblings) 23 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/microblaze/Kconfig | 6 +++++ arch/microblaze/lib/Makefile | 3 +-- arch/microblaze/lib/ashldi3.c | 28 --------------------- arch/microblaze/lib/ashrdi3.c | 30 ----------------------- arch/microblaze/lib/cmpdi2.c | 26 -------------------- arch/microblaze/lib/libgcc.h | 32 ------------------------ arch/microblaze/lib/lshrdi3.c | 28 --------------------- arch/microblaze/lib/muldi3.c | 57 ------------------------------------------- arch/microblaze/lib/ucmpdi2.c | 20 --------------- 9 files changed, 7 insertions(+), 223 deletions(-) delete mode 100644 arch/microblaze/lib/ashldi3.c delete mode 100644 arch/microblaze/lib/ashrdi3.c delete mode 100644 arch/microblaze/lib/cmpdi2.c delete mode 100644 arch/microblaze/lib/libgcc.h delete mode 100644 arch/microblaze/lib/lshrdi3.c delete mode 100644 arch/microblaze/lib/muldi3.c delete mode 100644 arch/microblaze/lib/ucmpdi2.c diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index 85885a501dce..833487c17996 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig @@ -34,6 +34,12 @@ config MICROBLAZE select TRACING_SUPPORT select VIRT_TO_BUS select CPU_NO_EFFICIENT_FFS + select GENERIC_ASHLDI3 + select GENERIC_ASHRDI3 + select GENERIC_CMPDI2 + select GENERIC_LSHRDI3 + select GENERIC_MULDI3 + select GENERIC_UCMPDI3 config SWAP def_bool n diff --git a/arch/microblaze/lib/Makefile b/arch/microblaze/lib/Makefile index 70c7ae6a3fb5..c9a4d537e2fd 100644 --- a/arch/microblaze/lib/Makefile +++ b/arch/microblaze/lib/Makefile @@ -19,5 +19,4 @@ endif lib-y += uaccess_old.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o cmpdi2.o divsi3.o lshrdi3.o modsi3.o -obj-y += muldi3.o mulsi3.o ucmpdi2.o udivsi3.o umodsi3.o +obj-y += divsi3.o modsi3.o mulsi3.o udivsi3.o umodsi3.o diff --git a/arch/microblaze/lib/ashldi3.c b/arch/microblaze/lib/ashldi3.c deleted file mode 100644 index 1af904cd972d..000000000000 --- a/arch/microblaze/lib/ashldi3.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/microblaze/lib/ashrdi3.c b/arch/microblaze/lib/ashrdi3.c deleted file mode 100644 index 32c334c05d04..000000000000 --- a/arch/microblaze/lib/ashrdi3.c +++ /dev/null @@ -1,30 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/microblaze/lib/cmpdi2.c b/arch/microblaze/lib/cmpdi2.c deleted file mode 100644 index 67abc9ac1bd4..000000000000 --- a/arch/microblaze/lib/cmpdi2.c +++ /dev/null @@ -1,26 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/microblaze/lib/libgcc.h b/arch/microblaze/lib/libgcc.h deleted file mode 100644 index ab077ef7e14b..000000000000 --- a/arch/microblaze/lib/libgcc.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -extern long long __ashldi3(long long u, word_type b); -extern long long __ashrdi3(long long u, word_type b); -extern word_type __cmpdi2(long long a, long long b); -extern long long __lshrdi3(long long u, word_type b); -extern long long __muldi3(long long u, long long v); -extern word_type __ucmpdi2(unsigned long long a, unsigned long long b); - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/microblaze/lib/lshrdi3.c b/arch/microblaze/lib/lshrdi3.c deleted file mode 100644 index adcb253f11c8..000000000000 --- a/arch/microblaze/lib/lshrdi3.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/microblaze/lib/muldi3.c b/arch/microblaze/lib/muldi3.c deleted file mode 100644 index a3f9a03acdcd..000000000000 --- a/arch/microblaze/lib/muldi3.c +++ /dev/null @@ -1,57 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -#define W_TYPE_SIZE 32 - -#define __ll_B ((unsigned long) 1 << (W_TYPE_SIZE / 2)) -#define __ll_lowpart(t) ((unsigned long) (t) & (__ll_B - 1)) -#define __ll_highpart(t) ((unsigned long) (t) >> (W_TYPE_SIZE / 2)) - -/* If we still don't have umul_ppmm, define it using plain C. */ -#if !defined(umul_ppmm) -#define umul_ppmm(w1, w0, u, v) \ - do { \ - unsigned long __x0, __x1, __x2, __x3; \ - unsigned short __ul, __vl, __uh, __vh; \ - \ - __ul = __ll_lowpart(u); \ - __uh = __ll_highpart(u); \ - __vl = __ll_lowpart(v); \ - __vh = __ll_highpart(v); \ - \ - __x0 = (unsigned long) __ul * __vl; \ - __x1 = (unsigned long) __ul * __vh; \ - __x2 = (unsigned long) __uh * __vl; \ - __x3 = (unsigned long) __uh * __vh; \ - \ - __x1 += __ll_highpart(__x0); /* this can't give carry */\ - __x1 += __x2; /* but this indeed can */ \ - if (__x1 < __x2) /* did we get it? */ \ - __x3 += __ll_B; /* yes, add it in the proper pos */ \ - \ - (w1) = __x3 + __ll_highpart(__x1); \ - (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0);\ - } while (0) -#endif - -#if !defined(__umulsidi3) -#define __umulsidi3(u, v) ({ \ - DWunion __w; \ - umul_ppmm(__w.s.high, __w.s.low, u, v); \ - __w.ll; \ - }) -#endif - -long long __muldi3(long long u, long long v) -{ - const DWunion uu = {.ll = u}; - const DWunion vv = {.ll = v}; - DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)}; - - w.s.high += ((unsigned long) uu.s.low * (unsigned long) vv.s.high - + (unsigned long) uu.s.high * (unsigned long) vv.s.low); - - return w.ll; -} -EXPORT_SYMBOL(__muldi3); diff --git a/arch/microblaze/lib/ucmpdi2.c b/arch/microblaze/lib/ucmpdi2.c deleted file mode 100644 index d05f1585121c..000000000000 --- a/arch/microblaze/lib/ucmpdi2.c +++ /dev/null @@ -1,20 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 3/7] microblaze: Use libgcc files from lib/ 2017-06-06 19:10 ` Palmer Dabbelt ` (7 preceding siblings ...) 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` [PATCH 4/7] score: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c Palmer Dabbelt ` (14 subsequent siblings) 23 siblings, 1 reply; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/microblaze/Kconfig | 6 +++++ arch/microblaze/lib/Makefile | 3 +-- arch/microblaze/lib/ashldi3.c | 28 --------------------- arch/microblaze/lib/ashrdi3.c | 30 ----------------------- arch/microblaze/lib/cmpdi2.c | 26 -------------------- arch/microblaze/lib/libgcc.h | 32 ------------------------ arch/microblaze/lib/lshrdi3.c | 28 --------------------- arch/microblaze/lib/muldi3.c | 57 ------------------------------------------- arch/microblaze/lib/ucmpdi2.c | 20 --------------- 9 files changed, 7 insertions(+), 223 deletions(-) delete mode 100644 arch/microblaze/lib/ashldi3.c delete mode 100644 arch/microblaze/lib/ashrdi3.c delete mode 100644 arch/microblaze/lib/cmpdi2.c delete mode 100644 arch/microblaze/lib/libgcc.h delete mode 100644 arch/microblaze/lib/lshrdi3.c delete mode 100644 arch/microblaze/lib/muldi3.c delete mode 100644 arch/microblaze/lib/ucmpdi2.c diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index 85885a501dce..833487c17996 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig @@ -34,6 +34,12 @@ config MICROBLAZE select TRACING_SUPPORT select VIRT_TO_BUS select CPU_NO_EFFICIENT_FFS + select GENERIC_ASHLDI3 + select GENERIC_ASHRDI3 + select GENERIC_CMPDI2 + select GENERIC_LSHRDI3 + select GENERIC_MULDI3 + select GENERIC_UCMPDI3 config SWAP def_bool n diff --git a/arch/microblaze/lib/Makefile b/arch/microblaze/lib/Makefile index 70c7ae6a3fb5..c9a4d537e2fd 100644 --- a/arch/microblaze/lib/Makefile +++ b/arch/microblaze/lib/Makefile @@ -19,5 +19,4 @@ endif lib-y += uaccess_old.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o cmpdi2.o divsi3.o lshrdi3.o modsi3.o -obj-y += muldi3.o mulsi3.o ucmpdi2.o udivsi3.o umodsi3.o +obj-y += divsi3.o modsi3.o mulsi3.o udivsi3.o umodsi3.o diff --git a/arch/microblaze/lib/ashldi3.c b/arch/microblaze/lib/ashldi3.c deleted file mode 100644 index 1af904cd972d..000000000000 --- a/arch/microblaze/lib/ashldi3.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/microblaze/lib/ashrdi3.c b/arch/microblaze/lib/ashrdi3.c deleted file mode 100644 index 32c334c05d04..000000000000 --- a/arch/microblaze/lib/ashrdi3.c +++ /dev/null @@ -1,30 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/microblaze/lib/cmpdi2.c b/arch/microblaze/lib/cmpdi2.c deleted file mode 100644 index 67abc9ac1bd4..000000000000 --- a/arch/microblaze/lib/cmpdi2.c +++ /dev/null @@ -1,26 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/microblaze/lib/libgcc.h b/arch/microblaze/lib/libgcc.h deleted file mode 100644 index ab077ef7e14b..000000000000 --- a/arch/microblaze/lib/libgcc.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -extern long long __ashldi3(long long u, word_type b); -extern long long __ashrdi3(long long u, word_type b); -extern word_type __cmpdi2(long long a, long long b); -extern long long __lshrdi3(long long u, word_type b); -extern long long __muldi3(long long u, long long v); -extern word_type __ucmpdi2(unsigned long long a, unsigned long long b); - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/microblaze/lib/lshrdi3.c b/arch/microblaze/lib/lshrdi3.c deleted file mode 100644 index adcb253f11c8..000000000000 --- a/arch/microblaze/lib/lshrdi3.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/microblaze/lib/muldi3.c b/arch/microblaze/lib/muldi3.c deleted file mode 100644 index a3f9a03acdcd..000000000000 --- a/arch/microblaze/lib/muldi3.c +++ /dev/null @@ -1,57 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -#define W_TYPE_SIZE 32 - -#define __ll_B ((unsigned long) 1 << (W_TYPE_SIZE / 2)) -#define __ll_lowpart(t) ((unsigned long) (t) & (__ll_B - 1)) -#define __ll_highpart(t) ((unsigned long) (t) >> (W_TYPE_SIZE / 2)) - -/* If we still don't have umul_ppmm, define it using plain C. */ -#if !defined(umul_ppmm) -#define umul_ppmm(w1, w0, u, v) \ - do { \ - unsigned long __x0, __x1, __x2, __x3; \ - unsigned short __ul, __vl, __uh, __vh; \ - \ - __ul = __ll_lowpart(u); \ - __uh = __ll_highpart(u); \ - __vl = __ll_lowpart(v); \ - __vh = __ll_highpart(v); \ - \ - __x0 = (unsigned long) __ul * __vl; \ - __x1 = (unsigned long) __ul * __vh; \ - __x2 = (unsigned long) __uh * __vl; \ - __x3 = (unsigned long) __uh * __vh; \ - \ - __x1 += __ll_highpart(__x0); /* this can't give carry */\ - __x1 += __x2; /* but this indeed can */ \ - if (__x1 < __x2) /* did we get it? */ \ - __x3 += __ll_B; /* yes, add it in the proper pos */ \ - \ - (w1) = __x3 + __ll_highpart(__x1); \ - (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0);\ - } while (0) -#endif - -#if !defined(__umulsidi3) -#define __umulsidi3(u, v) ({ \ - DWunion __w; \ - umul_ppmm(__w.s.high, __w.s.low, u, v); \ - __w.ll; \ - }) -#endif - -long long __muldi3(long long u, long long v) -{ - const DWunion uu = {.ll = u}; - const DWunion vv = {.ll = v}; - DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)}; - - w.s.high += ((unsigned long) uu.s.low * (unsigned long) vv.s.high - + (unsigned long) uu.s.high * (unsigned long) vv.s.low); - - return w.ll; -} -EXPORT_SYMBOL(__muldi3); diff --git a/arch/microblaze/lib/ucmpdi2.c b/arch/microblaze/lib/ucmpdi2.c deleted file mode 100644 index d05f1585121c..000000000000 --- a/arch/microblaze/lib/ucmpdi2.c +++ /dev/null @@ -1,20 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 3/7] microblaze: Use libgcc files from lib/ 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 0 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/microblaze/Kconfig | 6 +++++ arch/microblaze/lib/Makefile | 3 +-- arch/microblaze/lib/ashldi3.c | 28 --------------------- arch/microblaze/lib/ashrdi3.c | 30 ----------------------- arch/microblaze/lib/cmpdi2.c | 26 -------------------- arch/microblaze/lib/libgcc.h | 32 ------------------------ arch/microblaze/lib/lshrdi3.c | 28 --------------------- arch/microblaze/lib/muldi3.c | 57 ------------------------------------------- arch/microblaze/lib/ucmpdi2.c | 20 --------------- 9 files changed, 7 insertions(+), 223 deletions(-) delete mode 100644 arch/microblaze/lib/ashldi3.c delete mode 100644 arch/microblaze/lib/ashrdi3.c delete mode 100644 arch/microblaze/lib/cmpdi2.c delete mode 100644 arch/microblaze/lib/libgcc.h delete mode 100644 arch/microblaze/lib/lshrdi3.c delete mode 100644 arch/microblaze/lib/muldi3.c delete mode 100644 arch/microblaze/lib/ucmpdi2.c diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index 85885a501dce..833487c17996 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig @@ -34,6 +34,12 @@ config MICROBLAZE select TRACING_SUPPORT select VIRT_TO_BUS select CPU_NO_EFFICIENT_FFS + select GENERIC_ASHLDI3 + select GENERIC_ASHRDI3 + select GENERIC_CMPDI2 + select GENERIC_LSHRDI3 + select GENERIC_MULDI3 + select GENERIC_UCMPDI3 config SWAP def_bool n diff --git a/arch/microblaze/lib/Makefile b/arch/microblaze/lib/Makefile index 70c7ae6a3fb5..c9a4d537e2fd 100644 --- a/arch/microblaze/lib/Makefile +++ b/arch/microblaze/lib/Makefile @@ -19,5 +19,4 @@ endif lib-y += uaccess_old.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o cmpdi2.o divsi3.o lshrdi3.o modsi3.o -obj-y += muldi3.o mulsi3.o ucmpdi2.o udivsi3.o umodsi3.o +obj-y += divsi3.o modsi3.o mulsi3.o udivsi3.o umodsi3.o diff --git a/arch/microblaze/lib/ashldi3.c b/arch/microblaze/lib/ashldi3.c deleted file mode 100644 index 1af904cd972d..000000000000 --- a/arch/microblaze/lib/ashldi3.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/microblaze/lib/ashrdi3.c b/arch/microblaze/lib/ashrdi3.c deleted file mode 100644 index 32c334c05d04..000000000000 --- a/arch/microblaze/lib/ashrdi3.c +++ /dev/null @@ -1,30 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/microblaze/lib/cmpdi2.c b/arch/microblaze/lib/cmpdi2.c deleted file mode 100644 index 67abc9ac1bd4..000000000000 --- a/arch/microblaze/lib/cmpdi2.c +++ /dev/null @@ -1,26 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/microblaze/lib/libgcc.h b/arch/microblaze/lib/libgcc.h deleted file mode 100644 index ab077ef7e14b..000000000000 --- a/arch/microblaze/lib/libgcc.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -extern long long __ashldi3(long long u, word_type b); -extern long long __ashrdi3(long long u, word_type b); -extern word_type __cmpdi2(long long a, long long b); -extern long long __lshrdi3(long long u, word_type b); -extern long long __muldi3(long long u, long long v); -extern word_type __ucmpdi2(unsigned long long a, unsigned long long b); - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/microblaze/lib/lshrdi3.c b/arch/microblaze/lib/lshrdi3.c deleted file mode 100644 index adcb253f11c8..000000000000 --- a/arch/microblaze/lib/lshrdi3.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/microblaze/lib/muldi3.c b/arch/microblaze/lib/muldi3.c deleted file mode 100644 index a3f9a03acdcd..000000000000 --- a/arch/microblaze/lib/muldi3.c +++ /dev/null @@ -1,57 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -#define W_TYPE_SIZE 32 - -#define __ll_B ((unsigned long) 1 << (W_TYPE_SIZE / 2)) -#define __ll_lowpart(t) ((unsigned long) (t) & (__ll_B - 1)) -#define __ll_highpart(t) ((unsigned long) (t) >> (W_TYPE_SIZE / 2)) - -/* If we still don't have umul_ppmm, define it using plain C. */ -#if !defined(umul_ppmm) -#define umul_ppmm(w1, w0, u, v) \ - do { \ - unsigned long __x0, __x1, __x2, __x3; \ - unsigned short __ul, __vl, __uh, __vh; \ - \ - __ul = __ll_lowpart(u); \ - __uh = __ll_highpart(u); \ - __vl = __ll_lowpart(v); \ - __vh = __ll_highpart(v); \ - \ - __x0 = (unsigned long) __ul * __vl; \ - __x1 = (unsigned long) __ul * __vh; \ - __x2 = (unsigned long) __uh * __vl; \ - __x3 = (unsigned long) __uh * __vh; \ - \ - __x1 += __ll_highpart(__x0); /* this can't give carry */\ - __x1 += __x2; /* but this indeed can */ \ - if (__x1 < __x2) /* did we get it? */ \ - __x3 += __ll_B; /* yes, add it in the proper pos */ \ - \ - (w1) = __x3 + __ll_highpart(__x1); \ - (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0);\ - } while (0) -#endif - -#if !defined(__umulsidi3) -#define __umulsidi3(u, v) ({ \ - DWunion __w; \ - umul_ppmm(__w.s.high, __w.s.low, u, v); \ - __w.ll; \ - }) -#endif - -long long __muldi3(long long u, long long v) -{ - const DWunion uu = {.ll = u}; - const DWunion vv = {.ll = v}; - DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)}; - - w.s.high += ((unsigned long) uu.s.low * (unsigned long) vv.s.high - + (unsigned long) uu.s.high * (unsigned long) vv.s.low); - - return w.ll; -} -EXPORT_SYMBOL(__muldi3); diff --git a/arch/microblaze/lib/ucmpdi2.c b/arch/microblaze/lib/ucmpdi2.c deleted file mode 100644 index d05f1585121c..000000000000 --- a/arch/microblaze/lib/ucmpdi2.c +++ /dev/null @@ -1,20 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 4/7] score: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c 2017-06-06 19:10 ` Palmer Dabbelt ` (8 preceding siblings ...) 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt ` (13 subsequent siblings) 23 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/score/Kconfig | 5 +++++ arch/score/lib/Makefile | 3 --- arch/score/lib/ashldi3.c | 46 ---------------------------------------------- arch/score/lib/ashrdi3.c | 48 ------------------------------------------------ arch/score/lib/cmpdi2.c | 44 -------------------------------------------- arch/score/lib/libgcc.h | 37 ------------------------------------- arch/score/lib/lshrdi3.c | 47 ----------------------------------------------- arch/score/lib/ucmpdi2.c | 38 -------------------------------------- 8 files changed, 5 insertions(+), 263 deletions(-) delete mode 100644 arch/score/lib/ashldi3.c delete mode 100644 arch/score/lib/ashrdi3.c delete mode 100644 arch/score/lib/cmpdi2.c delete mode 100644 arch/score/lib/libgcc.h delete mode 100644 arch/score/lib/lshrdi3.c delete mode 100644 arch/score/lib/ucmpdi2.c diff --git a/arch/score/Kconfig b/arch/score/Kconfig index 507d63181389..151ec2296d53 100644 --- a/arch/score/Kconfig +++ b/arch/score/Kconfig @@ -15,6 +15,11 @@ config SCORE select MODULES_USE_ELF_REL select CLONE_BACKWARDS select CPU_NO_EFFICIENT_FFS + select GENERIC_ASHLDI3 + select GENERIC_ASHRDI3 + select GENERIC_CMPDI2 + select GENERIC_LSHRDI3 + select GENERIC_UCMPDI2 choice prompt "System type" diff --git a/arch/score/lib/Makefile b/arch/score/lib/Makefile index 553e30e81faf..ea3f3aba8c71 100644 --- a/arch/score/lib/Makefile +++ b/arch/score/lib/Makefile @@ -3,6 +3,3 @@ # lib-y += string.o checksum.o checksum_copy.o - -# libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o cmpdi2.o lshrdi3.o ucmpdi2.o diff --git a/arch/score/lib/ashldi3.c b/arch/score/lib/ashldi3.c deleted file mode 100644 index 15691a910431..000000000000 --- a/arch/score/lib/ashldi3.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * arch/score/lib/ashldi3.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/score/lib/ashrdi3.c b/arch/score/lib/ashrdi3.c deleted file mode 100644 index d9814a5d8d30..000000000000 --- a/arch/score/lib/ashrdi3.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * arch/score/lib/ashrdi3.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/score/lib/cmpdi2.c b/arch/score/lib/cmpdi2.c deleted file mode 100644 index 1ed5290c66ed..000000000000 --- a/arch/score/lib/cmpdi2.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * arch/score/lib/cmpdi2.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/score/lib/libgcc.h b/arch/score/lib/libgcc.h deleted file mode 100644 index 0f12543d9f31..000000000000 --- a/arch/score/lib/libgcc.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * arch/score/lib/libgcc.h - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__((mode(__word__))); - -struct DWstruct { - int low, high; -}; - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/score/lib/lshrdi3.c b/arch/score/lib/lshrdi3.c deleted file mode 100644 index ce21175fd791..000000000000 --- a/arch/score/lib/lshrdi3.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * arch/score/lib/lshrdi3.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include <linux/module.h> -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/score/lib/ucmpdi2.c b/arch/score/lib/ucmpdi2.c deleted file mode 100644 index b15241e0b079..000000000000 --- a/arch/score/lib/ucmpdi2.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * arch/score/lib/ucmpdi2.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 4/7] score: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c 2017-06-06 19:10 ` Palmer Dabbelt ` (9 preceding siblings ...) 2017-06-06 19:10 ` [PATCH 4/7] score: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt ` (12 subsequent siblings) 23 siblings, 1 reply; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/score/Kconfig | 5 +++++ arch/score/lib/Makefile | 3 --- arch/score/lib/ashldi3.c | 46 ---------------------------------------------- arch/score/lib/ashrdi3.c | 48 ------------------------------------------------ arch/score/lib/cmpdi2.c | 44 -------------------------------------------- arch/score/lib/libgcc.h | 37 ------------------------------------- arch/score/lib/lshrdi3.c | 47 ----------------------------------------------- arch/score/lib/ucmpdi2.c | 38 -------------------------------------- 8 files changed, 5 insertions(+), 263 deletions(-) delete mode 100644 arch/score/lib/ashldi3.c delete mode 100644 arch/score/lib/ashrdi3.c delete mode 100644 arch/score/lib/cmpdi2.c delete mode 100644 arch/score/lib/libgcc.h delete mode 100644 arch/score/lib/lshrdi3.c delete mode 100644 arch/score/lib/ucmpdi2.c diff --git a/arch/score/Kconfig b/arch/score/Kconfig index 507d63181389..151ec2296d53 100644 --- a/arch/score/Kconfig +++ b/arch/score/Kconfig @@ -15,6 +15,11 @@ config SCORE select MODULES_USE_ELF_REL select CLONE_BACKWARDS select CPU_NO_EFFICIENT_FFS + select GENERIC_ASHLDI3 + select GENERIC_ASHRDI3 + select GENERIC_CMPDI2 + select GENERIC_LSHRDI3 + select GENERIC_UCMPDI2 choice prompt "System type" diff --git a/arch/score/lib/Makefile b/arch/score/lib/Makefile index 553e30e81faf..ea3f3aba8c71 100644 --- a/arch/score/lib/Makefile +++ b/arch/score/lib/Makefile @@ -3,6 +3,3 @@ # lib-y += string.o checksum.o checksum_copy.o - -# libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o cmpdi2.o lshrdi3.o ucmpdi2.o diff --git a/arch/score/lib/ashldi3.c b/arch/score/lib/ashldi3.c deleted file mode 100644 index 15691a910431..000000000000 --- a/arch/score/lib/ashldi3.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * arch/score/lib/ashldi3.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/score/lib/ashrdi3.c b/arch/score/lib/ashrdi3.c deleted file mode 100644 index d9814a5d8d30..000000000000 --- a/arch/score/lib/ashrdi3.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * arch/score/lib/ashrdi3.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/score/lib/cmpdi2.c b/arch/score/lib/cmpdi2.c deleted file mode 100644 index 1ed5290c66ed..000000000000 --- a/arch/score/lib/cmpdi2.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * arch/score/lib/cmpdi2.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/score/lib/libgcc.h b/arch/score/lib/libgcc.h deleted file mode 100644 index 0f12543d9f31..000000000000 --- a/arch/score/lib/libgcc.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * arch/score/lib/libgcc.h - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__((mode(__word__))); - -struct DWstruct { - int low, high; -}; - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/score/lib/lshrdi3.c b/arch/score/lib/lshrdi3.c deleted file mode 100644 index ce21175fd791..000000000000 --- a/arch/score/lib/lshrdi3.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * arch/score/lib/lshrdi3.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include <linux/module.h> -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/score/lib/ucmpdi2.c b/arch/score/lib/ucmpdi2.c deleted file mode 100644 index b15241e0b079..000000000000 --- a/arch/score/lib/ucmpdi2.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * arch/score/lib/ucmpdi2.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 4/7] score: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 0 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/score/Kconfig | 5 +++++ arch/score/lib/Makefile | 3 --- arch/score/lib/ashldi3.c | 46 ---------------------------------------------- arch/score/lib/ashrdi3.c | 48 ------------------------------------------------ arch/score/lib/cmpdi2.c | 44 -------------------------------------------- arch/score/lib/libgcc.h | 37 ------------------------------------- arch/score/lib/lshrdi3.c | 47 ----------------------------------------------- arch/score/lib/ucmpdi2.c | 38 -------------------------------------- 8 files changed, 5 insertions(+), 263 deletions(-) delete mode 100644 arch/score/lib/ashldi3.c delete mode 100644 arch/score/lib/ashrdi3.c delete mode 100644 arch/score/lib/cmpdi2.c delete mode 100644 arch/score/lib/libgcc.h delete mode 100644 arch/score/lib/lshrdi3.c delete mode 100644 arch/score/lib/ucmpdi2.c diff --git a/arch/score/Kconfig b/arch/score/Kconfig index 507d63181389..151ec2296d53 100644 --- a/arch/score/Kconfig +++ b/arch/score/Kconfig @@ -15,6 +15,11 @@ config SCORE select MODULES_USE_ELF_REL select CLONE_BACKWARDS select CPU_NO_EFFICIENT_FFS + select GENERIC_ASHLDI3 + select GENERIC_ASHRDI3 + select GENERIC_CMPDI2 + select GENERIC_LSHRDI3 + select GENERIC_UCMPDI2 choice prompt "System type" diff --git a/arch/score/lib/Makefile b/arch/score/lib/Makefile index 553e30e81faf..ea3f3aba8c71 100644 --- a/arch/score/lib/Makefile +++ b/arch/score/lib/Makefile @@ -3,6 +3,3 @@ # lib-y += string.o checksum.o checksum_copy.o - -# libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o cmpdi2.o lshrdi3.o ucmpdi2.o diff --git a/arch/score/lib/ashldi3.c b/arch/score/lib/ashldi3.c deleted file mode 100644 index 15691a910431..000000000000 --- a/arch/score/lib/ashldi3.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * arch/score/lib/ashldi3.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/score/lib/ashrdi3.c b/arch/score/lib/ashrdi3.c deleted file mode 100644 index d9814a5d8d30..000000000000 --- a/arch/score/lib/ashrdi3.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * arch/score/lib/ashrdi3.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/score/lib/cmpdi2.c b/arch/score/lib/cmpdi2.c deleted file mode 100644 index 1ed5290c66ed..000000000000 --- a/arch/score/lib/cmpdi2.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * arch/score/lib/cmpdi2.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/score/lib/libgcc.h b/arch/score/lib/libgcc.h deleted file mode 100644 index 0f12543d9f31..000000000000 --- a/arch/score/lib/libgcc.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * arch/score/lib/libgcc.h - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__((mode(__word__))); - -struct DWstruct { - int low, high; -}; - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/score/lib/lshrdi3.c b/arch/score/lib/lshrdi3.c deleted file mode 100644 index ce21175fd791..000000000000 --- a/arch/score/lib/lshrdi3.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * arch/score/lib/lshrdi3.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include <linux/module.h> -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/score/lib/ucmpdi2.c b/arch/score/lib/ucmpdi2.c deleted file mode 100644 index b15241e0b079..000000000000 --- a/arch/score/lib/ucmpdi2.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * arch/score/lib/ucmpdi2.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 4/7] score: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c 2017-06-06 19:10 ` Palmer Dabbelt ` (10 preceding siblings ...) 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` [PATCH 5/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c Palmer Dabbelt ` (11 subsequent siblings) 23 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/score/Kconfig | 5 +++++ arch/score/lib/Makefile | 3 --- arch/score/lib/ashldi3.c | 46 ---------------------------------------------- arch/score/lib/ashrdi3.c | 48 ------------------------------------------------ arch/score/lib/cmpdi2.c | 44 -------------------------------------------- arch/score/lib/libgcc.h | 37 ------------------------------------- arch/score/lib/lshrdi3.c | 47 ----------------------------------------------- arch/score/lib/ucmpdi2.c | 38 -------------------------------------- 8 files changed, 5 insertions(+), 263 deletions(-) delete mode 100644 arch/score/lib/ashldi3.c delete mode 100644 arch/score/lib/ashrdi3.c delete mode 100644 arch/score/lib/cmpdi2.c delete mode 100644 arch/score/lib/libgcc.h delete mode 100644 arch/score/lib/lshrdi3.c delete mode 100644 arch/score/lib/ucmpdi2.c diff --git a/arch/score/Kconfig b/arch/score/Kconfig index 507d63181389..151ec2296d53 100644 --- a/arch/score/Kconfig +++ b/arch/score/Kconfig @@ -15,6 +15,11 @@ config SCORE select MODULES_USE_ELF_REL select CLONE_BACKWARDS select CPU_NO_EFFICIENT_FFS + select GENERIC_ASHLDI3 + select GENERIC_ASHRDI3 + select GENERIC_CMPDI2 + select GENERIC_LSHRDI3 + select GENERIC_UCMPDI2 choice prompt "System type" diff --git a/arch/score/lib/Makefile b/arch/score/lib/Makefile index 553e30e81faf..ea3f3aba8c71 100644 --- a/arch/score/lib/Makefile +++ b/arch/score/lib/Makefile @@ -3,6 +3,3 @@ # lib-y += string.o checksum.o checksum_copy.o - -# libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o cmpdi2.o lshrdi3.o ucmpdi2.o diff --git a/arch/score/lib/ashldi3.c b/arch/score/lib/ashldi3.c deleted file mode 100644 index 15691a910431..000000000000 --- a/arch/score/lib/ashldi3.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * arch/score/lib/ashldi3.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/score/lib/ashrdi3.c b/arch/score/lib/ashrdi3.c deleted file mode 100644 index d9814a5d8d30..000000000000 --- a/arch/score/lib/ashrdi3.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * arch/score/lib/ashrdi3.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/score/lib/cmpdi2.c b/arch/score/lib/cmpdi2.c deleted file mode 100644 index 1ed5290c66ed..000000000000 --- a/arch/score/lib/cmpdi2.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * arch/score/lib/cmpdi2.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/score/lib/libgcc.h b/arch/score/lib/libgcc.h deleted file mode 100644 index 0f12543d9f31..000000000000 --- a/arch/score/lib/libgcc.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * arch/score/lib/libgcc.h - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__((mode(__word__))); - -struct DWstruct { - int low, high; -}; - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/score/lib/lshrdi3.c b/arch/score/lib/lshrdi3.c deleted file mode 100644 index ce21175fd791..000000000000 --- a/arch/score/lib/lshrdi3.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * arch/score/lib/lshrdi3.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include <linux/module.h> -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/score/lib/ucmpdi2.c b/arch/score/lib/ucmpdi2.c deleted file mode 100644 index b15241e0b079..000000000000 --- a/arch/score/lib/ucmpdi2.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * arch/score/lib/ucmpdi2.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <linux/module.h> -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 5/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c 2017-06-06 19:10 ` Palmer Dabbelt ` (11 preceding siblings ...) 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt ` (10 subsequent siblings) 23 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/sh/Kconfig | 3 +++ arch/sh/boot/compressed/Makefile | 6 +++--- arch/sh/lib/Makefile | 4 +--- arch/sh/lib/ashldi3.c | 29 ----------------------------- arch/sh/lib/ashrdi3.c | 31 ------------------------------- arch/sh/lib/libgcc.h | 25 ------------------------- arch/sh/lib/lshrdi3.c | 29 ----------------------------- 7 files changed, 7 insertions(+), 120 deletions(-) delete mode 100644 arch/sh/lib/ashldi3.c delete mode 100644 arch/sh/lib/ashrdi3.c delete mode 100644 arch/sh/lib/libgcc.h delete mode 100644 arch/sh/lib/lshrdi3.c diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index ee086958b2b2..49b98f74d7a0 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -48,6 +48,9 @@ config SUPERH select HAVE_ARCH_AUDITSYSCALL select HAVE_FUTEX_CMPXCHG if FUTEX select HAVE_NMI + select GENERIC_ASHLDI3 + select GENERIC_ASHRDI3 + select GENERIC_LSHRDI3 help The SuperH is a RISC processor targeted for use in embedded systems and consumer electronics; it was also used in the Sega Dreamcast diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile index c4c47ea9fa94..45a8e1349103 100644 --- a/arch/sh/boot/compressed/Makefile +++ b/arch/sh/boot/compressed/Makefile @@ -38,10 +38,10 @@ LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(IMAGE_OFFSET) -e startup \ # # Pull in the necessary libgcc bits from the in-kernel implementation. # -lib1funcs-$(CONFIG_SUPERH32) := ashiftrt.S ashldi3.c ashrsi3.S ashlsi3.S \ - lshrsi3.S +lib1funcs-$(CONFIG_SUPERH32) := ashiftrt.S ashrsi3.S ashlsi3.S lshrsi3.S lib1funcs-obj := \ - $(addsuffix .o, $(basename $(addprefix $(obj)/, $(lib1funcs-y)))) + $(addsuffix .o, $(basename $(addprefix $(obj)/, $(lib1funcs-y)))) \ + $(srctree)/lib/ashldi3.o lib1funcs-dir := $(srctree)/arch/$(SRCARCH)/lib ifeq ($(BITS),64) diff --git a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile index 3baff31e58cf..971d9ac1e068 100644 --- a/arch/sh/lib/Makefile +++ b/arch/sh/lib/Makefile @@ -6,9 +6,7 @@ lib-y = delay.o memmove.o memchr.o \ checksum.o strlen.o div64.o div64-generic.o # Extracted from libgcc -obj-y += movmem.o ashldi3.o ashrdi3.o lshrdi3.o \ - ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o \ - udiv_qrnnd.o +obj-y += movmem.o ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o udiv_qrnnd.o udivsi3-y := udivsi3_i4i-Os.o diff --git a/arch/sh/lib/ashldi3.c b/arch/sh/lib/ashldi3.c deleted file mode 100644 index beb80f316095..000000000000 --- a/arch/sh/lib/ashldi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/sh/lib/ashrdi3.c b/arch/sh/lib/ashrdi3.c deleted file mode 100644 index c884a912b660..000000000000 --- a/arch/sh/lib/ashrdi3.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/sh/lib/libgcc.h b/arch/sh/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/sh/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sh/lib/lshrdi3.c b/arch/sh/lib/lshrdi3.c deleted file mode 100644 index dcf8d6810b7c..000000000000 --- a/arch/sh/lib/lshrdi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__lshrdi3); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 5/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c 2017-06-06 19:10 ` Palmer Dabbelt ` (12 preceding siblings ...) 2017-06-06 19:10 ` [PATCH 5/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-07 19:27 ` kbuild test robot 2017-06-06 19:10 ` Palmer Dabbelt ` (9 subsequent siblings) 23 siblings, 2 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/sh/Kconfig | 3 +++ arch/sh/boot/compressed/Makefile | 6 +++--- arch/sh/lib/Makefile | 4 +--- arch/sh/lib/ashldi3.c | 29 ----------------------------- arch/sh/lib/ashrdi3.c | 31 ------------------------------- arch/sh/lib/libgcc.h | 25 ------------------------- arch/sh/lib/lshrdi3.c | 29 ----------------------------- 7 files changed, 7 insertions(+), 120 deletions(-) delete mode 100644 arch/sh/lib/ashldi3.c delete mode 100644 arch/sh/lib/ashrdi3.c delete mode 100644 arch/sh/lib/libgcc.h delete mode 100644 arch/sh/lib/lshrdi3.c diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index ee086958b2b2..49b98f74d7a0 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -48,6 +48,9 @@ config SUPERH select HAVE_ARCH_AUDITSYSCALL select HAVE_FUTEX_CMPXCHG if FUTEX select HAVE_NMI + select GENERIC_ASHLDI3 + select GENERIC_ASHRDI3 + select GENERIC_LSHRDI3 help The SuperH is a RISC processor targeted for use in embedded systems and consumer electronics; it was also used in the Sega Dreamcast diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile index c4c47ea9fa94..45a8e1349103 100644 --- a/arch/sh/boot/compressed/Makefile +++ b/arch/sh/boot/compressed/Makefile @@ -38,10 +38,10 @@ LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(IMAGE_OFFSET) -e startup \ # # Pull in the necessary libgcc bits from the in-kernel implementation. # -lib1funcs-$(CONFIG_SUPERH32) := ashiftrt.S ashldi3.c ashrsi3.S ashlsi3.S \ - lshrsi3.S +lib1funcs-$(CONFIG_SUPERH32) := ashiftrt.S ashrsi3.S ashlsi3.S lshrsi3.S lib1funcs-obj := \ - $(addsuffix .o, $(basename $(addprefix $(obj)/, $(lib1funcs-y)))) + $(addsuffix .o, $(basename $(addprefix $(obj)/, $(lib1funcs-y)))) \ + $(srctree)/lib/ashldi3.o lib1funcs-dir := $(srctree)/arch/$(SRCARCH)/lib ifeq ($(BITS),64) diff --git a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile index 3baff31e58cf..971d9ac1e068 100644 --- a/arch/sh/lib/Makefile +++ b/arch/sh/lib/Makefile @@ -6,9 +6,7 @@ lib-y = delay.o memmove.o memchr.o \ checksum.o strlen.o div64.o div64-generic.o # Extracted from libgcc -obj-y += movmem.o ashldi3.o ashrdi3.o lshrdi3.o \ - ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o \ - udiv_qrnnd.o +obj-y += movmem.o ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o udiv_qrnnd.o udivsi3-y := udivsi3_i4i-Os.o diff --git a/arch/sh/lib/ashldi3.c b/arch/sh/lib/ashldi3.c deleted file mode 100644 index beb80f316095..000000000000 --- a/arch/sh/lib/ashldi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/sh/lib/ashrdi3.c b/arch/sh/lib/ashrdi3.c deleted file mode 100644 index c884a912b660..000000000000 --- a/arch/sh/lib/ashrdi3.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/sh/lib/libgcc.h b/arch/sh/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/sh/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sh/lib/lshrdi3.c b/arch/sh/lib/lshrdi3.c deleted file mode 100644 index dcf8d6810b7c..000000000000 --- a/arch/sh/lib/lshrdi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__lshrdi3); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 5/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-07 19:27 ` kbuild test robot 1 sibling, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/sh/Kconfig | 3 +++ arch/sh/boot/compressed/Makefile | 6 +++--- arch/sh/lib/Makefile | 4 +--- arch/sh/lib/ashldi3.c | 29 ----------------------------- arch/sh/lib/ashrdi3.c | 31 ------------------------------- arch/sh/lib/libgcc.h | 25 ------------------------- arch/sh/lib/lshrdi3.c | 29 ----------------------------- 7 files changed, 7 insertions(+), 120 deletions(-) delete mode 100644 arch/sh/lib/ashldi3.c delete mode 100644 arch/sh/lib/ashrdi3.c delete mode 100644 arch/sh/lib/libgcc.h delete mode 100644 arch/sh/lib/lshrdi3.c diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index ee086958b2b2..49b98f74d7a0 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -48,6 +48,9 @@ config SUPERH select HAVE_ARCH_AUDITSYSCALL select HAVE_FUTEX_CMPXCHG if FUTEX select HAVE_NMI + select GENERIC_ASHLDI3 + select GENERIC_ASHRDI3 + select GENERIC_LSHRDI3 help The SuperH is a RISC processor targeted for use in embedded systems and consumer electronics; it was also used in the Sega Dreamcast diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile index c4c47ea9fa94..45a8e1349103 100644 --- a/arch/sh/boot/compressed/Makefile +++ b/arch/sh/boot/compressed/Makefile @@ -38,10 +38,10 @@ LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(IMAGE_OFFSET) -e startup \ # # Pull in the necessary libgcc bits from the in-kernel implementation. # -lib1funcs-$(CONFIG_SUPERH32) := ashiftrt.S ashldi3.c ashrsi3.S ashlsi3.S \ - lshrsi3.S +lib1funcs-$(CONFIG_SUPERH32) := ashiftrt.S ashrsi3.S ashlsi3.S lshrsi3.S lib1funcs-obj := \ - $(addsuffix .o, $(basename $(addprefix $(obj)/, $(lib1funcs-y)))) + $(addsuffix .o, $(basename $(addprefix $(obj)/, $(lib1funcs-y)))) \ + $(srctree)/lib/ashldi3.o lib1funcs-dir := $(srctree)/arch/$(SRCARCH)/lib ifeq ($(BITS),64) diff --git a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile index 3baff31e58cf..971d9ac1e068 100644 --- a/arch/sh/lib/Makefile +++ b/arch/sh/lib/Makefile @@ -6,9 +6,7 @@ lib-y = delay.o memmove.o memchr.o \ checksum.o strlen.o div64.o div64-generic.o # Extracted from libgcc -obj-y += movmem.o ashldi3.o ashrdi3.o lshrdi3.o \ - ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o \ - udiv_qrnnd.o +obj-y += movmem.o ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o udiv_qrnnd.o udivsi3-y := udivsi3_i4i-Os.o diff --git a/arch/sh/lib/ashldi3.c b/arch/sh/lib/ashldi3.c deleted file mode 100644 index beb80f316095..000000000000 --- a/arch/sh/lib/ashldi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/sh/lib/ashrdi3.c b/arch/sh/lib/ashrdi3.c deleted file mode 100644 index c884a912b660..000000000000 --- a/arch/sh/lib/ashrdi3.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/sh/lib/libgcc.h b/arch/sh/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/sh/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sh/lib/lshrdi3.c b/arch/sh/lib/lshrdi3.c deleted file mode 100644 index dcf8d6810b7c..000000000000 --- a/arch/sh/lib/lshrdi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__lshrdi3); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* Re: [PATCH 5/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-07 19:27 ` kbuild test robot 2017-06-07 19:27 ` kbuild test robot 1 sibling, 1 reply; 93+ messages in thread From: kbuild test robot @ 2017-06-07 19:27 UTC (permalink / raw) Cc: kbuild-all, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch, Palmer Dabbelt [-- Attachment #1: Type: text/plain, Size: 1063 bytes --] Hi Palmer, [auto build test ERROR on linus/master] [also build test ERROR on v4.12-rc4 next-20170607] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Palmer-Dabbelt/lib-Add-shared-copies-of-some-GCC-library-routines/20170607-234018 config: sh-titan_defconfig (attached as .config) compiler: sh4-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=sh All errors (new ones prefixed by >>): >> make[3]: *** No rule to make target 'lib/ashldi3.o', needed by 'arch/sh/boot/compressed/vmlinux'. make[3]: Target 'arch/sh/boot/compressed/vmlinux' not remade because of errors. --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 16446 bytes --] ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 5/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c 2017-06-07 19:27 ` kbuild test robot @ 2017-06-07 19:27 ` kbuild test robot 0 siblings, 0 replies; 93+ messages in thread From: kbuild test robot @ 2017-06-07 19:27 UTC (permalink / raw) To: Palmer Dabbelt Cc: kbuild-all, monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch [-- Attachment #1: Type: text/plain, Size: 1063 bytes --] Hi Palmer, [auto build test ERROR on linus/master] [also build test ERROR on v4.12-rc4 next-20170607] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Palmer-Dabbelt/lib-Add-shared-copies-of-some-GCC-library-routines/20170607-234018 config: sh-titan_defconfig (attached as .config) compiler: sh4-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=sh All errors (new ones prefixed by >>): >> make[3]: *** No rule to make target 'lib/ashldi3.o', needed by 'arch/sh/boot/compressed/vmlinux'. make[3]: Target 'arch/sh/boot/compressed/vmlinux' not remade because of errors. --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 16446 bytes --] ^ permalink raw reply [flat|nested] 93+ messages in thread
* [PATCH 5/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c 2017-06-06 19:10 ` Palmer Dabbelt ` (13 preceding siblings ...) 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt ` (8 subsequent siblings) 23 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/sh/Kconfig | 3 +++ arch/sh/boot/compressed/Makefile | 6 +++--- arch/sh/lib/Makefile | 4 +--- arch/sh/lib/ashldi3.c | 29 ----------------------------- arch/sh/lib/ashrdi3.c | 31 ------------------------------- arch/sh/lib/libgcc.h | 25 ------------------------- arch/sh/lib/lshrdi3.c | 29 ----------------------------- 7 files changed, 7 insertions(+), 120 deletions(-) delete mode 100644 arch/sh/lib/ashldi3.c delete mode 100644 arch/sh/lib/ashrdi3.c delete mode 100644 arch/sh/lib/libgcc.h delete mode 100644 arch/sh/lib/lshrdi3.c diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index ee086958b2b2..49b98f74d7a0 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -48,6 +48,9 @@ config SUPERH select HAVE_ARCH_AUDITSYSCALL select HAVE_FUTEX_CMPXCHG if FUTEX select HAVE_NMI + select GENERIC_ASHLDI3 + select GENERIC_ASHRDI3 + select GENERIC_LSHRDI3 help The SuperH is a RISC processor targeted for use in embedded systems and consumer electronics; it was also used in the Sega Dreamcast diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile index c4c47ea9fa94..45a8e1349103 100644 --- a/arch/sh/boot/compressed/Makefile +++ b/arch/sh/boot/compressed/Makefile @@ -38,10 +38,10 @@ LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(IMAGE_OFFSET) -e startup \ # # Pull in the necessary libgcc bits from the in-kernel implementation. # -lib1funcs-$(CONFIG_SUPERH32) := ashiftrt.S ashldi3.c ashrsi3.S ashlsi3.S \ - lshrsi3.S +lib1funcs-$(CONFIG_SUPERH32) := ashiftrt.S ashrsi3.S ashlsi3.S lshrsi3.S lib1funcs-obj := \ - $(addsuffix .o, $(basename $(addprefix $(obj)/, $(lib1funcs-y)))) + $(addsuffix .o, $(basename $(addprefix $(obj)/, $(lib1funcs-y)))) \ + $(srctree)/lib/ashldi3.o lib1funcs-dir := $(srctree)/arch/$(SRCARCH)/lib ifeq ($(BITS),64) diff --git a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile index 3baff31e58cf..971d9ac1e068 100644 --- a/arch/sh/lib/Makefile +++ b/arch/sh/lib/Makefile @@ -6,9 +6,7 @@ lib-y = delay.o memmove.o memchr.o \ checksum.o strlen.o div64.o div64-generic.o # Extracted from libgcc -obj-y += movmem.o ashldi3.o ashrdi3.o lshrdi3.o \ - ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o \ - udiv_qrnnd.o +obj-y += movmem.o ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o udiv_qrnnd.o udivsi3-y := udivsi3_i4i-Os.o diff --git a/arch/sh/lib/ashldi3.c b/arch/sh/lib/ashldi3.c deleted file mode 100644 index beb80f316095..000000000000 --- a/arch/sh/lib/ashldi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/sh/lib/ashrdi3.c b/arch/sh/lib/ashrdi3.c deleted file mode 100644 index c884a912b660..000000000000 --- a/arch/sh/lib/ashrdi3.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/sh/lib/libgcc.h b/arch/sh/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/sh/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sh/lib/lshrdi3.c b/arch/sh/lib/lshrdi3.c deleted file mode 100644 index dcf8d6810b7c..000000000000 --- a/arch/sh/lib/lshrdi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__lshrdi3); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 5/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c 2017-06-06 19:10 ` Palmer Dabbelt ` (14 preceding siblings ...) 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` [PATCH 6/7] sparc: Use lib/{cmpdi2,ucmpdi2}.c Palmer Dabbelt ` (7 subsequent siblings) 23 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/sh/Kconfig | 3 +++ arch/sh/boot/compressed/Makefile | 6 +++--- arch/sh/lib/Makefile | 4 +--- arch/sh/lib/ashldi3.c | 29 ----------------------------- arch/sh/lib/ashrdi3.c | 31 ------------------------------- arch/sh/lib/libgcc.h | 25 ------------------------- arch/sh/lib/lshrdi3.c | 29 ----------------------------- 7 files changed, 7 insertions(+), 120 deletions(-) delete mode 100644 arch/sh/lib/ashldi3.c delete mode 100644 arch/sh/lib/ashrdi3.c delete mode 100644 arch/sh/lib/libgcc.h delete mode 100644 arch/sh/lib/lshrdi3.c diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index ee086958b2b2..49b98f74d7a0 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -48,6 +48,9 @@ config SUPERH select HAVE_ARCH_AUDITSYSCALL select HAVE_FUTEX_CMPXCHG if FUTEX select HAVE_NMI + select GENERIC_ASHLDI3 + select GENERIC_ASHRDI3 + select GENERIC_LSHRDI3 help The SuperH is a RISC processor targeted for use in embedded systems and consumer electronics; it was also used in the Sega Dreamcast diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile index c4c47ea9fa94..45a8e1349103 100644 --- a/arch/sh/boot/compressed/Makefile +++ b/arch/sh/boot/compressed/Makefile @@ -38,10 +38,10 @@ LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(IMAGE_OFFSET) -e startup \ # # Pull in the necessary libgcc bits from the in-kernel implementation. # -lib1funcs-$(CONFIG_SUPERH32) := ashiftrt.S ashldi3.c ashrsi3.S ashlsi3.S \ - lshrsi3.S +lib1funcs-$(CONFIG_SUPERH32) := ashiftrt.S ashrsi3.S ashlsi3.S lshrsi3.S lib1funcs-obj := \ - $(addsuffix .o, $(basename $(addprefix $(obj)/, $(lib1funcs-y)))) + $(addsuffix .o, $(basename $(addprefix $(obj)/, $(lib1funcs-y)))) \ + $(srctree)/lib/ashldi3.o lib1funcs-dir := $(srctree)/arch/$(SRCARCH)/lib ifeq ($(BITS),64) diff --git a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile index 3baff31e58cf..971d9ac1e068 100644 --- a/arch/sh/lib/Makefile +++ b/arch/sh/lib/Makefile @@ -6,9 +6,7 @@ lib-y = delay.o memmove.o memchr.o \ checksum.o strlen.o div64.o div64-generic.o # Extracted from libgcc -obj-y += movmem.o ashldi3.o ashrdi3.o lshrdi3.o \ - ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o \ - udiv_qrnnd.o +obj-y += movmem.o ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o udiv_qrnnd.o udivsi3-y := udivsi3_i4i-Os.o diff --git a/arch/sh/lib/ashldi3.c b/arch/sh/lib/ashldi3.c deleted file mode 100644 index beb80f316095..000000000000 --- a/arch/sh/lib/ashldi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/sh/lib/ashrdi3.c b/arch/sh/lib/ashrdi3.c deleted file mode 100644 index c884a912b660..000000000000 --- a/arch/sh/lib/ashrdi3.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/sh/lib/libgcc.h b/arch/sh/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/sh/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sh/lib/lshrdi3.c b/arch/sh/lib/lshrdi3.c deleted file mode 100644 index dcf8d6810b7c..000000000000 --- a/arch/sh/lib/lshrdi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__lshrdi3); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 6/7] sparc: Use lib/{cmpdi2,ucmpdi2}.c 2017-06-06 19:10 ` Palmer Dabbelt ` (15 preceding siblings ...) 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt ` (6 subsequent siblings) 23 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/sparc/Kconfig | 2 ++ arch/sparc/lib/Makefile | 4 ++-- arch/sparc/lib/cmpdi2.c | 27 --------------------------- arch/sparc/lib/libgcc.h | 18 ------------------ arch/sparc/lib/ucmpdi2.c | 19 ------------------- 5 files changed, 4 insertions(+), 66 deletions(-) delete mode 100644 arch/sparc/lib/cmpdi2.c delete mode 100644 arch/sparc/lib/libgcc.h delete mode 100644 arch/sparc/lib/ucmpdi2.c diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 58243b0d21c0..cbb1aeb0d419 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -52,6 +52,8 @@ config SPARC32 select CLZ_TAB select HAVE_UID16 select OLD_SIGACTION + select GENERIC_CMPDI2 + select GENERIC_UCMPDI2 config SPARC64 def_bool 64BIT diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile index 69912d2f8b54..815b4a336aa8 100644 --- a/arch/sparc/lib/Makefile +++ b/arch/sparc/lib/Makefile @@ -14,7 +14,7 @@ lib-$(CONFIG_SPARC32) += divdi3.o udivdi3.o lib-$(CONFIG_SPARC32) += copy_user.o locks.o lib-$(CONFIG_SPARC64) += atomic_64.o lib-$(CONFIG_SPARC32) += lshrdi3.o ashldi3.o -lib-$(CONFIG_SPARC32) += muldi3.o bitext.o cmpdi2.o +lib-$(CONFIG_SPARC32) += muldi3.o bitext.o lib-$(CONFIG_SPARC64) += copy_page.o clear_page.o bzero.o lib-$(CONFIG_SPARC64) += csum_copy.o csum_copy_from_user.o csum_copy_to_user.o @@ -42,5 +42,5 @@ lib-$(CONFIG_SPARC64) += copy_in_user.o memmove.o lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o obj-$(CONFIG_SPARC64) += iomap.o -obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o +obj-$(CONFIG_SPARC32) += atomic32.o obj-$(CONFIG_SPARC64) += PeeCeeI.o diff --git a/arch/sparc/lib/cmpdi2.c b/arch/sparc/lib/cmpdi2.c deleted file mode 100644 index 8c1306437ed1..000000000000 --- a/arch/sparc/lib/cmpdi2.c +++ /dev/null @@ -1,27 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} - -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/sparc/lib/libgcc.h b/arch/sparc/lib/libgcc.h deleted file mode 100644 index b84fd797f3ea..000000000000 --- a/arch/sparc/lib/libgcc.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -struct DWstruct { - int high, low; -}; - -typedef union -{ - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sparc/lib/ucmpdi2.c b/arch/sparc/lib/ucmpdi2.c deleted file mode 100644 index 1e06ed500682..000000000000 --- a/arch/sparc/lib/ucmpdi2.c +++ /dev/null @@ -1,19 +0,0 @@ -#include <linux/module.h> -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 6/7] sparc: Use lib/{cmpdi2,ucmpdi2}.c 2017-06-06 19:10 ` Palmer Dabbelt ` (16 preceding siblings ...) 2017-06-06 19:10 ` [PATCH 6/7] sparc: Use lib/{cmpdi2,ucmpdi2}.c Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt ` (5 subsequent siblings) 23 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/sparc/Kconfig | 2 ++ arch/sparc/lib/Makefile | 4 ++-- arch/sparc/lib/cmpdi2.c | 27 --------------------------- arch/sparc/lib/libgcc.h | 18 ------------------ arch/sparc/lib/ucmpdi2.c | 19 ------------------- 5 files changed, 4 insertions(+), 66 deletions(-) delete mode 100644 arch/sparc/lib/cmpdi2.c delete mode 100644 arch/sparc/lib/libgcc.h delete mode 100644 arch/sparc/lib/ucmpdi2.c diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 58243b0d21c0..cbb1aeb0d419 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -52,6 +52,8 @@ config SPARC32 select CLZ_TAB select HAVE_UID16 select OLD_SIGACTION + select GENERIC_CMPDI2 + select GENERIC_UCMPDI2 config SPARC64 def_bool 64BIT diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile index 69912d2f8b54..815b4a336aa8 100644 --- a/arch/sparc/lib/Makefile +++ b/arch/sparc/lib/Makefile @@ -14,7 +14,7 @@ lib-$(CONFIG_SPARC32) += divdi3.o udivdi3.o lib-$(CONFIG_SPARC32) += copy_user.o locks.o lib-$(CONFIG_SPARC64) += atomic_64.o lib-$(CONFIG_SPARC32) += lshrdi3.o ashldi3.o -lib-$(CONFIG_SPARC32) += muldi3.o bitext.o cmpdi2.o +lib-$(CONFIG_SPARC32) += muldi3.o bitext.o lib-$(CONFIG_SPARC64) += copy_page.o clear_page.o bzero.o lib-$(CONFIG_SPARC64) += csum_copy.o csum_copy_from_user.o csum_copy_to_user.o @@ -42,5 +42,5 @@ lib-$(CONFIG_SPARC64) += copy_in_user.o memmove.o lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o obj-$(CONFIG_SPARC64) += iomap.o -obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o +obj-$(CONFIG_SPARC32) += atomic32.o obj-$(CONFIG_SPARC64) += PeeCeeI.o diff --git a/arch/sparc/lib/cmpdi2.c b/arch/sparc/lib/cmpdi2.c deleted file mode 100644 index 8c1306437ed1..000000000000 --- a/arch/sparc/lib/cmpdi2.c +++ /dev/null @@ -1,27 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} - -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/sparc/lib/libgcc.h b/arch/sparc/lib/libgcc.h deleted file mode 100644 index b84fd797f3ea..000000000000 --- a/arch/sparc/lib/libgcc.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -struct DWstruct { - int high, low; -}; - -typedef union -{ - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sparc/lib/ucmpdi2.c b/arch/sparc/lib/ucmpdi2.c deleted file mode 100644 index 1e06ed500682..000000000000 --- a/arch/sparc/lib/ucmpdi2.c +++ /dev/null @@ -1,19 +0,0 @@ -#include <linux/module.h> -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 6/7] sparc: Use lib/{cmpdi2,ucmpdi2}.c 2017-06-06 19:10 ` Palmer Dabbelt ` (17 preceding siblings ...) 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt ` (4 subsequent siblings) 23 siblings, 1 reply; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/sparc/Kconfig | 2 ++ arch/sparc/lib/Makefile | 4 ++-- arch/sparc/lib/cmpdi2.c | 27 --------------------------- arch/sparc/lib/libgcc.h | 18 ------------------ arch/sparc/lib/ucmpdi2.c | 19 ------------------- 5 files changed, 4 insertions(+), 66 deletions(-) delete mode 100644 arch/sparc/lib/cmpdi2.c delete mode 100644 arch/sparc/lib/libgcc.h delete mode 100644 arch/sparc/lib/ucmpdi2.c diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 58243b0d21c0..cbb1aeb0d419 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -52,6 +52,8 @@ config SPARC32 select CLZ_TAB select HAVE_UID16 select OLD_SIGACTION + select GENERIC_CMPDI2 + select GENERIC_UCMPDI2 config SPARC64 def_bool 64BIT diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile index 69912d2f8b54..815b4a336aa8 100644 --- a/arch/sparc/lib/Makefile +++ b/arch/sparc/lib/Makefile @@ -14,7 +14,7 @@ lib-$(CONFIG_SPARC32) += divdi3.o udivdi3.o lib-$(CONFIG_SPARC32) += copy_user.o locks.o lib-$(CONFIG_SPARC64) += atomic_64.o lib-$(CONFIG_SPARC32) += lshrdi3.o ashldi3.o -lib-$(CONFIG_SPARC32) += muldi3.o bitext.o cmpdi2.o +lib-$(CONFIG_SPARC32) += muldi3.o bitext.o lib-$(CONFIG_SPARC64) += copy_page.o clear_page.o bzero.o lib-$(CONFIG_SPARC64) += csum_copy.o csum_copy_from_user.o csum_copy_to_user.o @@ -42,5 +42,5 @@ lib-$(CONFIG_SPARC64) += copy_in_user.o memmove.o lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o obj-$(CONFIG_SPARC64) += iomap.o -obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o +obj-$(CONFIG_SPARC32) += atomic32.o obj-$(CONFIG_SPARC64) += PeeCeeI.o diff --git a/arch/sparc/lib/cmpdi2.c b/arch/sparc/lib/cmpdi2.c deleted file mode 100644 index 8c1306437ed1..000000000000 --- a/arch/sparc/lib/cmpdi2.c +++ /dev/null @@ -1,27 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} - -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/sparc/lib/libgcc.h b/arch/sparc/lib/libgcc.h deleted file mode 100644 index b84fd797f3ea..000000000000 --- a/arch/sparc/lib/libgcc.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -struct DWstruct { - int high, low; -}; - -typedef union -{ - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sparc/lib/ucmpdi2.c b/arch/sparc/lib/ucmpdi2.c deleted file mode 100644 index 1e06ed500682..000000000000 --- a/arch/sparc/lib/ucmpdi2.c +++ /dev/null @@ -1,19 +0,0 @@ -#include <linux/module.h> -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 6/7] sparc: Use lib/{cmpdi2,ucmpdi2}.c 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 0 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/sparc/Kconfig | 2 ++ arch/sparc/lib/Makefile | 4 ++-- arch/sparc/lib/cmpdi2.c | 27 --------------------------- arch/sparc/lib/libgcc.h | 18 ------------------ arch/sparc/lib/ucmpdi2.c | 19 ------------------- 5 files changed, 4 insertions(+), 66 deletions(-) delete mode 100644 arch/sparc/lib/cmpdi2.c delete mode 100644 arch/sparc/lib/libgcc.h delete mode 100644 arch/sparc/lib/ucmpdi2.c diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 58243b0d21c0..cbb1aeb0d419 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -52,6 +52,8 @@ config SPARC32 select CLZ_TAB select HAVE_UID16 select OLD_SIGACTION + select GENERIC_CMPDI2 + select GENERIC_UCMPDI2 config SPARC64 def_bool 64BIT diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile index 69912d2f8b54..815b4a336aa8 100644 --- a/arch/sparc/lib/Makefile +++ b/arch/sparc/lib/Makefile @@ -14,7 +14,7 @@ lib-$(CONFIG_SPARC32) += divdi3.o udivdi3.o lib-$(CONFIG_SPARC32) += copy_user.o locks.o lib-$(CONFIG_SPARC64) += atomic_64.o lib-$(CONFIG_SPARC32) += lshrdi3.o ashldi3.o -lib-$(CONFIG_SPARC32) += muldi3.o bitext.o cmpdi2.o +lib-$(CONFIG_SPARC32) += muldi3.o bitext.o lib-$(CONFIG_SPARC64) += copy_page.o clear_page.o bzero.o lib-$(CONFIG_SPARC64) += csum_copy.o csum_copy_from_user.o csum_copy_to_user.o @@ -42,5 +42,5 @@ lib-$(CONFIG_SPARC64) += copy_in_user.o memmove.o lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o obj-$(CONFIG_SPARC64) += iomap.o -obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o +obj-$(CONFIG_SPARC32) += atomic32.o obj-$(CONFIG_SPARC64) += PeeCeeI.o diff --git a/arch/sparc/lib/cmpdi2.c b/arch/sparc/lib/cmpdi2.c deleted file mode 100644 index 8c1306437ed1..000000000000 --- a/arch/sparc/lib/cmpdi2.c +++ /dev/null @@ -1,27 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} - -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/sparc/lib/libgcc.h b/arch/sparc/lib/libgcc.h deleted file mode 100644 index b84fd797f3ea..000000000000 --- a/arch/sparc/lib/libgcc.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -struct DWstruct { - int high, low; -}; - -typedef union -{ - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sparc/lib/ucmpdi2.c b/arch/sparc/lib/ucmpdi2.c deleted file mode 100644 index 1e06ed500682..000000000000 --- a/arch/sparc/lib/ucmpdi2.c +++ /dev/null @@ -1,19 +0,0 @@ -#include <linux/module.h> -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 6/7] sparc: Use lib/{cmpdi2,ucmpdi2}.c 2017-06-06 19:10 ` Palmer Dabbelt ` (18 preceding siblings ...) 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` [PATCH 7/7] MIPS: Use generic libgcc intrinsics Palmer Dabbelt ` (3 subsequent siblings) 23 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt These files are functionally identical to the shared copies that I recently added. Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> --- arch/sparc/Kconfig | 2 ++ arch/sparc/lib/Makefile | 4 ++-- arch/sparc/lib/cmpdi2.c | 27 --------------------------- arch/sparc/lib/libgcc.h | 18 ------------------ arch/sparc/lib/ucmpdi2.c | 19 ------------------- 5 files changed, 4 insertions(+), 66 deletions(-) delete mode 100644 arch/sparc/lib/cmpdi2.c delete mode 100644 arch/sparc/lib/libgcc.h delete mode 100644 arch/sparc/lib/ucmpdi2.c diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 58243b0d21c0..cbb1aeb0d419 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -52,6 +52,8 @@ config SPARC32 select CLZ_TAB select HAVE_UID16 select OLD_SIGACTION + select GENERIC_CMPDI2 + select GENERIC_UCMPDI2 config SPARC64 def_bool 64BIT diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile index 69912d2f8b54..815b4a336aa8 100644 --- a/arch/sparc/lib/Makefile +++ b/arch/sparc/lib/Makefile @@ -14,7 +14,7 @@ lib-$(CONFIG_SPARC32) += divdi3.o udivdi3.o lib-$(CONFIG_SPARC32) += copy_user.o locks.o lib-$(CONFIG_SPARC64) += atomic_64.o lib-$(CONFIG_SPARC32) += lshrdi3.o ashldi3.o -lib-$(CONFIG_SPARC32) += muldi3.o bitext.o cmpdi2.o +lib-$(CONFIG_SPARC32) += muldi3.o bitext.o lib-$(CONFIG_SPARC64) += copy_page.o clear_page.o bzero.o lib-$(CONFIG_SPARC64) += csum_copy.o csum_copy_from_user.o csum_copy_to_user.o @@ -42,5 +42,5 @@ lib-$(CONFIG_SPARC64) += copy_in_user.o memmove.o lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o obj-$(CONFIG_SPARC64) += iomap.o -obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o +obj-$(CONFIG_SPARC32) += atomic32.o obj-$(CONFIG_SPARC64) += PeeCeeI.o diff --git a/arch/sparc/lib/cmpdi2.c b/arch/sparc/lib/cmpdi2.c deleted file mode 100644 index 8c1306437ed1..000000000000 --- a/arch/sparc/lib/cmpdi2.c +++ /dev/null @@ -1,27 +0,0 @@ -#include <linux/module.h> - -#include "libgcc.h" - -word_type __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} - -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/sparc/lib/libgcc.h b/arch/sparc/lib/libgcc.h deleted file mode 100644 index b84fd797f3ea..000000000000 --- a/arch/sparc/lib/libgcc.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -struct DWstruct { - int high, low; -}; - -typedef union -{ - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/sparc/lib/ucmpdi2.c b/arch/sparc/lib/ucmpdi2.c deleted file mode 100644 index 1e06ed500682..000000000000 --- a/arch/sparc/lib/ucmpdi2.c +++ /dev/null @@ -1,19 +0,0 @@ -#include <linux/module.h> -#include "libgcc.h" - -word_type __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 7/7] MIPS: Use generic libgcc intrinsics 2017-06-06 19:10 ` Palmer Dabbelt ` (19 preceding siblings ...) 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt ` (2 subsequent siblings) 23 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt, Matt Redfearn These routines in arch/mips/lib/ are functionally identical to those recently added to lib/ so remove them and select the generic ones. Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com> Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/mips/Kconfig | 5 +++++ arch/mips/boot/compressed/Makefile | 4 +++- arch/mips/lib/Makefile | 2 +- arch/mips/lib/ashldi3.c | 29 ----------------------------- arch/mips/lib/ashrdi3.c | 31 ------------------------------- arch/mips/lib/cmpdi2.c | 27 --------------------------- arch/mips/lib/libgcc.h | 25 ------------------------- arch/mips/lib/lshrdi3.c | 29 ----------------------------- arch/mips/lib/ucmpdi2.c | 21 --------------------- 9 files changed, 9 insertions(+), 164 deletions(-) delete mode 100644 arch/mips/lib/ashldi3.c delete mode 100644 arch/mips/lib/ashrdi3.c delete mode 100644 arch/mips/lib/cmpdi2.c delete mode 100644 arch/mips/lib/libgcc.h delete mode 100644 arch/mips/lib/lshrdi3.c delete mode 100644 arch/mips/lib/ucmpdi2.c diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 2828ecde133d..25713699ef1d 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -70,6 +70,11 @@ config MIPS select HAVE_EXIT_THREAD select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_COPY_THREAD_TLS + select GENERIC_ASHLDI3 + select GENERIC_ASHRDI3 + select GENERIC_CMPDI2 + select GENERIC_LSHRDI3 + select GENERIC_UCMPDI2 menu "Machine selection" diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile index c675eece389a..83cc738fb7af 100644 --- a/arch/mips/boot/compressed/Makefile +++ b/arch/mips/boot/compressed/Makefile @@ -48,7 +48,9 @@ vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o $(obj)/bswapsi.o extra-y += ashldi3.c bswapsi.c $(obj)/ashldi3.o $(obj)/bswapsi.o: KBUILD_CFLAGS += -I$(srctree)/arch/mips/lib -$(obj)/ashldi3.c $(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c +$(obj)/ashldi3.c $(obj)/%.c: $(srctree)/lib/%.c + $(call cmd,shipped) +$(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c $(call cmd,shipped) targets := $(notdir $(vmlinuzobjs-y)) diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile index 0344e575f522..814e739d6f86 100644 --- a/arch/mips/lib/Makefile +++ b/arch/mips/lib/Makefile @@ -15,4 +15,4 @@ obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o +obj-y += bswapsi.o bswapdi.o diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c deleted file mode 100644 index c3e22053d13e..000000000000 --- a/arch/mips/lib/ashldi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c deleted file mode 100644 index 17456024873d..000000000000 --- a/arch/mips/lib/ashrdi3.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c deleted file mode 100644 index 9d849d8743c9..000000000000 --- a/arch/mips/lib/cmpdi2.c +++ /dev/null @@ -1,27 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type notrace __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} - -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/mips/lib/libgcc.h b/arch/mips/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/mips/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c deleted file mode 100644 index 221167c1be55..000000000000 --- a/arch/mips/lib/lshrdi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/mips/lib/ucmpdi2.c b/arch/mips/lib/ucmpdi2.c deleted file mode 100644 index 08067fa538f2..000000000000 --- a/arch/mips/lib/ucmpdi2.c +++ /dev/null @@ -1,21 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type notrace __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} - -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 7/7] MIPS: Use generic libgcc intrinsics 2017-06-06 19:10 ` Palmer Dabbelt ` (20 preceding siblings ...) 2017-06-06 19:10 ` [PATCH 7/7] MIPS: Use generic libgcc intrinsics Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt 23 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt, Matt Redfearn These routines in arch/mips/lib/ are functionally identical to those recently added to lib/ so remove them and select the generic ones. Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com> Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/mips/Kconfig | 5 +++++ arch/mips/boot/compressed/Makefile | 4 +++- arch/mips/lib/Makefile | 2 +- arch/mips/lib/ashldi3.c | 29 ----------------------------- arch/mips/lib/ashrdi3.c | 31 ------------------------------- arch/mips/lib/cmpdi2.c | 27 --------------------------- arch/mips/lib/libgcc.h | 25 ------------------------- arch/mips/lib/lshrdi3.c | 29 ----------------------------- arch/mips/lib/ucmpdi2.c | 21 --------------------- 9 files changed, 9 insertions(+), 164 deletions(-) delete mode 100644 arch/mips/lib/ashldi3.c delete mode 100644 arch/mips/lib/ashrdi3.c delete mode 100644 arch/mips/lib/cmpdi2.c delete mode 100644 arch/mips/lib/libgcc.h delete mode 100644 arch/mips/lib/lshrdi3.c delete mode 100644 arch/mips/lib/ucmpdi2.c diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 2828ecde133d..25713699ef1d 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -70,6 +70,11 @@ config MIPS select HAVE_EXIT_THREAD select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_COPY_THREAD_TLS + select GENERIC_ASHLDI3 + select GENERIC_ASHRDI3 + select GENERIC_CMPDI2 + select GENERIC_LSHRDI3 + select GENERIC_UCMPDI2 menu "Machine selection" diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile index c675eece389a..83cc738fb7af 100644 --- a/arch/mips/boot/compressed/Makefile +++ b/arch/mips/boot/compressed/Makefile @@ -48,7 +48,9 @@ vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o $(obj)/bswapsi.o extra-y += ashldi3.c bswapsi.c $(obj)/ashldi3.o $(obj)/bswapsi.o: KBUILD_CFLAGS += -I$(srctree)/arch/mips/lib -$(obj)/ashldi3.c $(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c +$(obj)/ashldi3.c $(obj)/%.c: $(srctree)/lib/%.c + $(call cmd,shipped) +$(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c $(call cmd,shipped) targets := $(notdir $(vmlinuzobjs-y)) diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile index 0344e575f522..814e739d6f86 100644 --- a/arch/mips/lib/Makefile +++ b/arch/mips/lib/Makefile @@ -15,4 +15,4 @@ obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o +obj-y += bswapsi.o bswapdi.o diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c deleted file mode 100644 index c3e22053d13e..000000000000 --- a/arch/mips/lib/ashldi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c deleted file mode 100644 index 17456024873d..000000000000 --- a/arch/mips/lib/ashrdi3.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c deleted file mode 100644 index 9d849d8743c9..000000000000 --- a/arch/mips/lib/cmpdi2.c +++ /dev/null @@ -1,27 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type notrace __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} - -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/mips/lib/libgcc.h b/arch/mips/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/mips/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c deleted file mode 100644 index 221167c1be55..000000000000 --- a/arch/mips/lib/lshrdi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/mips/lib/ucmpdi2.c b/arch/mips/lib/ucmpdi2.c deleted file mode 100644 index 08067fa538f2..000000000000 --- a/arch/mips/lib/ucmpdi2.c +++ /dev/null @@ -1,21 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type notrace __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} - -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 7/7] MIPS: Use generic libgcc intrinsics 2017-06-06 19:10 ` Palmer Dabbelt ` (21 preceding siblings ...) 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt 23 siblings, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt, Matt Redfearn These routines in arch/mips/lib/ are functionally identical to those recently added to lib/ so remove them and select the generic ones. Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com> Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/mips/Kconfig | 5 +++++ arch/mips/boot/compressed/Makefile | 4 +++- arch/mips/lib/Makefile | 2 +- arch/mips/lib/ashldi3.c | 29 ----------------------------- arch/mips/lib/ashrdi3.c | 31 ------------------------------- arch/mips/lib/cmpdi2.c | 27 --------------------------- arch/mips/lib/libgcc.h | 25 ------------------------- arch/mips/lib/lshrdi3.c | 29 ----------------------------- arch/mips/lib/ucmpdi2.c | 21 --------------------- 9 files changed, 9 insertions(+), 164 deletions(-) delete mode 100644 arch/mips/lib/ashldi3.c delete mode 100644 arch/mips/lib/ashrdi3.c delete mode 100644 arch/mips/lib/cmpdi2.c delete mode 100644 arch/mips/lib/libgcc.h delete mode 100644 arch/mips/lib/lshrdi3.c delete mode 100644 arch/mips/lib/ucmpdi2.c diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 2828ecde133d..25713699ef1d 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -70,6 +70,11 @@ config MIPS select HAVE_EXIT_THREAD select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_COPY_THREAD_TLS + select GENERIC_ASHLDI3 + select GENERIC_ASHRDI3 + select GENERIC_CMPDI2 + select GENERIC_LSHRDI3 + select GENERIC_UCMPDI2 menu "Machine selection" diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile index c675eece389a..83cc738fb7af 100644 --- a/arch/mips/boot/compressed/Makefile +++ b/arch/mips/boot/compressed/Makefile @@ -48,7 +48,9 @@ vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o $(obj)/bswapsi.o extra-y += ashldi3.c bswapsi.c $(obj)/ashldi3.o $(obj)/bswapsi.o: KBUILD_CFLAGS += -I$(srctree)/arch/mips/lib -$(obj)/ashldi3.c $(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c +$(obj)/ashldi3.c $(obj)/%.c: $(srctree)/lib/%.c + $(call cmd,shipped) +$(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c $(call cmd,shipped) targets := $(notdir $(vmlinuzobjs-y)) diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile index 0344e575f522..814e739d6f86 100644 --- a/arch/mips/lib/Makefile +++ b/arch/mips/lib/Makefile @@ -15,4 +15,4 @@ obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o +obj-y += bswapsi.o bswapdi.o diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c deleted file mode 100644 index c3e22053d13e..000000000000 --- a/arch/mips/lib/ashldi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c deleted file mode 100644 index 17456024873d..000000000000 --- a/arch/mips/lib/ashrdi3.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c deleted file mode 100644 index 9d849d8743c9..000000000000 --- a/arch/mips/lib/cmpdi2.c +++ /dev/null @@ -1,27 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type notrace __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} - -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/mips/lib/libgcc.h b/arch/mips/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/mips/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c deleted file mode 100644 index 221167c1be55..000000000000 --- a/arch/mips/lib/lshrdi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/mips/lib/ucmpdi2.c b/arch/mips/lib/ucmpdi2.c deleted file mode 100644 index 08067fa538f2..000000000000 --- a/arch/mips/lib/ucmpdi2.c +++ /dev/null @@ -1,21 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type notrace __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} - -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 7/7] MIPS: Use generic libgcc intrinsics 2017-06-06 19:10 ` Palmer Dabbelt ` (22 preceding siblings ...) 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-09 19:53 ` Ralf Baechle 23 siblings, 2 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt, Matt Redfearn These routines in arch/mips/lib/ are functionally identical to those recently added to lib/ so remove them and select the generic ones. Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com> Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/mips/Kconfig | 5 +++++ arch/mips/boot/compressed/Makefile | 4 +++- arch/mips/lib/Makefile | 2 +- arch/mips/lib/ashldi3.c | 29 ----------------------------- arch/mips/lib/ashrdi3.c | 31 ------------------------------- arch/mips/lib/cmpdi2.c | 27 --------------------------- arch/mips/lib/libgcc.h | 25 ------------------------- arch/mips/lib/lshrdi3.c | 29 ----------------------------- arch/mips/lib/ucmpdi2.c | 21 --------------------- 9 files changed, 9 insertions(+), 164 deletions(-) delete mode 100644 arch/mips/lib/ashldi3.c delete mode 100644 arch/mips/lib/ashrdi3.c delete mode 100644 arch/mips/lib/cmpdi2.c delete mode 100644 arch/mips/lib/libgcc.h delete mode 100644 arch/mips/lib/lshrdi3.c delete mode 100644 arch/mips/lib/ucmpdi2.c diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 2828ecde133d..25713699ef1d 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -70,6 +70,11 @@ config MIPS select HAVE_EXIT_THREAD select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_COPY_THREAD_TLS + select GENERIC_ASHLDI3 + select GENERIC_ASHRDI3 + select GENERIC_CMPDI2 + select GENERIC_LSHRDI3 + select GENERIC_UCMPDI2 menu "Machine selection" diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile index c675eece389a..83cc738fb7af 100644 --- a/arch/mips/boot/compressed/Makefile +++ b/arch/mips/boot/compressed/Makefile @@ -48,7 +48,9 @@ vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o $(obj)/bswapsi.o extra-y += ashldi3.c bswapsi.c $(obj)/ashldi3.o $(obj)/bswapsi.o: KBUILD_CFLAGS += -I$(srctree)/arch/mips/lib -$(obj)/ashldi3.c $(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c +$(obj)/ashldi3.c $(obj)/%.c: $(srctree)/lib/%.c + $(call cmd,shipped) +$(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c $(call cmd,shipped) targets := $(notdir $(vmlinuzobjs-y)) diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile index 0344e575f522..814e739d6f86 100644 --- a/arch/mips/lib/Makefile +++ b/arch/mips/lib/Makefile @@ -15,4 +15,4 @@ obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o +obj-y += bswapsi.o bswapdi.o diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c deleted file mode 100644 index c3e22053d13e..000000000000 --- a/arch/mips/lib/ashldi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c deleted file mode 100644 index 17456024873d..000000000000 --- a/arch/mips/lib/ashrdi3.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c deleted file mode 100644 index 9d849d8743c9..000000000000 --- a/arch/mips/lib/cmpdi2.c +++ /dev/null @@ -1,27 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type notrace __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} - -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/mips/lib/libgcc.h b/arch/mips/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/mips/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c deleted file mode 100644 index 221167c1be55..000000000000 --- a/arch/mips/lib/lshrdi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/mips/lib/ucmpdi2.c b/arch/mips/lib/ucmpdi2.c deleted file mode 100644 index 08067fa538f2..000000000000 --- a/arch/mips/lib/ucmpdi2.c +++ /dev/null @@ -1,21 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type notrace __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} - -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 7/7] MIPS: Use generic libgcc intrinsics 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-09 19:53 ` Ralf Baechle 1 sibling, 0 replies; 93+ messages in thread From: Palmer Dabbelt @ 2017-06-06 19:10 UTC (permalink / raw) To: monstr, ralf, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch Cc: Palmer Dabbelt, Matt Redfearn These routines in arch/mips/lib/ are functionally identical to those recently added to lib/ so remove them and select the generic ones. Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com> Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> --- arch/mips/Kconfig | 5 +++++ arch/mips/boot/compressed/Makefile | 4 +++- arch/mips/lib/Makefile | 2 +- arch/mips/lib/ashldi3.c | 29 ----------------------------- arch/mips/lib/ashrdi3.c | 31 ------------------------------- arch/mips/lib/cmpdi2.c | 27 --------------------------- arch/mips/lib/libgcc.h | 25 ------------------------- arch/mips/lib/lshrdi3.c | 29 ----------------------------- arch/mips/lib/ucmpdi2.c | 21 --------------------- 9 files changed, 9 insertions(+), 164 deletions(-) delete mode 100644 arch/mips/lib/ashldi3.c delete mode 100644 arch/mips/lib/ashrdi3.c delete mode 100644 arch/mips/lib/cmpdi2.c delete mode 100644 arch/mips/lib/libgcc.h delete mode 100644 arch/mips/lib/lshrdi3.c delete mode 100644 arch/mips/lib/ucmpdi2.c diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 2828ecde133d..25713699ef1d 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -70,6 +70,11 @@ config MIPS select HAVE_EXIT_THREAD select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_COPY_THREAD_TLS + select GENERIC_ASHLDI3 + select GENERIC_ASHRDI3 + select GENERIC_CMPDI2 + select GENERIC_LSHRDI3 + select GENERIC_UCMPDI2 menu "Machine selection" diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile index c675eece389a..83cc738fb7af 100644 --- a/arch/mips/boot/compressed/Makefile +++ b/arch/mips/boot/compressed/Makefile @@ -48,7 +48,9 @@ vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o $(obj)/bswapsi.o extra-y += ashldi3.c bswapsi.c $(obj)/ashldi3.o $(obj)/bswapsi.o: KBUILD_CFLAGS += -I$(srctree)/arch/mips/lib -$(obj)/ashldi3.c $(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c +$(obj)/ashldi3.c $(obj)/%.c: $(srctree)/lib/%.c + $(call cmd,shipped) +$(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c $(call cmd,shipped) targets := $(notdir $(vmlinuzobjs-y)) diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile index 0344e575f522..814e739d6f86 100644 --- a/arch/mips/lib/Makefile +++ b/arch/mips/lib/Makefile @@ -15,4 +15,4 @@ obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o +obj-y += bswapsi.o bswapdi.o diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c deleted file mode 100644 index c3e22053d13e..000000000000 --- a/arch/mips/lib/ashldi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c deleted file mode 100644 index 17456024873d..000000000000 --- a/arch/mips/lib/ashrdi3.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c deleted file mode 100644 index 9d849d8743c9..000000000000 --- a/arch/mips/lib/cmpdi2.c +++ /dev/null @@ -1,27 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type notrace __cmpdi2(long long a, long long b) -{ - const DWunion au = { - .ll = a - }; - const DWunion bu = { - .ll = b - }; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - - return 1; -} - -EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/mips/lib/libgcc.h b/arch/mips/lib/libgcc.h deleted file mode 100644 index 05909d58e2fe..000000000000 --- a/arch/mips/lib/libgcc.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c deleted file mode 100644 index 221167c1be55..000000000000 --- a/arch/mips/lib/lshrdi3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -long long notrace __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} - -EXPORT_SYMBOL(__lshrdi3); diff --git a/arch/mips/lib/ucmpdi2.c b/arch/mips/lib/ucmpdi2.c deleted file mode 100644 index 08067fa538f2..000000000000 --- a/arch/mips/lib/ucmpdi2.c +++ /dev/null @@ -1,21 +0,0 @@ -#include <linux/export.h> - -#include "libgcc.h" - -word_type notrace __ucmpdi2(unsigned long long a, unsigned long long b) -{ - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((unsigned int) au.s.high < (unsigned int) bu.s.high) - return 0; - else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) - return 2; - if ((unsigned int) au.s.low < (unsigned int) bu.s.low) - return 0; - else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) - return 2; - return 1; -} - -EXPORT_SYMBOL(__ucmpdi2); -- 2.13.0 ^ permalink raw reply related [flat|nested] 93+ messages in thread
* Re: [PATCH 7/7] MIPS: Use generic libgcc intrinsics 2017-06-06 19:10 ` Palmer Dabbelt 2017-06-06 19:10 ` Palmer Dabbelt @ 2017-06-09 19:53 ` Ralf Baechle 2017-06-09 19:53 ` Ralf Baechle 1 sibling, 1 reply; 93+ messages in thread From: Ralf Baechle @ 2017-06-09 19:53 UTC (permalink / raw) To: Palmer Dabbelt Cc: monstr, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch, Matt Redfearn On Tue, Jun 06, 2017 at 12:10:23PM -0700, Palmer Dabbelt wrote: > These routines in arch/mips/lib/ are functionally identical to those > recently added to lib/ so remove them and select the generic ones. > > Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com> > Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Thanks, nice cleanup! Acked-by: Ralf Baechle <ralf@linux-mips.org> Ralf ^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 7/7] MIPS: Use generic libgcc intrinsics 2017-06-09 19:53 ` Ralf Baechle @ 2017-06-09 19:53 ` Ralf Baechle 0 siblings, 0 replies; 93+ messages in thread From: Ralf Baechle @ 2017-06-09 19:53 UTC (permalink / raw) To: Palmer Dabbelt Cc: monstr, liqin.linux, lennox.wu, ysato, dalias, davem, linux-mips, linux-sh, sparclinux, geert, linux-kernel, linux-arch, Matt Redfearn On Tue, Jun 06, 2017 at 12:10:23PM -0700, Palmer Dabbelt wrote: > These routines in arch/mips/lib/ are functionally identical to those > recently added to lib/ so remove them and select the generic ones. > > Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com> > Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Thanks, nice cleanup! Acked-by: Ralf Baechle <ralf@linux-mips.org> Ralf ^ permalink raw reply [flat|nested] 93+ messages in thread
end of thread, other threads:[~2017-06-09 19:53 UTC | newest]
Thread overview: 93+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-23 22:05 Unify the various copies of libgcc into lib Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-23 22:05 ` [PATCH 1/7] lib: Add shared copies of some GCC library routines Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-24 8:52 ` Matt Redfearn
2017-05-24 8:52 ` Matt Redfearn
2017-06-03 2:18 ` Palmer Dabbelt
2017-06-03 2:18 ` Palmer Dabbelt
2017-05-23 22:05 ` [PATCH 2/7] m32r: Use lib/ucmpdi2.c Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-23 22:05 ` [PATCH 3/7] microblaze: Use libgcc files from lib/ Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-24 11:22 ` kbuild test robot
2017-05-24 11:22 ` kbuild test robot
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-23 22:05 ` [PATCH 4/7] mips: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-24 9:01 ` Matt Redfearn
2017-05-24 9:01 ` Matt Redfearn
2017-06-03 2:18 ` Palmer Dabbelt
2017-05-24 11:39 ` kbuild test robot
2017-05-24 11:39 ` kbuild test robot
2017-05-24 11:50 ` kbuild test robot
2017-05-24 11:50 ` kbuild test robot
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-23 22:05 ` [PATCH 5/7] score: " Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-23 22:05 ` [PATCH 6/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-24 11:22 ` kbuild test robot
2017-05-24 11:22 ` kbuild test robot
2017-05-24 11:30 ` kbuild test robot
2017-05-24 11:30 ` kbuild test robot
2017-05-23 22:05 ` [PATCH 7/7] sparc: Use lib/{cmpdi2,ucmpdi2}.c Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-23 22:05 ` Palmer Dabbelt
2017-05-24 9:21 ` Unify the various copies of libgcc into lib Geert Uytterhoeven
2017-05-24 9:21 ` Geert Uytterhoeven
2017-06-03 2:59 ` Palmer Dabbelt
2017-06-03 2:59 ` Palmer Dabbelt
2017-05-24 13:49 ` David Howells
2017-05-24 13:49 ` David Howells
2017-05-24 13:59 ` John Paul Adrian Glaubitz
2017-05-24 13:59 ` John Paul Adrian Glaubitz
2017-06-06 19:10 ` Unify the various copies of libgcc into lib v2 Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` [PATCH 1/7] lib: Add shared copies of some GCC library routines Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` [PATCH 2/7] m32r: Use lib/ucmpdi2.c Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` [PATCH 3/7] microblaze: Use libgcc files from lib/ Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` [PATCH 4/7] score: Use lib/{ashldi3,ashrdi3,cmpdi2,lshrdi3,ucmpdi2}.c Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` [PATCH 5/7] sh: Use lib/ashldi3,ashrdi3,lshrdi3}.c Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-07 19:27 ` kbuild test robot
2017-06-07 19:27 ` kbuild test robot
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` [PATCH 6/7] sparc: Use lib/{cmpdi2,ucmpdi2}.c Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` [PATCH 7/7] MIPS: Use generic libgcc intrinsics Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-06 19:10 ` Palmer Dabbelt
2017-06-09 19:53 ` Ralf Baechle
2017-06-09 19:53 ` Ralf Baechle
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox