]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.cfg.linear-scan.allocation.state: set spill-area-size/align when the cfg...
authorBjörn Lindqvist <bjourne@gmail.com>
Mon, 13 Apr 2015 03:27:09 +0000 (05:27 +0200)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 29 Apr 2015 16:31:57 +0000 (09:31 -0700)
basis/compiler/cfg/cfg-docs.factor
basis/compiler/cfg/cfg-tests.factor
basis/compiler/cfg/cfg.factor
basis/compiler/cfg/linear-scan/allocation/state/state-tests.factor
basis/compiler/cfg/linear-scan/allocation/state/state.factor

index 30e30f89e6edd1243074c58147d421f9626cb32b..a0a82bf2f20253c1bcd6b453ba1448b382a60fdb 100644 (file)
@@ -19,7 +19,7 @@ HELP: <basic-block>
 
 HELP: <cfg>
 { $values { "entry" basic-block } { "word" word } { "label" "label" } { "cfg" cfg } }
-{ $description "Constructor for " { $link cfg } "." } ;
+{ $description "Constructor for " { $link cfg } ". " { $slot "spill-area-size" } " and " { $slot "spill-area-align" } " are set to default values." } ;
 
 HELP: cfg
 { $class-description
index c99f1a7274afe669484907b15f016bfecdebad55..7da21290bcc1b7ba323ae166b12bb091fcc81be9 100644 (file)
@@ -1,10 +1,17 @@
-USING: accessors compiler.cfg kernel tools.test ;
+USING: accessors combinators compiler.cfg kernel layouts tools.test ;
 IN: compiler.cfg.tests
 
 {
     "word"
     "label"
+    0
+    t
 } [
     "word" "label" <basic-block> <cfg>
-    [ word>> ] [ label>> ] bi
+    {
+        [ word>> ]
+        [ label>> ]
+        [ spill-area-size>> ]
+        [ spill-area-align>> cell = ]
+    } cleave
 ] unit-test
index a5e056d455a258fa1b1291cebdd36688e26c9cdb..85c91bf41325df8fe7eed2023fe1521fa31faf51 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel math namespaces vectors ;
+USING: accessors kernel layouts math namespaces vectors ;
 IN: compiler.cfg
 
 TUPLE: basic-block < identity-tuple
@@ -20,18 +20,24 @@ number
 
 M: basic-block hashcode* nip id>> ;
 
-TUPLE: cfg { entry basic-block } word label
-spill-area-size spill-area-align
-stack-frame
-frame-pointer?
-post-order linear-order
-predecessors-valid? dominance-valid? loops-valid? ;
+TUPLE: cfg
+    { entry basic-block }
+    word
+    label
+    { spill-area-size integer }
+    { spill-area-align integer }
+    stack-frame
+    frame-pointer?
+    post-order linear-order
+    predecessors-valid? dominance-valid? loops-valid? ;
 
 : <cfg> ( word label entry -- cfg )
     cfg new
         swap >>entry
         swap >>label
-        swap >>word ;
+        swap >>word
+        0 >>spill-area-size
+        cell >>spill-area-align ;
 
 : cfg-changed ( cfg -- )
     f >>post-order
index d798fbc612d027143b3c74c07a3b4e970b03edde..7df8cb1f622d55c3e5afb75c1c01d3b9b4850beb 100644 (file)
@@ -1,7 +1,7 @@
-USING: combinators.extras compiler.cfg compiler.cfg.instructions
+USING: accessors combinators.extras compiler.cfg compiler.cfg.instructions
 compiler.cfg.linear-scan.allocation.state
-compiler.cfg.linear-scan.live-intervals cpu.architecture
-cpu.x86.assembler.operands heaps kernel namespaces system tools.test ;
+compiler.cfg.linear-scan.live-intervals compiler.cfg.utilities cpu.architecture
+cpu.x86.assembler.operands heaps kernel layouts namespaces system tools.test ;
 IN: compiler.cfg.linear-scan.allocation.state.tests
 
 ! add-active
@@ -47,6 +47,12 @@ cpu x86.64? [
     ] unit-test
 ] when
 
+! align-spill-area
+{ t } [
+    3 f f { } 0 insns>block <cfg> [ align-spill-area ] keep
+    spill-area-align>> cell =
+] unit-test
+
 {
     T{ spill-slot f 0 }
     T{ spill-slot f 8 }
index d1a6c873bc552e65da327ed9b47648e7f087bcbe..7b62574d7fd099bfe186fc3cea2545990ee860e1 100644 (file)
@@ -3,7 +3,7 @@
 USING: accessors arrays assocs combinators compiler.cfg
 compiler.cfg.instructions
 compiler.cfg.linear-scan.live-intervals compiler.cfg.registers
-cpu.architecture fry heaps kernel layouts linked-assocs math
+cpu.architecture fry heaps kernel linked-assocs math
 math.order namespaces sequences ;
 FROM: assocs => change-at ;
 IN: compiler.cfg.linear-scan.allocation.state
@@ -121,14 +121,14 @@ ERROR: register-already-used live-interval ;
     [ swap [ align dup ] [ + ] bi ] change-spill-area-size drop
     <spill-slot> ;
 
-: align-spill-area ( align -- )
-    cfg get [ max ] change-spill-area-align drop ;
+: align-spill-area ( align cfg -- )
+    [ max ] change-spill-area-align drop ;
 
 SYMBOL: spill-slots
 
 : assign-spill-slot ( coalesced-vreg rep -- spill-slot )
     rep-size
-    [ align-spill-area ]
+    [ cfg get align-spill-area ]
     [ spill-slots get [ nip next-spill-slot ] 2cache ]
     bi ;
 
@@ -141,7 +141,6 @@ SYMBOL: spill-slots
     [ V{ } clone ] reg-class-assoc active-intervals set
     [ V{ } clone ] reg-class-assoc inactive-intervals set
     V{ } clone handled-intervals set
-    cfg get 0 >>spill-area-size cell >>spill-area-align drop
     H{ } clone spill-slots set
     -1 progress set ;