Commit 9180cca3 by Stephane Carrez Committed by Jeff Law

stor-layout.c (layout_union): Use HOST_WIDE_INT for const_size...

        * stor-layout.c (layout_union): Use HOST_WIDE_INT for const_size;
        check for member bit-size overflow and use var_size if it occurs.
        (layout_record): Use bitsize_int() to define the type size in bits.
        Likewise for computation and assignment to DECL_FIELD_BITPOS.
        (layout_decl): Likewise when assigning to DECL_SIZE.

From-SVN: r29969
parent 25238622
Thu Oct 14 03:59:57 1999 Stephane Carrez <stcarrez@worldnet.fr>
* stor-layout.c (layout_union): Use HOST_WIDE_INT for const_size;
check for member bit-size overflow and use var_size if it occurs.
(layout_record): Use bitsize_int() to define the type size in bits.
Likewise for computation and assignment to DECL_FIELD_BITPOS.
(layout_decl): Likewise when assigning to DECL_SIZE.
Thu Oct 14 02:57:05 1999 Richard Henderson <rth@cygnus.com> Thu Oct 14 02:57:05 1999 Richard Henderson <rth@cygnus.com>
* genrecog.c (validate_pattern): Typo last change. Verify * genrecog.c (validate_pattern): Typo last change. Verify
......
...@@ -261,8 +261,8 @@ layout_decl (decl, known_align) ...@@ -261,8 +261,8 @@ layout_decl (decl, known_align)
if (spec_size == 0 && DECL_NAME (decl) != 0) if (spec_size == 0 && DECL_NAME (decl) != 0)
abort (); abort ();
/* Size is specified number of bits. */ /* Size is specified in number of bits. */
DECL_SIZE (decl) = size_int (spec_size); DECL_SIZE (decl) = bitsize_int (spec_size, 0);
} }
/* Force alignment required for the data type. /* Force alignment required for the data type.
But if the decl itself wants greater alignment, don't override that. But if the decl itself wants greater alignment, don't override that.
...@@ -298,7 +298,7 @@ layout_decl (decl, known_align) ...@@ -298,7 +298,7 @@ layout_decl (decl, known_align)
DECL_ALIGN (decl) = MAX ((unsigned) GET_MODE_ALIGNMENT (xmode), DECL_ALIGN (decl) = MAX ((unsigned) GET_MODE_ALIGNMENT (xmode),
DECL_ALIGN (decl)); DECL_ALIGN (decl));
DECL_MODE (decl) = xmode; DECL_MODE (decl) = xmode;
DECL_SIZE (decl) = size_int (GET_MODE_BITSIZE (xmode)); DECL_SIZE (decl) = bitsize_int (GET_MODE_BITSIZE (xmode), 0);
/* This no longer needs to be accessed as a bit field. */ /* This no longer needs to be accessed as a bit field. */
DECL_BIT_FIELD (decl) = 0; DECL_BIT_FIELD (decl) = 0;
} }
...@@ -517,7 +517,7 @@ layout_record (rec) ...@@ -517,7 +517,7 @@ layout_record (rec)
DECL_FIELD_BITPOS (field) = var_size; DECL_FIELD_BITPOS (field) = var_size;
else else
{ {
DECL_FIELD_BITPOS (field) = size_int (const_size); DECL_FIELD_BITPOS (field) = bitsize_int (const_size, 0L);
/* If this field ended up more aligned than we thought it /* If this field ended up more aligned than we thought it
would be (we approximate this by seeing if its position would be (we approximate this by seeing if its position
...@@ -559,7 +559,7 @@ layout_record (rec) ...@@ -559,7 +559,7 @@ layout_record (rec)
if (var_size == 0) if (var_size == 0)
{ {
TYPE_SIZE (rec) = size_int (const_size); TYPE_SIZE (rec) = bitsize_int (const_size, 0L);
} }
else else
{ {
...@@ -607,7 +607,7 @@ layout_union (rec) ...@@ -607,7 +607,7 @@ layout_union (rec)
/* The size of the union, based on the fields scanned so far, /* The size of the union, based on the fields scanned so far,
is max (CONST_SIZE, VAR_SIZE). is max (CONST_SIZE, VAR_SIZE).
VAR_SIZE may be null; then CONST_SIZE by itself is the size. */ VAR_SIZE may be null; then CONST_SIZE by itself is the size. */
register int const_size = 0; register HOST_WIDE_INT const_size = 0;
register tree var_size = 0; register tree var_size = 0;
#ifdef STRUCTURE_SIZE_BOUNDARY #ifdef STRUCTURE_SIZE_BOUNDARY
...@@ -624,6 +624,8 @@ layout_union (rec) ...@@ -624,6 +624,8 @@ layout_union (rec)
for (field = TYPE_FIELDS (rec); field; field = TREE_CHAIN (field)) for (field = TYPE_FIELDS (rec); field; field = TREE_CHAIN (field))
{ {
tree dsize;
/* Enums which are local to this class need not be laid out. */ /* Enums which are local to this class need not be laid out. */
if (TREE_CODE (field) == CONST_DECL || TREE_CODE (field) == TYPE_DECL) if (TREE_CODE (field) == CONST_DECL || TREE_CODE (field) == TYPE_DECL)
continue; continue;
...@@ -642,19 +644,22 @@ layout_union (rec) ...@@ -642,19 +644,22 @@ layout_union (rec)
union_align = MAX (union_align, TYPE_ALIGN (TREE_TYPE (field))); union_align = MAX (union_align, TYPE_ALIGN (TREE_TYPE (field)));
#endif #endif
dsize = DECL_SIZE (field);
if (TREE_CODE (rec) == UNION_TYPE) if (TREE_CODE (rec) == UNION_TYPE)
{ {
/* Set union_size to max (decl_size, union_size). /* Set union_size to max (decl_size, union_size).
There are more and less general ways to do this. There are more and less general ways to do this.
Use only CONST_SIZE unless forced to use VAR_SIZE. */ Use only CONST_SIZE unless forced to use VAR_SIZE. */
if (TREE_CODE (DECL_SIZE (field)) == INTEGER_CST) if (TREE_CODE (dsize) == INTEGER_CST
&& ! TREE_CONSTANT_OVERFLOW (dsize)
&& TREE_INT_CST_HIGH (dsize) == 0)
const_size const_size
= MAX (const_size, TREE_INT_CST_LOW (DECL_SIZE (field))); = MAX (const_size, TREE_INT_CST_LOW (dsize));
else if (var_size == 0) else if (var_size == 0)
var_size = DECL_SIZE (field); var_size = dsize;
else else
var_size = size_binop (MAX_EXPR, var_size, DECL_SIZE (field)); var_size = size_binop (MAX_EXPR, var_size, dsize);
} }
else if (TREE_CODE (rec) == QUAL_UNION_TYPE) else if (TREE_CODE (rec) == QUAL_UNION_TYPE)
var_size = fold (build (COND_EXPR, sizetype, DECL_QUALIFIER (field), var_size = fold (build (COND_EXPR, sizetype, DECL_QUALIFIER (field),
......
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