[LLVMdev] LLVM languages cooperation

Chris Lattner sabre at nondot.org
Tue Feb 24 09:50:01 PST 2004


On Tue, 24 Feb 2004, [ISO-8859-1] Sébastien Pierre wrote:

> Chris Lattner wrote:
> >This really stems from
> >differing goals, though LLVM can certainly be used to compile MSIL-like
> >systems, so it's just a matter of specifying the rules and making the
> >front-ends stick to them.  :)

> Ok, this is clear. Do you plan any "foreign function interface" or
> something similar that would ease, if not automate communication across
> languages that have an LLVM backend ? It may look slightly out of the
> scope of the LLVM projet, but wouldn't it be interesting to provide some
> guidelines for LLVM backend developers to allow inter-language
> communication ?

I hadn't planned on it, but I can certainly describe what the C/C++
front-end emits.  Basically, the rules are as follows:

1. C++ references are turned into pointers
2. If a function returns an aggregate value (ie, a structure or array), it
   is changed to return void, and an extra (first) argument is added that
   is a pointer to the aggregate type.  The callee then fills in the
   aggregate argument instead of returning the aggregate.
3. If structures are passed by value, they are decimated, and all elements
   of the structure are passed as scalars.
4. Otherwise, all arguments are passed left-to-right in a very
   straight-forward fashion.

I think that these few rules represent the major non-obvious portions of
the interface that the C/C++ front-end generates.  If you have any
questions about other corner cases, I can certainly answer them, or you
can try out examples with the front-end.

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/





More information about the llvm-dev mailing list