This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] support static nested constructors in bitfields (2/2)
- From: Olivier Hainque <hainque at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: hainque at adacore dot com
- Date: Thu, 24 Jul 2008 12:07:45 +0200
- Subject: [PATCH] support static nested constructors in bitfields (2/2)
Hello,
This is the second part of the output_constructor rework to let it
handle nested aggregates in bitfields.
The general idea is to introduce a simple datastructure to keep track
of the current bitfield state and recurse, together with a predicate
to decide which values are handled and are thus considered valid
static initializers for bitfields.
Bootstrapped and regression tested on x86_64-suse-linux.
We are also using this internally with a GCC 4.3 base on a number of
other targets.
Thanks in advance,
Olivier
2008-07-24 Olivier Hainque <hainque@adacore.com>
Eric Botcazou <ebotcazou@adacore.com>
Support for output of static nested constructors within bitfields
* varasm.c (initializer_constant_valid_for_bitfield_p): New
predicate. Whether VALUE is a valid constant-valued expression
for use in initializing a static bit-field.
(oc_outer_state): New type. output_constructor outer state of
relevance in recursive calls.
(oc_local_state): byte_buffer_in_use is bool, not int. Add a
"last_relative_index" field to memorize the index of the last
array element output within a bitfield.
(output_constructor_array_range): Minor prototype and head
comment adjustments.
(output_constructor_regular_field): Likewise. Adjust assignments
to byte_buffer_in_use, now bool.
(output_constructor_bitfield): Likewise. Accept an OUTER state
argument for recursive processing. Recurse on record or array
CONSTRUCTOR values, possibly past noop conversions.
(output_constructor): Accept and honor an OUTER state argument for
recursive calls + return total size. Be prepared for nested
constructors initializing bitfields and consider BLKmode toplevel
fields as regular even if DECL_BIT_FIELD is set.
(output_constant): Feed OUTER in calls to output_constructor.
* output.h (initializer_constant_valid_for_bitfield_p): Declare.
ada/
* utils2.c (gnat_build_constructor): Factor out code. Use
initializer_constant_valid_for_bitfield_p for bit-fields and
account for BLKmode in addition to DECL_BIT_FIELD as in
output_constructor.
testsuite/
* gnat.dg/oconst[1-6].ad[bs]: New tests. Also support for ...
* gnat.dg/test_oconst.adb: New test.