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 | let (base_outcome, base_uart, base_lines, base_cycles) = run_with_regalloc(src, false); |
| 68 | let (alloc_outcome, alloc_uart, alloc_lines, alloc_cycles) = run_with_regalloc(src, true); |
| 69 | assert!( |
| 70 | matches!(base_outcome, RunOutcome::Halted(_)), |
| 71 | "baseline did not finish: {base_outcome:?}" |
| 72 | ); |
| 73 | assert_eq!( |
| 74 | format!("{base_outcome:?}"), |
| 75 | format!("{alloc_outcome:?}"), |
| 76 | "register allocation changed the exit outcome" |
| 77 | ); |
| 78 | assert_eq!( |
| 79 | base_uart, alloc_uart, |
| 80 | "register allocation changed UART output" |
| 81 | ); |
| 82 | ((base_lines, base_cycles), (alloc_lines, alloc_cycles)) |
| 83 | } |
| 84 | |
| 85 | #[test] |
| 86 | fn regalloc_arithmetic_branches_and_loops() { |
| 87 | let ((base_lines, base_cycles), (alloc_lines, alloc_cycles)) = assert_equivalent( |
| 88 | r#" |
| 89 | compute: (n: i64) -> i64 { |