compiler.cfg.*: new word reset-vreg-counter, useful for making test writing more convenient

db4
Björn Lindqvist 2015-03-26 14:19:00 +00:00 committed by John Benediktsson
parent 2536943e82
commit 4390561a6e
8 changed files with 21 additions and 33 deletions

View File

@ -248,9 +248,8 @@ IN: compiler.cfg.builder.tests
{ {
{ T{ ##load-integer { dst 78 } { val 0 } } } { T{ ##load-integer { dst 78 } { val 0 } } }
} [ } [
initial-height-state height-state set test-init
77 vreg-counter set-global 77 vreg-counter set-global
H{ } clone replace-mapping set
[ [
T{ #push { literal 0 } { out-d { 8537399 } } } emit-node T{ #push { literal 0 } { out-d { 8537399 } } } emit-node
] { } make ] { } make
@ -260,9 +259,7 @@ IN: compiler.cfg.builder.tests
{ { 1 1 } { 0 0 } } { { 1 1 } { 0 0 } }
H{ { D -1 4 } { D 0 4 } } H{ { D -1 4 } { D 0 4 } }
} [ } [
0 vreg-counter set-global test-init
initial-height-state height-state set
H{ } clone replace-mapping set
4 D 0 replace-loc 4 D 0 replace-loc
T{ #shuffle T{ #shuffle
{ mapping { { 2 4 } { 3 4 } } } { mapping { { 2 4 } { 3 4 } } }

View File

@ -18,12 +18,10 @@ IN: compiler.cfg.debugger
GENERIC: test-builder ( quot -- cfgs ) GENERIC: test-builder ( quot -- cfgs )
M: callable test-builder M: callable test-builder
0 vreg-counter set-global reset-vreg-counter build-tree optimize-tree gensym build-cfg ;
build-tree optimize-tree gensym build-cfg ;
M: word test-builder M: word test-builder
0 vreg-counter set-global [ reset-vreg-counter build-tree optimize-tree ] keep build-cfg ;
[ build-tree optimize-tree ] keep build-cfg ;
: test-ssa ( quot -- cfgs ) : test-ssa ( quot -- cfgs )
test-builder [ test-builder [

View File

@ -103,8 +103,6 @@ V{
[ ] [ 1 get instructions>> allocation-size 123 <alien> size assert= ] unit-test [ ] [ 1 get instructions>> allocation-size 123 <alien> size assert= ] unit-test
2 vreg-counter set-global
: gc-check? ( bb -- ? ) : gc-check? ( bb -- ? )
instructions>> instructions>>
{ {
@ -119,11 +117,9 @@ V{
T{ ##branch } T{ ##branch }
} = ; } = ;
4 vreg-counter set-global
[ t ] [ <gc-call> gc-call? ] unit-test [ t ] [ <gc-call> gc-call? ] unit-test
30 vreg-counter set-global reset-vreg-counter
V{ V{
T{ ##prologue } T{ ##prologue }

View File

@ -8,6 +8,9 @@ SYMBOL: vreg-counter
: next-vreg ( -- vreg ) : next-vreg ( -- vreg )
vreg-counter counter ; vreg-counter counter ;
: reset-vreg-counter ( -- )
0 vreg-counter set-global ;
SYMBOL: representations SYMBOL: representations
ERROR: bad-vreg vreg ; ERROR: bad-vreg vreg ;

View File

@ -8,8 +8,7 @@ IN: compiler.cfg.ssa.construction.tests
: reset-counters ( -- ) : reset-counters ( -- )
! Reset counters so that results are deterministic w.r.t. hash order ! Reset counters so that results are deterministic w.r.t. hash order
0 vreg-counter set-global reset-vreg-counter 0 basic-block set-global ;
0 basic-block set-global ;
: test-ssa ( -- ) : test-ssa ( -- )
0 get block>cfg 0 get block>cfg

View File

@ -24,8 +24,8 @@ IN: compiler.cfg.stacks.local.tests
{ { 0 4 } { 0 -2 } } height-state>insns { { 0 4 } { 0 -2 } } height-state>insns
] unit-test ] unit-test
{ 30 } [ { 1 } [
29 vreg-counter set-global <bihash> locs>vregs set D 0 loc>vreg test-init D 0 loc>vreg
] unit-test ] unit-test
{ {
@ -34,8 +34,7 @@ IN: compiler.cfg.stacks.local.tests
T{ ##copy { dst 2 } { src 26 } { rep any-rep } } T{ ##copy { dst 2 } { src 26 } { rep any-rep } }
} }
} [ } [
0 vreg-counter set-global <bihash> locs>vregs set test-init { { D 0 25 } { R 0 26 } } stack-changes
{ { D 0 25 } { R 0 26 } } stack-changes
] unit-test ] unit-test
{ 80 } [ { 80 } [
@ -52,8 +51,7 @@ IN: compiler.cfg.stacks.local.tests
{ 0 } [ { 0 } [
V{ } 0 insns>block basic-block set V{ } 0 insns>block basic-block set
begin-stack-analysis begin-local-analysis test-init compute-local-kill-set assoc-size
compute-local-kill-set assoc-size
] unit-test ] unit-test
{ H{ { R -4 R -4 } } } [ { H{ { R -4 R -4 } } } [

View File

@ -4,11 +4,8 @@ tools.test ;
IN: compiler.cfg.stacks.tests IN: compiler.cfg.stacks.tests
: test-init ( -- ) : test-init ( -- )
0 vreg-counter set-global reset-vreg-counter begin-stack-analysis begin-local-analysis
initial-height-state height-state set H{ } clone replace-mapping set ;
H{ } clone replace-mapping set
H{ } clone locs>vregs set
H{ } clone local-peek-set set ;
{ {
H{ { D 1 4 } { D 2 3 } { D 0 5 } } H{ { D 1 4 } { D 2 3 } { D 0 5 } }

View File

@ -532,7 +532,7 @@ TUPLE: myseq { underlying1 byte-array read-only } { underlying2 byte-array read-
! Stupid repro ! Stupid repro
USE: compiler.cfg.registers USE: compiler.cfg.registers
0 vreg-counter set-global reset-vreg-counter
{ fib-count2 } compile { fib-count2 } compile