RE: LLVM languages cooperation

Sebastien Pierre wrote:

I am an LLVM newbie, thinking about using LLVM as the platform for a toy
language.

BTW, you might want to check out this document that Reid wrote, which
describes his experiences writing a front-end for LLVM, and giving lots of
hints and tips: http://llvm.cs.uiuc.edu/docs/Stacker.html

-Chris

Chris Lattner wrote:

BTW, you might want to check out this document that Reid wrote, which

describes his experiences writing a front-end for LLVM, and giving lots of
hints and tips: http://llvm.cs.uiuc.edu/docs/Stacker.html

Thanks, I already had a quick look on it.
Also thanks for your explanation on how the C++ back-end converts function calls to LLVM code.

As you adviced earlier (about the Ruby LLVM back-end), back-end developers will have to write a runtime library for their own language (in any LLVM-supported language). This reminds me of Objective-C, which comes with a C-based runtime library which allows to use any Objective-C language from the C.

In this respect, it might be interesting to come up with guidelines (or maybe something more "formal") for back-end developers to write such cross-language communication runtime.

For instance, the Objective-C backend for GCC allows to send messages to objects (invoke methods), create and manipulate "selectors" (which reference methods), introspect classes, create new classes, etc. It does not offer any primitive types manipulation as they are the same as C.

As LLVM seems to offer a language-independant type system, maybe it would be easy to reference and interact with values of types (like instance of classes) of a foreign language ?

-- Sébastien

In this respect, it might be interesting to come up with guidelines (or
maybe something more "formal") for back-end developers to write such
cross-language communication runtime.

Sure, that sounds like a very worthwhile project, but also a hard one. :slight_smile:

As LLVM seems to offer a language-independant type system, maybe it
would be easy to reference and interact with values of types (like
instance of classes) of a foreign language ?

Yes, this is certainly possible. All that is required is a set of
guidelines that various llvm front-ends should work with. The hard part
about this is that the guidelines will be necessarily language-specific,
and you have an N^2 interaction matrix among languages.

That said, I'm sure it's possible, and there is probably a substantial
amount of overlap. For example, smalltalk, objc, and ruby all share a
related message dispatching style. It would be nice if front-ends for
these languages could share objects transparently...

-Chris