[PATCH] Add word-sized conversion functions to libgcc2
Richard Sandiford
richard@codesourcery.com
Tue May 23 14:21:00 GMT 2006
DJ Delorie <dj@redhat.com> writes:
>> - Make compiling libgcc2.c a no-op if LIBGCC2_UNITS_PER_WORD
>> > MIN_UNITS_PER_WORD.
>
> This totally breaks m32c-elf, which has MIN_UNITS_PER_WORD == 2 and
> LIBGCC_UNITS_PER_WORD == 4. The whole file goes away and nearly every
> program stops compiling.
I'm sorry. (I seem to be saying that a lot recently.)
> m32c-elf is a 16 bit port with 64 bit "long long", which forces
> libgcc2's units per word to 4:
>
> # elif (MIN_UNITS_PER_WORD > 2 \
> || (MIN_UNITS_PER_WORD > 1 && LONG_LONG_TYPE_SIZE > 32))
> # define LIBGCC2_UNITS_PER_WORD 4
And that value fails the:
#if LIBGCC2_UNITS_PER_WORD <= MIN_UNITS_PER_WORD
guard. Duh. I'd forgotten that the default LIBGCC2_UNITS_PER_WORD
could be greater than MIN_UNITS_PER_WORD.
The default LIBGCC2_UNITS_PER_WORD settings are really calculating the
maximum "word" size that is safe to use, given that we also need a valid
"doubleword". And to recap, the SIDITI stuff that I added could ask for
both a smaller word size (for SI and DI stuff on 64-bit targets) or a
larger word size (for TI stuff on 32-bit targets). The latter should
result in an empty file.
So, the patch below separates the two concepts. I've introduced
a LIBGCC2_MAX_UNITS_PER_WORD and then used that as the default
definition of LIBGCC2_UNITS_PER_WORD. The guard now checks against
LIBGCC2_MAX_UNITS_PER_WORD rather than MIN_UNITS_PER_WORD.
I've tested that m32c-elf builds non-empty libgcc files with this patch.
(There was a later spill failure building newlib.) I've also bootstrapped
& regression tested on x86_64-linux-gnu and tested on mips64-linux-gnu.
OK to isntall?
Richard
* libgcc2.c (LIBGCC2_MAX_UNITS_PER_WORD): New macro.
(LIBGCC2_UNITS_PER_WORD): Use LIBGCC2_MAX_UNITS_PER_WORD rather
than MIN_UNITS_PER_WORD to set the default, and in the guard.
Index: gcc/libgcc2.c
===================================================================
*** gcc/libgcc2.c (revision 114013)
--- gcc/libgcc2.c (working copy)
*************** #define ATTRIBUTE_HIDDEN
*** 44,61 ****
#define MIN_UNITS_PER_WORD UNITS_PER_WORD
#endif
#ifndef LIBGCC2_UNITS_PER_WORD
! # if MIN_UNITS_PER_WORD > 4
! # define LIBGCC2_UNITS_PER_WORD 8
! # elif (MIN_UNITS_PER_WORD > 2 \
! || (MIN_UNITS_PER_WORD > 1 && LONG_LONG_TYPE_SIZE > 32))
! # define LIBGCC2_UNITS_PER_WORD 4
! # else
! # define LIBGCC2_UNITS_PER_WORD MIN_UNITS_PER_WORD
! # endif
#endif
! #if LIBGCC2_UNITS_PER_WORD <= MIN_UNITS_PER_WORD
#include "libgcc2.h"
--- 44,66 ----
#define MIN_UNITS_PER_WORD UNITS_PER_WORD
#endif
+ /* Work out the largest "word" size that we can deal with on this target. */
+ #if MIN_UNITS_PER_WORD > 4
+ # define LIBGCC2_MAX_UNITS_PER_WORD 8
+ #elif (MIN_UNITS_PER_WORD > 2 \
+ || (MIN_UNITS_PER_WORD > 1 && LONG_LONG_TYPE_SIZE > 32))
+ # define LIBGCC2_MAX_UNITS_PER_WORD 4
+ #else
+ # define LIBGCC2_MAX_UNITS_PER_WORD MIN_UNITS_PER_WORD
+ #endif
+
+ /* Work out what word size we are using for this compilation.
+ The value can be set on the command line. */
#ifndef LIBGCC2_UNITS_PER_WORD
! #define LIBGCC2_UNITS_PER_WORD LIBGCC2_MAX_UNITS_PER_WORD
#endif
! #if LIBGCC2_UNITS_PER_WORD <= LIBGCC2_MAX_UNITS_PER_WORD
#include "libgcc2.h"
More information about the Gcc-patches
mailing list