From 75ce3f886daf0f9d6e0aee728a8ecd4a7e0d35da Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 22 Feb 2026 03:23:57 +0800 Subject: [PATCH] constrain the C compiler codegen 1. we can't resolve jump tables in Rust assembly. The label grammar isn't rich enough to do this. As a result, this code genreation method is suppressed. 2.there is no 'div' instruction on this PicoRV, so the +m is converted to +zmmul, which correctly emits mulitplies, but skips the divide. A soft divide library is provided for programs that require division. --- libs/bio-lib/src/c/build.zig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/bio-lib/src/c/build.zig b/libs/bio-lib/src/c/build.zig index b92c309b5..37c3ae3a9 100644 --- a/libs/bio-lib/src/c/build.zig +++ b/libs/bio-lib/src/c/build.zig @@ -27,6 +27,8 @@ pub fn build(b: *std.Build) void { b.graph.zig_exe, "cc", "-S", + // jump tables can't be translated in Rust assembly + "-fno-jump-tables", "-fverbose-asm", "-o", }); @@ -42,7 +44,10 @@ pub fn build(b: *std.Build) void { // Pack the reserve features directly into the -mcpu string. // This bypasses any issues with -ffixed-xN not being translated // into LLVM target features by the zig cc driver. - "-mcpu=generic_rv32+m+c" ++ + // + // Also note there is no hardware div support, just mul: so +zmmul allows + // mul's to be emitted, but not divs. + "-mcpu=generic_rv32+zmmul+c" ++ "+reserve_x16+reserve_x17+reserve_x18+reserve_x19" ++ "+reserve_x20+reserve_x21+reserve_x22+reserve_x23" ++ "+reserve_x24+reserve_x25+reserve_x26+reserve_x27" ++