]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.tree.*: docs
authorBjörn Lindqvist <bjourne@gmail.com>
Sun, 20 Sep 2015 09:39:34 +0000 (11:39 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Tue, 22 Sep 2015 06:52:36 +0000 (08:52 +0200)
basis/compiler/tree/cleanup/cleanup-docs.factor
basis/compiler/tree/cleanup/cleanup.factor
basis/compiler/tree/propagation/constraints/constraints-docs.factor
basis/compiler/tree/propagation/nodes/nodes-docs.factor
basis/compiler/tree/propagation/recursive/recursive-docs.factor [new file with mode: 0644]
basis/compiler/tree/propagation/recursive/recursive.factor
basis/compiler/tree/tree-docs.factor

index 45a8bb3941d0a95c0ea67d785331ad37b76c853d..8ceb66a1b109c5efcb7b0b6efc69123afeb8142d 100644 (file)
@@ -1,15 +1,26 @@
 USING: compiler.tree help.markup help.syntax kernel sequences ;
 IN: compiler.tree.cleanup
 
+HELP: >copy
+{ $values { "node" node } { "#copy" #copy } }
+{ $description "Creates a #copy node from the inputs and outputs of a node." } ;
+
 HELP: cleanup-folding?
 { $values { "#call" #call } { "?" boolean } }
 { $description "Checks if a " { $link #call } " node can be folded." } ;
 
 HELP: cleanup-tree
 { $values { "nodes" sequence } { "nodes'" sequence } }
-{ $description "Main entry point for the cleanup-tree optimization phase." } ;
+{ $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." } ;
+
+HELP: fold-only-branch
+{ $values { "#branch" #branch } { "node/nodes" "a " { $link node } " or a sequence of nodes" } }
+{ $description "If only one branch is live we don't need to branch at all; just drop the condition value." } ;
 
 ARTICLE: "compiler.tree.cleanup" "Cleanup Phase"
-"A phase run after propagation to finish the job, so to speak. Codifies speculative inlining decisions, deletes branches marked as never taken, and flattens local recursive blocks that do not call themselves." ;
+"A phase run after propagation to finish the job, so to speak. Codifies speculative inlining decisions, deletes branches marked as never taken, and flattens local recursive blocks that do not call themselves."
+$nl
+"Main entry point:"
+{ $subsections cleanup-tree } ;
 
 ABOUT: "compiler.tree.cleanup"
index 2596d641808fb15fffc7164694b40ba593fa8e85..9b7bc397e360764305790850dbeb345a5504a3d2 100644 (file)
@@ -24,8 +24,6 @@ M: node delete-node drop ;
 GENERIC: cleanup-tree* ( node -- node/nodes )
 
 : cleanup-tree ( nodes -- nodes' )
-    ! We don't recurse into children here, instead the methods
-    ! do it since the logic is a bit more involved
     [ cleanup-tree* ] map-flat ;
 
 ! Constant folding
@@ -114,8 +112,6 @@ M: #call cleanup-tree*
     ] change-children drop ;
 
 : fold-only-branch ( #branch -- node/nodes )
-    ! If only one branch is live we don't need to branch at
-    ! all; just drop the condition value.
     dup live-children sift dup length {
         { 0 [ drop in-d>> <#drop> ] }
         { 1 [ first swap in-d>> <#drop> prefix ] }
index 274c8656905394419d74d0cb909defe4b734c65b..afec7bcd0b18e8387e62976f1329571aaf5e3c6f 100644 (file)
@@ -1,11 +1,11 @@
-USING: help.markup help.syntax kernel ;
+USING: help.markup help.syntax kernel sequences ;
 IN: compiler.tree.propagation.constraints
 
 HELP: class-constraint
 { $class-description "A class constraint." } ;
 
 HELP: constraints
-{ $var-description "Maps constraints to constraints ('A implies B')" } ;
+{ $var-description "A " { $link sequence } " of assocs. They maps constraints to constraints ('A implies B')." } ;
 
 HELP: equivalence
 { $var-description "An equivalence constraint." } ;
index 6483ef868e14524c84dfd13400d47766ea838ca0..606b4140a6a8cd7f54d01bb508ad26e4a6d4793d 100644 (file)
@@ -1,10 +1,14 @@
-USING: compiler.tree help.markup help.syntax ;
+USING: assocs compiler.tree help.markup help.syntax sequences ;
 IN: compiler.tree.propagation.nodes
 
 HELP: annotate-node
 { $values { "node" node } }
 { $description "Initializes the info slot for SSA tree nodes that have it." } ;
 
+HELP: extract-value-info
+{ $values { "values" sequence } { "assoc" assoc } }
+{ $description "Creates an assoc mapping values to infos for the 'values'." } ;
+
 HELP: propagate-around
 { $values { "node" node } }
 { $description "Performs value propagation for an SSA node." } ;
diff --git a/basis/compiler/tree/propagation/recursive/recursive-docs.factor b/basis/compiler/tree/propagation/recursive/recursive-docs.factor
new file mode 100644 (file)
index 0000000..cd33c6c
--- /dev/null
@@ -0,0 +1,12 @@
+USING: compiler.tree compiler.tree.propagation.info
+compiler.tree.propagation.nodes help.markup help.syntax sequences ;
+IN: compiler.tree.propagation.recursive
+
+HELP: recursive-phi-infos
+{ $values { "node" #recursive } { "infos" sequence } }
+{ $description "The sequence of " { $link value-info-state } " that is the input to the recursive block." } ;
+
+ARTICLE: "compiler.tree.propagation.recursive" "Propagation for inline recursive combinators"
+"This vocab implements the " { $link propagate-before } ", " { $link annotate-node } " and " { $link propagate-around } " words for recursive tree nodes." ;
+
+ABOUT: "compiler.tree.propagation.recursive"
index 955716c12876b58c5b5443bcd36ca2342ee4f689..f008eb6daafa3832673ed0ca7024bd8c17e6ac51 100644 (file)
@@ -45,7 +45,12 @@ IN: compiler.tree.propagation.recursive
     2dup [ not ] either? [ drop ] [
         2dup [ class>> null-class? ] either? [ drop ] [
             [ clone ] dip
-            [ [ drop ] [ [ [ interval>> ] bi@ ] [ drop class>> ] 2bi generalize-counter-interval ] 2bi >>interval ]
+            [
+                [ drop ] [
+                    [ [ interval>> ] bi@ ] [ drop class>> ] 2bi
+                    generalize-counter-interval
+                ] 2bi >>interval
+            ]
             [ [ drop ] [ [ slots>> ] bi@ [ generalize-counter ] 2map ] 2bi >>slots ]
             bi
         ] if
index a7687cd33a7d4dde14484eb65c6b0fdcc4912c16..275a82dd3e2c6eda0d20a42e34911a6357b76e7c 100644 (file)
@@ -1,16 +1,17 @@
-USING: assocs help.markup help.syntax kernel kernel.private quotations
-sequences stack-checker.alien stack-checker.values
+USING: alien assocs help.markup help.syntax kernel kernel.private quotations
+sequences stack-checker.alien stack-checker.inlining stack-checker.values
 stack-checker.visitor words ;
 IN: compiler.tree
 
 HELP: node
-{ $class-description "Base class for all SSA tree nodes." } ;
+{ $class-description "Base class for all SSA tree nodes. The node is an " { $link identity-tuple } " which means that two different node instances with the same attributes are not equal." } ;
 
 HELP: #alien-node
 { $class-description "Base class for alien nodes. Its " { $snippet "params" } " slot holds an instance of the " { $link alien-node-params } " class." } ;
 
 HELP: #alien-invoke
-{ $class-description "SSA tree node that calls a function in a dynamically linked library." } ;
+{ $class-description "SSA tree node that calls a function in a dynamically linked library." }
+{ $see-also alien-invoke } ;
 
 HELP: #alien-callback
 { $class-description "SSA tree node that constructs an alien callback." } ;
@@ -27,9 +28,26 @@ HELP: #call
   }
 } ;
 
+HELP: #call-recursive
+{ $class-description "In a " { $link #recursive } " block of the SSA tree, this node represents a call back to the beginning of the block." }
+{ $see-also #recursive } ;
+
 HELP: #declare
 { $class-description "SSA tree node emitted when " { $link declare } " declarations are encountered." } ;
 
+HELP: #enter-recursive
+{ $class-description "This node works is placed first in the " { $slot "child" } " sequence for " { $link #recursive } " nodes and works like a header for it." }
+{ $see-also #recursive #return-recursive } ;
+
+HELP: #if
+{ $class-description "SSA tree node that implements conditional branching. It has the following slots:"
+  { $table
+    { { $slot "children" }
+      { "A two item " { $link sequence } ". The first item holds the instructions executed if the condition is true and the second those that are executed if it is not true." }
+    }
+  }
+} ;
+
 HELP: #introduce
 { $class-description "SSA tree node that puts an input value from the \"outside\" on the stack. It is used to \"introduce\" data stack parameter whenever they are needed. It has the following slots:"
   { $table
@@ -37,6 +55,9 @@ HELP: #introduce
   }
 } ;
 
+HELP: #phi
+{ $class-description "#phi is a SSA tree node type that unifies two branches in an " { $link #if } "." } ;
+
 HELP: #push
 { $class-description "SSA tree node that puts a literal value on the stack. It has the following slots:"
   { $table
@@ -45,19 +66,19 @@ HELP: #push
 }
 { $notes "A " { $link quotation } " is also a literal." } ;
 
-HELP: #shuffle
-{ $class-description "SSA tree node that represents a stack shuffling operation such as " { $link swap } ". It has the following slots:"
+HELP: #recursive
+{ $class-description "Instruction which encodes a loop. It has the following slots:"
   { $table
-    { { $slot "mapping" } { "An " { $link assoc } " that shows how the shuffle output values (the keys) correspond to their inputs (the values)." } }
+    { { $slot "child" } { "A sequence of nodes representing the body of the loop." } }
+    { { $slot "loop?" } { "If " { $link t } ", the recursion is implemented using a jump, otherwise as a call back to the word." } }
   }
-} ;
+}
+{ $see-also inline-recursive-word } ;
 
-HELP: #if
-{ $class-description "SSA tree node that implements conditional branching. It has the following slots:"
+HELP: #shuffle
+{ $class-description "SSA tree node that represents a stack shuffling operation such as " { $link swap } ". It has the following slots:"
   { $table
-    { { $slot "children" }
-      { "A two item " { $link sequence } ". The first item holds the instructions executed if the condition is true and the second those that are executed if it is not true." }
-    }
+    { { $slot "mapping" } { "An " { $link assoc } " that shows how the shuffle output values (the keys) correspond to their inputs (the values)." } }
   }
 } ;
 
@@ -71,6 +92,13 @@ ARTICLE: "compiler.tree" "High-level optimizer operating on lexical tree SSA IR"
   #call
   #declare
   #shuffle
+}
+"Nodes for control flow:"
+{ $subsections
+  #call-recursive
+  #enter-recursive
+  #recursive
+  #return-recursive
 } ;
 
 ABOUT: "compiler.tree"