Re: Connect The Dots: iPhone Graphics, OS X, LLVM, ARM, and Ruby?



"Leen Toelen" <toelen gmail com> writes:

> We'll start with what the heck LLVM does, and go from there.
> 
>    - LLVM <http://www.llvm.org/> is a fascinating compiler system that
>    optimizes code at many stages, from compile-time to run-time optimizations;
>    e.g., your code is optimized while it's still running!

I have actually been looking at LLVM lately. Some quick notes from me
playing around with it:

- It is an excellent compiler that generates really good machine code
  (on x86 at least).

- It supports vector code, aka SIMD instructions. It supports at least
  SSE and 3D-now. The vector code generated is good.

- It can be retargeted with a flexible machine description language
  (flexible enough to do something sensible with x86)

- The input you give it is an SSA graph where all the temporaries have
  explicit types such as 'int' or 'vector4x16'. Generating code for
  the Render operations (and the core operations for that matter) in
  this language looks very much doable.

- I haven't investigated this in detail, but I don't see any reason
  LLVM couldn't be retargeted to GPU shaders (which are more or less
  SIMD instructions anyway).

- It is written in C++ with STL, which among other things means the
  binaries of the compiler itself are huge. As an example, a simple
  Hello World jit compiler was over 3MB of text, which included 470
  copies of some copy_backwards_iterator() function. This may
  obviously be a problem for embedded systems, but even on desktop
  systems such a huge binary is going to use a lot of CPU cache.
      Looking at the implementation of GCC's libstdc++ STL was
  horrifying - it seems to follow the philosophy of "everything that
  can be inlined should be inlined". I believe it can be fixed, but
  obviously only with cooperation from the gcc people.

So I think it's definitely worthwhile looking into LLVM some more.


Soren



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]