Add LLVM IR codegen
authorLuke Lau <luke_lau@icloud.com>
Mon, 3 Jun 2019 14:47:05 +0000 (15:47 +0100)
committerLuke Lau <luke_lau@icloud.com>
Mon, 3 Jun 2019 23:11:03 +0000 (00:11 +0100)
commitde8c7223c79f10c69f9916db1f15b34d20938e2c
treeab091fa4056e0080df5df5473156e2e53b7dc7ce
parent5c4c0171f43b2d66cec3a882cdf2ecd904c83a1a
parentc426d6ca5a444eec434eec6a58c86e2d24a7c992
Add LLVM IR codegen

Now that we have our AST built up, its time to start thinking about
semantics. And to think about semantics, we need to start building up
code that does what our AST says.

In most compilers, we don't directly convert the AST right down to
machine code: Usually there's an intermediate representation involved
that's somewhere between our programming language and machine code. LLVM
has an intermediate representation called LLVM IR, and that's what we'll
be converting our AST to.

llvm-hs provides a monadic way of building up modules and functions,
with ModuleBuilder and IRBuilder respectively. To generate our code we
will traverse our AST inside these monads, spitting out LLVM IR as we go
along.