]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.cfg.gvn.testing: clean stuff up; get full, proper graphviz output
authorAlex Vondrak <ajvondrak@csupomona.edu>
Thu, 9 Jun 2011 19:08:25 +0000 (12:08 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 12 Sep 2012 22:14:07 +0000 (15:14 -0700)
extra/compiler/cfg/graphviz/graphviz.factor
extra/compiler/cfg/gvn/gvn.factor
extra/compiler/cfg/gvn/testing/testing.factor

index 0fd6ae14a602ce56573c054ebb8e9883210f5e08..591e496dbdbed6e08f2a8d0b3b111713bac84503 100644 (file)
@@ -59,6 +59,9 @@ IN: compiler.cfg.graphviz
     [ number>string png ]
     tri* ;
 
+SYMBOL: passes
+\ optimize-cfg def>> passes set
+
 : watch-pass ( cfg pass pass# -- cfg' )
     [ perform-pass ] 2keep draw-cfg ;
 
@@ -66,11 +69,11 @@ IN: compiler.cfg.graphviz
     \ build-cfg 0 draw-cfg ;
 
 : watch-passes ( cfg -- cfg' )
-    \ optimize-cfg def>> [ 1 + watch-pass ] each-index ;
+    passes get [ 1 + watch-pass ] each-index ;
 
 : finish-watching-passes ( cfg -- )
     \ finalize-cfg
-    \ optimize-cfg def>> length 1 +
+    passes get length 1 +
     watch-pass drop ;
 
 : watch-cfg ( path cfg -- )
index 5f399fa65c1819b13e047524edddfde36c9c29b5..6a35dca71a695d1065bd6f5e8e37d3235824c4b0 100644 (file)
@@ -75,12 +75,15 @@ M: array process-instruction
     ! won't be sound
     dup [ process-instruction drop ] each ;
 
+: value-numbering-iteration ( cfg -- )
+    [ value-numbering-step ] simple-optimization ;
+
 : value-numbering ( cfg -- cfg )
     dup
     init-gvn
     '[
         changed? off
-        _ [ value-numbering-step ] simple-optimization
+        _ value-numbering-iteration
         changed? get
     ] loop
 
index 39685ed61af0e882bc781795054296caf8e1c29f..a585ef0c4bc4797c4b852d1f28c34077231fc687 100644 (file)
@@ -1,17 +1,11 @@
 ! Copyright (C) 2011 Alex Vondrak.  See
 ! http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs compiler.cfg
-compiler.cfg.alias-analysis compiler.cfg.block-joining
-compiler.cfg.branch-splitting compiler.cfg.copy-prop
-compiler.cfg.dce compiler.cfg.debugger
-compiler.cfg.finalization compiler.cfg.graphviz
+USING: accessors assocs compiler.cfg compiler.cfg.graphviz
 compiler.cfg.gvn compiler.cfg.gvn.expressions
-compiler.cfg.gvn.graph compiler.cfg.height
-compiler.cfg.ssa.construction compiler.cfg.tco
-compiler.cfg.useless-conditionals formatting fry graphviz
-graphviz.notation graphviz.render io kernel math math.parser
-math.private namespaces prettyprint sequences sorting strings
-tools.annotations ;
+compiler.cfg.gvn.graph compiler.cfg.optimizer continuations
+formatting graphviz graphviz.notation graphviz.render
+io.directories kernel math.parser namespaces prettyprint
+sequences sorting splitting tools.annotations ;
 IN: compiler.cfg.gvn.testing
 
 GENERIC: expr>str ( expr -- str )
@@ -46,19 +40,6 @@ M: object expr>str [ unparse ] map " " join ;
         "<%d> : {%s}\\l" sprintf
     ] map "" concat-as ;
 
-SYMBOL: gvn-test
-
-[ 0 100 [ 1 fixnum+fast ] times ]
-test-builder first [
-    optimize-tail-calls
-    delete-useless-conditionals
-    split-branches
-    join-blocks
-    normalize-height
-    construct-ssa
-    alias-analysis
-] with-cfg gvn-test set-global
-
 : basic-block# ( -- n )
     basic-block get number>> ;
 
@@ -75,25 +56,41 @@ test-builder first [
         basic-block# add-node[ "bold" =style ];
     add ;
 
-: draw-annotated-cfg ( -- )
-    cfg get cfgviz add-gvns add-lvns
-    basic-block# number>string "bb" prepend png ;
+SYMBOL: iteration
+
+: iteration-dir ( -- path )
+    iteration get number>string "gvn-iter" prepend ;
 
-: watch-gvn ( -- )
+: new-iteration ( -- )
+    iteration inc iteration-dir make-directories ;
+
+: draw-annotated-cfg ( -- )
+    iteration-dir [
+        cfg get cfgviz add-gvns add-lvns
+        basic-block# number>string "bb" prepend png
+    ] with-directory ;
+
+: annotate-gvn ( -- )
+    \ value-numbering-iteration
+    [ [ new-iteration ] prepend ] annotate
     \ value-numbering-step
-    [ '[ _ call draw-annotated-cfg ] ] annotate ;
+    [ [ draw-annotated-cfg ] append ] annotate ;
 
 : reset-gvn ( -- )
+    \ value-numbering-iteration reset
     \ value-numbering-step reset ;
 
-: test-gvn ( -- )
-    watch-gvn
-    gvn-test get-global [
-        {
-            value-numbering
-            copy-propagation
-            eliminate-dead-code
-            finalize-cfg
-        } [ watch-pass ] each-index drop
-    ] with-cfg
-    reset-gvn ;
+! Replace compiler.cfg.value-numbering:value-numbering with
+! compiler.cfg.gvn:value-numbering
+
+: gvn-passes ( -- passes )
+    \ optimize-cfg def>> [
+        name>> "value-numbering" =
+    ] split-when [ value-numbering ] join ;
+
+: watch-gvn ( path quot -- )
+    annotate-gvn [
+        gvn-passes passes [
+            0 iteration [ watch-optimizer* ] with-variable
+        ] with-variable
+    ] [ reset-gvn ] [ ] cleanup ;