Prevent Zig from emitting function prologues for noreturn functions?
Ziggit
Prevent Zig from emitting function prologues for noreturn functions?
I’m working on a project that involves writing some embedded RISC-V code in Zig. I’ve got this code snippet: export fn main() noreturn { const x = fib(15); asm volatile ("ecall" : : [arg0] "{s1}" (x), ); unreachable; } fn fib(x: u32) u32 { if (x <= 2) { return 1; } return fib(x - 1) +% fib(x - 2); } If I compile this with -O small -target riscv32-freestanding-none (Godbolt link), the main function produces this assembly code: example.main: ...
0 comments
No comments yet.