MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / regalloc_heap_alloc_and_uart_output

Function regalloc_heap_alloc_and_uart_output

tests/integration/regalloc.rs:286–314  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

284#[test]
285fn regalloc_heap_alloc_and_uart_output() {
286 // malloc results cross a call boundary into allocated registers; printing
287 // exercises stdlib calls with allocated arguments.
288 assert_equivalent(
289 r#"
290console := import("console")
291external free: (p: i64*) -> void
292
293main: () -> i32 {
294 p: i64* = new(i64, 8)
295 i: i64 = 0
296 while i < 8 {
297 p[i] = i * i
298 i = i + 1
299 }
300 total: i64 = 0
301 i = 0
302 while i < 8 {
303 total = total + p[i]
304 i = i + 1
305 }
306 console.putchar(65 + (total % 26) as i32)
307 console.putchar(10)
308 free(p)
309 return (total % 256) as i32
310}
311"#,
312 );
313}
314
315#[test]
316fn regalloc_composes_with_peephole_and_ir_opt() {
317 // All three optimization flags together must still be behavior-preserving.

Callers

nothing calls this directly

Calls 1

assert_equivalentFunction · 0.85

Tested by

no test coverage detected