This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH]: Move mn10200 *div*.c files to common config directory
- To: gcc-patches at gcc dot gnu dot org
- Subject: [PATCH]: Move mn10200 *div*.c files to common config directory
- From: Stephane Carrez <Stephane dot Carrez at worldnet dot fr>
- Date: Sun, 05 Nov 2000 12:08:13 +0100
Hi!
This patch moves the following files that implement 32-bit divisions:
gcc/config/mn10200/udivmod.c
gcc/config/mn10200/udivmodsi4.c
gcc/config/mn10200/divmod.c
to the gcc/config directory so that several ports can use them. The C files
are not changed. The patch fixes mn10200 and m68hc11 targets to take this
move into account.
I've built the mn10200 (after Michael libgcc2.h patch). It compiled as far
as this patch is concerned but gcc crashed in:
./libgcc2.c:748: Internal compiler error in update_equiv_regs, at local-alloc.c:1093
Do you agree with this patch?
Stephane
2000-11-05 Stephane Carrez <Stephane.Carrez@worldnet.fr>
* config/mn10200/udivmod.c, config/mn10200/divmod.c,
config/mn10200/udivmodsi4.c: Moved from here.
* config/udivmod.c, config/divmod.c, config/udivmodsi4.c: To here.
* config/mn10200/t-mn10200 (LIB2FUNCS_EXTRA): Use the generic
C division functions.
* config/m68hc11/t-m68hc11-gas (LIB2FUNCS_EXTRA): Likewise.
Index: gcc/config/divmod.c
===================================================================
RCS file: divmod.c
diff -N divmod.c
*** /dev/null Tue May 5 13:32:27 1998
--- divmod.c Sun Nov 5 01:56:52 2000
***************
*** 0 ****
--- 1,50 ----
+ long udivmodsi4 ();
+
+ long
+ __divsi3 (long a, long b)
+ {
+ int neg = 0;
+ long res;
+
+ if (a < 0)
+ {
+ a = -a;
+ neg = !neg;
+ }
+
+ if (b < 0)
+ {
+ b = -b;
+ neg = !neg;
+ }
+
+ res = udivmodsi4 (a, b, 0);
+
+ if (neg)
+ res = -res;
+
+ return res;
+ }
+
+ long
+ __modsi3 (long a, long b)
+ {
+ int neg = 0;
+ long res;
+
+ if (a < 0)
+ {
+ a = -a;
+ neg = 1;
+ }
+
+ if (b < 0)
+ b = -b;
+
+ res = udivmodsi4 (a, b, 1);
+
+ if (neg)
+ res = -res;
+
+ return res;
+ }
Index: gcc/config/udivmod.c
===================================================================
RCS file: udivmod.c
diff -N udivmod.c
*** /dev/null Tue May 5 13:32:27 1998
--- udivmod.c Sun Nov 5 01:56:52 2000
***************
*** 0 ****
--- 1,14 ----
+ long udivmodsi4 ();
+
+ long
+ __udivsi3 (long a, long b)
+ {
+ return udivmodsi4 (a, b, 0);
+ }
+
+ long
+ __umodsi3 (long a, long b)
+ {
+ return udivmodsi4 (a, b, 1);
+ }
+
Index: gcc/config/udivmodsi4.c
===================================================================
RCS file: udivmodsi4.c
diff -N udivmodsi4.c
*** /dev/null Tue May 5 13:32:27 1998
--- udivmodsi4.c Sun Nov 5 01:56:52 2000
***************
*** 0 ****
--- 1,24 ----
+ unsigned long
+ udivmodsi4(unsigned long num, unsigned long den, int modwanted)
+ {
+ unsigned long bit = 1;
+ unsigned long res = 0;
+
+ while (den < num && bit && !(den & (1L<<31)))
+ {
+ den <<=1;
+ bit <<=1;
+ }
+ while (bit)
+ {
+ if (num >= den)
+ {
+ num -= den;
+ res |= bit;
+ }
+ bit >>=1;
+ den >>=1;
+ }
+ if (modwanted) return num;
+ return res;
+ }
Index: gcc/config/m68hc11/t-m68hc11-gas
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/m68hc11/t-m68hc11-gas,v
retrieving revision 1.1
diff -p -r1.1 t-m68hc11-gas
*** t-m68hc11-gas 2000/09/08 20:54:44 1.1
--- t-m68hc11-gas 2000/11/05 09:56:54
*************** LIB1ASMFUNCS = _mulsi3 \
*** 28,37 ****
TARGET_LIBGCC2_CFLAGS = -DUSE_GAS -DIN_GCC
! # 32-bit div/mod from the mn10200 port. Prototypes have been added
! # to avoid problems in passing 16/32-bit int (last param of udivmodsi4).
! LIB2FUNCS_EXTRA = $(srcdir)/config/m68hc11/udivmodsi4.c \
! $(srcdir)/config/m68hc11/divmod.c $(srcdir)/config/m68hc11/udivmod.c
# Don't compile with -g1 this reduces the size of some sections (.eh_frame).
LIBGCC2_DEBUG_CFLAGS =
--- 28,36 ----
TARGET_LIBGCC2_CFLAGS = -DUSE_GAS -DIN_GCC
! # C implementation of 32-bit div/mod.
! LIB2FUNCS_EXTRA = $(srcdir)/config/udivmodsi4.c \
! $(srcdir)/config/divmod.c $(srcdir)/config/udivmod.c
# Don't compile with -g1 this reduces the size of some sections (.eh_frame).
LIBGCC2_DEBUG_CFLAGS =
Index: gcc/config/mn10200/divmod.c
===================================================================
RCS file: divmod.c
diff -N divmod.c
*** /sourceware/cvs-tmp/cvsDC4qFr Sun Nov 5 01:56:59 2000
--- /dev/null Tue May 5 13:32:27 1998
***************
*** 1,50 ****
- long udivmodsi4 ();
-
- long
- __divsi3 (long a, long b)
- {
- int neg = 0;
- long res;
-
- if (a < 0)
- {
- a = -a;
- neg = !neg;
- }
-
- if (b < 0)
- {
- b = -b;
- neg = !neg;
- }
-
- res = udivmodsi4 (a, b, 0);
-
- if (neg)
- res = -res;
-
- return res;
- }
-
- long
- __modsi3 (long a, long b)
- {
- int neg = 0;
- long res;
-
- if (a < 0)
- {
- a = -a;
- neg = 1;
- }
-
- if (b < 0)
- b = -b;
-
- res = udivmodsi4 (a, b, 1);
-
- if (neg)
- res = -res;
-
- return res;
- }
--- 0 ----
Index: gcc/config/mn10200/t-mn10200
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/mn10200/t-mn10200,v
retrieving revision 1.5
diff -p -r1.5 t-mn10200
*** t-mn10200 1999/08/05 03:27:48 1.5
--- t-mn10200 2000/11/05 09:56:58
*************** LIB1ASMFUNCS = _divhi3 \
*** 33,40 ****
# We do not have DF or DI types, so fake out the libgcc2 compilation.
TARGET_LIBGCC2_CFLAGS=-DDF=SF -DDI=SI
! LIB2FUNCS_EXTRA = $(srcdir)/config/mn10200/udivmodsi4.c \
! $(srcdir)/config/mn10200/divmod.c $(srcdir)/config/mn10200/udivmod.c
# We want fine grained libraries, so use the new code to build the
# floating point emulation libraries. The mn10200 only has single
--- 33,40 ----
# We do not have DF or DI types, so fake out the libgcc2 compilation.
TARGET_LIBGCC2_CFLAGS=-DDF=SF -DDI=SI
! LIB2FUNCS_EXTRA = $(srcdir)/config/udivmodsi4.c \
! $(srcdir)/config/divmod.c $(srcdir)/config/udivmod.c
# We want fine grained libraries, so use the new code to build the
# floating point emulation libraries. The mn10200 only has single
Index: gcc/config/mn10200/udivmod.c
===================================================================
RCS file: udivmod.c
diff -N udivmod.c
*** /sourceware/cvs-tmp/cvsV6ZLbz Sun Nov 5 01:56:59 2000
--- /dev/null Tue May 5 13:32:27 1998
***************
*** 1,14 ****
- long udivmodsi4 ();
-
- long
- __udivsi3 (long a, long b)
- {
- return udivmodsi4 (a, b, 0);
- }
-
- long
- __umodsi3 (long a, long b)
- {
- return udivmodsi4 (a, b, 1);
- }
-
--- 0 ----
Index: gcc/config/mn10200/udivmodsi4.c
===================================================================
RCS file: udivmodsi4.c
diff -N udivmodsi4.c
*** /sourceware/cvs-tmp/cvsshuHME Sun Nov 5 01:56:59 2000
--- /dev/null Tue May 5 13:32:27 1998
***************
*** 1,24 ****
- unsigned long
- udivmodsi4(unsigned long num, unsigned long den, int modwanted)
- {
- unsigned long bit = 1;
- unsigned long res = 0;
-
- while (den < num && bit && !(den & (1L<<31)))
- {
- den <<=1;
- bit <<=1;
- }
- while (bit)
- {
- if (num >= den)
- {
- num -= den;
- res |= bit;
- }
- bit >>=1;
- den >>=1;
- }
- if (modwanted) return num;
- return res;
- }
--- 0 ----