From e45bf2f0b17fc6c844a0a3365fe30a4d9ee23f4e Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 31 Aug 2023 15:08:17 +0200 Subject: [PATCH] call every riscv submachine at least once (#549) --- riscv/src/compiler.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/riscv/src/compiler.rs b/riscv/src/compiler.rs index 45ad5c6a3..e9b64023a 100644 --- a/riscv/src/compiler.rs +++ b/riscv/src/compiler.rs @@ -223,6 +223,7 @@ impl asm_utils::compiler::Compiler for Risc { .into_iter() .map(|(id, dir, file)| format!("debug file {id} {} {};", quote(&dir), quote(&file))) .chain(["call __data_init;".to_string()]) + .chain(call_every_submachine()) .chain([ format!("// Set stack pointer\nx2 <=X= {stack_start};"), "call __runtime_start;".to_string(), @@ -431,6 +432,18 @@ fn store_data_objects<'a>( (code, positions) } +fn call_every_submachine() -> Vec { + // TODO This is a hacky snippet to ensure that every submachine in the RISCV machine + // is called at least once. This is needed for witgen until it can do default blocks + // automatically. + // https://github.com/powdr-labs/powdr/issues/548 + vec![ + "x10 <== and(x10, x10);".to_string(), + "x10 <== shl(x10, x10);".to_string(), + "x10 <=X= 0;".to_string(), + ] +} + fn next_multiple_of_four(x: usize) -> usize { ((x + 3) / 4) * 4 }