]> gcc.gnu.org Git - gcc.git/commitdiff
varasm.c (assemble_variable): Compute the alignment of the data earlier so that both...
authorJohn Wehle <john@feith.com>
Mon, 11 May 1998 23:47:28 +0000 (23:47 +0000)
committerJeff Law <law@gcc.gnu.org>
Mon, 11 May 1998 23:47:28 +0000 (17:47 -0600)
        * 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

gcc/ChangeLog
gcc/tm.texi
gcc/varasm.c

index e34df5fb8e57d9c14aeaff48ac385aec023b0193..37585510cc10e5b66070553f5c0ecae00bf36fb6 100644 (file)
@@ -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.
index a74bcfbea840269609675fd63d0468efbdead131..b95514e538bbbebe912462767cfa01d32d963937 100644 (file)
@@ -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.
index 8bc7509e42112a3018a3055e0a4f5af5725ce349..afdee7b78e5a5fcde18de7b511318201079d6dae 100644 (file)
@@ -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
This page took 0.097551 seconds and 5 git commands to generate.