]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/compiler/cfg/linear-scan/live-intervals/live-intervals.factor
use reject instead of [ ... not ] filter.
[factor.git] / basis / compiler / cfg / linear-scan / live-intervals / live-intervals.factor
index ad4ab4fe16390ae26fa027b3f40a1acd3e84058a..97211a91523f55a2324f7c1d230fda4251c6feec 100644 (file)
@@ -1,15 +1,10 @@
 ! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: namespaces kernel assocs accessors locals sequences math
-math.order fry combinators binary-search
-compiler.cfg.instructions
-compiler.cfg.registers
-compiler.cfg.def-use
-compiler.cfg.liveness
-compiler.cfg.linearization
-compiler.cfg.ssa.destruction.leaders
-compiler.cfg
-cpu.architecture ;
+USING: accessors assocs binary-search combinators
+compiler.cfg.def-use compiler.cfg.instructions
+compiler.cfg.linearization compiler.cfg.liveness
+compiler.cfg.registers compiler.cfg.ssa.destruction.leaders cpu.architecture
+fry kernel locals math math.intervals math.order namespaces sequences ;
 IN: compiler.cfg.linear-scan.live-intervals
 
 TUPLE: live-range from to ;
@@ -96,7 +91,6 @@ M: live-interval-state covers? ( insn# live-interval -- ? )
 
 SYMBOLS: from to ;
 
-! Mapping from vreg to live-interval
 SYMBOL: live-intervals
 
 : live-interval ( vreg -- live-interval )
@@ -165,12 +159,10 @@ M: hairy-clobber-insn compute-live-intervals* ( insn -- )
         [ live-interval add-range ] 2with each
     ] if ;
 
-! A location where all registers have to be spilled
 TUPLE: sync-point n keep-dst? ;
 
 C: <sync-point> sync-point
 
-! Sequence of sync points
 SYMBOL: sync-points
 
 GENERIC: compute-sync-points* ( insn -- )
@@ -184,20 +176,18 @@ M: clobber-insn compute-sync-points*
 M: insn compute-sync-points* drop ;
 
 : compute-live-intervals-step ( bb -- )
-    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 ;
+    {
+        [ block-from from set ]
+        [ block-to to set ]
+        [ handle-live-out ]
+        [
+            instructions>> <reversed> [
+                [ compute-live-intervals* ]
+                [ compute-sync-points* ]
+                bi
+            ] each
+        ]
+    } cleave ;
 
 : init-live-intervals ( -- )
     H{ } clone live-intervals set
@@ -213,8 +203,6 @@ ERROR: bad-live-interval live-interval ;
     dup start>> -1 = [ bad-live-interval ] [ drop ] if ;
 
 : finish-live-intervals ( live-intervals -- seq )
-    ! Since live intervals are computed in a backward order, we have
-    ! to reverse some sequences, and compute the start and end.
     values dup [
         {
             [ [ { } like reverse! ] change-ranges drop ]
@@ -226,7 +214,8 @@ ERROR: bad-live-interval live-interval ;
 
 : compute-live-intervals ( cfg -- live-intervals sync-points )
     init-live-intervals
-    linearization-order <reversed> [ compute-live-intervals-step ] each
+    linearization-order <reversed> [ kill-block?>> ] reject
+    [ compute-live-intervals-step ] each
     live-intervals get finish-live-intervals
     sync-points get ;