2016-03-06 22:42:28 -05:00
|
|
|
USING: accessors alien alien.c-types compiler.cfg compiler.cfg.builder
|
2016-03-08 08:38:48 -05:00
|
|
|
compiler.cfg.builder.alien compiler.cfg.builder.blocks
|
|
|
|
compiler.cfg.instructions compiler.cfg.registers compiler.test
|
|
|
|
compiler.tree.builder compiler.tree.optimizer cpu.architecture
|
|
|
|
cpu.x86.assembler cpu.x86.assembler.operands kernel make namespaces
|
|
|
|
sequences system tools.test words ;
|
2015-03-19 13:03:49 -04:00
|
|
|
IN: compiler.cfg.builder.alien.tests
|
|
|
|
|
2015-04-29 22:49:48 -04:00
|
|
|
! unboxing ints is only needed on 32bit archs
|
|
|
|
cpu x86.32?
|
|
|
|
{
|
|
|
|
{ 2 4 }
|
|
|
|
{ { int-rep f f } { int-rep f f } }
|
|
|
|
V{
|
|
|
|
T{ ##unbox-any-c-ptr { dst 2 } { src 1 } }
|
|
|
|
T{ ##unbox
|
|
|
|
{ dst 4 }
|
|
|
|
{ src 3 }
|
|
|
|
{ unboxer "to_fixnum" }
|
|
|
|
{ rep int-rep }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-03-19 13:03:49 -04:00
|
|
|
{
|
|
|
|
{ 2 3 }
|
|
|
|
{ { int-rep f f } { int-rep f f } }
|
|
|
|
V{ T{ ##unbox-any-c-ptr { dst 2 } { src 1 } } }
|
2015-04-29 22:49:48 -04:00
|
|
|
} ? [
|
2015-03-19 13:03:49 -04:00
|
|
|
[ { c-string int } unbox-parameters ] V{ } make
|
2015-03-26 18:46:37 -04:00
|
|
|
] cfg-unit-test
|
2016-03-06 22:42:28 -05:00
|
|
|
|
|
|
|
: dummy-assembly ( -- ass )
|
|
|
|
int { } cdecl [
|
|
|
|
EAX 33 MOV
|
|
|
|
] alien-assembly ;
|
|
|
|
|
|
|
|
{ t } [
|
2016-03-08 08:38:48 -05:00
|
|
|
<basic-block> dup set-basic-block dup
|
2016-03-06 22:42:28 -05:00
|
|
|
\ dummy-assembly build-tree optimize-tree first
|
|
|
|
[ emit-node ] V{ } make drop eq?
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
: dummy-callback ( -- cb )
|
|
|
|
void { } cdecl [ ] alien-callback ;
|
|
|
|
|
|
|
|
{ 2 t } [
|
|
|
|
\ dummy-callback build-tree optimize-tree gensym build-cfg
|
|
|
|
[ length ] [ second frame-pointer?>> ] bi
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
{
|
|
|
|
V{
|
|
|
|
T{ ##load-reference { dst 1 } { obj t } }
|
|
|
|
T{ ##load-integer { dst 2 } { val 3 } }
|
|
|
|
T{ ##copy { dst 4 } { src 1 } { rep any-rep } }
|
|
|
|
T{ ##copy { dst 3 } { src 2 } { rep any-rep } }
|
|
|
|
T{ ##inc { loc D: 2 } }
|
|
|
|
T{ ##branch }
|
|
|
|
}
|
|
|
|
} [
|
2016-03-08 08:38:48 -05:00
|
|
|
<basic-block> dup set-basic-block
|
2016-03-06 22:42:28 -05:00
|
|
|
\ dummy-callback build-tree optimize-tree 3 swap nth child>>
|
|
|
|
[ emit-callback-body drop ] V{ } make
|
|
|
|
] cfg-unit-test
|