compiler.cfg.*: putting test-init in compiler.cfg.stacks.tests didn't work, put new word cfg-unit-test in compiler.test

db4
Björn Lindqvist 2015-03-26 22:46:37 +00:00 committed by John Benediktsson
parent 4390561a6e
commit b983053130
5 changed files with 47 additions and 52 deletions

View File

@ -1,5 +1,5 @@
USING: alien.c-types compiler.cfg.builder.alien compiler.cfg.instructions USING: alien.c-types compiler.cfg.builder.alien compiler.cfg.instructions
compiler.cfg.registers compiler.cfg.stacks.local compiler.cfg.stacks.tests compiler.cfg.registers compiler.cfg.stacks.local compiler.test
cpu.architecture kernel make namespaces tools.test ; cpu.architecture kernel make namespaces tools.test ;
IN: compiler.cfg.builder.alien.tests IN: compiler.cfg.builder.alien.tests
@ -8,6 +8,5 @@ IN: compiler.cfg.builder.alien.tests
{ { int-rep f f } { int-rep f f } } { { int-rep f f } { int-rep f f } }
V{ T{ ##unbox-any-c-ptr { dst 2 } { src 1 } } } V{ T{ ##unbox-any-c-ptr { dst 2 } { src 1 } } }
} [ } [
test-init
[ { c-string int } unbox-parameters ] V{ } make [ { c-string int } unbox-parameters ] V{ } make
] unit-test ] cfg-unit-test

View File

@ -3,11 +3,11 @@ combinators.short-circuit compiler.cfg compiler.cfg.builder compiler.cfg.checker
compiler.cfg.debugger compiler.cfg.instructions compiler.cfg.optimizer compiler.cfg.debugger compiler.cfg.instructions compiler.cfg.optimizer
compiler.cfg.predecessors compiler.cfg.registers compiler.cfg.representations compiler.cfg.predecessors compiler.cfg.registers compiler.cfg.representations
compiler.cfg.rpo compiler.cfg.stacks compiler.cfg.stacks.local compiler.cfg.rpo compiler.cfg.stacks compiler.cfg.stacks.local
compiler.cfg.stacks.tests compiler.cfg.utilities compiler.tree compiler.cfg.utilities compiler.test compiler.tree compiler.tree.builder
compiler.tree.builder compiler.tree.optimizer fry hashtables kernel compiler.tree.optimizer fry hashtables kernel kernel.private locals make math
kernel.private locals make math math.partial-dispatch math.private namespaces math.partial-dispatch math.private namespaces prettyprint sbufs sequences
prettyprint sbufs sequences sequences.private slots.private strings sequences.private slots.private strings strings.private tools.test vectors
strings.private tools.test vectors words ; words ;
FROM: alien.c-types => int ; FROM: alien.c-types => int ;
IN: compiler.cfg.builder.tests IN: compiler.cfg.builder.tests
@ -248,18 +248,16 @@ IN: compiler.cfg.builder.tests
{ {
{ T{ ##load-integer { dst 78 } { val 0 } } } { T{ ##load-integer { dst 78 } { val 0 } } }
} [ } [
test-init
77 vreg-counter set-global 77 vreg-counter set-global
[ [
T{ #push { literal 0 } { out-d { 8537399 } } } emit-node T{ #push { literal 0 } { out-d { 8537399 } } } emit-node
] { } make ] { } make
] unit-test ] cfg-unit-test
{ {
{ { 1 1 } { 0 0 } } { { 1 1 } { 0 0 } }
H{ { D -1 4 } { D 0 4 } } H{ { D -1 4 } { D 0 4 } }
} [ } [
test-init
4 D 0 replace-loc 4 D 0 replace-loc
T{ #shuffle T{ #shuffle
{ mapping { { 2 4 } { 3 4 } } } { mapping { { 2 4 } { 3 4 } } }
@ -268,46 +266,42 @@ IN: compiler.cfg.builder.tests
} emit-node } emit-node
height-state get height-state get
replace-mapping get replace-mapping get
] unit-test ] cfg-unit-test
{ 1 } [ { 1 } [
V{ } 0 insns>block basic-block set V{ } 0 insns>block basic-block set init-cfg-test
begin-stack-analysis begin-local-analysis
V{ } 1 insns>block [ emit-loop-call ] V{ } make drop V{ } 1 insns>block [ emit-loop-call ] V{ } make drop
basic-block get successors>> length basic-block get successors>> length
] unit-test ] unit-test
! emit-loop-call ! emit-loop-call
{ "bar" } [ { "bar" } [
V{ } "foo" insns>block basic-block set V{ } "foo" insns>block basic-block set init-cfg-test
begin-stack-analysis begin-local-analysis [ [ V{ } "bar" insns>block emit-loop-call ] V{ } make drop
V{ } "bar" insns>block emit-loop-call basic-block get successors>> first number>>
] V{ } make drop basic-block get successors>> first number>>
] unit-test ] unit-test
! begin-cfg ! begin-cfg
SYMBOL: foo SYMBOL: foo
{ foo } [ { foo } [
begin-stack-analysis \ foo f begin-cfg word>> \ foo f begin-cfg word>>
] unit-test ] cfg-unit-test
! store-shuffle ! store-shuffle
{ {
H{ { D 2 1 } } H{ { D 2 1 } }
} [ } [
test-init
T{ #shuffle { in-d { 7 3 0 } } { out-d { 55 } } { mapping { { 55 3 } } } } T{ #shuffle { in-d { 7 3 0 } } { out-d { 55 } } { mapping { { 55 3 } } } }
emit-node replace-mapping get emit-node replace-mapping get
] unit-test ] cfg-unit-test
{ {
H{ { D -1 1 } { D 0 1 } } H{ { D -1 1 } { D 0 1 } }
} [ } [
test-init
T{ #shuffle T{ #shuffle
{ in-d { 7 } } { in-d { 7 } }
{ out-d { 55 77 } } { out-d { 55 77 } }
{ mapping { { 55 7 } { 77 7 } } } { mapping { { 55 7 } { 77 7 } } }
} emit-node replace-mapping get } emit-node replace-mapping get
] unit-test ] cfg-unit-test

View File

@ -1,22 +1,21 @@
USING: accessors assocs biassocs combinators compiler.cfg USING: accessors assocs biassocs combinators compiler.cfg
compiler.cfg.instructions compiler.cfg.registers compiler.cfg.stacks compiler.cfg.instructions compiler.cfg.registers compiler.cfg.stacks
compiler.cfg.stacks.height compiler.cfg.stacks.local compiler.cfg.stacks.tests compiler.cfg.stacks.height compiler.cfg.stacks.local compiler.cfg.utilities
compiler.cfg.utilities cpu.architecture namespaces kernel tools.test ; compiler.test cpu.architecture namespaces kernel tools.test ;
IN: compiler.cfg.stacks.local.tests IN: compiler.cfg.stacks.local.tests
{ {
{ { 3 3 } { 0 0 } } { { 3 3 } { 0 0 } }
} [ } [
test-init
D 3 inc-stack height-state get D 3 inc-stack height-state get
] unit-test ] cfg-unit-test
{ {
{ { 5 3 } { 0 0 } } { { 5 3 } { 0 0 } }
} [ } [
{ { 2 0 } { 0 0 } } height-state set { { 2 0 } { 0 0 } } height-state set
D 3 inc-stack height-state get D 3 inc-stack height-state get
] unit-test ] cfg-unit-test
{ {
{ T{ ##inc { loc D 4 } } T{ ##inc { loc R -2 } } } { T{ ##inc { loc D 4 } } T{ ##inc { loc R -2 } } }
@ -25,8 +24,8 @@ IN: compiler.cfg.stacks.local.tests
] unit-test ] unit-test
{ 1 } [ { 1 } [
test-init D 0 loc>vreg D 0 loc>vreg
] unit-test ] cfg-unit-test
{ {
{ {
@ -34,24 +33,22 @@ IN: compiler.cfg.stacks.local.tests
T{ ##copy { dst 2 } { src 26 } { rep any-rep } } T{ ##copy { dst 2 } { src 26 } { rep any-rep } }
} }
} [ } [
test-init { { D 0 25 } { R 0 26 } } stack-changes { { D 0 25 } { R 0 26 } } stack-changes
] unit-test ] cfg-unit-test
{ 80 } [ { 80 } [
test-init
80 D 77 replace-loc 80 D 77 replace-loc
D 77 peek-loc D 77 peek-loc
] unit-test ] cfg-unit-test
{ H{ { D -1 40 } } } [ { H{ { D -1 40 } } } [
test-init D 1 inc-stack 40 D 0 replace-loc replace-mapping get
D 1 inc-stack 40 D 0 replace-loc ] cfg-unit-test
replace-mapping get
] unit-test
{ 0 } [ { 0 } [
V{ } 0 insns>block basic-block set V{ } 0 insns>block basic-block set
test-init compute-local-kill-set assoc-size init-cfg-test
compute-local-kill-set assoc-size
] unit-test ] unit-test
{ H{ { R -4 R -4 } } } [ { H{ { R -4 R -4 } } } [

View File

@ -1,28 +1,23 @@
USING: accessors arrays assocs combinators compiler.cfg.registers USING: accessors arrays assocs combinators compiler.cfg.registers
compiler.cfg.stacks compiler.cfg.stacks.local kernel literals namespaces compiler.cfg.stacks compiler.cfg.stacks.local compiler.test kernel literals
tools.test ; namespaces tools.test ;
IN: compiler.cfg.stacks.tests IN: compiler.cfg.stacks.tests
: test-init ( -- )
reset-vreg-counter begin-stack-analysis begin-local-analysis
H{ } clone replace-mapping set ;
{ {
H{ { D 1 4 } { D 2 3 } { D 0 5 } } H{ { D 1 4 } { D 2 3 } { D 0 5 } }
{ { 0 0 } { 0 0 } } { { 0 0 } { 0 0 } }
} [ } [
test-init
{ 3 4 5 } ds-loc store-vregs { 3 4 5 } ds-loc store-vregs
replace-mapping get replace-mapping get
height-state get height-state get
] unit-test ] cfg-unit-test
! load-vregs ! load-vregs
{ {
{ 1 2 3 4 5 6 7 8 } { 1 2 3 4 5 6 7 8 }
} [ } [
test-init 8 ds-loc load-vregs 8 ds-loc load-vregs
] unit-test ] cfg-unit-test
! 2inputs ! 2inputs
{ {
@ -30,5 +25,5 @@ IN: compiler.cfg.stacks.tests
2 2
{ { -2 -2 } { 0 0 } } { { -2 -2 } { 0 0 } }
} [ } [
test-init 2inputs height-state get 2inputs height-state get
] unit-test ] cfg-unit-test

View File

@ -17,3 +17,13 @@ IN: compiler.test
: compiler-test ( name -- ) : compiler-test ( name -- )
"resource:basis/compiler/tests/" ".factor" surround run-test-file ; "resource:basis/compiler/tests/" ".factor" surround run-test-file ;
USING: compiler.cfg.registers compiler.cfg.stacks compiler.cfg.stacks.local
fry namespaces ;
: init-cfg-test ( -- )
reset-vreg-counter begin-stack-analysis begin-local-analysis
H{ } clone replace-mapping set ;
: cfg-unit-test ( result quot -- )
'[ init-cfg-test @ ] unit-test ; inline