-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add Rust->Wasm->IR Fibonacci example
Set opt-level=z (optimize for size) to avoid loops unrolling optimization in Fibonacci Rust test.
- Loading branch information
Showing
2 changed files
with
134 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#![no_std] | ||
#![no_main] | ||
|
||
#[panic_handler] | ||
fn my_panic(_info: &core::panic::PanicInfo) -> ! { | ||
loop {} | ||
} | ||
|
||
#[inline(never)] | ||
#[no_mangle] | ||
pub fn fib(n: u32) -> u32 { | ||
let mut a = 0; | ||
let mut b = 1; | ||
for _ in 0..n { | ||
let c = a + b; | ||
a = b; | ||
b = c; | ||
} | ||
a | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn __main() -> u32 { | ||
fib(25) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters