[LLVMdev] variable sized structs in LLVM
Reid Spencer
reid at x10sys.com
Mon Jun 20 16:33:02 PDT 2005
Its certainly possible to generate .ll files but its probably about the
same amount of work to use the LLVM API and there are significant speed
and validity benefits to doing so.
Here's some ideas on how to handle this situation for the variable sized
structs you need for PyPy:
1. Don't support the feature in your first release (not sure if this is
viable or not).
2. Make some worst case assumptions about size and alignment (8 bytes)
and allocate that size, possibly over-allocating memory.
3. Figure out the exact maximum size of the struct so you can declare
the type correctly.
4. Implement variable sized fields as separately allocated arrays so
that your example becomes:
%struct.array = type { int, int, int* }
The third field is allocated according to the actual size needed.
This is a bit more code generation but should be fairly efficient.
Reid.
On Tue, 2005-06-21 at 00:40 +0200, Carl Friedrich Bolz wrote:
> Hi Reid,
>
> Reid Spencer wrote:
> > Yes, for that you need TargetData:
> >
> > http://illuvium.net/docs/doxygen/classllvm_1_1TargetData.html
>
> I feared that that would be the answer :-). We're not using the LLVM-API
> at the moment. We're just generating a .ll file 'by hand', e.g. via
> simple string operations. I guess we get what we deserve :-).
>
> Thanks for your help,
>
> Carl Friedrich
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050620/78ba6d6b/attachment.sig>
More information about the llvm-dev
mailing list