]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.cfg.ssa.destruction.coalescing: simpler code for setting up the
authorBjörn Lindqvist <bjourne@gmail.com>
Tue, 28 Jul 2015 18:39:51 +0000 (20:39 +0200)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 29 Jul 2015 00:58:28 +0000 (17:58 -0700)
initial leader-map and class-element-map

basis/compiler/cfg/ssa/destruction/coalescing/coalescing-tests.factor
basis/compiler/cfg/ssa/destruction/coalescing/coalescing.factor

index 4eecdb006188fb0ae23be20899c7a6380a70ea96..309cda82c17ddbd1c025b05d2d1c435587f12409 100644 (file)
@@ -1,15 +1,64 @@
 USING: assocs compiler.cfg.def-use compiler.cfg.instructions
-compiler.cfg.ssa.destruction.coalescing compiler.cfg.ssa.destruction.leaders
-cpu.architecture grouping kernel make namespaces random sequences tools.test ;
+compiler.cfg.ssa.destruction.coalescing
+compiler.cfg.ssa.destruction.leaders compiler.cfg.ssa.interference
+compiler.cfg.utilities cpu.architecture grouping kernel make
+namespaces random sequences tools.test ;
 QUALIFIED: sets
 IN: compiler.cfg.ssa.destruction.coalescing.tests
 
-! init-coalescing
+! initial-class-elements
 {
-    H{ { 123 123 } { 77 77 } }
+    H{
+        {
+            77
+            { T{ vreg-info { vreg 77 } { value 77 } { bb "bb2" } } }
+        }
+        {
+            123
+            {
+                T{ vreg-info
+                   { vreg 123 }
+                   { value 123 }
+                   { bb "bb1" }
+                }
+            }
+        }
+    }
 } [
     H{ { 123 "bb1" } { 77 "bb2" } } defs set
-    init-coalescing
+    initial-class-elements
+] unit-test
+
+! initial-leaders
+{
+    H{ { 65 65 } { 99 99 } { 62 62 } { 303 303 } }
+} [
+    {
+        T{ ##load-vector
+           { dst 62 }
+           { val B{ 0 0 0 0 0 0 0 64 0 0 0 0 0 0 52 64 } }
+           { rep double-2-rep }
+        }
+        T{ ##add-vector
+           { dst 65 }
+           { src1 62 }
+           { src2 63 }
+           { rep double-2-rep }
+        }
+        T{ ##allot
+           { dst 99 }
+           { size 24 }
+           { temp 303 }
+        }
+    } insns>cfg initial-leaders
+] unit-test
+
+! init-coalescing
+{
+    H{ { 118 118 } }
+} [
+    { T{ ##phi { dst 118 } { inputs H{ { 4 120 } { 2 119 } } } } } insns>cfg
+    dup compute-defs init-coalescing
     leader-map get
 ] unit-test
 
index 11aeb9afad33e4fb325d25cd485050e05d1c629c..90e0049f930095f28e984d3e6bf76700b932819a 100644 (file)
@@ -14,14 +14,6 @@ SYMBOL: class-element-map
 : value-of ( vreg -- value )
     dup insn-of dup ##tagged>integer? [ nip src>> ] [ drop ] if ;
 
-: init-coalescing ( -- )
-    defs get
-    [ keys unique leader-map set ]
-    [
-        [ [ dup dup value-of ] dip <vreg-info> 1array ] assoc-map
-        class-element-map set
-    ] bi ;
-
 : coalesce-elements ( merged follower leader -- )
     class-element-map get [ delete-at ] [ set-at ] bi-curry bi* ;
 
@@ -50,15 +42,12 @@ M: insn coalesce-insn drop ;
 M: alien-call-insn coalesce-insn drop ;
 
 M: vreg-insn coalesce-insn
-    [ temp-vregs [ leader-map get conjoin ] each ]
-    [
-        [ defs-vregs ] [ uses-vregs ] bi
-        2dup [ empty? not ] both? [
-            [ first ] bi@
-            2dup [ rep-of reg-class-of ] bi@ eq?
-            [ 2array , ] [ 2drop ] if
-        ] [ 2drop ] if
-    ] bi ;
+    [ defs-vregs ] [ uses-vregs ] bi
+    2dup [ empty? not ] both? [
+        [ first ] bi@
+        2dup [ rep-of reg-class-of ] bi@ eq?
+        [ 2array , ] [ 2drop ] if
+    ] [ 2drop ] if ;
 
 M: ##copy coalesce-insn
     [ dst>> ] [ src>> ] bi 2array , ;
@@ -73,7 +62,17 @@ M: ##phi coalesce-insn
     [ dst>> ] [ inputs>> values ] bi zip-scalar
     natural-sort t try-eliminate-copies ;
 
+: initial-leaders ( cfg -- leaders )
+    cfg>insns [ [ defs-vregs ] [ temp-vregs ] bi append ] map concat unique ;
+
+: initial-class-elements ( -- class-elements )
+    defs get [ [ dup dup value-of ] dip <vreg-info> 1array ] assoc-map ;
+
+: init-coalescing ( cfg -- )
+    initial-leaders leader-map set
+    initial-class-elements class-element-map set ;
+
 : coalesce-cfg ( cfg -- )
-    init-coalescing
+    dup init-coalescing
     cfg>insns-rpo [ [ coalesce-insn ] each ] V{ } make
     f try-eliminate-copies ;