Skip to content

Commit 1fae2e9

Browse files
committed
[WIP] Implement live variable analysis
Signed-off-by: Adam Laszlo Kulcsar <[email protected]>
1 parent 59c6dfd commit 1fae2e9

File tree

11 files changed

+3082
-339
lines changed

11 files changed

+3082
-339
lines changed

asd.wast

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
(module
2+
(type (;0;) (func))
3+
(type (;1;) (func (param i32 i32 i32)))
4+
(import "spectest" "print_i32" (func $print_i32 (param i32)))
5+
6+
(global $max i32 (i32.const 3))
7+
8+
(func $qs (type 1) (param i32 i32 i32)
9+
(local i32 i32 i32 i32 i32 i32 i32 i32)
10+
local.get 1
11+
local.get 2
12+
i32.lt_s
13+
if ;; label = @1
14+
local.get 0
15+
local.get 2
16+
i32.const 2
17+
i32.shl
18+
i32.add
19+
local.set 7
20+
loop ;; label = @2
21+
i32.const 0
22+
local.set 3
23+
local.get 2
24+
local.get 1
25+
i32.sub
26+
local.tee 8
27+
i32.const 0
28+
i32.gt_s
29+
if ;; label = @3
30+
local.get 7
31+
i32.load
32+
local.set 6
33+
i32.const 0
34+
local.set 4
35+
loop ;; label = @4
36+
block ;; label = @5
37+
local.get 6
38+
local.get 0
39+
local.get 1
40+
local.get 3
41+
i32.add
42+
i32.const 2
43+
i32.shl
44+
i32.add
45+
local.tee 5
46+
i32.load
47+
local.tee 9
48+
i32.gt_s
49+
if ;; label = @6
50+
local.get 3
51+
i32.const 1
52+
i32.add
53+
local.set 3
54+
br 1 (;@5;)
55+
end
56+
local.get 5
57+
local.get 0
58+
local.get 2
59+
local.get 4
60+
i32.sub
61+
i32.const 2
62+
i32.shl
63+
i32.add
64+
local.tee 5
65+
i32.const 4
66+
i32.sub
67+
local.tee 10
68+
i32.load
69+
i32.store
70+
local.get 5
71+
local.get 9
72+
i32.store
73+
local.get 10
74+
local.get 6
75+
i32.store
76+
local.get 4
77+
i32.const 1
78+
i32.add
79+
local.set 4
80+
end
81+
local.get 3
82+
local.get 4
83+
i32.add
84+
local.get 8
85+
i32.lt_s
86+
br_if 0 (;@4;)
87+
end
88+
end
89+
local.get 0
90+
local.get 1
91+
local.get 1
92+
local.get 3
93+
i32.add
94+
local.tee 1
95+
i32.const 1
96+
i32.sub
97+
call $qs
98+
local.get 1
99+
i32.const 1
100+
i32.add
101+
local.tee 1
102+
local.get 2
103+
i32.lt_s
104+
br_if 0 (;@2;)
105+
end
106+
end)
107+
108+
109+
110+
(func $print (type 0)
111+
(local i32 i32)
112+
global.get $max
113+
local.set 1
114+
(loop
115+
local.get 0
116+
i32.const 4
117+
i32.mul
118+
i32.load
119+
call $print_i32
120+
121+
local.get 0
122+
i32.const 1
123+
i32.add
124+
local.tee 0
125+
local.get 1
126+
i32.ne
127+
br_if 0
128+
)
129+
130+
)
131+
132+
(func $start (type 0)
133+
(local i32 i32)
134+
global.get $max
135+
local.set 1
136+
137+
(loop
138+
local.get 0
139+
i32.const 4
140+
i32.mul
141+
local.get 1
142+
local.get 0
143+
i32.sub
144+
i32.store
145+
146+
local.get 0
147+
i32.const 1
148+
i32.add
149+
local.tee 0
150+
local.get 1
151+
i32.ne
152+
br_if 0
153+
)
154+
;; call $print
155+
i32.const 0
156+
i32.const 0
157+
global.get $max
158+
call $qs
159+
;; call $print
160+
)
161+
162+
163+
(memory (;0;) 256 256)
164+
165+
(start $start)
166+
167+
(func (export "read") (param i32) (result i32)
168+
(i32.load (local.get 0))
169+
)
170+
171+
)
172+
173+
(assert_return (invoke "read" (i32.const 0)) (i32.const 0))
174+
(assert_return (invoke "read" (i32.const 4)) (i32.const 1))
175+
(assert_return (invoke "read" (i32.const 8)) (i32.const 2))

notes.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
normal fails:
2+
huffman (out of bounds memory)
3+
simd stuff
4+
sometimes stuff with jit, due to reg alloc

0 commit comments

Comments
 (0)