OSDN Git Service

* gfortran.dg/ishft.f90: Remove kind suffix from BOZ constant
[pf3gnuchains/gcc-fork.git] / gcc / stor-layout.c
index ccbca42..ac7fb74 100644 (file)
@@ -330,8 +330,8 @@ layout_decl (tree decl, unsigned int known_align)
     }
   else if (DECL_SIZE_UNIT (decl) == 0)
     DECL_SIZE_UNIT (decl)
-      = convert (sizetype, size_binop (CEIL_DIV_EXPR, DECL_SIZE (decl),
-                                      bitsize_unit_node));
+      = fold_convert (sizetype, size_binop (CEIL_DIV_EXPR, DECL_SIZE (decl),
+                                           bitsize_unit_node));
 
   if (code != FIELD_DECL)
     /* For non-fields, update the alignment from the type.  */
@@ -540,7 +540,8 @@ tree
 bit_from_pos (tree offset, tree bitpos)
 {
   return size_binop (PLUS_EXPR, bitpos,
-                    size_binop (MULT_EXPR, convert (bitsizetype, offset),
+                    size_binop (MULT_EXPR, 
+                                fold_convert (bitsizetype, offset),
                                 bitsize_unit_node));
 }
 
@@ -548,9 +549,9 @@ tree
 byte_from_pos (tree offset, tree bitpos)
 {
   return size_binop (PLUS_EXPR, offset,
-                    convert (sizetype,
-                             size_binop (TRUNC_DIV_EXPR, bitpos,
-                                         bitsize_unit_node)));
+                    fold_convert (sizetype,
+                                  size_binop (TRUNC_DIV_EXPR, bitpos,
+                                              bitsize_unit_node)));
 }
 
 void
@@ -558,9 +559,9 @@ pos_from_bit (tree *poffset, tree *pbitpos, unsigned int off_align,
              tree pos)
 {
   *poffset = size_binop (MULT_EXPR,
-                        convert (sizetype,
-                                 size_binop (FLOOR_DIV_EXPR, pos,
-                                             bitsize_int (off_align))),
+                        fold_convert (sizetype,
+                                      size_binop (FLOOR_DIV_EXPR, pos,
+                                                  bitsize_int (off_align))),
                         size_int (off_align / BITS_PER_UNIT));
   *pbitpos = size_binop (FLOOR_MOD_EXPR, pos, bitsize_int (off_align));
 }
@@ -580,7 +581,8 @@ normalize_offset (tree *poffset, tree *pbitpos, unsigned int off_align)
 
       *poffset
        = size_binop (PLUS_EXPR, *poffset,
-                     size_binop (MULT_EXPR, convert (sizetype, extra_aligns),
+                     size_binop (MULT_EXPR, 
+                                 fold_convert (sizetype, extra_aligns),
                                  size_int (off_align / BITS_PER_UNIT)));
 
       *pbitpos
@@ -869,9 +871,9 @@ place_field (record_layout_info rli, tree field)
          /* First adjust OFFSET by the partial bits, then align.  */
          rli->offset
            = size_binop (PLUS_EXPR, rli->offset,
-                         convert (sizetype,
-                                  size_binop (CEIL_DIV_EXPR, rli->bitpos,
-                                              bitsize_unit_node)));
+                         fold_convert (sizetype,
+                                       size_binop (CEIL_DIV_EXPR, rli->bitpos,
+                                                   bitsize_unit_node)));
          rli->bitpos = bitsize_zero_node;
 
          rli->offset = round_up (rli->offset, desired_align / BITS_PER_UNIT);
@@ -1147,9 +1149,9 @@ place_field (record_layout_info rli, tree field)
     {
       rli->offset
        = size_binop (PLUS_EXPR, rli->offset,
-                     convert (sizetype,
-                              size_binop (CEIL_DIV_EXPR, rli->bitpos,
-                                          bitsize_unit_node)));
+                     fold_convert (sizetype,
+                                   size_binop (CEIL_DIV_EXPR, rli->bitpos,
+                                               bitsize_unit_node)));
       rli->offset
        = size_binop (PLUS_EXPR, rli->offset, DECL_SIZE_UNIT (field));
       rli->bitpos = bitsize_zero_node;
@@ -1296,12 +1298,14 @@ compute_record_mode (tree type)
 #endif /* MEMBER_TYPE_FORCES_BLK  */
     }
 
-  /* If we only have one real field; use its mode.  This only applies to
-     RECORD_TYPE.  This does not apply to unions.  */
-  if (TREE_CODE (type) == RECORD_TYPE && mode != VOIDmode)
+  TYPE_MODE (type) = mode_for_size_tree (TYPE_SIZE (type), MODE_INT, 1);
+
+  /* If we only have one real field; use its mode if that mode's size
+     matches the type's size.  This only applies to RECORD_TYPE.  This
+     does not apply to unions.  */
+  if (TREE_CODE (type) == RECORD_TYPE && mode != VOIDmode
+      && GET_MODE_SIZE (mode) == GET_MODE_SIZE (TYPE_MODE (type)))
     TYPE_MODE (type) = mode;
-  else
-    TYPE_MODE (type) = mode_for_size_tree (TYPE_SIZE (type), MODE_INT, 1);
 
   /* If structure's known alignment is less than what the scalar
      mode would need, and it matters, then stick with BLKmode.  */
@@ -1351,9 +1355,9 @@ finalize_type_size (tree type)
        result will fit in sizetype.  We will get more efficient code using
        sizetype, so we force a conversion.  */
     TYPE_SIZE_UNIT (type)
-      = convert (sizetype,
-                size_binop (FLOOR_DIV_EXPR, TYPE_SIZE (type),
-                            bitsize_unit_node));
+      = fold_convert (sizetype,
+                     size_binop (FLOOR_DIV_EXPR, TYPE_SIZE (type),
+                                 bitsize_unit_node));
 
   if (TYPE_SIZE (type) != 0)
     {
@@ -1572,6 +1576,10 @@ layout_type (tree type)
                                                 nunits_tree, 0);
        TYPE_SIZE (type) = int_const_binop (MULT_EXPR, TYPE_SIZE (innertype),
                                            nunits_tree, 0);
+
+       /* Always naturally align vectors.  This prevents ABI changes
+          depending on whether or not native vector modes are supported.  */
+       TYPE_ALIGN (type) = tree_low_cst (TYPE_SIZE (type), 0);
         break;
       }
 
@@ -1636,10 +1644,10 @@ layout_type (tree type)
            /* The initial subtraction should happen in the original type so
               that (possible) negative values are handled appropriately.  */
            length = size_binop (PLUS_EXPR, size_one_node,
-                                convert (sizetype,
-                                         fold (build2 (MINUS_EXPR,
-                                                       TREE_TYPE (lb),
-                                                       ub, lb))));
+                                fold_convert (sizetype,
+                                              fold (build2 (MINUS_EXPR,
+                                                            TREE_TYPE (lb),
+                                                            ub, lb))));
 
            /* Special handling for arrays of bits (for Chill).  */
            element_size = TYPE_SIZE (element);
@@ -1668,7 +1676,8 @@ layout_type (tree type)
              length = size_binop (MAX_EXPR, length, size_zero_node);
 
            TYPE_SIZE (type) = size_binop (MULT_EXPR, element_size,
-                                          convert (bitsizetype, length));
+                                          fold_convert (bitsizetype, 
+                                                        length));
 
            /* If we know the size of the element, calculate the total
               size directly, rather than do some division thing below.
@@ -1754,40 +1763,6 @@ layout_type (tree type)
       }
       break;
 
-    case SET_TYPE:  /* Used by Chill and Pascal.  */
-      {
-       unsigned int alignment;
-       HOST_WIDE_INT size_in_bits;
-       HOST_WIDE_INT rounded_size;
-
-       gcc_assert (TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
-                   == INTEGER_CST);
-       gcc_assert (TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (type)))
-                   == INTEGER_CST);
-
-#ifndef SET_WORD_SIZE
-#define SET_WORD_SIZE BITS_PER_WORD
-#endif
-       alignment = set_alignment ? set_alignment : SET_WORD_SIZE;
-       size_in_bits
-         = (tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), 0)
-            - tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), 0) + 1);
-       rounded_size
-         = ((size_in_bits + alignment - 1) / alignment) * alignment;
-
-       if (rounded_size > (int) alignment)
-         TYPE_MODE (type) = BLKmode;
-       else
-         TYPE_MODE (type) = mode_for_size (alignment, MODE_INT, 1);
-
-       TYPE_SIZE (type) = bitsize_int (rounded_size);
-       TYPE_SIZE_UNIT (type) = size_int (rounded_size / BITS_PER_UNIT);
-       TYPE_ALIGN (type) = alignment;
-       TYPE_USER_ALIGN (type) = 0;
-       TYPE_PRECISION (type) = size_in_bits;
-      }
-      break;
-
     case FILE_TYPE:
       /* The size may vary in different languages, so the language front end
         should fill in the size.  */