[llvm-commits] RFC: initial union syntax support

Andrew Lenharth andrewl at lenharth.org
Wed May 13 07:02:00 PDT 2009


On Wed, May 13, 2009 at 12:57 AM, Chris Lattner <clattner at apple.com> wrote:
>
> On May 12, 2009, at 4:00 PM, Andrew Lenharth wrote:
>
>> Updated patch.  Supports C, Cpp, and all (?) native codegen.  BasicAA
>> updated to be conservative (but not completely enough yet).
>>
>> Making unions a type of struct makes most code just work as most code
>> uses getOffset variants since structs can already have zero width
>> elements.
>
> Hi Andrew,
>
> What problem does this solve?

Being able to write target independent frontends with union support.
{int, union {...} } becomes a nice tagged union without having to try
to figure out the largest object or the most restricted alignment
(necessary if using bitcasts).  More generally, there is no way to
write target independent unions right now. (size_t problem).

Cleaning up the mess of casts that is the current llvm-gcc output for
unions (where possible).  This might have a code size reduction
(larger types and one more GEP constant instead of casts) (or
increase), I haven't tackled the llvm-gcc portion as the union
handling was more than I wanted to figure out yesterday.

Andrew

>
> -Chris
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list