compiler.cfg.*: getting an instruction sequence from a cfg is used in a few tests so let's make a word for it

db4
Björn Lindqvist 2014-11-24 06:25:34 +01:00
parent 22c512788b
commit 4c07d04417
3 changed files with 7 additions and 6 deletions

View File

@ -124,8 +124,7 @@ M: rs-loc pprint* \ R pprint-loc ;
] map concat >hashtable representations set ; ] map concat >hashtable representations set ;
: count-insns ( quot insn-check -- ? ) : count-insns ( quot insn-check -- ? )
[ test-regs [ post-order [ instructions>> ] map concat ] map concat ] dip [ test-regs [ cfg>insns ] map concat ] dip count ; inline
count ; inline
: contains-insn? ( quot insn-check -- ? ) : contains-insn? ( quot insn-check -- ? )
count-insns 0 > ; inline count-insns 0 > ; inline

View File

@ -1,5 +1,5 @@
USING: accessors arrays assocs compiler.cfg compiler.cfg.dependence USING: accessors arrays assocs compiler.cfg compiler.cfg.dependence
compiler.cfg.dependence.tests compiler.cfg.instructions compiler.cfg.test-words compiler.cfg.instructions
compiler.cfg.linearization compiler.cfg.registers compiler.cfg.scheduling compiler.cfg.linearization compiler.cfg.registers compiler.cfg.scheduling
compiler.cfg.utilities grouping kernel math namespaces tools.test random compiler.cfg.utilities grouping kernel math namespaces tools.test random
sequences sets splitting vectors words compiler.cfg.test-words ; sequences sets splitting vectors words compiler.cfg.test-words ;
@ -55,8 +55,7 @@ IN: compiler.cfg.scheduling.tests
T{ ##load-tagged } T{ ##load-tagged }
T{ ##allot } T{ ##allot }
T{ ##set-slot-imm } T{ ##set-slot-imm }
} insns>cfg schedule-instructions } insns>cfg schedule-instructions cfg>insns [ insn#>> ] all?
linearization-order [ instructions>> ] map concat [ insn#>> ] all?
] unit-test ] unit-test
: test-1187 ( -- insns ) : test-1187 ( -- insns )

View File

@ -3,7 +3,7 @@
USING: accessors assocs combinators combinators.short-circuit USING: accessors assocs combinators combinators.short-circuit
cpu.architecture kernel layouts locals make math namespaces sequences cpu.architecture kernel layouts locals make math namespaces sequences
sets vectors fry arrays compiler.cfg compiler.cfg.instructions sets vectors fry arrays compiler.cfg compiler.cfg.instructions
compiler.cfg.rpo compiler.utilities ; compiler.cfg.linearization compiler.cfg.rpo compiler.utilities ;
IN: compiler.cfg.utilities IN: compiler.cfg.utilities
: block>cfg ( bb -- cfg ) : block>cfg ( bb -- cfg )
@ -15,6 +15,9 @@ IN: compiler.cfg.utilities
: insns>cfg ( insns -- cfg ) : insns>cfg ( insns -- cfg )
0 insns>block block>cfg ; 0 insns>block block>cfg ;
: cfg>insns ( cfg -- insns )
linearization-order [ instructions>> ] map concat ;
: back-edge? ( from to -- ? ) : back-edge? ( from to -- ? )
[ number>> ] bi@ >= ; [ number>> ] bi@ >= ;