This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hello, This is a first patch out of two to implement support for output of static nested constructors within bitfields, pretty common and easy to get in Ada, for instance: << type u1 is mod 2**1; type u8 is mod 2**8; type HI_Record is record A, B : U8; end record; pragma Suppress_Initialization (HI_Record); type Blob is record Bit : U1; Agg : HI_Record; end record; pragma Suppress_Initialization (Blob); for Blob use record Bit at 0 range 0 .. 0; Agg at 0 range 1 .. 16; -- bits 1 to 16 from start byte 0 end record; K0 : Blob := (Bit => 0, Agg => (A => 3, B => 7)); >> The goal is to let such constructs generate a static initializer instead of hairy run-time elaboration code with shifts, masks and so on. The bulk of the overall support is in output_constructor. As this is a complex function already, this first patch is a suggestion to split three helpers out of it, one for each case of processed element kind in the current code: << if (index && TREE_CODE (index) == RANGE_EXPR) [...] else if (field == 0 || !DECL_BIT_FIELD (field)) [... An element that is not a bit-field ...] else if (val != 0 && TREE_CODE (val) != INTEGER_CST) error ("invalid initial value for member %qs", else [... INTEGER_CST bitfield ...] >> The split is performed by introducing a simple datastructure to represent the local state and use an instance of it to communicate with the helpers. 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-23 Olivier Hainque <hainque@adacore.com> * varasm.c (oc_local_state): New structure, output_constructor local state to support communication with helpers. (output_constructor_array_range): New output_constructor helper, extracted code for an array range element. (output_constructor_regular_field): New output_constructor helper, extracted code for an element that is not a bitfield. (output_constructor_bitfield): New output_constructor helper, extracted code for a bitfield element. (output_constructor): Rework to use helpers.
Attachment:
oc-split.dif
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |