Sun, 22 Aug 2010

LLVM Backend for DDC : Milestone #2.

For a couple of weeks after AusHac 2010 I didn't manage to find any time to
working on DDC at all, but I'm now back on it and late last week I reached the
second milestone on the
LLVM backend for DDC.
The backend now has the ability to box and unbox 32 bit integers and perform
simple arithmetic operations on valid combinations of them.

Disciple code that can currently be compiled correctly via LLVM includes basic
stuff like:

While writing the Haskell code for DDC, I'm finding that its easiest to generate
LLVM code for a specific narrow case first and then generalize it as more cases
come to light.
I also found that the way I had been doing the LLVM code generation was tedious
and ugly, invloving lots of concatenation of small lists.
To fix this I built myself an LlvmM monad on top of the
StateT monad:

type LlvmM = StateT [[LlvmStatement]] IO

Using this I can then generate a block of LLVM code as a list of
LlvmStatements and add it to the monad using an
addBlock function which basically pushes the blocks of code
down onto a stack: