PATCH: Allow BITS_PER_UNIT != 8
Lars Brinkhoff
lars.spam@nocrew.org
Mon Jan 15 05:13:00 GMT 2001
The function get_mode_alignment() in stor-layout.c doesn't work if
BITS_PER_UNIT isn't 2^n.
2001-01-13 lars brinkhoff <lars@brinkhoff.se>
* stor-layout.c (get_mode_alignment): Remove the restriction
that BITS_PER_UNIT must be a power of 2.
Index: stor-layout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stor-layout.c,v
retrieving revision 1.92
diff -u -r1.92 stor-layout.c
--- stor-layout.c 2000/12/17 17:22:41 1.92
+++ stor-layout.c 2001/01/15 13:08:48
@@ -1795,10 +1795,11 @@
get_mode_alignment (mode)
enum machine_mode mode;
{
- unsigned int alignment = GET_MODE_UNIT_SIZE (mode) * BITS_PER_UNIT;
+ unsigned int alignment = GET_MODE_UNIT_SIZE (mode);
/* Extract the LSB of the size. */
alignment = alignment & -alignment;
+ alignment *= BITS_PER_UNIT;
alignment = MIN (BIGGEST_ALIGNMENT, MAX (1, alignment));
return alignment;
lars@brinkhoff.se writes:
> I'm writing a new processor backend. When porting the backend from
> GCC 2.95.2 to the current CVS tree I stumbled accross this code, which
> does not work on processors which does not have 2^n word length.
>
> /* Return the alignment of MODE. This will be bounded by 1 and
> BIGGEST_ALIGNMENT. */
>
> unsigned int
> get_mode_alignment (mode)
> enum machine_mode mode;
> {
> unsigned int alignment = GET_MODE_UNIT_SIZE (mode) * BITS_PER_UNIT;
>
> /* Extract the LSB of the size. */
> alignment = alignment & -alignment;
>
> alignment = MIN (BIGGEST_ALIGNMENT, MAX (1, alignment));
> return alignment;
> }
>
> Here's the corresponding ChangeLog entry:
>
> 2000-02-24 Nathan Sidwell <nathan@codesourcery.com>
>
> * machmode.h (get_mode_alignment): Declare.
> (GET_MODE_ALIGNMENT): Call it.
> * stor-layout.c (get_mode_alignment): New function. Make
> sure alignment is always power of 2.
>
> A tentative patch would thus be:
>
> 2001-01-13 lars brinkhoff <lars@brinkhoff.se>
>
> * stor-layout.c (get_mode_alignment): Remove the restriction
> that alignment is always a power of 2.
>
> diff -u -r1.92 stor-layout.c
> --- stor-layout.c 2000/12/17 17:22:41 1.92
> +++ stor-layout.c 2001/01/13 09:24:50
> @@ -1797,9 +1797,6 @@
> {
> unsigned int alignment = GET_MODE_UNIT_SIZE (mode) * BITS_PER_UNIT;
>
> - /* Extract the LSB of the size. */
> - alignment = alignment & -alignment;
> -
> alignment = MIN (BIGGEST_ALIGNMENT, MAX (1, alignment));
> return alignment;
> }
>
--
http://lars.nocrew.org/
More information about the Gcc-patches
mailing list