Introducing Orc
Orc is a new sub-project of Liboil that I’ve been working on for a few weeks. Orc stands for Oil Runtime Compiler, which further expands to Optimized Inner Loop Runtime Compiler. As its name implies, the Orc library compiles code into a runnable function, and does it using SIMD instructions when available. The “code” is currently an intermediate form that is roughly a platform-agnostic assembly language that understands variables and simple arrays. It’s an intermediate form in the sense that it’s currently only stored as a list of structs — there isn’t a parser yet. Orc can generate MMX and Altivec code for a few simple functions that is as fast as the corresponding liboil function. There are also software fallbacks for those not-so-mainstream architectures.
There have been many motivations for creating Orc, which I will go into at another time.
One of the primary goals of Orc is to create a simple compiler (actually, it’s a really fancy assembler that understands register allocation) that is user-expandable: an Orc user can create additional opcodes, variable types, and rules for translating those opcodes into machine code. One of the potential applications for Orc is pixman, which would require adding types (ARGB pixels) and opcodes (compositing operations).
May 23rd, 2008 at 12:23 pm
Did you consider LLVM?
It is used by Apple and others for the type of dynamic code specialization you are describing.
The LLVM Compiler Infrastructure
http://llvm.org/
May 23rd, 2008 at 12:43 pm
llvm: LLVM is a good tool, and a very general version of what Orc does. However, I was not able to get it to produce code that was as fast as liboil code. In addition, Orc is much more extensible in the exact areas I need and I think other people need.
As much as I dislike NIH syndrome, this project definitely borders on it. My defense is that I now have a working runtime compiler with features I need, rather than still attempting to hack those features onto LLVM.
May 23rd, 2008 at 6:40 pm
It’s not entirely clear from the text that orc is part of the liboil source.