[LLVMdev] [PATCH] - Union types, attempt 2

Chris Lattner clattner at apple.com
Fri Jan 15 10:11:44 PST 2010


On Jan 13, 2010, at 12:11 PM, Talin wrote:
>
> It depends on whether or not unions can be passed around as SSA  
> values or not. I can think of situations where you would want to.
>
> In particular, GEP is useful because you can avoid the bitcast above  
> - GEP to element 0 if you want an int (in the example above), or to  
> element 1 if you want a double.
>
> Also, I'm thinking that insertvalue might be the best way to  
> construct a constant union. Right now there's a bit of a problem in  
> that the data type of a constant must match exactly the declared  
> type; However in the case of a union what we want is for the data  
> type of the initializer to exactly match the type of one of the  
> union members. I thought this would be relatively easy to do, but  
> it's a little trickier than I realized.

I think it is useful to support insert/extract on unions just for  
orthogonality alone.  Stuff that works on structs should generally  
work on unions too.

-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100115/b79cc1e6/attachment.html>


More information about the llvm-dev mailing list