OSDN Git Service

* Makefile.in (install-info): Simplify.
[pf3gnuchains/gcc-fork.git] / gcc / stor-layout.c
index e2395c4..dcdca57 100644 (file)
@@ -298,20 +298,7 @@ int_mode_for_mode (enum machine_mode mode)
 unsigned int
 get_mode_alignment (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 MIN (BIGGEST_ALIGNMENT, MAX (1, mode_base_align[mode]*BITS_PER_UNIT));
 }
 
 /* Return the value of VALUE, rounded up to a multiple of DIVISOR.
@@ -344,7 +331,8 @@ do_type_align (tree type, tree decl)
   if (TYPE_ALIGN (type) > DECL_ALIGN (decl))
     {
       DECL_ALIGN (decl) = TYPE_ALIGN (type);
-      DECL_USER_ALIGN (decl) = TYPE_USER_ALIGN (type);
+      if (TREE_CODE (decl) == FIELD_DECL)
+       DECL_USER_ALIGN (decl) = TYPE_USER_ALIGN (type);
     }
 }
 
@@ -515,11 +503,10 @@ layout_decl (tree decl, unsigned int known_align)
          int size_as_int = TREE_INT_CST_LOW (size);
 
          if (compare_tree_int (size, size_as_int) == 0)
-           warning ("%Hsize of '%D' is %d bytes",
-                     &DECL_SOURCE_LOCATION (decl), decl, size_as_int);
+           warning ("%Jsize of '%D' is %d bytes", decl, decl, size_as_int);
          else
-           warning ("size of '%D' is larger than %d bytes",
-                     &DECL_SOURCE_LOCATION (decl), decl, larger_than_size);
+           warning ("%Jsize of '%D' is larger than %d bytes",
+                     decl, decl, larger_than_size);
        }
     }
 
@@ -884,11 +871,11 @@ place_field (record_layout_info rli, tree field)
          if (TYPE_ALIGN (type) > desired_align)
            {
              if (STRICT_ALIGNMENT)
-               warning ("%Hpacked attribute causes inefficient alignment "
-                         "for '%D'", &DECL_SOURCE_LOCATION (field), field);
+               warning ("%Jpacked attribute causes inefficient alignment "
+                         "for '%D'", field, field);
              else
-               warning ("%Hpacked attribute is unnecessary for '%D'",
-                         &DECL_SOURCE_LOCATION (field), field);
+               warning ("%Jpacked attribute is unnecessary for '%D'",
+                        field, field);
            }
        }
       else
@@ -903,8 +890,7 @@ place_field (record_layout_info rli, tree field)
         Bump the cumulative size to multiple of field alignment.  */
 
       if (warn_padded)
-       warning ("%Hpadding struct to align '%D'",
-                 &DECL_SOURCE_LOCATION (field), field);
+       warning ("%Jpadding struct to align '%D'", field, field);
 
       /* If the alignment is still within offset_align, just align
         the bit position.  */
@@ -1092,6 +1078,7 @@ place_field (record_layout_info rli, tree field)
                rli->prev_field = NULL;
            }
 
+         rli->offset_align = tree_low_cst (TYPE_SIZE (type), 0);
          normalize_rli (rli);
         }
 
@@ -1318,7 +1305,9 @@ compute_record_mode (tree type)
 
       if (TREE_CODE (TREE_TYPE (field)) == ERROR_MARK
          || (TYPE_MODE (TREE_TYPE (field)) == BLKmode
-             && ! TYPE_NO_FORCE_BLK (TREE_TYPE (field)))
+             && ! TYPE_NO_FORCE_BLK (TREE_TYPE (field))
+             && !(TYPE_SIZE (TREE_TYPE (field)) != 0
+                  && integer_zerop (TYPE_SIZE (TREE_TYPE (field)))))
          || ! host_integerp (bit_position (field), 1)
          || DECL_SIZE (field) == 0
          || ! host_integerp (DECL_SIZE (field), 1))
@@ -1957,6 +1946,58 @@ set_sizetype (tree type)
   sizetype_set = 1;
 }
 \f
+/* TYPE is an integral type, i.e., an INTEGRAL_TYPE, ENUMERAL_TYPE,
+   BOOLEAN_TYPE, or CHAR_TYPE.  Set TYPE_MIN_VALUE and TYPE_MAX_VALUE
+   for TYPE, based on the PRECISION and whether or not the TYPE
+   IS_UNSIGNED.  PRECISION need not correspond to a width supported
+   natively by the hardware; for example, on a machine with 8-bit,
+   16-bit, and 32-bit register modes, PRECISION might be 7, 23, or
+   61.  */
+
+void
+set_min_and_max_values_for_integral_type (tree type,
+                                         int precision,
+                                         bool is_unsigned)
+{
+  tree min_value;
+  tree max_value;
+
+  if (is_unsigned)
+    {
+      min_value = build_int_2 (0, 0);
+      max_value 
+       = build_int_2 (precision - HOST_BITS_PER_WIDE_INT >= 0
+                      ? -1 : ((HOST_WIDE_INT) 1 << precision) - 1,
+                      precision - HOST_BITS_PER_WIDE_INT > 0
+                      ? ((unsigned HOST_WIDE_INT) ~0
+                         >> (HOST_BITS_PER_WIDE_INT
+                             - (precision - HOST_BITS_PER_WIDE_INT)))
+                      : 0);
+    }
+  else
+    {
+      min_value 
+       = build_int_2 ((precision - HOST_BITS_PER_WIDE_INT > 0
+                       ? 0 : (HOST_WIDE_INT) (-1) << (precision - 1)),
+                      (((HOST_WIDE_INT) (-1)
+                        << (precision - HOST_BITS_PER_WIDE_INT - 1 > 0
+                            ? precision - HOST_BITS_PER_WIDE_INT - 1
+                            : 0))));    
+      max_value
+       = build_int_2 ((precision - HOST_BITS_PER_WIDE_INT > 0
+                       ? -1 : ((HOST_WIDE_INT) 1 << (precision - 1)) - 1),
+                      (precision - HOST_BITS_PER_WIDE_INT - 1 > 0
+                       ? (((HOST_WIDE_INT) 1
+                           << (precision - HOST_BITS_PER_WIDE_INT - 1))) - 1
+                       : 0));
+    }
+
+  TREE_TYPE (min_value) = type;
+  TREE_TYPE (max_value) = type;
+  TYPE_MIN_VALUE (type) = min_value;
+  TYPE_MAX_VALUE (type) = max_value;
+}
+
 /* Set the extreme values of TYPE based on its precision in bits,
    then lay it out.  Used when make_signed_type won't do
    because the tree code is not INTEGER_TYPE.
@@ -1973,23 +2014,8 @@ fixup_signed_type (tree type)
   if (precision > HOST_BITS_PER_WIDE_INT * 2)
     precision = HOST_BITS_PER_WIDE_INT * 2;
 
-  TYPE_MIN_VALUE (type)
-    = build_int_2 ((precision - HOST_BITS_PER_WIDE_INT > 0
-                   ? 0 : (HOST_WIDE_INT) (-1) << (precision - 1)),
-                  (((HOST_WIDE_INT) (-1)
-                    << (precision - HOST_BITS_PER_WIDE_INT - 1 > 0
-                        ? precision - HOST_BITS_PER_WIDE_INT - 1
-                        : 0))));
-  TYPE_MAX_VALUE (type)
-    = build_int_2 ((precision - HOST_BITS_PER_WIDE_INT > 0
-                   ? -1 : ((HOST_WIDE_INT) 1 << (precision - 1)) - 1),
-                  (precision - HOST_BITS_PER_WIDE_INT - 1 > 0
-                   ? (((HOST_WIDE_INT) 1
-                       << (precision - HOST_BITS_PER_WIDE_INT - 1))) - 1
-                   : 0));
-
-  TREE_TYPE (TYPE_MIN_VALUE (type)) = type;
-  TREE_TYPE (TYPE_MAX_VALUE (type)) = type;
+  set_min_and_max_values_for_integral_type (type, precision, 
+                                           /*is_unsigned=*/false);
 
   /* Lay out the type: set its alignment, size, etc.  */
   layout_type (type);
@@ -2010,17 +2036,8 @@ fixup_unsigned_type (tree type)
   if (precision > HOST_BITS_PER_WIDE_INT * 2)
     precision = HOST_BITS_PER_WIDE_INT * 2;
 
-  TYPE_MIN_VALUE (type) = build_int_2 (0, 0);
-  TYPE_MAX_VALUE (type)
-    = build_int_2 (precision - HOST_BITS_PER_WIDE_INT >= 0
-                  ? -1 : ((HOST_WIDE_INT) 1 << precision) - 1,
-                  precision - HOST_BITS_PER_WIDE_INT > 0
-                  ? ((unsigned HOST_WIDE_INT) ~0
-                     >> (HOST_BITS_PER_WIDE_INT
-                         - (precision - HOST_BITS_PER_WIDE_INT)))
-                  : 0);
-  TREE_TYPE (TYPE_MIN_VALUE (type)) = type;
-  TREE_TYPE (TYPE_MAX_VALUE (type)) = type;
+  set_min_and_max_values_for_integral_type (type, precision, 
+                                           /*is_unsigned=*/true);
 
   /* Lay out the type: set its alignment, size, etc.  */
   layout_type (type);