aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJohn Wehle <john@feith.com>1998-05-11 23:47:28 +0000
committerJeff Law <law@gcc.gnu.org>1998-05-11 17:47:28 -0600
commit8a198bd23f1d5ca756295e0b0295db98f4752677 (patch)
tree410a3ff25df88c10b9c9c4cb17863bd3dea83ea5 /gcc
parentcf4ccd63bc9d72c975529785f74743a9310a37d6 (diff)
downloadgcc-8a198bd23f1d5ca756295e0b0295db98f4752677.zip
gcc-8a198bd23f1d5ca756295e0b0295db98f4752677.tar.gz
gcc-8a198bd23f1d5ca756295e0b0295db98f4752677.tar.bz2
varasm.c (assemble_variable): Compute the alignment of the data earlier so that both initialized and...
* varasm.c (assemble_variable): Compute the alignment of the data earlier so that both initialized and uninitialized variables are effected by DATA_ALIGNMENT. * tm.texi (DATA_ALIGNMENT): Updated appropriately. From-SVN: r19692
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/tm.texi6
-rw-r--r--gcc/varasm.c74
3 files changed, 49 insertions, 38 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e34df5f..3758551 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+Tue May 12 00:47:33 1998 John Wehle (john@feith.com)
+
+ * varasm.c (assemble_variable): Compute the alignment of the data
+ earlier so that both initialized and uninitialized variables are
+ effected by DATA_ALIGNMENT.
+ * tm.texi (DATA_ALIGNMENT): Updated appropriately.
+
Mon May 11 19:57:58 1998 Jeffrey A Law (law@cygnus.com)
* mips.c: Prototype static functions.
diff --git a/gcc/tm.texi b/gcc/tm.texi
index a74bcfb..b95514e 100644
--- a/gcc/tm.texi
+++ b/gcc/tm.texi
@@ -810,9 +810,9 @@ the default value is @code{BIGGEST_ALIGNMENT}.
@findex DATA_ALIGNMENT
@item DATA_ALIGNMENT (@var{type}, @var{basic-align})
-If defined, a C expression to compute the alignment for a static
-variable. @var{type} is the data type, and @var{basic-align} is the
-alignment that the object would ordinarily have. The value of this
+If defined, a C expression to compute the alignment for a variables in
+the static store. @var{type} is the data type, and @var{basic-align} is
+the alignment that the object would ordinarily have. The value of this
macro is used instead of that alignment to align the object.
If this macro is not defined, then @var{basic-align} is used.
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 8bc7509..afdee7b 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -1275,6 +1275,42 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
strcpy (first_global_object_name, p);
}
+ /* Compute the alignment of this data. */
+
+ align = DECL_ALIGN (decl);
+
+ /* In the case for initialing an array whose length isn't specified,
+ where we have not yet been able to do the layout,
+ figure out the proper alignment now. */
+ if (dont_output_data && DECL_SIZE (decl) == 0
+ && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
+ align = MAX (align, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl))));
+
+ /* Some object file formats have a maximum alignment which they support.
+ In particular, a.out format supports a maximum alignment of 4. */
+#ifndef MAX_OFILE_ALIGNMENT
+#define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
+#endif
+ if (align > MAX_OFILE_ALIGNMENT)
+ {
+ warning_with_decl (decl,
+ "alignment of `%s' is greater than maximum object file alignment");
+ align = MAX_OFILE_ALIGNMENT;
+ }
+
+ /* On some machines, it is good to increase alignment sometimes. */
+#ifdef DATA_ALIGNMENT
+ align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
+#endif
+#ifdef CONSTANT_ALIGNMENT
+ if (DECL_INITIAL (decl) != 0 && DECL_INITIAL (decl) != error_mark_node)
+ align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
+#endif
+
+ /* Reset the alignment in case we have made it tighter, so we can benefit
+ from it in get_pointer_alignment. */
+ DECL_ALIGN (decl) = align;
+
/* Handle uninitialized definitions. */
if ((DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node)
@@ -1464,42 +1500,10 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
if (in_section != saved_in_section)
variable_section (decl, reloc);
- /* Compute and output the alignment of this data. */
-
- align = DECL_ALIGN (decl);
- /* In the case for initialing an array whose length isn't specified,
- where we have not yet been able to do the layout,
- figure out the proper alignment now. */
- if (dont_output_data && DECL_SIZE (decl) == 0
- && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
- align = MAX (align, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl))));
-
- /* Some object file formats have a maximum alignment which they support.
- In particular, a.out format supports a maximum alignment of 4. */
-#ifndef MAX_OFILE_ALIGNMENT
-#define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
-#endif
- if (align > MAX_OFILE_ALIGNMENT)
- {
- warning_with_decl (decl,
- "alignment of `%s' is greater than maximum object file alignment");
- align = MAX_OFILE_ALIGNMENT;
- }
-#ifdef DATA_ALIGNMENT
- /* On some machines, it is good to increase alignment sometimes. */
- align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
-#endif
-#ifdef CONSTANT_ALIGNMENT
- if (DECL_INITIAL (decl))
- align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
-#endif
-
- /* Reset the alignment in case we have made it tighter, so we can benefit
- from it in get_pointer_alignment. */
- DECL_ALIGN (decl) = align;
-
+ /* Output the alignment of this data. */
if (align > BITS_PER_UNIT)
- ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
+ ASM_OUTPUT_ALIGN (asm_out_file,
+ floor_log2 (DECL_ALIGN (decl) / BITS_PER_UNIT));
/* Do any machine/system dependent processing of the object. */
#ifdef ASM_DECLARE_OBJECT_NAME