2018-03-19 00:50:32 -04:00
USING: classes compiler.tree help.markup help.syntax kernel sequences ;
2014-04-24 15:35:04 -04:00
IN: compiler.tree.cleanup
2016-11-30 08:42:29 -05:00
HELP: (cleanup-folding)
2018-08-10 14:04:49 -04:00
{ $values { "call#" call# } { "nodes" sequence } }
{ $description "Replace a call# having a known result with a drop# of its inputs followed by push# nodes for the outputs." } ;
2016-11-30 08:42:29 -05:00
2015-09-20 05:39:34 -04:00
HELP: >copy
2018-08-10 14:04:49 -04:00
{ $values { "node" node } { "copy#" copy# } }
{ $description "Creates a copy# node from the inputs and outputs of a node." } ;
2015-09-20 05:39:34 -04:00
2015-06-14 01:40:17 -04:00
HELP: cleanup-folding?
2018-08-10 14:04:49 -04:00
{ $values { "call#" call# } { "?" boolean } }
{ $description "Checks if a " { $link call# } " node can be folded." } ;
2014-04-24 15:35:04 -04:00
2015-06-06 00:22:50 -04:00
HELP: cleanup-tree
2014-05-10 19:45:07 -04:00
{ $values { "nodes" sequence } { "nodes'" sequence } }
2016-11-30 08:42:29 -05:00
{ $description "Main entry point for the cleanup-tree optimization phase. We don't recurse into children here, instead the methods do it since the logic is a bit more involved." }
{ $see-also cleanup-tree* } ;
2015-09-20 05:39:34 -04:00
2016-11-30 08:42:29 -05:00
HELP: cleanup-tree*
{ $values { "node" node } { "node/nodes" "a node or a sequence of nodes" } }
{ $description "Runs the cleanup pass for an SSA node." } ;
2016-03-18 11:28:01 -04:00
HELP: flatten-recursive
2018-08-10 14:04:49 -04:00
{ $values { "recursive#" recursive# } { "nodes" sequence } }
{ $description "Converts " { $link enter-recursive# } " and " { $link return-recursive# } " into " { $link copy# } " nodes." } ;
2016-03-18 11:28:01 -04:00
2015-09-20 05:39:34 -04:00
HELP: fold-only-branch
2018-08-10 14:04:49 -04:00
{ $values { "branch#" branch# } { "node/nodes" "a " { $link node } " or a sequence of nodes" } }
2015-09-20 05:39:34 -04:00
{ $description "If only one branch is live we don't need to branch at all; just drop the condition value." } ;
2015-06-14 01:40:17 -04:00
2016-11-30 08:42:29 -05:00
HELP: record-predicate-folding
2018-08-10 14:04:49 -04:00
{ $values { "call#" call# } }
2016-11-30 08:42:29 -05:00
{ $description "Adds a suitable dependency for a call to a word that is a " { $link predicate } " word that has been folded." } ;
2015-06-14 01:40:17 -04:00
ARTICLE: "compiler.tree.cleanup" "Cleanup Phase"
2016-03-18 11:28:01 -04:00
"A phase run after propagation to finish the job, so to speak. Codifies speculative inlining decisions, deletes branches marked as never taken, replaces folded calls with constants and flattens local recursive blocks that do not call themselves."
2015-09-20 05:39:34 -04:00
$nl
"Main entry point:"
2016-03-18 11:28:01 -04:00
{ $subsections cleanup-tree }
2016-11-30 08:42:29 -05:00
"Each node type implements its own method on the " { $link cleanup-tree* } " generic."
$nl
"Previous pass: " { $vocab-link "compiler.tree.propagation" } ", next pass: " { $vocab-link "compiler.tree.escape-analysis" } "." ;
2015-06-14 01:40:17 -04:00
ABOUT: "compiler.tree.cleanup"