1 USING: accessors assocs compiler compiler.cfg
2 compiler.cfg.debugger compiler.cfg.instructions compiler.cfg.mr
3 compiler.cfg.registers compiler.codegen compiler.units
4 cpu.architecture hashtables kernel namespaces sequences
5 tools.test vectors words layouts literals math arrays
6 alien.syntax math.private ;
7 IN: compiler.tests.low-level-ir
9 : compile-cfg ( cfg -- word )
11 [ build-mr generate code>> ] dip
12 [ associate >alist modify-code-heap ] keep ;
14 : compile-test-cfg ( -- word )
17 dup fake-representations representations get >>reps
20 : compile-test-bb ( insns -- result )
21 V{ T{ ##prologue } T{ ##branch } } [ clone ] map 0 test-bb
24 T{ ##replace f 0 D 0 }
26 } [ clone ] map append 1 test-bb
30 } [ clone ] map 2 test-bb
34 execute( -- result ) ;
39 T{ ##load-immediate f 0 5 }
45 T{ ##load-reference f 0 "hello" }
49 ! make sure slot access works when the destination is
53 T{ ##load-immediate f 1 $[ 2 cell log2 shift array tag-number - ] }
54 T{ ##load-reference f 0 { t f t } }
61 T{ ##load-reference f 0 { t f t } }
62 T{ ##slot-imm f 0 0 2 $[ array tag-number ] }
68 T{ ##load-immediate f 1 $[ 2 cell log2 shift array tag-number - ] }
69 T{ ##load-reference f 0 { t f t } }
70 T{ ##set-slot f 0 0 1 }
77 T{ ##load-reference f 0 { t f t } }
78 T{ ##set-slot-imm f 0 0 2 $[ array tag-number ] }
85 T{ ##load-immediate f 0 4 }
92 T{ ##load-immediate f 0 4 }
93 T{ ##shl-imm f 0 0 3 }
99 T{ ##load-reference f 1 B{ 31 67 52 } }
100 T{ ##unbox-any-c-ptr f 0 1 2 }
101 T{ ##alien-unsigned-1 f 0 0 0 }
102 T{ ##shl-imm f 0 0 3 }
108 T{ ##load-reference f 0 "hello world" }
109 T{ ##load-immediate f 1 3 }
110 T{ ##string-nth f 0 0 1 2 }
111 T{ ##shl-imm f 0 0 3 }
117 T{ ##load-immediate f 0 16 }
118 T{ ##add-imm f 0 0 -8 }