diff options
author | Per Bothner <bothner@gcc.gnu.org> | 1994-08-31 17:15:03 -0700 |
---|---|---|
committer | Per Bothner <bothner@gcc.gnu.org> | 1994-08-31 17:15:03 -0700 |
commit | b5d11e41da327b7783b6a7c0a4be1a75c58aec54 (patch) | |
tree | 93310a5edd39928ddbc4237e78b2065826a8ae94 | |
parent | 94d6511c61decde2c932e8800b4469eeaccd5e62 (diff) | |
download | gcc-b5d11e41da327b7783b6a7c0a4be1a75c58aec54.zip gcc-b5d11e41da327b7783b6a7c0a4be1a75c58aec54.tar.gz gcc-b5d11e41da327b7783b6a7c0a4be1a75c58aec54.tar.bz2 |
stor-layout.c (set_alignment): New global.
* stor-layout.c (set_alignment): New global.
(layout-type): Add support for SET_TYPE.
From-SVN: r8010
-rw-r--r-- | gcc/stor-layout.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index d2c6f28..9fdc651 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -44,6 +44,10 @@ tree size_one_node; The value is measured in bits. */ int maximum_field_alignment; +/* If non-zero, the alignment of a bitsting or (power-)set value, in bits. + May be overridden by front-ends. */ +int set_alignment = 0; + #define GET_MODE_ALIGNMENT(MODE) \ MIN (BIGGEST_ALIGNMENT, \ MAX (1, (GET_MODE_UNIT_SIZE (MODE) * BITS_PER_UNIT))) @@ -898,6 +902,31 @@ layout_type (type) TYPE_ALIGN (type) = GET_MODE_ALIGNMENT (TYPE_MODE (type)); break; + case SET_TYPE: + if (TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) != INTEGER_CST + || TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (type))) != INTEGER_CST) + abort(); + else + { +#ifndef SET_WORD_SIZE +#define SET_WORD_SIZE BITS_PER_WORD +#endif + int alignment = set_alignment ? set_alignment : SET_WORD_SIZE; + int size_in_bits = + TREE_INT_CST_LOW (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) + - TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (type))) + 1; + int rounded_size + = ((size_in_bits + alignment - 1) / alignment) * alignment; + if (rounded_size > alignment) + TYPE_MODE (type) = BLKmode; + else + TYPE_MODE (type) = mode_for_size (alignment, MODE_INT, 1); + TYPE_SIZE (type) = size_int (rounded_size); + TYPE_ALIGN (type) = alignment; + 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. */ |