diff --git a/basis/compiler/cfg/stacks/height/height-tests.factor b/basis/compiler/cfg/stacks/height/height-tests.factor new file mode 100644 index 0000000000..36e277db61 --- /dev/null +++ b/basis/compiler/cfg/stacks/height/height-tests.factor @@ -0,0 +1,14 @@ +USING: accessors assocs combinators compiler.cfg compiler.cfg.registers +compiler.cfg.stacks compiler.cfg.stacks.height kernel tools.test ; +IN: compiler.cfg.stacks.height.tests + +{ + T{ ds-loc f 4 } + T{ rs-loc f 5 } +} [ + begin-stack-analysis + 3 4 T{ basic-block } + [ record-stack-heights ] + [ D 1 swap untranslate-loc ] + [ R 1 swap untranslate-loc ] tri +] unit-test diff --git a/basis/compiler/cfg/stacks/local/local-tests.factor b/basis/compiler/cfg/stacks/local/local-tests.factor new file mode 100644 index 0000000000..760c18a86d --- /dev/null +++ b/basis/compiler/cfg/stacks/local/local-tests.factor @@ -0,0 +1,36 @@ +USING: accessors assocs biassocs combinators compiler.cfg.instructions +compiler.cfg.registers compiler.cfg.stacks.local cpu.architecture kernel +namespaces sequences tools.test ; +IN: compiler.cfg.stacks.local.tests + +{ T{ current-height f 3 0 3 0 } } [ + current-height new current-height [ + 3 inc-d current-height get + ] with-variable +] unit-test + +{ + { T{ ##inc-d { n 4 } } T{ ##inc-r { n -2 } } } +} [ + T{ current-height { emit-d 4 } { emit-r -2 } } height-changes +] unit-test + +{ 30 } [ + 29 vreg-counter set-global locs>vregs set D 0 loc>vreg +] unit-test + +{ + { + T{ ##copy { dst 1 } { src 25 } { rep any-rep } } + T{ ##copy { dst 2 } { src 26 } { rep any-rep } } + } +} [ + 0 vreg-counter set-global locs>vregs set + { { D 0 25 } { R 0 26 } } stack-changes +] unit-test + +{ 80 } [ + current-height new current-height set + H{ } clone replace-mapping set 80 + D 77 replace-loc D 77 peek-loc +] unit-test diff --git a/basis/compiler/cfg/stacks/stacks-tests.factor b/basis/compiler/cfg/stacks/stacks-tests.factor new file mode 100644 index 0000000000..cbd1a28cdb --- /dev/null +++ b/basis/compiler/cfg/stacks/stacks-tests.factor @@ -0,0 +1,12 @@ +USING: accessors arrays assocs combinators compiler.cfg.registers +compiler.cfg.stacks.local kernel literals namespaces tools.test ; +IN: compiler.cfg.stacks + +{ H{ { D -2 4 } { D -1 3 } { D -3 5 } } } [ + { + ${ current-height current-height new } + ${ replace-mapping H{ } clone } + } [ + { 3 4 5 } ds-store replace-mapping get + ] with-variables +] unit-test