compiler.*: use block>cfg and insns>block in many tests instead of wordier code

db4
Björn Lindqvist 2014-11-07 19:02:14 +01:00 committed by Doug Coleman
parent c8a022423e
commit 96396cb3ad
21 changed files with 70 additions and 88 deletions

View File

@ -1,4 +1,4 @@
USING: accessors assocs compiler.cfg
USING: accessors assocs compiler.cfg.utilities compiler.cfg
compiler.cfg.branch-splitting compiler.cfg.debugger
compiler.cfg.predecessors compiler.cfg.rpo compiler.cfg.instructions fry kernel
tools.test namespaces sequences vectors ;
@ -18,7 +18,7 @@ IN: compiler.cfg.branch-splitting.tests
check-predecessors ;
: test-branch-splitting ( -- )
cfg new 0 get >>entry check-branch-splitting ;
0 get block>cfg check-branch-splitting ;
V{ T{ ##branch } } 0 test-bb
@ -82,4 +82,4 @@ V{ T{ ##branch } } 2 test-bb
1 2 edge
[ ] [ test-branch-splitting ] unit-test
[ ] [ test-branch-splitting ] unit-test

View File

@ -1,11 +1,10 @@
USING: compiler.cfg.copy-prop tools.test namespaces kernel
compiler.cfg.debugger compiler.cfg accessors
compiler.cfg.registers compiler.cfg.instructions
cpu.architecture ;
USING: accessors compiler.cfg compiler.cfg.copy-prop compiler.cfg.debugger
compiler.cfg.instructions compiler.cfg.registers compiler.cfg.utilities
cpu.architecture kernel namespaces tools.test ;
IN: compiler.cfg.copy-prop.tests
: test-copy-propagation ( -- )
cfg new 0 get >>entry copy-propagation drop ;
0 get block>cfg copy-propagation drop ;
! Simple example
V{

View File

@ -1,14 +1,11 @@
! Copyright (C) 2009 Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
USING: tools.test compiler.cfg kernel accessors compiler.cfg.dce
compiler.cfg.instructions compiler.cfg.registers cpu.architecture ;
USING: accessors kernel compiler.cfg compiler.cfg.dce compiler.cfg.instructions
compiler.cfg.registers compiler.cfg.utilities cpu.architecture tools.test ;
IN: compiler.cfg.dce.tests
: test-dce ( insns -- insns' )
<basic-block> swap >>instructions
cfg new swap >>entry
eliminate-dead-code
entry>> instructions>> ;
insns>cfg eliminate-dead-code entry>> instructions>> ;
[ V{
T{ ##load-integer { dst 1 } { val 8 } }

View File

@ -100,8 +100,7 @@ M: rs-loc pprint* \ R pprint-loc ;
] each-phi ;
: test-bb ( insns n -- )
[ <basic-block> swap >>number swap >>instructions dup ] keep set
resolve-phis ;
[ insns>block dup ] keep set resolve-phis ;
: edge ( from to -- )
[ get ] bi@ 1vector >>successors drop ;

View File

@ -1,13 +1,9 @@
! Copyright (C) 2009 Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel tools.test accessors vectors sequences namespaces
arrays
cpu.architecture
compiler.cfg.def-use
compiler.cfg
compiler.cfg.debugger
compiler.cfg.instructions
compiler.cfg.registers ;
arrays compiler.cfg.def-use compiler.cfg compiler.cfg.debugger
compiler.cfg.instructions compiler.cfg.registers compiler.cfg.utilities
cpu.architecture ;
IN: compiler.cfg.def-use.tests
V{
@ -32,5 +28,5 @@ V{
4 6 edge
5 6 edge
cfg new 1 get >>entry 0 set
1 get block>cfg 0 set
[ ] [ 0 get compute-defs ] unit-test

View File

@ -1,11 +1,10 @@
USING: tools.test sequences vectors namespaces kernel accessors assocs sets
math.ranges arrays compiler.cfg compiler.cfg.dominance compiler.cfg.debugger
compiler.cfg.predecessors ;
compiler.cfg.predecessors compiler.cfg.utilities ;
IN: compiler.cfg.dominance.tests
: test-dominance ( -- )
cfg new 0 get >>entry
needs-dominance drop ;
0 get block>cfg needs-dominance drop ;
! Example with no back edges
V{ } 0 test-bb

View File

@ -4,7 +4,7 @@ compiler.cfg.registers compiler.cfg.instructions compiler.cfg
compiler.cfg.predecessors compiler.cfg.rpo cpu.architecture
tools.test kernel vectors namespaces accessors sequences alien
memory classes make combinators.short-circuit byte-arrays
compiler.cfg.comparisons ;
compiler.cfg.comparisons compiler.cfg.utilities ;
IN: compiler.cfg.gc-checks.tests
[ { } ] [
@ -84,7 +84,7 @@ IN: compiler.cfg.gc-checks.tests
: test-gc-checks ( -- )
H{ } clone representations set
cfg new 0 get >>entry cfg set ;
0 get block>cfg cfg set ;
V{
T{ ##inc-d f 3 }

View File

@ -77,7 +77,7 @@ M: ##box-displaced-alien allocation-size* drop 5 cells ;
] each ;
: make-blocks ( insns-seq -- bbs )
[ <basic-block> swap >>instructions ] map ;
[ f insns>block ] map ;
: <gc-call> ( -- bb )
<basic-block>

View File

@ -19,7 +19,8 @@ compiler.cfg.linear-scan.allocation
compiler.cfg.linear-scan.allocation.state
compiler.cfg.linear-scan.allocation.splitting
compiler.cfg.linear-scan.allocation.spilling
compiler.cfg.linear-scan.debugger ;
compiler.cfg.linear-scan.debugger
compiler.cfg.utilities ;
FROM: namespaces => set ;
IN: compiler.cfg.linear-scan.tests
@ -37,7 +38,7 @@ V{
} 0 test-bb
: test-live-intervals ( -- )
cfg new 0 get >>entry
0 get block>cfg
[ cfg set ] [ number-instructions ] [ compute-live-intervals ] tri
2drop ;

View File

@ -1,5 +1,5 @@
USING: compiler.cfg.debugger compiler.cfg compiler.cfg.linearization
kernel accessors sequences sets tools.test namespaces ;
compiler.cfg.utilities kernel accessors sequences sets tools.test namespaces ;
IN: compiler.cfg.linearization.tests
V{ } 0 test-bb
@ -11,4 +11,4 @@ V{ } 2 test-bb
0 { 1 1 } edges
1 2 edge
[ t ] [ cfg new 0 get >>entry linearization-order [ id>> ] map all-unique? ] unit-test
[ t ] [ 0 get block>cfg linearization-order [ id>> ] map all-unique? ] unit-test

View File

@ -1,14 +1,13 @@
USING: compiler.cfg.liveness
compiler.cfg.debugger compiler.cfg.instructions
compiler.cfg.predecessors compiler.cfg.registers compiler.cfg
compiler.cfg compiler.cfg.debugger compiler.cfg.instructions
compiler.cfg.predecessors compiler.cfg.registers compiler.cfg.utilities
cpu.architecture accessors namespaces sequences kernel
tools.test vectors alien math compiler.cfg.comparisons
cpu.x86.assembler.operands assocs ;
IN: compiler.cfg.liveness.tests
: test-liveness ( -- )
cfg new 1 get >>entry
compute-live-sets ;
1 get block>cfg compute-live-sets ;
! Sanity check...
@ -197,7 +196,7 @@ V{
5 6 edge
6 7 edge
[ ] [ cfg new 0 get >>entry dup cfg set compute-live-sets ] unit-test
[ ] [ 0 get block>cfg dup cfg set compute-live-sets ] unit-test
[ t ] [ 0 get live-in assoc-empty? ] unit-test
@ -236,7 +235,7 @@ H{
{ 1 int-rep }
} representations set
[ ] [ cfg new 0 get >>entry dup cfg set compute-live-sets ] unit-test
[ ] [ 0 get block>cfg dup cfg set compute-live-sets ] unit-test
[ V{ { 1 0 } } ] [ 1 get instructions>> 2 swap nth gc-map>> derived-roots>> ] unit-test
@ -244,4 +243,4 @@ H{
[ V{ { 1 0 } } ] [ 1 get instructions>> 4 swap nth gc-map>> derived-roots>> ] unit-test
[ { 0 } ] [ 1 get instructions>> 4 swap nth gc-map>> gc-roots>> ] unit-test
[ { 0 } ] [ 1 get instructions>> 4 swap nth gc-map>> gc-roots>> ] unit-test

View File

@ -1,7 +1,6 @@
USING: compiler.cfg compiler.cfg.loop-detection
compiler.cfg.predecessors
compiler.cfg.debugger
tools.test kernel namespaces accessors ;
USING: compiler.cfg compiler.cfg.loop-detection compiler.cfg.debugger
compiler.cfg.predecessors compiler.cfg.utilities tools.test kernel namespaces
accessors ;
IN: compiler.cfg.loop-detection.tests
V{ } 0 test-bb
@ -11,7 +10,8 @@ V{ } 2 test-bb
0 { 1 2 } edges
2 0 edge
: test-loop-detection ( -- ) cfg new 0 get >>entry needs-loops drop ;
: test-loop-detection ( -- )
0 get block>cfg needs-loops drop ;
[ ] [ test-loop-detection ] unit-test

View File

@ -3,11 +3,12 @@ compiler.cfg.instructions
compiler.cfg.registers
compiler.cfg.debugger
compiler.cfg.representations.coalescing
compiler.cfg.utilities
tools.test ;
IN: compiler.cfg.representations.coalescing.tests
: test-scc ( -- )
cfg new 0 get >>entry compute-components ;
0 get block>cfg compute-components ;
V{
T{ ##prologue }

View File

@ -4,7 +4,7 @@ compiler.cfg.representations.preferred cpu.architecture kernel
namespaces tools.test sequences arrays system literals layouts
math compiler.constants compiler.cfg.representations.conversion
compiler.cfg.representations.rewrite
compiler.cfg.comparisons
compiler.cfg.comparisons compiler.cfg.utilities
make ;
FROM: alien.c-types => char ;
IN: compiler.cfg.representations
@ -52,7 +52,7 @@ H{ } clone representations set
] unit-test
: test-representations ( -- )
cfg new 0 get >>entry dup cfg set select-representations drop ;
0 get block>cfg dup cfg set select-representations drop ;
! Make sure cost calculation isn't completely wrong
V{

View File

@ -1,7 +1,8 @@
USING: accessors compiler.cfg compiler.cfg.debugger
compiler.cfg.dominance compiler.cfg.instructions
compiler.cfg.predecessors compiler.cfg.ssa.construction assocs
compiler.cfg.registers cpu.architecture kernel namespaces sequences
compiler.cfg.registers compiler.cfg.utilities cpu.architecture kernel
namespaces sequences
tools.test vectors ;
IN: compiler.cfg.ssa.construction.tests
@ -11,7 +12,7 @@ IN: compiler.cfg.ssa.construction.tests
0 basic-block set-global ;
: test-ssa ( -- )
cfg new 0 get >>entry
0 get block>cfg
dup cfg set
construct-ssa
drop ;
@ -197,4 +198,4 @@ V{
[ V{ } ] [ 5 get instructions>> [ ##phi? ] filter ] unit-test
[ V{ } ] [ 7 get instructions>> [ ##phi? ] filter ] unit-test
[ V{ } ] [ 7 get instructions>> [ ##phi? ] filter ] unit-test

View File

@ -1,12 +1,12 @@
USING: accessors arrays compiler.cfg compiler.cfg.debugger
compiler.cfg.dominance compiler.cfg.predecessors
compiler.cfg.ssa.construction.tdmsc kernel namespaces sequences
tools.test vectors sets ;
compiler.cfg.ssa.construction.tdmsc compiler.cfg.utilities kernel namespaces
sequences sets tools.test vectors ;
FROM: namespaces => set ;
IN: compiler.cfg.ssa.construction.tdmsc.tests
: test-tdmsc ( -- )
cfg new 0 get >>entry dup cfg set
0 get block>cfg dup cfg set
compute-merge-sets ;
V{ } 0 test-bb

View File

@ -5,12 +5,13 @@ compiler.cfg.registers compiler.cfg.predecessors
compiler.cfg.comparisons compiler.cfg.ssa.interference
compiler.cfg.ssa.interference.private
compiler.cfg.ssa.interference.live-ranges
compiler.cfg.utilities
cpu.architecture kernel namespaces tools.test alien.c-types
arrays sequences slots ;
IN: compiler.cfg.ssa.interference.tests
: test-interference ( -- )
cfg new 0 get >>entry
0 get block>cfg
dup compute-live-sets
dup compute-defs
dup compute-insns
@ -358,4 +359,4 @@ V{
[ f ] [ 33 21 test-vregs-intersect? ] unit-test
[ f ] [ 32 21 test-vregs-intersect? ] unit-test
[ f ] [ 32 33 test-vregs-intersect? ] unit-test
[ f ] [ 32 33 test-vregs-intersect? ] unit-test

View File

@ -3,8 +3,8 @@ compiler.cfg.registers compiler.cfg.debugger compiler.cfg.comparisons
cpu.architecture tools.test kernel math combinators.short-circuit
accessors sequences compiler.cfg.predecessors locals compiler.cfg.dce
compiler.cfg.ssa.destruction compiler.cfg.loop-detection
compiler.cfg.representations compiler.cfg assocs vectors arrays
layouts literals namespaces alien compiler.cfg.value-numbering.simd
compiler.cfg.representations compiler.cfg compiler.cfg.utilities assocs vectors
arrays layouts literals namespaces alien compiler.cfg.value-numbering.simd
system ;
QUALIFIED-WITH: alien.c-types c
IN: compiler.cfg.value-numbering.tests
@ -1245,7 +1245,7 @@ cpu x86? [
T{ ##compare-integer-imm f 1 0 0 cc<= }
} value-numbering-step
] unit-test
[
{
T{ ##peek f 0 D 0 }
@ -2747,7 +2747,7 @@ V{
test-diamond
[ ] [
cfg new 0 get >>entry dup cfg set
0 get block>cfg dup cfg set
value-numbering
select-representations
destruct-ssa drop
@ -2787,7 +2787,7 @@ V{
test-diamond
[ ] [
cfg new 0 get >>entry
0 get block>cfg
value-numbering
eliminate-dead-code
drop
@ -2856,7 +2856,7 @@ V{
4 5 edge
[ ] [
cfg new 0 get >>entry
0 get block>cfg
value-numbering eliminate-dead-code drop
] unit-test

View File

@ -2,8 +2,8 @@ USING: accessors assocs compiler compiler.cfg
compiler.cfg.debugger compiler.cfg.instructions
compiler.cfg.registers compiler.cfg.linear-scan
compiler.cfg.ssa.destruction compiler.cfg.build-stack-frame
compiler.codegen compiler.units cpu.architecture hashtables
kernel namespaces sequences tools.test vectors words layouts
compiler.cfg.utilities compiler.codegen compiler.units cpu.architecture
hashtables kernel namespaces sequences tools.test vectors words layouts
literals math arrays alien.c-types alien.syntax math.private ;
IN: compiler.tests.low-level-ir
@ -13,7 +13,7 @@ IN: compiler.tests.low-level-ir
[ associate >alist t t modify-code-heap ] keep ;
: compile-test-cfg ( -- word )
cfg new 0 get >>entry
0 get block>cfg
dup cfg set
dup fake-representations
destruct-ssa

View File

@ -2,11 +2,10 @@ USING: compiler.cfg.gvn compiler.cfg.instructions
compiler.cfg.registers compiler.cfg.debugger
compiler.cfg.comparisons cpu.architecture tools.test kernel
math combinators.short-circuit accessors sequences
compiler.cfg.predecessors locals compiler.cfg.dce
compiler.cfg.predecessors compiler.cfg.utilities locals compiler.cfg.dce
compiler.cfg.ssa.destruction compiler.cfg.loop-detection
compiler.cfg.representations compiler.cfg assocs vectors arrays
layouts literals namespaces alien compiler.cfg.gvn.simd system
;
layouts literals namespaces alien compiler.cfg.gvn.simd system ;
QUALIFIED-WITH: alien.c-types c
IN: compiler.cfg.gvn.tests
@ -28,7 +27,7 @@ IN: compiler.cfg.gvn.tests
: value-number-bb ( insns -- insns' )
0 test-bb
cfg new 0 get >>entry
0 get block>cfg
value-numbering drop
0 get instructions>> ;
@ -2616,7 +2615,7 @@ cell 8 = [
V{ } 1 test-bb
V{ } 2 test-bb
0 { 1 2 } edges
cfg new 0 get >>entry
0 get block>cfg
value-numbering drop
0 get [ instructions>> ] [ successors>> first number>> 1 - ] bi ;
@ -2800,7 +2799,7 @@ V{
test-diamond
[ ] [
cfg new 0 get >>entry dup cfg set
0 get block>cfg dup cfg set
value-numbering
select-representations
destruct-ssa drop
@ -2839,11 +2838,7 @@ V{
test-diamond
[ ] [
cfg new 0 get >>entry
value-numbering
drop
] unit-test
[ ] [ 0 get block>cfg value-numbering drop ] unit-test
[ t ] [ 1 get successors>> first 3 get eq? ] unit-test
@ -2908,7 +2903,7 @@ V{
4 5 edge
[ ] [
cfg new 0 get >>entry
0 get block>cfg
value-numbering eliminate-dead-code drop
] unit-test
@ -3183,10 +3178,7 @@ V{
test-diamond
[ ] [
cfg new 0 get >>entry
value-numbering drop
] unit-test
[ ] [ 0 get block>cfg value-numbering drop ] unit-test
! First ##load-integer cannot be turned into a ##copy because
! the canonical leader for the value 100 is unavailable, but
@ -3246,10 +3238,7 @@ V{ T{ ##epilogue } T{ ##return } } 5 test-bb
3 2 edge
4 5 edge
[ ] [
cfg new 0 get >>entry
value-numbering eliminate-dead-code drop
] unit-test
[ ] [ 0 get block>cfg value-numbering eliminate-dead-code drop ] unit-test
[ 1 ] [ 1 get instructions>> [ ##load-integer? ] count ] unit-test
[ 1 ] [ 2 get instructions>> [ ##phi? ] count ] unit-test

View File

@ -3,7 +3,7 @@
USING: accessors assocs compiler.cfg compiler.cfg.debugger
compiler.cfg.graphviz compiler.cfg.gvn
compiler.cfg.gvn.expressions compiler.cfg.gvn.graph
compiler.cfg.optimizer continuations formatting graphviz
compiler.cfg.optimizer compiler.cfg.utilities continuations formatting graphviz
graphviz.notation graphviz.render io.directories kernel
math.parser namespaces prettyprint sequences sorting splitting
tools.annotations ;
@ -104,4 +104,4 @@ SYMBOL: iteration
] [ reset-gvn ] [ ] cleanup ;
: watch-gvn-bb ( path insns -- )
0 test-bb cfg new 0 get >>entry watch-gvn-cfg ;
0 test-bb 0 get block>cfg watch-gvn-cfg ;