compiler.cfg.ssa.destruction.coalescing: simpler code for setting up the

initial leader-map and class-element-map
db4
Björn Lindqvist 2015-07-28 20:39:51 +02:00 committed by John Benediktsson
parent 1b6fa50ff2
commit 820207c5b0
2 changed files with 71 additions and 23 deletions

View 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

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