compiler.cfg.linear-scan.allocation.state: set spill-area-size/align when the cfg tuple is created

db4
Björn Lindqvist 2015-04-13 05:27:09 +02:00 committed by John Benediktsson
parent d486de889d
commit 5cd44dc07c
5 changed files with 37 additions and 19 deletions

View 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

View 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

View 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

View 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 }

View 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 ;