Introduce codeGen compiler phase

Rebased version of #80. Review by @cvogt.