Word length != 2^n
lars@brinkhoff.se
lars@brinkhoff.se
Sat Jan 13 01:38:00 GMT 2001
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;
}
More information about the Gcc-patches
mailing list