aboutsummaryrefslogtreecommitdiff
path: root/gcc/stor-layout.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r--gcc/stor-layout.c41
1 files changed, 39 insertions, 2 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index db4c09f29f7..4fb290847ef 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -1,6 +1,6 @@
/* C-compiler utilities for types and variables storage layout
Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1996, 1998,
- 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of GCC.
@@ -298,6 +298,29 @@ int_mode_for_mode (mode)
return mode;
}
+/* 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;
+
+ if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT
+ || GET_MODE_CLASS (mode) == MODE_COMPLEX_INT)
+ alignment = GET_MODE_UNIT_SIZE (mode);
+ else
+ alignment = GET_MODE_SIZE (mode);
+
+ /* Extract the LSB of the size. */
+ alignment = alignment & -alignment;
+ alignment *= BITS_PER_UNIT;
+
+ alignment = MIN (BIGGEST_ALIGNMENT, MAX (1, alignment));
+ return alignment;
+}
+
/* Return the value of VALUE, rounded up to a multiple of DIVISOR.
This can only be applied to objects of a sizetype. */
@@ -343,6 +366,7 @@ layout_decl (decl, known_align)
{
tree type = TREE_TYPE (decl);
enum tree_code code = TREE_CODE (decl);
+ rtx rtl = NULL_RTX;
if (code == CONST_DECL)
return;
@@ -350,6 +374,8 @@ layout_decl (decl, known_align)
&& code != TYPE_DECL && code != FIELD_DECL)
abort ();
+ rtl = DECL_RTL_IF_SET (decl);
+
if (type == error_mark_node)
type = void_type_node;
@@ -464,6 +490,15 @@ layout_decl (decl, known_align)
larger_than_size);
}
}
+
+ /* If the RTL was already set, update its mode and mem attributes. */
+ if (rtl)
+ {
+ PUT_MODE (rtl, DECL_MODE (decl));
+ SET_DECL_RTL (decl, 0);
+ set_mem_attributes (rtl, decl, 1);
+ SET_DECL_RTL (decl, rtl);
+ }
}
/* Hook for a front-end function that can modify the record layout as needed
@@ -735,7 +770,7 @@ update_alignment_for_field (rli, field, known_align)
within the structure. */
if (! integer_zerop (DECL_SIZE (field)))
rli->record_align = MAX (rli->record_align, desired_align);
- else if (! DECL_PACKED (field))
+ else if (! DECL_PACKED (field) && !user_align)
desired_align = TYPE_ALIGN (type);
/* A named bit field of declared type `int'
@@ -771,6 +806,8 @@ update_alignment_for_field (rli, field, known_align)
TYPE_USER_ALIGN (rli->t) |= user_align;
+ DECL_ALIGN (field) = desired_align;
+
return desired_align;
}