[LLVMdev] Union types

Renato Golin rengolin at systemcall.org
Wed Apr 7 15:24:38 PDT 2010


On 7 April 2010 18:05, Talin <viridia at gmail.com> wrote:
> The alternative is to simply
> recalculate the union size each time it is needed -- it does seem like a lot
> of extra complexity to have a whole cache just for the size.

Hi Talin,

As a first implementation it doesn't seem like too much to recalculate
the union size every time, usually unions have less than a few dozen
fields, anyway.

I don't know how the lowering do the struct (and I'm on holiday now,
so hard to check), but an extra method on UnionType (or whatever
reflects on the lowering code) seems simple enough to return the size,
calculated on the c-tor or dynamically, via getPrimitiveSizeInBits()
method on each field.

cheers,
--renato

http://systemcall.org/

Reclaim your digital rights, eliminate DRM, learn more at
http://www.defectivebydesign.org/what_is_drm



More information about the llvm-dev mailing list