git @ Cat's Eye Technologies SixtyPical / a5d9467
Add more tests. Apparently our algorithm does not do a good job. Chris Pressey 3 years ago
1 changed file(s) with 79 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
8080 = ]
8181 = ]
8282
83 If main does a `goto foo`, then it can fall through to `foo`.
83 If `main` does a `goto foo`, then it can fall through to `foo`.
8484
8585 | define foo routine trashes a, z, n
8686 | {
101101 More than one routine can fall through to a routine. We pick one
102102 of them to fall through, when selecting the order of routines.
103103
104 Also note, `main` is always serialized first, so that the entry
105 point of the entire program appears at the beginning of the code.
106
107104 | define foo routine trashes a, z, n
108105 | {
109106 | ld a, 0
126123 = ],
127124 = [
128125 = "bar"
126 = ]
127 = ]
128
129 Because `main` is always serialized first (so that the entry
130 point of the entire program appears at the beginning of the code),
131 nothing ever falls through to `main`.
132
133 | define foo routine trashes a, z, n
134 | {
135 | ld a, 0
136 | goto main
137 | }
138 |
139 | define main routine trashes a, z, n
140 | {
141 | ld a, 1
142 | }
143 = [
144 = [
145 = "main"
146 = ],
147 = [
148 = "foo"
129149 = ]
130150 = ]
131151
225245 = ]
226246 = ]
227247
248 Our algorithm might not be strictly optimal, but it does a good job.
249
250 | define r1 routine trashes a, z, n
251 | {
252 | ld a, 0
253 | goto r2
254 | }
255 |
256 | define r2 routine trashes a, z, n
257 | {
258 | ld a, 0
259 | goto r3
260 | }
261 |
262 | define r3 routine trashes a, z, n
263 | {
264 | ld a, 0
265 | goto r4
266 | }
267 |
268 | define r4 routine trashes a, z, n
269 | {
270 | ld a, 0
271 | }
272 |
273 | define r5 routine trashes a, z, n
274 | {
275 | ld a, 0
276 | goto r6
277 | }
278 |
279 | define r6 routine trashes a, z, n
280 | {
281 | ld a, 0
282 | goto r3
283 | }
284 |
285 | define main routine trashes a, z, n
286 | {
287 | goto r1
288 | }
289 = [
290 = [
291 = "main",
292 = "r1",
293 = "r2",
294 = "r3",
295 = "r4"
296 = ],
297 = [
298 = "r5",
299 = "r6"
300 = ]
301 = ]
302
228303 -> Tests for functionality "Compile SixtyPical program with fallthru optimization"
229304
230305 Basic test for actually applying this optimization when compiling SixtyPical programs.