[LLVMdev] First-class structs

Jon Harrop jon at ffconsultancy.com
Tue Dec 16 14:18:03 PST 2008


Apologies for the dumb questions but I'm rustier than I had hoped on this.

I'm trying to write a mini ML implementation and am considering trying to 
optimize tuples into structs to avoid heap allocation when possible. Tuples 
are often used to return multiple values in ML so I am likely to wind up 
returning structs from functions.

I also want to support as much of a C-like representation of the internal data 
structures as possible in order to ease interoperability. This raises several 
questions:

1. What is a function returning a struct compiled to (e.g. by GCC on Linux)?

2. What caveats are there (e.g. is complex in C99 handled differently?)?

3. If I just throw IL at LLVM naively, when is it likely to emit code that is 
incompatible with GCC-compiled C code or barf entirely in this context (e.g. 
are >2 fields in a returned struct on x86 not yet implemented)?

4. Will run-time performance be degraded if I make heavy use of nested structs 
and/or return them from functions?

Many thanks,
-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e



More information about the llvm-dev mailing list