Assert the program behaves identically with allocation off and on, and return the (off, on) instruction counts and cycle counts for extra checks.
(src: &str)
| 67 | // Asserts identical behaviour with allocation off and on, and returns the |
| 68 | // (off, on) instruction and cycle counts for extra checks. |
| 69 | fn assert_equivalent(src: &str) -> ((usize, u64), (usize, u64)) { |
| 70 | let (base_outcome, base_uart, base_lines, base_cycles) = run_with_regalloc(src, false); |
| 71 | let (alloc_outcome, alloc_uart, alloc_lines, alloc_cycles) = run_with_regalloc(src, true); |
| 72 | assert!( |
| 73 | matches!(base_outcome, StepOutcome::Halted(_)), |
| 74 | "baseline did not finish: {base_outcome:?}" |
| 75 | ); |
| 76 | assert_eq!( |
| 77 | format!("{base_outcome:?}"), |
| 78 | format!("{alloc_outcome:?}"), |
| 79 | "register allocation changed the exit outcome" |
| 80 | ); |
| 81 | assert_eq!( |
| 82 | base_uart, alloc_uart, |
| 83 | "register allocation changed UART output" |
| 84 | ); |
| 85 | ((base_lines, base_cycles), (alloc_lines, alloc_cycles)) |
| 86 | } |
| 87 | |
| 88 | #[test] |
| 89 | fn regalloc_arithmetic_branches_and_loops() { |