Merge branch 'master' of git://factorcode.org/git/factor
commit
397def0ede
|
@ -17,21 +17,19 @@ V{
|
|||
V{
|
||||
T{ ##replace f V int-regs 2 D 0 }
|
||||
} 2 test-bb
|
||||
1 get 2 get 1vector >>successors drop
|
||||
1 2 edge
|
||||
V{
|
||||
T{ ##replace f V int-regs 0 D 0 }
|
||||
} 3 test-bb
|
||||
2 get 3 get 1vector >>successors drop
|
||||
2 3 edge
|
||||
V{ } 4 test-bb
|
||||
V{ } 5 test-bb
|
||||
3 get 4 get 5 get V{ } 2sequence >>successors drop
|
||||
V int-regs 2
|
||||
2 get V int-regs 0 2array
|
||||
3 get V int-regs 1 2array
|
||||
2array \ ##phi new-insn 1vector
|
||||
6 test-bb
|
||||
4 get 6 get 1vector >>successors drop
|
||||
5 get 6 get 1vector >>successors drop
|
||||
3 { 4 5 } edges
|
||||
V{
|
||||
T{ ##phi f V int-regs 2 H{ { 2 V int-regs 0 } { 3 V int-regs 1 } } }
|
||||
} 6 test-bb
|
||||
4 6 edge
|
||||
5 6 edge
|
||||
|
||||
cfg new 1 get >>entry 0 set
|
||||
[ ] [ 0 get compute-def-use ] unit-test
|
||||
[ ] [ 0 get [ compute-defs ] [ compute-uses ] bi ] unit-test
|
||||
|
|
|
@ -92,6 +92,3 @@ SYMBOLS: defs insns uses ;
|
|||
] each
|
||||
] each-basic-block
|
||||
use [ keys ] assoc-map uses set ;
|
||||
|
||||
: compute-def-use ( cfg -- )
|
||||
[ compute-defs ] [ compute-uses ] [ compute-insns ] tri ;
|
||||
|
|
|
@ -97,9 +97,9 @@ M: insn prepare-insn drop ;
|
|||
: destruct-ssa ( cfg -- cfg' )
|
||||
dup cfg-has-phis? [
|
||||
dup construct-cssa
|
||||
compute-ssa-live-sets
|
||||
dup compute-defs
|
||||
dup compute-dominance
|
||||
compute-ssa-live-sets
|
||||
dup compute-live-ranges
|
||||
dup prepare-coalescing
|
||||
process-copies
|
||||
|
|
|
@ -9,7 +9,9 @@ compiler.cfg.ssa.liveness
|
|||
compiler.cfg.debugger
|
||||
compiler.cfg.instructions
|
||||
compiler.cfg.predecessors
|
||||
compiler.cfg.registers ;
|
||||
compiler.cfg.registers
|
||||
compiler.cfg.dominance
|
||||
compiler.cfg.def-use ;
|
||||
IN: compiler.cfg.ssa.liveness
|
||||
|
||||
[ t ] [ { 1 } 1 only? ] unit-test
|
||||
|
@ -17,69 +19,74 @@ IN: compiler.cfg.ssa.liveness
|
|||
[ f ] [ { 2 1 } 1 only? ] unit-test
|
||||
[ f ] [ { 2 } 1 only? ] unit-test
|
||||
|
||||
: test-liveness ( -- )
|
||||
cfg new 0 get >>entry
|
||||
compute-predecessors
|
||||
dup compute-defs
|
||||
dup compute-uses
|
||||
dup compute-dominance
|
||||
precompute-liveness ;
|
||||
|
||||
V{
|
||||
T{ ##peek f V int-regs 0 D 0 }
|
||||
T{ ##replace f V int-regs 0 D 0 }
|
||||
T{ ##replace f V int-regs 1 D 1 }
|
||||
} 1 test-bb
|
||||
} 0 test-bb
|
||||
|
||||
V{
|
||||
T{ ##replace f V int-regs 2 D 0 }
|
||||
} 2 test-bb
|
||||
} 1 test-bb
|
||||
|
||||
V{
|
||||
T{ ##replace f V int-regs 3 D 0 }
|
||||
} 3 test-bb
|
||||
} 2 test-bb
|
||||
|
||||
1 { 2 3 } edges
|
||||
0 { 1 2 } edges
|
||||
|
||||
cfg new 1 get >>entry 4 set
|
||||
|
||||
[ ] [ 4 get compute-predecessors drop ] unit-test
|
||||
[ ] [ 4 get precompute-liveness ] unit-test
|
||||
[ ] [ test-liveness ] unit-test
|
||||
|
||||
[ H{ } ] [ back-edge-targets get ] unit-test
|
||||
[ t ] [ 1 get R_q { 1 2 3 } [ get ] map unique = ] unit-test
|
||||
[ t ] [ 0 get R_q { 0 1 2 } [ get ] map unique = ] unit-test
|
||||
[ t ] [ 1 get R_q { 1 } [ get ] map unique = ] unit-test
|
||||
[ t ] [ 2 get R_q { 2 } [ get ] map unique = ] unit-test
|
||||
[ t ] [ 3 get R_q { 3 } [ get ] map unique = ] unit-test
|
||||
|
||||
: self-T_q ( n -- ? )
|
||||
get [ T_q ] [ 1array unique ] bi = ;
|
||||
|
||||
[ t ] [ 0 self-T_q ] unit-test
|
||||
[ t ] [ 1 self-T_q ] unit-test
|
||||
[ t ] [ 2 self-T_q ] unit-test
|
||||
[ t ] [ 3 self-T_q ] unit-test
|
||||
|
||||
[ f ] [ V int-regs 0 0 get live-in? ] unit-test
|
||||
[ t ] [ V int-regs 1 0 get live-in? ] unit-test
|
||||
[ t ] [ V int-regs 2 0 get live-in? ] unit-test
|
||||
[ t ] [ V int-regs 3 0 get live-in? ] unit-test
|
||||
|
||||
[ f ] [ V int-regs 0 0 get live-out? ] unit-test
|
||||
[ f ] [ V int-regs 1 0 get live-out? ] unit-test
|
||||
[ t ] [ V int-regs 2 0 get live-out? ] unit-test
|
||||
[ t ] [ V int-regs 3 0 get live-out? ] unit-test
|
||||
|
||||
[ f ] [ V int-regs 0 1 get live-in? ] unit-test
|
||||
[ t ] [ V int-regs 1 1 get live-in? ] unit-test
|
||||
[ f ] [ V int-regs 1 1 get live-in? ] unit-test
|
||||
[ t ] [ V int-regs 2 1 get live-in? ] unit-test
|
||||
[ t ] [ V int-regs 3 1 get live-in? ] unit-test
|
||||
[ f ] [ V int-regs 3 1 get live-in? ] unit-test
|
||||
|
||||
[ f ] [ V int-regs 0 1 get live-out? ] unit-test
|
||||
[ f ] [ V int-regs 1 1 get live-out? ] unit-test
|
||||
[ t ] [ V int-regs 2 1 get live-out? ] unit-test
|
||||
[ t ] [ V int-regs 3 1 get live-out? ] unit-test
|
||||
[ f ] [ V int-regs 2 1 get live-out? ] unit-test
|
||||
[ f ] [ V int-regs 3 1 get live-out? ] unit-test
|
||||
|
||||
[ f ] [ V int-regs 0 2 get live-in? ] unit-test
|
||||
[ f ] [ V int-regs 1 2 get live-in? ] unit-test
|
||||
[ t ] [ V int-regs 2 2 get live-in? ] unit-test
|
||||
[ f ] [ V int-regs 3 2 get live-in? ] unit-test
|
||||
[ f ] [ V int-regs 2 2 get live-in? ] unit-test
|
||||
[ t ] [ V int-regs 3 2 get live-in? ] unit-test
|
||||
|
||||
[ f ] [ V int-regs 0 2 get live-out? ] unit-test
|
||||
[ f ] [ V int-regs 1 2 get live-out? ] unit-test
|
||||
[ f ] [ V int-regs 2 2 get live-out? ] unit-test
|
||||
[ f ] [ V int-regs 3 2 get live-out? ] unit-test
|
||||
|
||||
[ f ] [ V int-regs 0 3 get live-in? ] unit-test
|
||||
[ f ] [ V int-regs 1 3 get live-in? ] unit-test
|
||||
[ f ] [ V int-regs 2 3 get live-in? ] unit-test
|
||||
[ t ] [ V int-regs 3 3 get live-in? ] unit-test
|
||||
|
||||
[ f ] [ V int-regs 0 3 get live-out? ] unit-test
|
||||
[ f ] [ V int-regs 1 3 get live-out? ] unit-test
|
||||
[ f ] [ V int-regs 2 3 get live-out? ] unit-test
|
||||
[ f ] [ V int-regs 3 3 get live-out? ] unit-test
|
||||
|
||||
V{ } 0 test-bb
|
||||
V{ } 1 test-bb
|
||||
V{ } 2 test-bb
|
||||
|
@ -89,10 +96,7 @@ V{
|
|||
} 4 test-bb
|
||||
test-diamond
|
||||
|
||||
cfg new 1 get >>entry 5 set
|
||||
|
||||
[ ] [ 5 get compute-predecessors drop ] unit-test
|
||||
[ ] [ 5 get precompute-liveness ] unit-test
|
||||
[ ] [ test-liveness ] unit-test
|
||||
|
||||
[ t ] [ V int-regs 0 1 get live-in? ] unit-test
|
||||
[ t ] [ V int-regs 1 1 get live-in? ] unit-test
|
||||
|
@ -127,7 +131,9 @@ cfg new 1 get >>entry 5 set
|
|||
[ f ] [ V int-regs 2 4 get live-out? ] unit-test
|
||||
|
||||
! This is the CFG in Figure 3 from the paper
|
||||
V{ } 0 test-bb
|
||||
V{ } 1 test-bb
|
||||
0 1 edge
|
||||
V{ } 2 test-bb
|
||||
1 2 edge
|
||||
V{
|
||||
|
@ -159,9 +165,7 @@ V{ } 7 test-bb
|
|||
10 8 edge
|
||||
7 2 edge
|
||||
|
||||
cfg new 1 get >>entry 0 set
|
||||
[ ] [ 0 get compute-predecessors drop ] unit-test
|
||||
[ ] [ 0 get precompute-liveness ] unit-test
|
||||
[ ] [ test-liveness ] unit-test
|
||||
|
||||
[ t ] [ 1 get R_q 1 11 [a,b] [ get ] map unique = ] unit-test
|
||||
[ t ] [ 2 get R_q 2 11 [a,b] [ get ] map unique = ] unit-test
|
||||
|
|
|
@ -80,13 +80,7 @@ SYMBOL: back-edge-targets
|
|||
PRIVATE>
|
||||
|
||||
: precompute-liveness ( cfg -- )
|
||||
! Maybe dominance and def-use should be called before this, separately
|
||||
{
|
||||
[ compute-dominance ]
|
||||
[ compute-def-use ]
|
||||
[ compute-R_q ]
|
||||
[ compute-T_q ]
|
||||
} cleave ;
|
||||
[ compute-R_q ] [ compute-T_q ] bi ;
|
||||
|
||||
<PRIVATE
|
||||
|
||||
|
|
Loading…
Reference in New Issue