[LLVMdev] Suggestion: Support union types in IR
clattner at apple.com
Fri Jan 2 14:05:18 CST 2009
On Jan 1, 2009, at 6:25 AM, Jon Harrop wrote:
>> Exactly. I'm not especially interested in C-style unions, I'm
>> in discriminated unions. But the actual discriminator field is easily
>> represented in LLVM IR already, so there's no need to extend the IR
>> support them. That's why I am only asking for C-style union support -
>> it's a lower-level primitive that you can use to build discriminated
>> unions on top of.
> I don't think you would want to build discriminated unions on top of
> unions though.
>> The problem with varying-size structs is that it would be nice to be
>> able to pass them as function parameters and function return values
>> using LLVM's support of structs as first-class data types.
> As I understand it, LLVM does not provide first-class structs and
> to return arbitrary structs from functions will randomly break. I
> believe you
> need to implement that yourself in whatever way your target language
This is a current implementation deficiency, not a design limitation.
We welcome patches to fix this.
More information about the LLVMdev