LLVM: Factor out accumulation of LLVM statements and variables
authorBen Gamari <bgamari.foss@gmail.com>
Fri, 2 Oct 2015 13:49:24 +0000 (15:49 +0200)
committerBen Gamari <ben@smart-cactus.org>
Fri, 2 Oct 2015 14:34:21 +0000 (16:34 +0200)
commit953940850f7f2aaf53d91e882a3216bfcf30c8f5
treecf19fa6ee02e85c007b4c9d1caacd9c040023d10
parentbd41eb2ad9507d3f408e25c8dece61f389f11a2a
LLVM: Factor out accumulation of LLVM statements and variables

The LLVM code generator currently has a rather large amount of
boilerplate devoted to piping around and building up various AST
elements. This is rather unfortunate for a language which prides itself
on ease of abstraction and detracts from readability.

Here I continue a refactoring that I originally suggested in D991, using
`WriterT` to factor out this pattern. `WriterT` is in general a bit
problematic from an evaluation perspective, but the expressions here are
small enough that it should be a problem in practice.

Test Plan: Validate

Reviewers: austin

Reviewed By: austin

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1286
compiler/llvmGen/LlvmCodeGen/CodeGen.hs