From: Stephane Carrez Date: Thu, 30 Nov 2000 08:25:59 +0000 (+0100) Subject: udivmod.c, [...]: Moved from here. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=75273d0832af1a5ce7bd23bff7221094e197b8e1;p=gcc.git udivmod.c, [...]: Moved from here. * 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. From-SVN: r37868 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 654e0237d05..8ce00fedeff 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2000-11-05 Stephane Carrez + + * 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. + Thu Nov 30 01:12:52 2000 Jeffrey A Law (law@cygnus.com) * pa.md (conditional moves): Avoid holes in operand list. diff --git a/gcc/config/divmod.c b/gcc/config/divmod.c new file mode 100644 index 00000000000..6faa09102b5 --- /dev/null +++ b/gcc/config/divmod.c @@ -0,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; +} diff --git a/gcc/config/m68hc11/t-m68hc11-gas b/gcc/config/m68hc11/t-m68hc11-gas index 221a8530c93..ec4b59e027b 100644 --- a/gcc/config/m68hc11/t-m68hc11-gas +++ b/gcc/config/m68hc11/t-m68hc11-gas @@ -28,10 +28,9 @@ LIB1ASMFUNCS = _mulsi3 \ 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 +# 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 = diff --git a/gcc/config/mn10200/divmod.c b/gcc/config/mn10200/divmod.c deleted file mode 100644 index 6faa09102b5..00000000000 --- a/gcc/config/mn10200/divmod.c +++ /dev/null @@ -1,50 +0,0 @@ -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; -} diff --git a/gcc/config/mn10200/t-mn10200 b/gcc/config/mn10200/t-mn10200 index f27815a2dc0..072d6f42b88 100644 --- a/gcc/config/mn10200/t-mn10200 +++ b/gcc/config/mn10200/t-mn10200 @@ -33,8 +33,8 @@ LIB1ASMFUNCS = _divhi3 \ # 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 +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 diff --git a/gcc/config/mn10200/udivmod.c b/gcc/config/mn10200/udivmod.c deleted file mode 100644 index 1395e9cc940..00000000000 --- a/gcc/config/mn10200/udivmod.c +++ /dev/null @@ -1,14 +0,0 @@ -long udivmodsi4 (); - -long -__udivsi3 (long a, long b) -{ - return udivmodsi4 (a, b, 0); -} - -long -__umodsi3 (long a, long b) -{ - return udivmodsi4 (a, b, 1); -} - diff --git a/gcc/config/mn10200/udivmodsi4.c b/gcc/config/mn10200/udivmodsi4.c deleted file mode 100644 index 83c2340c2f8..00000000000 --- a/gcc/config/mn10200/udivmodsi4.c +++ /dev/null @@ -1,24 +0,0 @@ -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; -} diff --git a/gcc/config/udivmod.c b/gcc/config/udivmod.c new file mode 100644 index 00000000000..1395e9cc940 --- /dev/null +++ b/gcc/config/udivmod.c @@ -0,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); +} + diff --git a/gcc/config/udivmodsi4.c b/gcc/config/udivmodsi4.c new file mode 100644 index 00000000000..83c2340c2f8 --- /dev/null +++ b/gcc/config/udivmodsi4.c @@ -0,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; +}