[LLVMdev] Testing LLVM on OS X

Chris Lattner sabre at nondot.org
Fri Apr 30 18:42:02 PDT 2004


On Fri, 30 Apr 2004, Patrick Flanagan wrote:
> Thanks! Grabbed the latest from CVS and added that linker option to the
> config file. It looks like it compiles and runs the SPEC tests ok now.

Great!

> Just to make sure I understand how LLVM works, got a few clarifications:
>
> 1. The ppc code I'm generating with the -native-cbe is static, correct?

Yes, it's purely static with the -native-cbe or -native options.

> 2. Is there a frontend to any of the other gnu compiler collection
> stuff? Eg g77 or something for compiling fortran code or is c/c++ the
> focus right now?

So far only C and C++ are currently supported.  Objective C support is
extremely close to working, but I haven't had time to work on it at all,
and I don't know objective C very well in any case. :)  Fortran, Java, and
Ada support has not been tried at all, and are likely to be more work than
objc.

If you are familiar with GCC, adding support for the other GCC front-ends
is not very difficult.  It basically amounts to implementing the langhooks
that are used to expand the language-specific tree nodes into the
appropriate LLVM code.  Of all of them, having G77 would be particularly
nice, because it would allow us to run the rest of SpecFP, though f2c
might be another option if it works very well (I've never tried it
before).

Long-term we'd like to have a nice F90 front-end, perhaps based on the
Cray front-end.  If anyone is interested in Fortran, this would be an
excellent project. :)

> 3. Does the code that uses the JIT compiler (I know, doesn't currently
> exist on ppc) currently take advantage of run-time optimization? If I
> ran the SPEC suite with a JIT compiled version several times, would I
> except the score to eventually increase at all, depending on what the
> benchmark does?

Nope, not currently.  The ultimate goal is to support this, but right now
it's not implemented.

> I only know just enough about compilers to be dangerous, but I'm working
> on learning more :). If no one else is currently working on this, what
> would be needed in order to get the JIT compiler up and running on
> ppc/os x? Is it just a matter of taking some tree/rtl form stuff and
> emitting ppc code instead of x86 code?

Basically a new code generator would need to be written.  The current X86
code generator (ignoring the experimental instruction selectors) is about
8-9000 LOC (about 4800 SLOC, as reported by sloccount) in the
lib/Target/X86 directory, which should give you an idea of how much work
it currently is to implement a code generator.  The X86 backend also has a
bunch of little optimizations in it, so a simple code generator would
probably be a lot less code.  We are slowly working on developing tools
that will reduce this amount of code further, but they won't be ready for
some time.

I emailed the guys that started working on the PPC backend.  My impression
is that it is close to working, but they ran into some issues with stack
frame layout, and hadn't had time to look into them recently.  They are
currently trying to get it cleared through their company to release the
code, which will allow others to continue their work (cross your fingers
:).

> Is there code that needs to be ported to os x so it can profile itself?

The only thing that LLVM is missing on OS/X (besides a code generator)
that I'm aware of is support for dynamic plugin loading (Brian would know
more).  If you look in lib/Support/DynamicLinker.cpp, you'll see some
stuff that is only defined for HAVE_DLOPEN.  It would be very handy to get
support for OS/X, which doesn't have the dl* family of syscalls.

-Chris

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




More information about the llvm-dev mailing list