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.
This commit is contained in:
bunnie 2026-02-22 03:23:57 +08:00
parent 174b97a3a7
commit 75ce3f886d

View file

@ -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" ++