compiler.cfg.*: docs for compiler.cfg.dominance and compiler.cfg.ssa.construction

db4
Björn Lindqvist 2014-12-10 16:51:53 +01:00
parent 53b7f82368
commit 054982f24a
4 changed files with 49 additions and 31 deletions

View File

@ -0,0 +1,20 @@
USING: compiler.cfg compiler.cfg.dominance.private help.markup help.syntax
sequences ;
IN: compiler.cfg.dominance
HELP: dom-parents
{ $var-description "Maps bb -> idom(bb)" } ;
HELP: dom-children
{ $values { "bb" basic-block } { "seq" sequence } }
{ $description "Maps bb -> {bb' | idom(bb') = bb}" } ;
ARTICLE: "compiler.cfg.dominance" "A Simple, Fast Dominance Algorithm" $nl
"A Simple, Fast Dominance Algorithm" $nl
"Keith D. Cooper, Timothy J. Harvey, and Ken Kennedy" $nl
"http://www.cs.rice.edu/~keith/EMBED/dom.pdf"
$nl
"Also, a nice overview is given in these lecture notes:" $nl
"http://llvm.cs.uiuc.edu/~vadve/CS526/public_html/Notes/4ssa.4up.pdf" ;
ABOUT: "compiler.cfg.dominance"

View File

@ -6,18 +6,8 @@ compiler.cfg.rpo compiler.cfg.predecessors ;
FROM: namespaces => set ; FROM: namespaces => set ;
IN: compiler.cfg.dominance IN: compiler.cfg.dominance
! Reference:
! A Simple, Fast Dominance Algorithm
! Keith D. Cooper, Timothy J. Harvey, and Ken Kennedy
! http://www.cs.rice.edu/~keith/EMBED/dom.pdf
! Also, a nice overview is given in these lecture notes:
! http://llvm.cs.uiuc.edu/~vadve/CS526/public_html/Notes/4ssa.4up.pdf
<PRIVATE <PRIVATE
! Maps bb -> idom(bb)
SYMBOL: dom-parents SYMBOL: dom-parents
PRIVATE> PRIVATE>
@ -48,7 +38,6 @@ PRIVATE>
reverse-post-order reverse-post-order
unclip dup set-idom drop '[ _ iterate ] loop ; unclip dup set-idom drop '[ _ iterate ] loop ;
! Maps bb -> {bb' | idom(bb') = bb}
SYMBOL: dom-childrens SYMBOL: dom-childrens
PRIVATE> PRIVATE>

View File

@ -0,0 +1,29 @@
USING: compiler.cfg.instructions compiler.cfg.ssa.construction.private
help.markup help.syntax ;
IN: compiler.cfg.ssa.construction
HELP: phis
{ $var-description "Maps vregs to " { $link ##phi } " instructions." } ;
HELP: used-vregs
{ $var-description "Worklist of used vregs, to calculate used phis." } ;
HELP: defs
{ $var-description "Maps vregs to sets of basic blocks." } ;
HELP: defs-multi
{ $var-description "Set of vregs defined in more than one basic block." } ;
HELP: inserting-phis
{ $var-description "Maps basic blocks to sequences of " { $link ##phi } " instructions." } ;
ARTICLE: "compiler.cfg.ssa.construction" "SSA construction"
"Iterated dominance frontiers are computed using the DJ Graph method in " { $vocab-link "compiler.cfg.ssa.construction.tdmsc" } "."
$nl
"The renaming algorithm is based on \"Practical Improvements to the Construction and Destruction of Static Single Assignment Form\"."
$nl
"We construct pruned SSA without computing live sets, by building a dependency graph for phi instructions, marking the transitive closure of a vertex as live if it is referenced by some non-phi instruction. Thanks to Cameron Zwarich for the trick."
$nl
"http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.49.9683" ;
ABOUT: "compiler.cfg.ssa.construction"

View File

@ -15,27 +15,10 @@ FROM: assocs => change-at ;
FROM: namespaces => set ; FROM: namespaces => set ;
IN: compiler.cfg.ssa.construction IN: compiler.cfg.ssa.construction
! Iterated dominance frontiers are computed using the DJ Graph
! method in compiler.cfg.ssa.construction.tdmsc.
! The renaming algorithm is based on "Practical Improvements to
! the Construction and Destruction of Static Single Assignment
! Form".
! We construct pruned SSA without computing live sets, by
! building a dependency graph for phi instructions, marking the
! transitive closure of a vertex as live if it is referenced by
! some non-phi instruction. Thanks to Cameron Zwarich for the
! trick.
! http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.49.9683
<PRIVATE <PRIVATE
! Maps vregs to sets of basic blocks
SYMBOL: defs SYMBOL: defs
! Set of vregs defined in more than one basic block
SYMBOL: defs-multi SYMBOL: defs-multi
GENERIC: compute-insn-defs ( bb insn -- ) GENERIC: compute-insn-defs ( bb insn -- )
@ -56,7 +39,6 @@ M: vreg-insn compute-insn-defs
[ compute-insn-defs ] with each [ compute-insn-defs ] with each
] simple-analysis ; ] simple-analysis ;
! Maps basic blocks to sequences of ##phi instructions
SYMBOL: inserting-phis SYMBOL: inserting-phis
: insert-phi-later ( vreg bb -- ) : insert-phi-later ( vreg bb -- )
@ -71,10 +53,8 @@ SYMBOL: inserting-phis
defs-multi get members defs-multi get members
defs get '[ dup _ at compute-phis-for ] each ; defs get '[ dup _ at compute-phis-for ] each ;
! Maps vregs to ##phi instructions
SYMBOL: phis SYMBOL: phis
! Worklist of used vregs, to calculate used phis
SYMBOL: used-vregs SYMBOL: used-vregs
! Maps vregs to renaming stacks ! Maps vregs to renaming stacks