Compile a simple function (#2)

* Implement basics.

* Execute code

* Add wasm2wat test cases.

* abi_loc_for_arg for stack.

* Assert that sp_depth is 0 at the epilogue

* Do 32bit add.

* Assert that RAX can be used as a scratch register

* Reuse assembler.

* Align stack slots.
This commit is contained in:
Sergey Pepyakin
2018-11-08 22:56:27 +01:00
committed by Dan Gohman
parent d3bc26bc93
commit 08240761d5
9 changed files with 338 additions and 72 deletions

View File

@@ -21,7 +21,10 @@ fn read_to_end<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
fn maybe_main() -> Result<(), String> {
let data = read_to_end("test.wasm").map_err(|e| e.to_string())?;
translate(&data).map_err(|e| e.to_string())?;
let translated = translate(&data).map_err(|e| e.to_string())?;
let result = translated.execute_func(0, 5, 3);
println!("f(5, 3) = {}", result);
Ok(())
}