2009-07-27 23:29:33 -04:00
|
|
|
USING: accessors assocs compiler compiler.cfg
|
|
|
|
compiler.cfg.debugger compiler.cfg.instructions compiler.cfg.mr
|
|
|
|
compiler.cfg.registers compiler.codegen compiler.units
|
|
|
|
cpu.architecture hashtables kernel namespaces sequences
|
|
|
|
tools.test vectors words layouts literals math arrays
|
2009-08-26 07:58:47 -04:00
|
|
|
alien.syntax math.private ;
|
2009-07-28 12:16:21 -04:00
|
|
|
IN: compiler.tests.low-level-ir
|
2009-07-27 23:29:33 -04:00
|
|
|
|
|
|
|
: compile-cfg ( cfg -- word )
|
|
|
|
gensym
|
|
|
|
[ build-mr generate code>> ] dip
|
|
|
|
[ associate >alist modify-code-heap ] keep ;
|
|
|
|
|
|
|
|
: compile-test-cfg ( -- word )
|
2009-08-08 05:02:18 -04:00
|
|
|
cfg new 0 get >>entry
|
2009-08-08 21:02:56 -04:00
|
|
|
dup cfg set
|
2009-08-08 05:02:18 -04:00
|
|
|
dup fake-representations representations get >>reps
|
2009-07-27 23:29:33 -04:00
|
|
|
compile-cfg ;
|
|
|
|
|
|
|
|
: compile-test-bb ( insns -- result )
|
2009-09-22 06:07:52 -04:00
|
|
|
V{ T{ ##prologue } T{ ##branch } } [ clone ] map 0 test-bb
|
2009-07-27 23:29:33 -04:00
|
|
|
V{
|
|
|
|
T{ ##inc-d f 1 }
|
2009-08-08 05:02:18 -04:00
|
|
|
T{ ##replace f 0 D 0 }
|
2009-07-27 23:29:33 -04:00
|
|
|
T{ ##branch }
|
2009-07-29 07:39:54 -04:00
|
|
|
} [ clone ] map append 1 test-bb
|
2009-07-27 23:29:33 -04:00
|
|
|
V{
|
|
|
|
T{ ##epilogue }
|
|
|
|
T{ ##return }
|
2009-07-29 07:39:54 -04:00
|
|
|
} [ clone ] map 2 test-bb
|
2009-08-02 04:49:25 -04:00
|
|
|
0 1 edge
|
|
|
|
1 2 edge
|
2009-07-27 23:29:33 -04:00
|
|
|
compile-test-cfg
|
|
|
|
execute( -- result ) ;
|
|
|
|
|
|
|
|
! loading immediates
|
|
|
|
[ f ] [
|
|
|
|
V{
|
2009-08-08 05:02:18 -04:00
|
|
|
T{ ##load-immediate f 0 5 }
|
2009-07-27 23:29:33 -04:00
|
|
|
} compile-test-bb
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ "hello" ] [
|
|
|
|
V{
|
2009-08-08 05:02:18 -04:00
|
|
|
T{ ##load-reference f 0 "hello" }
|
2009-07-27 23:29:33 -04:00
|
|
|
} compile-test-bb
|
|
|
|
] unit-test
|
|
|
|
|
2009-08-26 07:58:47 -04:00
|
|
|
! ##copy on floats. We can only run this test if float intrinsics
|
|
|
|
! are enabled.
|
|
|
|
\ float+ "intrinsic" word-prop [
|
|
|
|
[ 1.5 ] [
|
|
|
|
V{
|
|
|
|
T{ ##load-reference f 4 1.5 }
|
|
|
|
T{ ##unbox-float f 1 4 }
|
2009-09-03 21:58:56 -04:00
|
|
|
T{ ##copy f 2 1 double-rep }
|
2009-08-26 07:58:47 -04:00
|
|
|
T{ ##box-float f 3 2 }
|
|
|
|
T{ ##copy f 0 3 int-rep }
|
|
|
|
} compile-test-bb
|
|
|
|
] unit-test
|
|
|
|
] when
|
2009-08-25 20:41:17 -04:00
|
|
|
|
2009-07-27 23:29:33 -04:00
|
|
|
! make sure slot access works when the destination is
|
|
|
|
! one of the sources
|
|
|
|
[ t ] [
|
|
|
|
V{
|
2009-08-08 05:02:18 -04:00
|
|
|
T{ ##load-immediate f 1 $[ 2 cell log2 shift ] }
|
|
|
|
T{ ##load-reference f 0 { t f t } }
|
|
|
|
T{ ##slot f 0 0 1 $[ array tag-number ] 2 }
|
2009-07-27 23:29:33 -04:00
|
|
|
} compile-test-bb
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ t ] [
|
|
|
|
V{
|
2009-08-08 05:02:18 -04:00
|
|
|
T{ ##load-reference f 0 { t f t } }
|
2009-09-22 06:07:52 -04:00
|
|
|
T{ ##slot-imm f 0 0 2 $[ array tag-number ] }
|
2009-07-27 23:29:33 -04:00
|
|
|
} compile-test-bb
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ t ] [
|
|
|
|
V{
|
2009-08-08 05:02:18 -04:00
|
|
|
T{ ##load-immediate f 1 $[ 2 cell log2 shift ] }
|
|
|
|
T{ ##load-reference f 0 { t f t } }
|
|
|
|
T{ ##set-slot f 0 0 1 $[ array tag-number ] 2 }
|
2009-07-27 23:29:33 -04:00
|
|
|
} compile-test-bb
|
|
|
|
dup first eq?
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ t ] [
|
|
|
|
V{
|
2009-08-08 05:02:18 -04:00
|
|
|
T{ ##load-reference f 0 { t f t } }
|
|
|
|
T{ ##set-slot-imm f 0 0 2 $[ array tag-number ] }
|
2009-07-27 23:29:33 -04:00
|
|
|
} compile-test-bb
|
|
|
|
dup first eq?
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ 8 ] [
|
|
|
|
V{
|
2009-08-08 05:02:18 -04:00
|
|
|
T{ ##load-immediate f 0 4 }
|
|
|
|
T{ ##shl f 0 0 0 }
|
2009-07-27 23:29:33 -04:00
|
|
|
} compile-test-bb
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ 4 ] [
|
|
|
|
V{
|
2009-08-08 05:02:18 -04:00
|
|
|
T{ ##load-immediate f 0 4 }
|
|
|
|
T{ ##shl-imm f 0 0 3 }
|
2009-07-27 23:29:33 -04:00
|
|
|
} compile-test-bb
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ 31 ] [
|
|
|
|
V{
|
2009-08-08 05:02:18 -04:00
|
|
|
T{ ##load-reference f 1 B{ 31 67 52 } }
|
|
|
|
T{ ##unbox-any-c-ptr f 0 1 2 }
|
|
|
|
T{ ##alien-unsigned-1 f 0 0 }
|
|
|
|
T{ ##shl-imm f 0 0 3 }
|
2009-07-27 23:29:33 -04:00
|
|
|
} compile-test-bb
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ CHAR: l ] [
|
|
|
|
V{
|
2009-08-08 05:02:18 -04:00
|
|
|
T{ ##load-reference f 0 "hello world" }
|
|
|
|
T{ ##load-immediate f 1 3 }
|
|
|
|
T{ ##string-nth f 0 0 1 2 }
|
|
|
|
T{ ##shl-imm f 0 0 3 }
|
2009-07-27 23:29:33 -04:00
|
|
|
} compile-test-bb
|
|
|
|
] unit-test
|
|
|
|
|
2009-07-28 07:45:31 -04:00
|
|
|
[ 1 ] [
|
|
|
|
V{
|
2009-08-08 05:02:18 -04:00
|
|
|
T{ ##load-immediate f 0 16 }
|
|
|
|
T{ ##add-imm f 0 0 -8 }
|
2009-07-28 07:45:31 -04:00
|
|
|
} compile-test-bb
|
|
|
|
] unit-test
|
|
|
|
|
2009-07-27 23:29:33 -04:00
|
|
|
! These are def-is-use-insns
|
|
|
|
USE: multiline
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
[ 100 ] [
|
|
|
|
V{
|
2009-08-08 05:02:18 -04:00
|
|
|
T{ ##load-immediate f 0 100 }
|
|
|
|
T{ ##integer>bignum f 0 0 1 }
|
2009-07-27 23:29:33 -04:00
|
|
|
} compile-test-bb
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ 1 ] [
|
|
|
|
V{
|
2009-08-08 05:02:18 -04:00
|
|
|
T{ ##load-reference f 0 ALIEN: 8 }
|
|
|
|
T{ ##unbox-any-c-ptr f 0 0 1 }
|
2009-07-27 23:29:33 -04:00
|
|
|
} compile-test-bb
|
|
|
|
] unit-test
|
|
|
|
|
2009-08-25 20:41:17 -04:00
|
|
|
*/
|