Commit 8a198bd2 by John Wehle Committed by Jeff Law

varasm.c (assemble_variable): Compute the alignment of the data earlier so that…

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
parent cf4ccd63
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.
......
......@@ -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.
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment