2014-11-07 18:49:59 -05:00
|
|
|
USING: accessors compiler.cfg compiler.cfg.instructions
|
|
|
|
compiler.cfg.linearization compiler.cfg.scheduling compiler.cfg.utilities
|
2014-11-08 13:01:00 -05:00
|
|
|
vocabs.loader namespaces tools.test arrays kernel random sequences sets words ;
|
2010-04-15 18:36:43 -04:00
|
|
|
IN: compiler.cfg.scheduling.tests
|
|
|
|
|
2014-11-07 18:49:59 -05:00
|
|
|
! Test split-insns
|
2014-11-08 13:01:00 -05:00
|
|
|
{
|
|
|
|
{
|
|
|
|
V{ }
|
|
|
|
V{ }
|
|
|
|
V{ T{ ##test-branch } }
|
|
|
|
}
|
|
|
|
} [ V{ T{ ##test-branch } } split-insns ] unit-test
|
2010-07-15 17:38:34 -04:00
|
|
|
|
2014-11-08 13:01:00 -05:00
|
|
|
{
|
|
|
|
{
|
|
|
|
V{ T{ ##inc-d } T{ ##inc-r } T{ ##callback-inputs } }
|
|
|
|
V{ T{ ##add } T{ ##sub } T{ ##mul } }
|
|
|
|
V{ T{ ##test-branch } }
|
|
|
|
}
|
|
|
|
} [
|
2010-07-15 17:38:34 -04:00
|
|
|
V{
|
|
|
|
T{ ##inc-d }
|
|
|
|
T{ ##inc-r }
|
|
|
|
T{ ##callback-inputs }
|
|
|
|
T{ ##add }
|
|
|
|
T{ ##sub }
|
|
|
|
T{ ##mul }
|
|
|
|
T{ ##test-branch }
|
2014-11-08 13:01:00 -05:00
|
|
|
} split-insns
|
2010-07-15 17:38:34 -04:00
|
|
|
] unit-test
|
2010-07-15 20:55:31 -04:00
|
|
|
|
|
|
|
[
|
2014-11-08 13:01:00 -05:00
|
|
|
{
|
|
|
|
V{ }
|
|
|
|
V{ T{ ##add } T{ ##sub } T{ ##mul } }
|
|
|
|
V{ T{ ##dispatch } }
|
|
|
|
}
|
2010-07-15 20:55:31 -04:00
|
|
|
] [
|
|
|
|
V{
|
|
|
|
T{ ##add }
|
|
|
|
T{ ##sub }
|
|
|
|
T{ ##mul }
|
|
|
|
T{ ##dispatch }
|
2014-11-08 13:01:00 -05:00
|
|
|
} split-insns
|
2010-07-15 20:55:31 -04:00
|
|
|
] unit-test
|
2014-11-07 18:49:59 -05:00
|
|
|
|
|
|
|
! Instructions gets numbered as a side-effect
|
|
|
|
{ t } [
|
|
|
|
V{
|
|
|
|
T{ ##inc-r }
|
|
|
|
T{ ##inc-d }
|
|
|
|
T{ ##load-tagged }
|
|
|
|
T{ ##allot }
|
|
|
|
T{ ##set-slot-imm }
|
|
|
|
} insns>cfg schedule-instructions
|
|
|
|
linearization-order [ instructions>> ] map concat [ insn#>> ] all?
|
|
|
|
] unit-test
|
|
|
|
|
2014-11-08 13:01:00 -05:00
|
|
|
: test-1187 ( -- insns )
|
2014-11-07 18:49:59 -05:00
|
|
|
V{
|
|
|
|
##inc-r
|
|
|
|
##inc-d
|
|
|
|
##peek
|
|
|
|
##peek
|
|
|
|
##load-tagged
|
|
|
|
##allot
|
|
|
|
##set-slot-imm
|
|
|
|
##load-reference
|
|
|
|
##allot
|
|
|
|
##set-slot-imm
|
|
|
|
##set-slot-imm
|
|
|
|
##set-slot-imm
|
|
|
|
##replace-imm
|
|
|
|
##replace
|
|
|
|
##replace
|
|
|
|
##replace
|
|
|
|
##replace
|
|
|
|
##replace-imm
|
|
|
|
##replace
|
|
|
|
##branch
|
2014-11-08 13:01:00 -05:00
|
|
|
} [ 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
|
2014-11-07 18:49:59 -05:00
|
|
|
] unit-test
|