Final stage of compilation generates machine code from dataflow IR


The compiler first builds an SSA IR tree of the word to be compiled (see compiler.tree.builder) then this vocab converts it to a CFG IR tree. The result is not in SSA form; this is constructed later by calling compiler.cfg.ssa.construction:construct-ssa.

Each tree node type has its own implementation of the emit-node generic. In that word, cfg instructions (tuples prefixed with ##) are outputted to basic blocks and the cfg constructed.

Main word:
build-cfg ( nodes word -- procedures )


Block adders:
begin-word ( block -- block' )

end-word ( block -- block' )


Combinators:
with-cfg-builder ( nodes word label quot: ( ..a block -- ..b ) -- )


Emitters for #call:
emit-call ( block word height -- block' )

emit-loop-call ( successor-block current-block -- )


Emitters for #dispatch and #if:
emit-actual-if ( block #if -- block' )

emit-branch ( nodes block -- pair/f )

emit-if ( block node -- block' )

emit-trivial-if ( -- )


Emitters for #recursive:
emit-loop ( block #recursive -- block' )

emit-recursive ( block #recursive -- block' )

end-branch ( block/f -- pair/f )


Helpers for #shuffle:
height-changes ( #shuffle -- height-changes )

out-vregs/stack ( #shuffle -- pair )