This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: alias.c:nonoverlapping_component_refs_p
- From: Geert Bosch <bosch at gnat dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>,gcc-patches at gcc dot gnu dot org
- Date: Mon, 3 Dec 2001 21:44:26 -0500
- Subject: Re: alias.c:nonoverlapping_component_refs_p
On Monday, December 3, 2001, at 09:04 , Richard Henderson wrote:
> Err.. why? What can you do with a collapsed represenation that
> you can't do with the uncollapsed representation? It's all
> compiler internals after all...
The issue is that the user can define representation clauses
that allow full control over the in-memory layout of types.
This means that we could have something like:
type T (X, Y : Boolean) is record
case X is
when False => A : Float;
when True => B : Float;
case Y is
when False => C : Float;
when True => D : Float;
end case;
end case;
end record;
for T use record
A at 0 range 0 .. 31;
B at 8 range 0 .. 31;
C at 4 range 0 .. 31;
D at 4 range 0 .. 31;
Y at 12 range 0 .. 7;
end record;
for T'Alignment use 16;
pragma Pack (T);
And the final layout of the type is then (use -gnatR to see this):
for T'Object_Size use 128;
for T'Value_Size use 105;
for T'Alignment use 16;
for T use record
X at 13 range 0 .. 0;
Y at 12 range 0 .. 7;
A at 0 range 0 .. 31;
B at 8 range 0 .. 31;
C at 4 range 0 .. 31;
D at 4 range 0 .. 31;
end record;
Complete control over representation is one of the main benefits of
Ada in the embedded market, as this allows easy modelling of hardware
interfaces. I don't think it would be feasible to model such arbitrary
representations using union's and structs.
-Geert