compiler.cfg.scheduling: split-insns returns a 3-tuple instead of 3 items on the stack
parent
c777cb954a
commit
a1b20e451b
|
@ -1,24 +1,24 @@
|
||||||
USING: accessors compiler.cfg compiler.cfg.instructions
|
USING: accessors compiler.cfg compiler.cfg.instructions
|
||||||
compiler.cfg.linearization compiler.cfg.scheduling compiler.cfg.utilities
|
compiler.cfg.linearization compiler.cfg.scheduling compiler.cfg.utilities
|
||||||
vocabs.loader namespaces tools.test arrays kernel random sequences words ;
|
vocabs.loader namespaces tools.test arrays kernel random sequences sets words ;
|
||||||
IN: compiler.cfg.scheduling.tests
|
IN: compiler.cfg.scheduling.tests
|
||||||
|
|
||||||
! Test split-insns
|
! Test split-insns
|
||||||
[
|
{
|
||||||
{ }
|
{
|
||||||
{ }
|
V{ }
|
||||||
{ T{ ##test-branch } }
|
V{ }
|
||||||
] [
|
|
||||||
V{ T{ ##test-branch } }
|
V{ T{ ##test-branch } }
|
||||||
split-insns
|
}
|
||||||
[ >array ] tri@
|
} [ V{ T{ ##test-branch } } split-insns ] unit-test
|
||||||
] unit-test
|
|
||||||
|
|
||||||
[
|
{
|
||||||
{ T{ ##inc-d } T{ ##inc-r } T{ ##callback-inputs } }
|
{
|
||||||
{ T{ ##add } T{ ##sub } T{ ##mul } }
|
V{ T{ ##inc-d } T{ ##inc-r } T{ ##callback-inputs } }
|
||||||
{ T{ ##test-branch } }
|
V{ T{ ##add } T{ ##sub } T{ ##mul } }
|
||||||
] [
|
V{ T{ ##test-branch } }
|
||||||
|
}
|
||||||
|
} [
|
||||||
V{
|
V{
|
||||||
T{ ##inc-d }
|
T{ ##inc-d }
|
||||||
T{ ##inc-r }
|
T{ ##inc-r }
|
||||||
|
@ -27,24 +27,22 @@ IN: compiler.cfg.scheduling.tests
|
||||||
T{ ##sub }
|
T{ ##sub }
|
||||||
T{ ##mul }
|
T{ ##mul }
|
||||||
T{ ##test-branch }
|
T{ ##test-branch }
|
||||||
}
|
} split-insns
|
||||||
split-insns
|
|
||||||
[ >array ] tri@
|
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[
|
[
|
||||||
{ }
|
{
|
||||||
{ T{ ##add } T{ ##sub } T{ ##mul } }
|
V{ }
|
||||||
{ T{ ##dispatch } }
|
V{ T{ ##add } T{ ##sub } T{ ##mul } }
|
||||||
|
V{ T{ ##dispatch } }
|
||||||
|
}
|
||||||
] [
|
] [
|
||||||
V{
|
V{
|
||||||
T{ ##add }
|
T{ ##add }
|
||||||
T{ ##sub }
|
T{ ##sub }
|
||||||
T{ ##mul }
|
T{ ##mul }
|
||||||
T{ ##dispatch }
|
T{ ##dispatch }
|
||||||
}
|
} split-insns
|
||||||
split-insns
|
|
||||||
[ >array ] tri@
|
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
! Instructions gets numbered as a side-effect
|
! Instructions gets numbered as a side-effect
|
||||||
|
@ -59,29 +57,7 @@ IN: compiler.cfg.scheduling.tests
|
||||||
linearization-order [ instructions>> ] map concat [ insn#>> ] all?
|
linearization-order [ instructions>> ] map concat [ insn#>> ] all?
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
{
|
: test-1187 ( -- insns )
|
||||||
{ T{ ##inc-r } T{ ##inc-d } }
|
|
||||||
{
|
|
||||||
T{ ##peek }
|
|
||||||
T{ ##peek }
|
|
||||||
T{ ##load-tagged }
|
|
||||||
T{ ##allot }
|
|
||||||
T{ ##set-slot-imm }
|
|
||||||
T{ ##load-reference }
|
|
||||||
T{ ##allot }
|
|
||||||
T{ ##set-slot-imm }
|
|
||||||
T{ ##set-slot-imm }
|
|
||||||
T{ ##set-slot-imm }
|
|
||||||
T{ ##replace-imm }
|
|
||||||
T{ ##replace }
|
|
||||||
T{ ##replace }
|
|
||||||
T{ ##replace }
|
|
||||||
T{ ##replace }
|
|
||||||
T{ ##replace-imm }
|
|
||||||
T{ ##replace }
|
|
||||||
}
|
|
||||||
{ T{ ##branch } }
|
|
||||||
} [
|
|
||||||
V{
|
V{
|
||||||
##inc-r
|
##inc-r
|
||||||
##inc-d
|
##inc-d
|
||||||
|
@ -103,5 +79,35 @@ IN: compiler.cfg.scheduling.tests
|
||||||
##replace-imm
|
##replace-imm
|
||||||
##replace
|
##replace
|
||||||
##branch
|
##branch
|
||||||
} [ new ] map split-insns [ >array ] tri@
|
} [ new ] map ;
|
||||||
|
|
||||||
|
{
|
||||||
|
{
|
||||||
|
V{ T{ ##inc-r } T{ ##inc-d } }
|
||||||
|
V{
|
||||||
|
T{ ##peek }
|
||||||
|
T{ ##peek }
|
||||||
|
T{ ##load-tagged }
|
||||||
|
T{ ##allot }
|
||||||
|
T{ ##set-slot-imm }
|
||||||
|
T{ ##load-reference }
|
||||||
|
T{ ##allot }
|
||||||
|
T{ ##set-slot-imm }
|
||||||
|
T{ ##set-slot-imm }
|
||||||
|
T{ ##set-slot-imm }
|
||||||
|
T{ ##replace-imm }
|
||||||
|
T{ ##replace }
|
||||||
|
T{ ##replace }
|
||||||
|
T{ ##replace }
|
||||||
|
T{ ##replace }
|
||||||
|
T{ ##replace-imm }
|
||||||
|
T{ ##replace }
|
||||||
|
}
|
||||||
|
V{ T{ ##branch } }
|
||||||
|
}
|
||||||
|
} [ test-1187 split-insns ] unit-test
|
||||||
|
|
||||||
|
! You should get the exact same instruction order each time.
|
||||||
|
{ 1 } [
|
||||||
|
10 [ test-1187 split-insns 1 swap nth ] replicate members length
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
|
@ -25,7 +25,7 @@ ERROR: bad-delete-at key assoc ;
|
||||||
'[ [ precedes>> _ swap check-delete-at ] each ]
|
'[ [ precedes>> _ swap check-delete-at ] each ]
|
||||||
[ [ ready? ] filter roots get push-all ] bi ;
|
[ [ ready? ] filter roots get push-all ] bi ;
|
||||||
|
|
||||||
: score ( insn -- n )
|
: score ( node -- n )
|
||||||
[ parent-index>> ] [ registers>> neg ] [ insn>> insn#>> ] tri 3array ;
|
[ parent-index>> ] [ registers>> neg ] [ insn>> insn#>> ] tri 3array ;
|
||||||
|
|
||||||
: pull-out-nth ( n seq -- elt )
|
: pull-out-nth ( n seq -- elt )
|
||||||
|
@ -66,12 +66,11 @@ conditional-branch-insn
|
||||||
: final-insn-start ( insns -- n )
|
: final-insn-start ( insns -- n )
|
||||||
[ final-insn? not ] find-last drop [ 1 + ] [ 0 ] if* ;
|
[ final-insn? not ] find-last drop [ 1 + ] [ 0 ] if* ;
|
||||||
|
|
||||||
: split-insns ( insns -- pre body post )
|
: split-insns ( insns -- pre/body/post )
|
||||||
dup [ initial-insn-end ] [ final-insn-start ] bi 2array split-indices
|
dup [ initial-insn-end ] [ final-insn-start ] bi 2array split-indices ;
|
||||||
first3 ;
|
|
||||||
|
|
||||||
: reorder ( insns -- insns' )
|
: reorder ( insns -- insns' )
|
||||||
split-insns [
|
split-insns first3 [
|
||||||
build-dependence-graph
|
build-dependence-graph
|
||||||
build-fan-in-trees
|
build-fan-in-trees
|
||||||
[ (reorder) ] V{ } make reverse
|
[ (reorder) ] V{ } make reverse
|
||||||
|
|
Loading…
Reference in New Issue