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 } } 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 ! ##copy on floats. We can only run this test if float intrinsics
51 \ float+ "intrinsic" word-prop [
54 T{ ##load-reference f 4 1.5 }
55 T{ ##unbox-float f 1 4 }
56 T{ ##copy f 2 1 double-rep }
57 T{ ##box-float f 3 2 }
58 T{ ##copy f 0 3 int-rep }
63 ! make sure slot access works when the destination is
67 T{ ##load-immediate f 1 $[ 2 cell log2 shift ] }
68 T{ ##load-reference f 0 { t f t } }
69 T{ ##slot f 0 0 1 $[ array tag-number ] 2 }
75 T{ ##load-reference f 0 { t f t } }
76 T{ ##slot-imm f 0 0 2 $[ array tag-number ] 2 }
82 T{ ##load-immediate f 1 $[ 2 cell log2 shift ] }
83 T{ ##load-reference f 0 { t f t } }
84 T{ ##set-slot f 0 0 1 $[ array tag-number ] 2 }
91 T{ ##load-reference f 0 { t f t } }
92 T{ ##set-slot-imm f 0 0 2 $[ array tag-number ] }
99 T{ ##load-immediate f 0 4 }
106 T{ ##load-immediate f 0 4 }
107 T{ ##shl-imm f 0 0 3 }
113 T{ ##load-reference f 1 B{ 31 67 52 } }
114 T{ ##unbox-any-c-ptr f 0 1 2 }
115 T{ ##alien-unsigned-1 f 0 0 }
116 T{ ##shl-imm f 0 0 3 }
122 T{ ##load-reference f 0 "hello world" }
123 T{ ##load-immediate f 1 3 }
124 T{ ##string-nth f 0 0 1 2 }
125 T{ ##shl-imm f 0 0 3 }
131 T{ ##load-immediate f 0 16 }
132 T{ ##add-imm f 0 0 -8 }
136 ! These are def-is-use-insns
143 T{ ##load-immediate f 0 100 }
144 T{ ##integer>bignum f 0 0 1 }
150 T{ ##load-reference f 0 ALIEN: 8 }
151 T{ ##unbox-any-c-ptr f 0 0 1 }