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

me22 me22.ca at gmail.com
Fri Jan 15 08:45:03 CST 2010


2010/1/14 Talin <viridia at gmail.com>:
> Originally I thought about having the last be detected
> automatically by what type of initializer was used:
>     @foo = constant union { i32, float } i32 4
> However, from a syntactical standpoint what you get is two types in a row -
> "union { i32, float }" followed by "i32". That is completely unlike any
> other IR syntax and doesn't fit well into the parser.
>

It seems to me like that's similar to the ptrtoint and such
instructions that change the type and not necessarily the value, so
perhaps the main union operations should be:

    %foo = elementtounion i32 4 to union { i32, float }
    %bar = uniontoelement union { i32, float } %foo to i32

Conceptually I dislike the insertvalue, since the point of an insert
is to keep some other part of the value intact, something not needed
with unions.



More information about the LLVMdev mailing list