[llvm-commits] RFC: initial union syntax support

Chris Lattner clattner at apple.com
Thu May 14 13:44:38 PDT 2009


On May 14, 2009, at 1:04 PM, Frits van Bommel wrote:

> Nick Lewycky wrote:
>> Andrew Lenharth wrote:
>>> The whole point of this exercise is to remove bitcasts.  In fact,
>>> though I am not suggesting it, you could do away with bitcasts
>>> completely given unions.
>
> I disagree with this. Proper union support will allow more than just  
> doing away
> with bitcasts in a few places. A union type would have both the  
> maximum size and
> maximum alignment of any member, so that e.g. explicit padding to  
> get a union in
> a struct at the right alignment won't be necessary.

I think that unions are a potentially interesting feature, but they  
definately don't eliminate the need for pointer bitcasts.

Some random things:

1. Union types should be uniqued, but the type as written in the code  
should be used for uniquing.  u{i32, i32} should be distinct from  
u{i32}.
2. GEP into the union should be allowed.
3. We need a ConstantStruct equivalent.
4. Unions should work as first class aggregates, just like structs.

I haven't had a chance to look at the patch yet,

-Chris



More information about the llvm-commits mailing list