]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.cfg: now that kill-blocks cannot contain instructions that define vregs...
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Tue, 27 Jul 2010 16:40:31 +0000 (12:40 -0400)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Tue, 27 Jul 2010 16:40:31 +0000 (12:40 -0400)
basis/compiler/cfg/copy-prop/copy-prop.factor
basis/compiler/cfg/def-use/def-use.factor
basis/compiler/cfg/linear-scan/assignment/assignment.factor
basis/compiler/cfg/linear-scan/live-intervals/live-intervals.factor
basis/compiler/cfg/linear-scan/resolve/resolve.factor
basis/compiler/cfg/representations/coalescing/coalescing.factor
basis/compiler/cfg/save-contexts/save-contexts.factor
basis/compiler/cfg/ssa/destruction/destruction.factor
basis/compiler/cfg/ssa/interference/live-ranges/live-ranges.factor

index 29498affc2db7fb65c4aff1f6df9dcccab23228e..e4de7d9880a7be554082792fb8cf4d8a94f99ea6 100644 (file)
@@ -53,8 +53,8 @@ M: insn visit-insn drop ;
 : (collect-copies) ( cfg -- )
     [
         phis get clear-assoc
-        instructions>> [ visit-insn ] each
-    ] each-basic-block ;
+        [ visit-insn ] each
+    ] simple-analysis ;
 
 : collect-copies ( cfg -- )
     H{ } clone copies set
index 99e87b277be16bcbfb8f73e67f72302dce80f8dd..04443db45d4de5cfaa7eb903b82649cb58540cda 100644 (file)
@@ -4,7 +4,7 @@ USING: accessors assocs arrays classes combinators
 compiler.units fry generalizations sequences.generalizations
 generic kernel locals namespaces quotations sequences sets slots
 words compiler.cfg.instructions compiler.cfg.instructions.syntax
-compiler.cfg.rpo ;
+compiler.cfg.rpo compiler.cfg ;
 FROM: namespaces => set ;
 FROM: sets => members ;
 IN: compiler.cfg.def-use
@@ -91,17 +91,17 @@ SYMBOLS: defs insns ;
 : compute-defs ( cfg -- )
     H{ } clone [
         '[
-            dup instructions>> [
+            [ basic-block get ] dip [
                 _ set-def-of
             ] with each
-        ] each-basic-block
+        ] simple-analysis
     ] keep defs set ;
 
 : compute-insns ( cfg -- )
     H{ } clone [
         '[
-            instructions>> [
+            [
                 dup _ set-def-of
             ] each
-        ] each-basic-block
+        ] simple-analysis
     ] keep insns set ;
index cab4438ec9b189ff54ea2073fafdaa16aae71af5..ef02b890f7b17991a27d39d27e88943255fe2d3b 100644 (file)
@@ -158,20 +158,22 @@ M: insn assign-registers-in-insn drop ;
     } cleave ;
 
 :: assign-registers-in-block ( bb -- )
-    bb [
-        [
-            bb begin-block
+    bb kill-block?>> [
+        bb [
             [
-                {
-                    [ insn#>> 1 - prepare-insn ]
-                    [ insn#>> prepare-insn ]
-                    [ assign-registers-in-insn ]
-                    [ , ]
-                } cleave
-            ] each
-            bb compute-live-out
-        ] V{ } make
-    ] change-instructions drop ;
+                bb begin-block
+                [
+                    {
+                        [ insn#>> 1 - prepare-insn ]
+                        [ insn#>> prepare-insn ]
+                        [ assign-registers-in-insn ]
+                        [ , ]
+                    } cleave
+                ] each
+                bb compute-live-out
+            ] V{ } make
+        ] change-instructions drop
+    ] unless ;
 
 : assign-registers ( live-intervals cfg -- )
     [ init-assignment ] dip
index fbe0cd4507be86600267096ed42f7ef17af7221c..41545981c2786f2356b28d46f39cee646f68fbab 100644 (file)
@@ -171,18 +171,20 @@ M: clobber-insn compute-sync-points*
 M: insn compute-sync-points* drop ;
 
 : compute-live-intervals-step ( bb -- )
-    {
-        [ block-from from set ]
-        [ block-to to set ]
-        [ handle-live-out ]
-        [
-            instructions>> <reversed> [
-                [ compute-live-intervals* ]
-                [ compute-sync-points* ]
-                bi
-            ] each
-        ]
-    } cleave ;
+    dup kill-block?>> [ drop ] [
+        {
+            [ block-from from set ]
+            [ block-to to set ]
+            [ handle-live-out ]
+            [
+                instructions>> <reversed> [
+                    [ compute-live-intervals* ]
+                    [ compute-sync-points* ]
+                    bi
+                ] each
+            ]
+        } cleave
+    ] if ;
 
 : init-live-intervals ( -- )
     H{ } clone live-intervals set
index 9d3c91ca18b0a4ab86177e1dedb7260a926c24b2..564c2978f5f587240029e84ae09fbad1a5c34824 100644 (file)
@@ -99,7 +99,9 @@ SYMBOL: temp
     2dup compute-mappings perform-mappings ;
 
 : resolve-block-data-flow ( bb -- )
-    dup successors>> [ resolve-edge-data-flow ] with each ;
+    dup kill-block?>> [ drop ] [
+        dup successors>> [ resolve-edge-data-flow ] with each
+    ] if ;
 
 : resolve-data-flow ( cfg -- )
     needs-predecessors
index 6e31e82201d10bcc532efc8ef736ebbd2ec21ce8..2caa485045649ddeb13bd9b2ba612b4fd42d0d36 100644 (file)
@@ -11,10 +11,10 @@ SYMBOL: components
 
 : init-components ( cfg components -- )
     '[
-        instructions>> [
+        [
             defs-vregs [ _ add-atom ] each
         ] each
-    ] each-basic-block ;
+    ] simple-analysis ;
 
 GENERIC# visit-insn 1 ( insn disjoint-set -- )
 
@@ -28,10 +28,10 @@ M: insn visit-insn 2drop ;
 
 : merge-components ( cfg components -- )
     '[
-        instructions>> [
+        [
             _ visit-insn
         ] each
-    ] each-basic-block ;
+    ] simple-analysis ;
 
 : compute-components ( cfg -- )
     <disjoint-set>
index 57691f1a4eb1c150403eb846effc143d31355d5d..3e42c51bc5cb0c7db614317226bd495240aaa3d1 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2009, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors compiler.cfg.instructions compiler.cfg.registers
-compiler.cfg.rpo cpu.architecture kernel sequences vectors ;
+compiler.cfg.rpo cpu.architecture kernel sequences vectors
+combinators.short-circuit ;
 IN: compiler.cfg.save-contexts
 
 ! Insert context saves.
@@ -14,7 +15,10 @@ M: gc-map-insn needs-save-context? drop t ;
 M: insn needs-save-context? drop f ;
 
 : bb-needs-save-context? ( insn -- ? )
-    instructions>> [ needs-save-context? ] any? ;
+    {
+        [ kill-block?>> not ]
+        [ instructions>> [ needs-save-context? ] any? ]
+    } 1&& ;
 
 GENERIC: modifies-context? ( insn -- ? )
 
index bd5a84afc7e2e01c201a0b6c6f8e21ccc4f59b4e..197093e5ae47bd834661b4b70203f587b8bbbf4a 100644 (file)
@@ -103,12 +103,9 @@ M: ##phi prepare-insn
     [ dst>> ] [ inputs>> values ] bi
     [ maybe-eliminate-copy ] with each ;
 
-: prepare-block ( bb -- )
-    instructions>> [ prepare-insn ] each ;
-
 : prepare-coalescing ( cfg -- )
     init-coalescing
-    [ prepare-block ] each-basic-block ;
+    [ [ prepare-insn ] each ] simple-analysis ;
 
 : process-copies ( -- )
     copies get [ maybe-eliminate-copy ] assoc-each ;
index d301b14996281620941580618459e623be6884b9..ffbbf8739f20e40247be5beb27c2b00f725ce130 100644 (file)
@@ -38,13 +38,12 @@ M: insn record-insn
 
 SYMBOLS: def-indices kill-indices ;
 
-: compute-local-live-ranges ( bb -- )
+: compute-local-live-ranges ( insns -- )
     H{ } clone local-def-indices set
     H{ } clone local-kill-indices set
-    [ instructions>> [ swap record-insn ] each-index ]
-    [ [ local-def-indices get ] dip def-indices get set-at ]
-    [ [ local-kill-indices get ] dip kill-indices get set-at ]
-    tri ;
+    [ swap record-insn ] each-index
+    local-def-indices get basic-block get def-indices get set-at
+    local-kill-indices get basic-block get kill-indices get set-at ;
 
 PRIVATE>
 
@@ -53,7 +52,7 @@ PRIVATE>
 
     H{ } clone def-indices set
     H{ } clone kill-indices set
-    [ compute-local-live-ranges ] each-basic-block ;
+    [ compute-local-live-ranges ] simple-analysis ;
 
 : def-index ( vreg bb -- n )
     def-indices get at at ;