Register allocation V2

This lays the groundwork for other on-the-fly optimisations,
like passing literals through in order to do const folding
in linear time, while compiling.
This commit is contained in:
Jef
2018-12-13 16:05:24 +01:00
parent 4994e3671c
commit 17ecd049a1
4 changed files with 590 additions and 229 deletions

View File

@@ -201,7 +201,9 @@ fn function_read_args_spill_to_stack() {
assert_eq!(
{
let translated = translate_wat(code);
let out: u32 = unsafe { translated.execute_func(0, (7, 6, 5, 4, 3, 2, 1, 0)) };
let out: u32 = unsafe {
translated.execute_func(0, (7u32, 6u32, 5u32, 4u32, 3u32, 2u32, 1u32, 0u32))
};
out
},
7
@@ -213,6 +215,7 @@ fn function_write_args_spill_to_stack() {
let code = r#"
(module
(func (param i32) (param i32) (param i32) (param i32)
(param i32) (param i32) (param i32) (param i32)
(param i32) (param i32) (param i32) (param i32)
(result i32)
@@ -225,16 +228,21 @@ fn function_write_args_spill_to_stack() {
(get_local 5)
(get_local 6)
(get_local 7)
(get_local 8)
(get_local 9)
(get_local 10)
(get_local 11)
)
)
(func $called
(param i32) (param i32) (param i32) (param i32)
(param i32) (param i32) (param i32) (param i32)
(param i32) (param i32) (param i32) (param i32)
(result i32)
(call $assert_zero
(get_local 7)
(get_local 11)
)
(get_local 0)
)
@@ -251,10 +259,10 @@ fn function_write_args_spill_to_stack() {
assert_eq!(
{
let translated = translate_wat(code);
let out: u32 = unsafe { translated.execute_func(0, (7, 6, 5, 4, 3, 2, 1, 0)) };
let out: u32 = unsafe { translated.execute_func(0, (11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)) };
out
},
7
11
);
}
#[test]