compiler.cfg.stacks.local: simplified code for getting kill locations

char-rename
Björn Lindqvist 2016-09-06 22:46:10 +02:00
parent c640e3b8c1
commit 6f06b51443
3 changed files with 17 additions and 18 deletions

View File

@ -34,8 +34,6 @@ HELP: height-state
}
{ $see-also inc-stack reset-incs } ;
! { $var-description "A two-tuple used to keep track of the heights of the data and retain stacks in a " { $link basic-block } " The idea is that if the stack change instructions are tracked, then multiple changes can be folded into one. The first item is the datastacks current height and queued up height change. The second item is the same for the retain stack." } ;
HELP: height-state>insns
{ $values { "state" sequence } { "insns" sequence } }
{ $description "Converts a " { $link height-state } " tuple to 0-2 stack height change instructions." }
@ -59,11 +57,11 @@ HELP: loc>vreg
HELP: local-kill-set
{ $values
{ "ds-height" integer }
{ "ds-inc" integer }
{ "rs-height" integer }
{ "state" sequence }
{ "set" hash-set }
{ "rs-inc" integer }
}
{ $description "The set of stack locations that was killed." }
{ $description "The set of stack locations that was killed. Locations on a stack are deemed killed if that stacks height is decremented." }
{ $see-also compute-local-kill-set } ;
HELP: local-peek-set

View File

@ -33,14 +33,15 @@ IN: compiler.cfg.stacks.local.tests
{ }
{ }
{ -6 -5 -4 -3 }
{ -7 -6 -5 }
} [
-10 -16 kill-locations
-10 -6 kill-locations
0 0 kill-locations
2 6 kill-locations
6 2 kill-locations
2 4 kill-locations
6 -4 kill-locations
7 -3 kill-locations
] unit-test
! loc>vreg
{ 1 } [
D: 0 loc>vreg

View File

@ -32,14 +32,6 @@ TUPLE: height-state ds-begin rs-begin ds-inc rs-inc ;
dup rs-inc>> '[ _ + ] change-rs-begin
0 >>ds-inc 0 >>rs-inc drop ;
: kill-locations ( begin-height current-height -- seq )
dupd [-] iota [ swap - ] with map ;
: local-kill-set ( ds-begin rs-begin ds-current rs-current -- set )
swapd [ kill-locations ] 2bi@
[ [ <ds-loc> ] map ] [ [ <rs-loc> ] map ] bi*
append >hash-set ;
SYMBOLS: locs>vregs local-peek-set replaces ;
: loc>vreg ( loc -- vreg ) locs>vregs get [ drop next-vreg ] cache ;
@ -66,8 +58,16 @@ SYMBOLS: locs>vregs local-peek-set replaces ;
: record-stack-heights ( ds-height rs-height bb -- )
[ rs-height<< ] keep ds-height<< ;
: kill-locations ( begin inc -- seq )
0 min neg iota [ swap - ] with map ;
: local-kill-set ( ds-begin ds-inc rs-begin rs-inc -- set )
[ kill-locations ] 2bi@
[ [ <ds-loc> ] map ] [ [ <rs-loc> ] map ] bi*
append >hash-set ;
: compute-local-kill-set ( height-state -- set )
{ [ ds-begin>> ] [ rs-begin>> ] [ ds-height ] [ rs-height ] } cleave
{ [ ds-begin>> ] [ ds-inc>> ] [ rs-begin>> ] [ rs-inc>> ] } cleave
local-kill-set ;
: begin-local-analysis ( basic-block -- )