diff --git a/compiler/test/__snapshots__/arrays.0f9e7d37.0.snapshot b/compiler/test/__snapshots__/arrays.0f9e7d37.0.snapshot index e5c9a4010..854386054 100644 --- a/compiler/test/__snapshots__/arrays.0f9e7d37.0.snapshot +++ b/compiler/test/__snapshots__/arrays.0f9e7d37.0.snapshot @@ -1,250 +1,28 @@ arrays › array_access -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"GRAIN$EXPORT$panicWithException\" (global $GRAIN$EXPORT$panicWithException_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.10 (result i32) - (block $compile_store.3 - (global.set $x_1113 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $MArrayGet.9 (result i32) - (local.set $1 - (i32.const 1) - ) - (local.set $2 - (global.get $x_1113) - ) - (block $resolve_idx.8 - (if - (i32.eqz - (i32.and - (local.get $1) - (i32.const 1) - ) - ) - (block $IndexNotSimpleInteger.7 - (local.set $1 - (i32.load offset=4 - (local.get $1) - ) - ) - (drop - (if (result i32) - (i32.or - (i32.eq - (local.get $1) - (i32.const 2) - ) - (i32.eq - (local.get $1) - (i32.const 4) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.6 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.5 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 69) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - ) - (local.set $1 - (i32.shr_s - (local.get $1) - (i32.const 1) - ) - ) - (if - (i32.lt_s - (local.get $1) - (i32.const 0) - ) - (local.set $1 - (i32.add - (local.get $1) - (i32.load offset=4 - (local.get $2) - ) - ) - ) - ) - (if - (i32.le_u - (i32.load offset=4 - (local.get $2) - ) - (local.get $1) - ) - (drop - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (i32.add - (i32.shl - (local.get $1) - (i32.const 2) - ) - (local.get $2) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MArrayOp + (MArrayGet + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))) + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name x)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/arrays.1deb7b51.0.snapshot b/compiler/test/__snapshots__/arrays.1deb7b51.0.snapshot index 43ccc57b0..58fc2ee09 100644 --- a/compiler/test/__snapshots__/arrays.1deb7b51.0.snapshot +++ b/compiler/test/__snapshots__/arrays.1deb7b51.0.snapshot @@ -1,265 +1,32 @@ arrays › array_access5 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"GRAIN$EXPORT$panicWithException\" (global $GRAIN$EXPORT$panicWithException_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.11 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (tuple.extract 0 - (tuple.make - (block $MArrayGet.10 (result i32) - (local.set $1 - (i32.const -5) - ) - (local.set $2 - (local.get $6) - ) - (block $resolve_idx.9 - (if - (i32.eqz - (i32.and - (local.get $1) - (i32.const 1) - ) - ) - (block $IndexNotSimpleInteger.8 - (local.set $1 - (i32.load offset=4 - (local.get $1) - ) - ) - (drop - (if (result i32) - (i32.or - (i32.eq - (local.get $1) - (i32.const 2) - ) - (i32.eq - (local.get $1) - (i32.const 4) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.6 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 69) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - ) - (local.set $1 - (i32.shr_s - (local.get $1) - (i32.const 1) - ) - ) - (if - (i32.lt_s - (local.get $1) - (i32.const 0) - ) - (local.set $1 - (i32.add - (local.get $1) - (i32.load offset=4 - (local.get $2) - ) - ) - ) - ) - (if - (i32.le_u - (i32.load offset=4 - (local.get $2) - ) - (local.get $1) - ) - (drop - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.5 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (i32.add - (i32.shl - (local.get $1) - (i32.const 2) - ) - (local.get $2) - ) - ) - ) - ) - (block $cleanup.4 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MArrayOp + (MArrayGet + ((immediate_desc (MImmConst (MConstI32 -3))) + (immediate_analyses ((last_usage Unknown))))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/arrays.24453e6e.0.snapshot b/compiler/test/__snapshots__/arrays.24453e6e.0.snapshot index 617668248..f151bcdb8 100644 --- a/compiler/test/__snapshots__/arrays.24453e6e.0.snapshot +++ b/compiler/test/__snapshots__/arrays.24453e6e.0.snapshot @@ -1,65 +1,18 @@ arrays › array1_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/arrays.28fcc534.0.snapshot b/compiler/test/__snapshots__/arrays.28fcc534.0.snapshot index d6b32719c..13d5c033d 100644 --- a/compiler/test/__snapshots__/arrays.28fcc534.0.snapshot +++ b/compiler/test/__snapshots__/arrays.28fcc534.0.snapshot @@ -1,250 +1,28 @@ arrays › array_access4 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"GRAIN$EXPORT$panicWithException\" (global $GRAIN$EXPORT$panicWithException_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.10 (result i32) - (block $compile_store.3 - (global.set $x_1113 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $MArrayGet.9 (result i32) - (local.set $1 - (i32.const -3) - ) - (local.set $2 - (global.get $x_1113) - ) - (block $resolve_idx.8 - (if - (i32.eqz - (i32.and - (local.get $1) - (i32.const 1) - ) - ) - (block $IndexNotSimpleInteger.7 - (local.set $1 - (i32.load offset=4 - (local.get $1) - ) - ) - (drop - (if (result i32) - (i32.or - (i32.eq - (local.get $1) - (i32.const 2) - ) - (i32.eq - (local.get $1) - (i32.const 4) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.6 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.5 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 69) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - ) - (local.set $1 - (i32.shr_s - (local.get $1) - (i32.const 1) - ) - ) - (if - (i32.lt_s - (local.get $1) - (i32.const 0) - ) - (local.set $1 - (i32.add - (local.get $1) - (i32.load offset=4 - (local.get $2) - ) - ) - ) - ) - (if - (i32.le_u - (i32.load offset=4 - (local.get $2) - ) - (local.get $1) - ) - (drop - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (i32.add - (i32.shl - (local.get $1) - (i32.const 2) - ) - (local.get $2) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MArrayOp + (MArrayGet + ((immediate_desc (MImmConst (MConstI32 -2))) + (immediate_analyses ((last_usage Unknown))))) + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name x)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/arrays.4c8c9f91.0.snapshot b/compiler/test/__snapshots__/arrays.4c8c9f91.0.snapshot index c660f7449..898af8fb4 100644 --- a/compiler/test/__snapshots__/arrays.4c8c9f91.0.snapshot +++ b/compiler/test/__snapshots__/arrays.4c8c9f91.0.snapshot @@ -1,250 +1,28 @@ arrays › array_access2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"GRAIN$EXPORT$panicWithException\" (global $GRAIN$EXPORT$panicWithException_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.10 (result i32) - (block $compile_store.3 - (global.set $x_1113 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $MArrayGet.9 (result i32) - (local.set $1 - (i32.const 3) - ) - (local.set $2 - (global.get $x_1113) - ) - (block $resolve_idx.8 - (if - (i32.eqz - (i32.and - (local.get $1) - (i32.const 1) - ) - ) - (block $IndexNotSimpleInteger.7 - (local.set $1 - (i32.load offset=4 - (local.get $1) - ) - ) - (drop - (if (result i32) - (i32.or - (i32.eq - (local.get $1) - (i32.const 2) - ) - (i32.eq - (local.get $1) - (i32.const 4) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.6 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.5 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 69) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - ) - (local.set $1 - (i32.shr_s - (local.get $1) - (i32.const 1) - ) - ) - (if - (i32.lt_s - (local.get $1) - (i32.const 0) - ) - (local.set $1 - (i32.add - (local.get $1) - (i32.load offset=4 - (local.get $2) - ) - ) - ) - ) - (if - (i32.le_u - (i32.load offset=4 - (local.get $2) - ) - (local.get $1) - ) - (drop - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (i32.add - (i32.shl - (local.get $1) - (i32.const 2) - ) - (local.get $2) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MArrayOp + (MArrayGet + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))) + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name x)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/arrays.6eac4e1f.0.snapshot b/compiler/test/__snapshots__/arrays.6eac4e1f.0.snapshot index f845fb662..248d4a6df 100644 --- a/compiler/test/__snapshots__/arrays.6eac4e1f.0.snapshot +++ b/compiler/test/__snapshots__/arrays.6eac4e1f.0.snapshot @@ -1,250 +1,28 @@ arrays › array_access3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"GRAIN$EXPORT$panicWithException\" (global $GRAIN$EXPORT$panicWithException_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.10 (result i32) - (block $compile_store.3 - (global.set $x_1113 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $MArrayGet.9 (result i32) - (local.set $1 - (i32.const 5) - ) - (local.set $2 - (global.get $x_1113) - ) - (block $resolve_idx.8 - (if - (i32.eqz - (i32.and - (local.get $1) - (i32.const 1) - ) - ) - (block $IndexNotSimpleInteger.7 - (local.set $1 - (i32.load offset=4 - (local.get $1) - ) - ) - (drop - (if (result i32) - (i32.or - (i32.eq - (local.get $1) - (i32.const 2) - ) - (i32.eq - (local.get $1) - (i32.const 4) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.6 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.5 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 69) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - ) - (local.set $1 - (i32.shr_s - (local.get $1) - (i32.const 1) - ) - ) - (if - (i32.lt_s - (local.get $1) - (i32.const 0) - ) - (local.set $1 - (i32.add - (local.get $1) - (i32.load offset=4 - (local.get $2) - ) - ) - ) - ) - (if - (i32.le_u - (i32.load offset=4 - (local.get $2) - ) - (local.get $1) - ) - (drop - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (i32.add - (i32.shl - (local.get $1) - (i32.const 2) - ) - (local.get $2) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MArrayOp + (MArrayGet + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))) + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name x)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/arrays.74d79181.0.snapshot b/compiler/test/__snapshots__/arrays.74d79181.0.snapshot index 11a9b199a..d0b5bde11 100644 --- a/compiler/test/__snapshots__/arrays.74d79181.0.snapshot +++ b/compiler/test/__snapshots__/arrays.74d79181.0.snapshot @@ -1,250 +1,28 @@ arrays › array_access5 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"GRAIN$EXPORT$panicWithException\" (global $GRAIN$EXPORT$panicWithException_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.10 (result i32) - (block $compile_store.3 - (global.set $x_1113 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $MArrayGet.9 (result i32) - (local.set $1 - (i32.const -5) - ) - (local.set $2 - (global.get $x_1113) - ) - (block $resolve_idx.8 - (if - (i32.eqz - (i32.and - (local.get $1) - (i32.const 1) - ) - ) - (block $IndexNotSimpleInteger.7 - (local.set $1 - (i32.load offset=4 - (local.get $1) - ) - ) - (drop - (if (result i32) - (i32.or - (i32.eq - (local.get $1) - (i32.const 2) - ) - (i32.eq - (local.get $1) - (i32.const 4) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.6 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.5 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 69) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - ) - (local.set $1 - (i32.shr_s - (local.get $1) - (i32.const 1) - ) - ) - (if - (i32.lt_s - (local.get $1) - (i32.const 0) - ) - (local.set $1 - (i32.add - (local.get $1) - (i32.load offset=4 - (local.get $2) - ) - ) - ) - ) - (if - (i32.le_u - (i32.load offset=4 - (local.get $2) - ) - (local.get $1) - ) - (drop - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (i32.add - (i32.shl - (local.get $1) - (i32.const 2) - ) - (local.get $2) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MArrayOp + (MArrayGet + ((immediate_desc (MImmConst (MConstI32 -3))) + (immediate_analyses ((last_usage Unknown))))) + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name x)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/arrays.9e17b4d1.0.snapshot b/compiler/test/__snapshots__/arrays.9e17b4d1.0.snapshot index 356b660f0..bbd587e82 100644 --- a/compiler/test/__snapshots__/arrays.9e17b4d1.0.snapshot +++ b/compiler/test/__snapshots__/arrays.9e17b4d1.0.snapshot @@ -1,65 +1,18 @@ arrays › array3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/arrays.b85cb7fc.0.snapshot b/compiler/test/__snapshots__/arrays.b85cb7fc.0.snapshot index 4ec5675f0..343071485 100644 --- a/compiler/test/__snapshots__/arrays.b85cb7fc.0.snapshot +++ b/compiler/test/__snapshots__/arrays.b85cb7fc.0.snapshot @@ -1,65 +1,18 @@ arrays › array1_trailing_space -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.00bcbc39.0.snapshot b/compiler/test/__snapshots__/basic_functionality.00bcbc39.0.snapshot index 761bd6d9f..901140719 100644 --- a/compiler/test/__snapshots__/basic_functionality.00bcbc39.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.00bcbc39.0.snapshot @@ -1,85 +1,52 @@ basic functionality › assignment1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1117 (param i32 i32 i32) (result i32))) - (global $t_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.2 - (global.set $t_1113 - (i32.const 5) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $*_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $t_1113) - ) - (i32.const 5) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_set.5 (result i32) - (global.set $t_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $t_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func *_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind t_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name t)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.00cfdb2e.0.snapshot b/compiler/test/__snapshots__/basic_functionality.00cfdb2e.0.snapshot index aa59bf5b1..17fd9e931 100644 --- a/compiler/test/__snapshots__/basic_functionality.00cfdb2e.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.00cfdb2e.0.snapshot @@ -1,35 +1,13 @@ basic functionality › binop2.4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -3) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 -2))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.03de4778.0.snapshot b/compiler/test/__snapshots__/basic_functionality.03de4778.0.snapshot index 10e9abfad..975015b11 100644 --- a/compiler/test/__snapshots__/basic_functionality.03de4778.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.03de4778.0.snapshot @@ -1,35 +1,13 @@ basic functionality › neg -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -79) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 -40))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.040643b3.0.snapshot b/compiler/test/__snapshots__/basic_functionality.040643b3.0.snapshot index 623579219..66f8fcc2c 100644 --- a/compiler/test/__snapshots__/basic_functionality.040643b3.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.040643b3.0.snapshot @@ -1,67 +1,48 @@ basic functionality › comp5 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<\" (global $<_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<\" (func $<_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $<_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<_1114) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const 9) - ) - (block $compile_block.4 (result i32) - (i32.const 11) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func <_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.06bd2a80.0.snapshot b/compiler/test/__snapshots__/basic_functionality.06bd2a80.0.snapshot index 7dcb135c2..cfac5f319 100644 --- a/compiler/test/__snapshots__/basic_functionality.06bd2a80.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.06bd2a80.0.snapshot @@ -1,64 +1,22 @@ basic functionality › assignment1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $t_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.4 (result i32) - (block $compile_store.2 - (global.set $t_1113 - (i32.const 5) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_set.3 (result i32) - (global.set $t_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.const 3) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $t_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MSet (MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name t)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.0996c5f7.0.snapshot b/compiler/test/__snapshots__/basic_functionality.0996c5f7.0.snapshot index cf6e10609..467b63cf8 100644 --- a/compiler/test/__snapshots__/basic_functionality.0996c5f7.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.0996c5f7.0.snapshot @@ -1,48 +1,33 @@ basic functionality › modulo4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$%\" (global $%_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"%\" (func $%_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $%_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $%_1113) - ) - (i32.const -33) - (i32.const 35) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func %_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind %_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 -17))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 17))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.0a230f18.0.snapshot b/compiler/test/__snapshots__/basic_functionality.0a230f18.0.snapshot index bc8734bd2..8b0f04187 100644 --- a/compiler/test/__snapshots__/basic_functionality.0a230f18.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.0a230f18.0.snapshot @@ -1,48 +1,33 @@ basic functionality › land4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$&\" (global $&_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"&\" (func $&_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $&_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $&_1113) - ) - (i32.const 1) - (i32.const 1) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name &))) (mimp_mod pervasives.gr) (mimp_name &) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name &))) (mimp_mod pervasives.gr) (mimp_name &) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func &_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind &_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.0a2e4afa.0.snapshot b/compiler/test/__snapshots__/basic_functionality.0a2e4afa.0.snapshot index dc2f4c8c0..584c76276 100644 --- a/compiler/test/__snapshots__/basic_functionality.0a2e4afa.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.0a2e4afa.0.snapshot @@ -1,48 +1,33 @@ basic functionality › lxor1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$^\" (global $^_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"^\" (func $^_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $^_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $^_1113) - ) - (i32.const 3) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name ^))) (mimp_mod pervasives.gr) (mimp_name ^) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ^))) (mimp_mod pervasives.gr) (mimp_name ^) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ^_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ^_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.0c0b170b.0.snapshot b/compiler/test/__snapshots__/basic_functionality.0c0b170b.0.snapshot index 2381f4173..a51e6996f 100644 --- a/compiler/test/__snapshots__/basic_functionality.0c0b170b.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.0c0b170b.0.snapshot @@ -1,48 +1,33 @@ basic functionality › lor1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$|\" (global $|_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"|\" (func $|_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $|_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $|_1113) - ) - (i32.const 3) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name |))) (mimp_mod pervasives.gr) (mimp_name |) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name |))) (mimp_mod pervasives.gr) (mimp_name |) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func |_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind |_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.0c400bde.0.snapshot b/compiler/test/__snapshots__/basic_functionality.0c400bde.0.snapshot index 1f2757e89..0a542c834 100644 --- a/compiler/test/__snapshots__/basic_functionality.0c400bde.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.0c400bde.0.snapshot @@ -1,48 +1,33 @@ basic functionality › modulo6 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$%\" (global $%_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"%\" (func $%_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $%_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $%_1113) - ) - (i32.const 35) - (i32.const 35) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func %_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind %_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 17))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 17))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.0e812a39.0.snapshot b/compiler/test/__snapshots__/basic_functionality.0e812a39.0.snapshot index ac5ef3233..f3a56107b 100644 --- a/compiler/test/__snapshots__/basic_functionality.0e812a39.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.0e812a39.0.snapshot @@ -1,65 +1,58 @@ basic functionality › precedence1 -(module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1116 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1116 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.3 - (block $compile_store.2 - (local.set $6 - (call $*_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1116) - ) - (i32.const 9) - (i32.const 13) - ) - ) - (block $do_backpatches.1 - ) - ) - (return_call $+_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1113) - ) - (i32.const 7) - (local.get $6) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func *_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func +_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.0f79ce35.0.snapshot b/compiler/test/__snapshots__/basic_functionality.0f79ce35.0.snapshot index 1ba18ed5d..84f8e8393 100644 --- a/compiler/test/__snapshots__/basic_functionality.0f79ce35.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.0f79ce35.0.snapshot @@ -1,48 +1,34 @@ basic functionality › comp16 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (i32.const 2147483646) - (i32.const 2147483646) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + (((Unmanaged WasmI32) (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.10dda088.0.snapshot b/compiler/test/__snapshots__/basic_functionality.10dda088.0.snapshot index ac8a9e2d2..ca4645dce 100644 --- a/compiler/test/__snapshots__/basic_functionality.10dda088.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.10dda088.0.snapshot @@ -1,67 +1,48 @@ basic functionality › comp3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>=\" (global $>=_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">=\" (func $>=_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $>=_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>=_1114) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const 9) - ) - (block $compile_block.4 (result i32) - (i32.const 11) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name >=))) (mimp_mod pervasives.gr) (mimp_name >=) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >=))) (mimp_mod pervasives.gr) (mimp_name >=) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func >=_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind >=_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.122e74b0.0.snapshot b/compiler/test/__snapshots__/basic_functionality.122e74b0.0.snapshot index 86fd6579e..eb165c881 100644 --- a/compiler/test/__snapshots__/basic_functionality.122e74b0.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.122e74b0.0.snapshot @@ -1,112 +1,50 @@ basic functionality › print_line_ending1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $print_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1113) - ) - (i32.const 3) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString \"\"))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MReturnCallKnown (func print_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.125626a9.0.snapshot b/compiler/test/__snapshots__/basic_functionality.125626a9.0.snapshot index e0f7a5415..c6ef4f5ee 100644 --- a/compiler/test/__snapshots__/basic_functionality.125626a9.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.125626a9.0.snapshot @@ -1,48 +1,33 @@ basic functionality › orshadow -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $+_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1114) - ) - (i32.const 3) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func +_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.13335202.0.snapshot b/compiler/test/__snapshots__/basic_functionality.13335202.0.snapshot index da00cb8d1..2129eaacb 100644 --- a/compiler/test/__snapshots__/basic_functionality.13335202.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.13335202.0.snapshot @@ -1,65 +1,58 @@ basic functionality › precedence2 -(module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1115 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1115 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.3 - (block $compile_store.2 - (local.set $6 - (call $*_1115 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1115) - ) - (i32.const 9) - (i32.const 13) - ) - ) - (block $do_backpatches.1 - ) - ) - (return_call $+_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1113) - ) - (local.get $6) - (i32.const 7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func *_1115) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func +_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.1ad0f349.0.snapshot b/compiler/test/__snapshots__/basic_functionality.1ad0f349.0.snapshot index 5d0d6a865..ea8bcce9d 100644 --- a/compiler/test/__snapshots__/basic_functionality.1ad0f349.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.1ad0f349.0.snapshot @@ -1,65 +1,58 @@ basic functionality › precedence3 -(module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$%\" (global $%_1116 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"%\" (func $%_1116 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.3 - (block $compile_store.2 - (local.set $6 - (call $%_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $%_1116) - ) - (i32.const 9) - (i32.const 13) - ) - ) - (block $do_backpatches.1 - ) - ) - (return_call $+_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1113) - ) - (i32.const 7) - (local.get $6) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func %_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind %_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func +_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.1ae16d82.0.snapshot b/compiler/test/__snapshots__/basic_functionality.1ae16d82.0.snapshot index c4ac6bdb5..e08790f3b 100644 --- a/compiler/test/__snapshots__/basic_functionality.1ae16d82.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.1ae16d82.0.snapshot @@ -1,48 +1,33 @@ basic functionality › binop4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $*_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1113) - ) - (i32.const 5) - (i32.const 7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func *_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.1b68c8db.0.snapshot b/compiler/test/__snapshots__/basic_functionality.1b68c8db.0.snapshot index 2754fe0c8..5b1d94acd 100644 --- a/compiler/test/__snapshots__/basic_functionality.1b68c8db.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.1b68c8db.0.snapshot @@ -1,48 +1,33 @@ basic functionality › lsl1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<<\" (global $<<_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<<\" (func $<<_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $<<_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<<_1113) - ) - (i32.const 15) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name <<))) (mimp_mod pervasives.gr) (mimp_name <<) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <<))) (mimp_mod pervasives.gr) (mimp_name <<) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func <<_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <<_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 7))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.1bf5759c.0.snapshot b/compiler/test/__snapshots__/basic_functionality.1bf5759c.0.snapshot index 1b7cb1b03..4ba4f71b1 100644 --- a/compiler/test/__snapshots__/basic_functionality.1bf5759c.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.1bf5759c.0.snapshot @@ -1,72 +1,101 @@ basic functionality › unsafe_wasm_globals -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_f64_=>_i32 (func (param i32 f64) (result i32))) - (type $i32_f32_=>_i32 (func (param i32 f32) (result i32))) - (type $i32_i64_=>_i32 (func (param i32 i64) (result i32))) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$unsafeWasmGlobalsExports.gr\" \"GRAIN$EXPORT$_F64_VAL\" (global $_F64_VAL_1159 (mut f64))) - (import \"GRAIN$MODULE$runtime/debugPrint.gr\" \"GRAIN$EXPORT$printF64\" (global $printF64_1158 (mut i32))) - (import \"GRAIN$MODULE$unsafeWasmGlobalsExports.gr\" \"GRAIN$EXPORT$_F32_VAL\" (global $_F32_VAL_1157 (mut f32))) - (import \"GRAIN$MODULE$runtime/debugPrint.gr\" \"GRAIN$EXPORT$printF32\" (global $printF32_1156 (mut i32))) - (import \"GRAIN$MODULE$unsafeWasmGlobalsExports.gr\" \"GRAIN$EXPORT$_I64_VAL\" (global $_I64_VAL_1155 (mut i64))) - (import \"GRAIN$MODULE$runtime/debugPrint.gr\" \"GRAIN$EXPORT$printI64\" (global $printI64_1154 (mut i32))) - (import \"GRAIN$MODULE$unsafeWasmGlobalsExports.gr\" \"GRAIN$EXPORT$_I32_VAL\" (global $_I32_VAL_1153 (mut i32))) - (import \"GRAIN$MODULE$runtime/debugPrint.gr\" \"GRAIN$EXPORT$printI32\" (global $printI32_1152 (mut i32))) - (import \"GRAIN$MODULE$runtime/debugPrint.gr\" \"printF64\" (func $printF64_1158 (param i32 f64) (result i32))) - (import \"GRAIN$MODULE$runtime/debugPrint.gr\" \"printF32\" (func $printF32_1156 (param i32 f32) (result i32))) - (import \"GRAIN$MODULE$runtime/debugPrint.gr\" \"printI64\" (func $printI64_1154 (param i32 i64) (result i32))) - (import \"GRAIN$MODULE$runtime/debugPrint.gr\" \"printI32\" (func $printI32_1152 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (drop - (call $printI32_1152 - (global.get $printI32_1152) - (global.get $_I32_VAL_1153) - ) - ) - (drop - (call $printI64_1154 - (global.get $printI64_1154) - (global.get $_I64_VAL_1155) - ) - ) - (drop - (call $printF32_1156 - (global.get $printF32_1156) - (global.get $_F32_VAL_1157) - ) - ) - (return_call $printF64_1158 - (global.get $printF64_1158) - (global.get $_F64_VAL_1159) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 509 -) +((functions ()) + (imports + (((mimp_id ((name _F64_VAL))) (mimp_mod unsafeWasmGlobalsExports.gr) + (mimp_name _F64_VAL) (mimp_type (MGlobalImport (Unmanaged WasmF64) true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name printF64))) (mimp_mod runtime/debugPrint.gr) + (mimp_name printF64) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmF64)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name printF64))) (mimp_mod runtime/debugPrint.gr) + (mimp_name printF64) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name _F32_VAL))) (mimp_mod unsafeWasmGlobalsExports.gr) + (mimp_name _F32_VAL) (mimp_type (MGlobalImport (Unmanaged WasmF32) true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name printF32))) (mimp_mod runtime/debugPrint.gr) + (mimp_name printF32) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmF32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name printF32))) (mimp_mod runtime/debugPrint.gr) + (mimp_name printF32) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name _I64_VAL))) (mimp_mod unsafeWasmGlobalsExports.gr) + (mimp_name _I64_VAL) (mimp_type (MGlobalImport (Unmanaged WasmI64) true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name printI64))) (mimp_mod runtime/debugPrint.gr) + (mimp_name printI64) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI64)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name printI64))) (mimp_mod runtime/debugPrint.gr) + (mimp_name printI64) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name _I32_VAL))) (mimp_mod unsafeWasmGlobalsExports.gr) + (mimp_name _I32_VAL) (mimp_type (MGlobalImport (Unmanaged WasmI32) true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name printI32))) (mimp_mod runtime/debugPrint.gr) + (mimp_name printI32) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name printI32))) (mimp_mod runtime/debugPrint.gr) + (mimp_name printI32) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func printI32_1152) + (closure + ((immediate_desc (MImmBinding (MGlobalBind printI32_1152 Managed))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MImmBinding (MGlobalBind _I32_VAL_1153 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func printI64_1154) + (closure + ((immediate_desc (MImmBinding (MGlobalBind printI64_1154 Managed))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmI64)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MImmBinding (MGlobalBind _I64_VAL_1155 (Unmanaged WasmI64)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func printF32_1156) + (closure + ((immediate_desc (MImmBinding (MGlobalBind printF32_1156 Managed))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmF32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MImmBinding (MGlobalBind _F32_VAL_1157 (Unmanaged WasmF32)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func printF64_1158) + (closure + ((immediate_desc (MImmBinding (MGlobalBind printF64_1158 Managed))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmF64)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MImmBinding (MGlobalBind _F64_VAL_1159 (Unmanaged WasmF64)))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.1d2ec323.0.snapshot b/compiler/test/__snapshots__/basic_functionality.1d2ec323.0.snapshot index 020c5a128..0dd7da048 100644 --- a/compiler/test/__snapshots__/basic_functionality.1d2ec323.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.1d2ec323.0.snapshot @@ -1,260 +1,107 @@ basic functionality › comp22 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$isnt\" (global $isnt_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"isnt\" (func $isnt_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (block $compile_block.19 - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_tuple.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.18 - (local.set $11 - (block $allocate_adt.16 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (local.get $9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $10) - ) - (local.get $0) - ) - ) - (block $do_backpatches.17 - ) - ) - (return_call $isnt_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $isnt_1113) - ) - (local.get $8) - (local.get $11) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name isnt))) (mimp_mod pervasives.gr) (mimp_name isnt) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name isnt))) (mimp_mod pervasives.gr) (mimp_name isnt) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MReturnCallKnown (func isnt_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind isnt_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 6) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.1e4b1f39.0.snapshot b/compiler/test/__snapshots__/basic_functionality.1e4b1f39.0.snapshot index 147bc9682..4aa86f09a 100644 --- a/compiler/test/__snapshots__/basic_functionality.1e4b1f39.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.1e4b1f39.0.snapshot @@ -1,48 +1,33 @@ basic functionality › land1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$&\" (global $&_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"&\" (func $&_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $&_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $&_1113) - ) - (i32.const 3) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name &))) (mimp_mod pervasives.gr) (mimp_name &) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name &))) (mimp_mod pervasives.gr) (mimp_name &) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func &_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind &_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.1f787365.0.snapshot b/compiler/test/__snapshots__/basic_functionality.1f787365.0.snapshot index 6039c5a95..9310368cb 100644 --- a/compiler/test/__snapshots__/basic_functionality.1f787365.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.1f787365.0.snapshot @@ -1,88 +1,52 @@ basic functionality › orshort2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.4 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (drop - (call $print_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1113) - ) - (i32.const 3) - (local.get $6) - ) - ) - (i32.const 2147483646) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.20f7581b.0.snapshot b/compiler/test/__snapshots__/basic_functionality.20f7581b.0.snapshot index b793ef5c1..efa319c05 100644 --- a/compiler/test/__snapshots__/basic_functionality.20f7581b.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.20f7581b.0.snapshot @@ -1,35 +1,13 @@ basic functionality › simple_min -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -2147483647) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 -1073741824))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.240ef39e.0.snapshot b/compiler/test/__snapshots__/basic_functionality.240ef39e.0.snapshot index a37c84ec6..dbbed7c9c 100644 --- a/compiler/test/__snapshots__/basic_functionality.240ef39e.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.240ef39e.0.snapshot @@ -1,67 +1,48 @@ basic functionality › comp4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>\" (global $>_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">\" (func $>_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $>_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>_1114) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const 9) - ) - (block $compile_block.4 (result i32) - (i32.const 11) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func >_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind >_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.2756b429.0.snapshot b/compiler/test/__snapshots__/basic_functionality.2756b429.0.snapshot index 269bbdd8a..c4cb5f237 100644 --- a/compiler/test/__snapshots__/basic_functionality.2756b429.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.2756b429.0.snapshot @@ -1,35 +1,13 @@ basic functionality › forty -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 81) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 40))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.27a7e2f7.0.snapshot b/compiler/test/__snapshots__/basic_functionality.27a7e2f7.0.snapshot index cdd63deb0..1fe5a735e 100644 --- a/compiler/test/__snapshots__/basic_functionality.27a7e2f7.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.27a7e2f7.0.snapshot @@ -1,65 +1,9 @@ basic functionality › bigint_start_pos -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (i64.store offset=16 - (local.get $0) - (i64.const -1) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MBigInt (flags ()) (limbs (-1)))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.28405f1f.0.snapshot b/compiler/test/__snapshots__/basic_functionality.28405f1f.0.snapshot index e93614609..c85a42556 100644 --- a/compiler/test/__snapshots__/basic_functionality.28405f1f.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.28405f1f.0.snapshot @@ -1,65 +1,58 @@ basic functionality › precedence4 -(module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$%\" (global $%_1115 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"%\" (func $%_1115 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.3 - (block $compile_store.2 - (local.set $6 - (call $%_1115 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $%_1115) - ) - (i32.const 9) - (i32.const 13) - ) - ) - (block $do_backpatches.1 - ) - ) - (return_call $+_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1113) - ) - (local.get $6) - (i32.const 7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func %_1115) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind %_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func +_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.28bf4c9e.0.snapshot b/compiler/test/__snapshots__/basic_functionality.28bf4c9e.0.snapshot index 0237f8d80..375889190 100644 --- a/compiler/test/__snapshots__/basic_functionality.28bf4c9e.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.28bf4c9e.0.snapshot @@ -1,48 +1,33 @@ basic functionality › binop2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $-_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1113) - ) - (i32.const 5) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func -_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.2bcc447b.0.snapshot b/compiler/test/__snapshots__/basic_functionality.2bcc447b.0.snapshot index 2096b8083..8106e7a60 100644 --- a/compiler/test/__snapshots__/basic_functionality.2bcc447b.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.2bcc447b.0.snapshot @@ -1,186 +1,95 @@ basic functionality › assert2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"GRAIN$EXPORT$panicWithException\" (global $GRAIN$EXPORT$panicWithException_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1116 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1116 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.14 (result i32) - (block $compile_store.2 - (local.set $6 - (call $+_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1116) - ) - (i32.const 7) - (i32.const 7) - ) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $9 - (call $==_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1114) - ) - (local.get $6) - (i32.const 13) - ) - ) - (block $do_backpatches.3 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $9) - (i32.const 31) - ) - (block $compile_block.5 (result i32) - (i32.const 1879048190) - ) - (block $compile_block.13 - (block $compile_store.8 - (local.set $7 - (block $allocate_string.6 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 64) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 51) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 8028075845441778497) - ) - (i64.store offset=16 - (local.get $0) - (i64.const 2322294380849939822) - ) - (i64.store offset=24 - (local.get $0) - (i64.const 8028075845441778497) - ) - (i64.store offset=32 - (local.get $0) - (i64.const 7234307576302018670) - ) - (i64.store offset=40 - (local.get $0) - (i64.const 7310313481145575712) - ) - (i64.store offset=48 - (local.get $0) - (i64.const 7956009102162949234) - ) - (i64.store offset=56 - (local.get $0) - (i64.const 3219557) - ) - (local.get $0) - ) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.11 - (local.set $8 - (block $allocate_adt.9 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 59) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 65) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=20 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $throw.12 - (drop - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (local.get $8) - ) - ) - (unreachable) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func +_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MString + \"AssertionError: Assertion failed in assert2, line 1\"))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 29))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 32))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MPrim1 Throw + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.2cb30a54.0.snapshot b/compiler/test/__snapshots__/basic_functionality.2cb30a54.0.snapshot index 8b73fb0d9..1cbb461b9 100644 --- a/compiler/test/__snapshots__/basic_functionality.2cb30a54.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.2cb30a54.0.snapshot @@ -1,65 +1,10 @@ basic functionality › bigint_start_neg -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i64.store offset=16 - (local.get $0) - (i64.const -1) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc (MAllocate (MBigInt (flags (BigIntNegative)) (limbs (-1)))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.2d7e34cf.0.snapshot b/compiler/test/__snapshots__/basic_functionality.2d7e34cf.0.snapshot index ae9e0d884..167643539 100644 --- a/compiler/test/__snapshots__/basic_functionality.2d7e34cf.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.2d7e34cf.0.snapshot @@ -1,35 +1,13 @@ basic functionality › and2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 2147483646) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.2f2f8795.0.snapshot b/compiler/test/__snapshots__/basic_functionality.2f2f8795.0.snapshot index 44f59ae1b..549f6056d 100644 --- a/compiler/test/__snapshots__/basic_functionality.2f2f8795.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.2f2f8795.0.snapshot @@ -1,48 +1,33 @@ basic functionality › lsl2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<<\" (global $<<_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<<\" (func $<<_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $<<_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<<_1113) - ) - (i32.const 1) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name <<))) (mimp_mod pervasives.gr) (mimp_name <<) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <<))) (mimp_mod pervasives.gr) (mimp_name <<) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func <<_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <<_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.2f53324c.0.snapshot b/compiler/test/__snapshots__/basic_functionality.2f53324c.0.snapshot index 64450037b..6116f9b0c 100644 --- a/compiler/test/__snapshots__/basic_functionality.2f53324c.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.2f53324c.0.snapshot @@ -1,48 +1,34 @@ basic functionality › comp17 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$isnt\" (global $isnt_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"isnt\" (func $isnt_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $isnt_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $isnt_1113) - ) - (i32.const 2147483646) - (i32.const -2) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name isnt))) (mimp_mod pervasives.gr) (mimp_name isnt) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name isnt))) (mimp_mod pervasives.gr) (mimp_name isnt) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func isnt_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind isnt_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + (((Unmanaged WasmI32) (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.2f65c8cf.0.snapshot b/compiler/test/__snapshots__/basic_functionality.2f65c8cf.0.snapshot index cf253a537..96a8a8d80 100644 --- a/compiler/test/__snapshots__/basic_functionality.2f65c8cf.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.2f65c8cf.0.snapshot @@ -1,35 +1,13 @@ basic functionality › fals -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 2147483646) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.304ca65f.0.snapshot b/compiler/test/__snapshots__/basic_functionality.304ca65f.0.snapshot index 857a37750..2aba1f732 100644 --- a/compiler/test/__snapshots__/basic_functionality.304ca65f.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.304ca65f.0.snapshot @@ -1,35 +1,13 @@ basic functionality › oct_neg -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -125) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 -63))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.31e0d562.0.snapshot b/compiler/test/__snapshots__/basic_functionality.31e0d562.0.snapshot index 0589e6612..d1e74fd4f 100644 --- a/compiler/test/__snapshots__/basic_functionality.31e0d562.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.31e0d562.0.snapshot @@ -1,57 +1,9 @@ basic functionality › infinity -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (f64.store offset=8 - (local.get $0) - (f64.const inf) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MFloat64 9218868437227405312)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.32a8c452.0.snapshot b/compiler/test/__snapshots__/basic_functionality.32a8c452.0.snapshot index 030c9ebdb..87d276037 100644 --- a/compiler/test/__snapshots__/basic_functionality.32a8c452.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.32a8c452.0.snapshot @@ -1,102 +1,71 @@ basic functionality › complex2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1116 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1116 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.6 - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (call $+_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1116) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.4 - ) - ) - (return_call $print_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1113) - ) - (local.get $7) - (local.get $6) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func +_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func print_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.34dcfbdd.0.snapshot b/compiler/test/__snapshots__/basic_functionality.34dcfbdd.0.snapshot index 20ccce0ac..0c685317b 100644 --- a/compiler/test/__snapshots__/basic_functionality.34dcfbdd.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.34dcfbdd.0.snapshot @@ -1,57 +1,9 @@ basic functionality › int64_1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 99999999999999999) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MInt64 99999999999999999)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.3c2ba165.0.snapshot b/compiler/test/__snapshots__/basic_functionality.3c2ba165.0.snapshot index d38657bc3..d838604ae 100644 --- a/compiler/test/__snapshots__/basic_functionality.3c2ba165.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.3c2ba165.0.snapshot @@ -1,292 +1,123 @@ basic functionality › comp20 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$isnt\" (global $isnt_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"isnt\" (func $isnt_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (block $compile_block.19 - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.18 - (local.set $11 - (block $allocate_adt.16 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $10) - ) - (local.get $0) - ) - ) - (block $do_backpatches.17 - ) - ) - (return_call $isnt_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $isnt_1113) - ) - (local.get $8) - (local.get $11) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name isnt))) (mimp_mod pervasives.gr) (mimp_name isnt) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name isnt))) (mimp_mod pervasives.gr) (mimp_name isnt) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MReturnCallKnown (func isnt_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind isnt_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 6) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.3e5f990b.0.snapshot b/compiler/test/__snapshots__/basic_functionality.3e5f990b.0.snapshot index 5cceacca2..3032f9716 100644 --- a/compiler/test/__snapshots__/basic_functionality.3e5f990b.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.3e5f990b.0.snapshot @@ -1,48 +1,33 @@ basic functionality › lor3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$|\" (global $|_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"|\" (func $|_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $|_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $|_1113) - ) - (i32.const 1) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name |))) (mimp_mod pervasives.gr) (mimp_name |) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name |))) (mimp_mod pervasives.gr) (mimp_name |) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func |_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind |_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.3edefd23.0.snapshot b/compiler/test/__snapshots__/basic_functionality.3edefd23.0.snapshot index eb7bdd441..fe5aac76f 100644 --- a/compiler/test/__snapshots__/basic_functionality.3edefd23.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.3edefd23.0.snapshot @@ -1,46 +1,30 @@ basic functionality › decr_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$decr\" (global $decr_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"decr\" (func $decr_1113 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $decr_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $decr_1113) - ) - (i32.const 1) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name decr))) (mimp_mod pervasives.gr) (mimp_name decr) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name decr))) (mimp_mod pervasives.gr) (mimp_name decr) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func decr_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind decr_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.3ffd0bf3.0.snapshot b/compiler/test/__snapshots__/basic_functionality.3ffd0bf3.0.snapshot index b0e2e3dbc..a1d5e014b 100644 --- a/compiler/test/__snapshots__/basic_functionality.3ffd0bf3.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.3ffd0bf3.0.snapshot @@ -1,35 +1,13 @@ basic functionality › orshort1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -2) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.427c6671.0.snapshot b/compiler/test/__snapshots__/basic_functionality.427c6671.0.snapshot index 552237e7d..ac894d738 100644 --- a/compiler/test/__snapshots__/basic_functionality.427c6671.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.427c6671.0.snapshot @@ -1,53 +1,9 @@ basic functionality › uint64_1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_uint64.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 12) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 99999999999999999) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MUint64 99999999999999999)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.448497ab.0.snapshot b/compiler/test/__snapshots__/basic_functionality.448497ab.0.snapshot index 547ac7c6c..c3a225675 100644 --- a/compiler/test/__snapshots__/basic_functionality.448497ab.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.448497ab.0.snapshot @@ -1,35 +1,13 @@ basic functionality › binop5 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 5) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.46348f36.0.snapshot b/compiler/test/__snapshots__/basic_functionality.46348f36.0.snapshot index 43c408598..abc07701f 100644 --- a/compiler/test/__snapshots__/basic_functionality.46348f36.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.46348f36.0.snapshot @@ -1,76 +1,66 @@ basic functionality › precedence5 -(module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<\" (global $<_1117 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>\" (global $>_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<\" (func $<_1117 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">\" (func $>_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $>_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>_1114) - ) - (i32.const 9) - (i32.const 7) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 - (return_call $<_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<_1117) - ) - (i32.const 19) - (i32.const 27) - ) - ) - (block $compile_block.4 (result i32) - (local.get $6) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func >_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind >_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + (((instr_desc + (MReturnCallKnown (func <_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 9))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 13))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.48db380c.0.snapshot b/compiler/test/__snapshots__/basic_functionality.48db380c.0.snapshot index cb94986b2..2920904cc 100644 --- a/compiler/test/__snapshots__/basic_functionality.48db380c.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.48db380c.0.snapshot @@ -1,35 +1,13 @@ basic functionality › if4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 7) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.4d1501b9.0.snapshot b/compiler/test/__snapshots__/basic_functionality.4d1501b9.0.snapshot index 60072f874..18109681c 100644 --- a/compiler/test/__snapshots__/basic_functionality.4d1501b9.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.4d1501b9.0.snapshot @@ -1,57 +1,9 @@ basic functionality › nan -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (f64.store offset=8 - (local.get $0) - (f64.const nan:0x8000000000000) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MFloat64 9221120237041090560)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.4d6f9417.0.snapshot b/compiler/test/__snapshots__/basic_functionality.4d6f9417.0.snapshot index a40b2ea9f..f0374692e 100644 --- a/compiler/test/__snapshots__/basic_functionality.4d6f9417.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.4d6f9417.0.snapshot @@ -1,35 +1,13 @@ basic functionality › not1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 2147483646) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.4f5bd247.0.snapshot b/compiler/test/__snapshots__/basic_functionality.4f5bd247.0.snapshot index 7dac306da..9c2a1be3c 100644 --- a/compiler/test/__snapshots__/basic_functionality.4f5bd247.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.4f5bd247.0.snapshot @@ -1,57 +1,9 @@ basic functionality › heap_number_i64_wrapper -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 2147483648) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MInt64 2147483648)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.52ca8e0e.0.snapshot b/compiler/test/__snapshots__/basic_functionality.52ca8e0e.0.snapshot index d0364f37f..2aa7d1cfa 100644 --- a/compiler/test/__snapshots__/basic_functionality.52ca8e0e.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.52ca8e0e.0.snapshot @@ -1,261 +1,136 @@ basic functionality › func_shadow -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1118 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1118 (param i32 i32 i32) (result i32))) - (global $foo_1115 (mut i32) (i32.const 0)) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $compile_block.3 (result i32) - (tuple.extract 0 - (tuple.make - (block $allocate_string.2 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $1) - (i64.const 7496034) - ) - (local.get $1) - ) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $foo_1115 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $compile_block.6 (result i32) - (tuple.extract 0 - (tuple.make - (block $allocate_string.5 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $1) - (i64.const 8020322) - ) - (local.get $1) - ) - (block $cleanup.4 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.21 - (block $compile_store.8 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.11 - (local.set $6 - (block $allocate_adt.9 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $7 - (call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (drop - (call $print_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1118) - ) - (local.get $7) - (local.get $6) - ) - ) - (block $compile_store.15 - (global.set $foo_1115 - (i32.const 0) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.18 - (local.set $8 - (block $allocate_adt.16 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $9 - (call $foo_1115 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1115) - ) - ) - ) - (block $do_backpatches.19 - ) - ) - (return_call $print_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1118) - ) - (local.get $9) - (local.get $8) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 374 -) +((functions + (((id ((name foo))) (name (foo)) (args (Managed)) (return_type (Managed)) + (closure ()) + (body + (((instr_desc + (MCleanup (((instr_desc (MAllocate (MString bar))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())) + ((id ((name foo))) (name (foo)) (args (Managed)) (return_type (Managed)) + (closure ()) + (body + (((instr_desc + (MCleanup (((instr_desc (MAllocate (MString baz))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() (Managed))) (args ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1118 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind foo_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MCallKnown (func foo_1115) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() (Managed))) (args ()))))))))) + ((instr_desc + (MReturnCallKnown (func print_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1118 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name foo)) true Managed ()) (((name foo)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.565dbeda.0.snapshot b/compiler/test/__snapshots__/basic_functionality.565dbeda.0.snapshot index f18cf7240..7e1547b37 100644 --- a/compiler/test/__snapshots__/basic_functionality.565dbeda.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.565dbeda.0.snapshot @@ -1,35 +1,13 @@ basic functionality › hex_neg -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -509) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 -255))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.5705b20c.0.snapshot b/compiler/test/__snapshots__/basic_functionality.5705b20c.0.snapshot index c1004010c..4e7e0ee57 100644 --- a/compiler/test/__snapshots__/basic_functionality.5705b20c.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.5705b20c.0.snapshot @@ -1,48 +1,33 @@ basic functionality › modulo5 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$%\" (global $%_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"%\" (func $%_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $%_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $%_1113) - ) - (i32.const 35) - (i32.const -33) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func %_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind %_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 17))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 -17))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.593b8d63.0.snapshot b/compiler/test/__snapshots__/basic_functionality.593b8d63.0.snapshot index f45143107..1e7e2f560 100644 --- a/compiler/test/__snapshots__/basic_functionality.593b8d63.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.593b8d63.0.snapshot @@ -1,113 +1,90 @@ basic functionality › if_one_sided6 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1121 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<\" (global $<_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1121 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<\" (func $<_1116 (param i32 i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.10 (result i32) - (block $compile_store.2 - (global.set $x_1113 - (i32.const 3) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $7 - (call $<_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<_1116) - ) - (i32.const 7) - (i32.const 9) - ) - ) - (block $do_backpatches.3 - ) - ) - (drop - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.8 (result i32) - (block $compile_store.6 - (local.set $6 - (call $+_1121 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1121) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_set.7 (result i32) - (global.set $x_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $x_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_block.9 (result i32) - (i32.const 1879048190) - ) - ) - ) - (global.get $x_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func <_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func +_1121) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1121 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name x)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.5b56d472.0.snapshot b/compiler/test/__snapshots__/basic_functionality.5b56d472.0.snapshot index f18af66ca..7905be67b 100644 --- a/compiler/test/__snapshots__/basic_functionality.5b56d472.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.5b56d472.0.snapshot @@ -1,35 +1,13 @@ basic functionality › and3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 2147483646) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.5cd54e52.0.snapshot b/compiler/test/__snapshots__/basic_functionality.5cd54e52.0.snapshot index 9fa929804..4cecbd4d1 100644 --- a/compiler/test/__snapshots__/basic_functionality.5cd54e52.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.5cd54e52.0.snapshot @@ -1,35 +1,13 @@ basic functionality › or4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 2147483646) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.5d973a3e.0.snapshot b/compiler/test/__snapshots__/basic_functionality.5d973a3e.0.snapshot index 213e0f4ea..b3e6e5ab3 100644 --- a/compiler/test/__snapshots__/basic_functionality.5d973a3e.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.5d973a3e.0.snapshot @@ -1,48 +1,33 @@ basic functionality › binop6 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$%\" (global $%_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"%\" (func $%_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $%_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $%_1113) - ) - (i32.const 19) - (i32.const 11) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func %_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind %_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 9))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.61c58118.0.snapshot b/compiler/test/__snapshots__/basic_functionality.61c58118.0.snapshot index 4ea5c5a80..badadf60f 100644 --- a/compiler/test/__snapshots__/basic_functionality.61c58118.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.61c58118.0.snapshot @@ -1,78 +1,42 @@ basic functionality › block_no_expression -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $f_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $f_1113 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (i32.const 1879048190) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.5 - (block $compile_store.4 - (global.set $f_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (return_call $f_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $f_1113) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((name f))) (name (f)) (args (Managed)) + (return_type ((Unmanaged WasmI32))) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown)))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind f_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func f_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind f_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() ((Unmanaged WasmI32)))) (args ())))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name f)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.626b2e44.0.snapshot b/compiler/test/__snapshots__/basic_functionality.626b2e44.0.snapshot index af8a0cb99..118e833b3 100644 --- a/compiler/test/__snapshots__/basic_functionality.626b2e44.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.626b2e44.0.snapshot @@ -1,110 +1,84 @@ basic functionality › if_one_sided5 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1121 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<\" (global $<_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1121 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<\" (func $<_1116 (param i32 i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.10 (result i32) - (block $compile_store.2 - (global.set $x_1113 - (i32.const 3) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $7 - (call $<_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<_1116) - ) - (i32.const 7) - (i32.const 9) - ) - ) - (block $do_backpatches.3 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.8 (result i32) - (block $compile_store.6 - (local.set $6 - (call $+_1121 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1121) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_set.7 (result i32) - (global.set $x_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $x_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_block.9 (result i32) - (i32.const 1879048190) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func <_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func +_1121) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1121 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name x)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.65d36891.0.snapshot b/compiler/test/__snapshots__/basic_functionality.65d36891.0.snapshot index 3db36ae85..d5b7e732b 100644 --- a/compiler/test/__snapshots__/basic_functionality.65d36891.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.65d36891.0.snapshot @@ -1,48 +1,33 @@ basic functionality › lor2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$|\" (global $|_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"|\" (func $|_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $|_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $|_1113) - ) - (i32.const 3) - (i32.const 1) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name |))) (mimp_mod pervasives.gr) (mimp_name |) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name |))) (mimp_mod pervasives.gr) (mimp_name |) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func |_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind |_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.67d2cc45.0.snapshot b/compiler/test/__snapshots__/basic_functionality.67d2cc45.0.snapshot index 528e6e32c..dedfc7d94 100644 --- a/compiler/test/__snapshots__/basic_functionality.67d2cc45.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.67d2cc45.0.snapshot @@ -1,48 +1,33 @@ basic functionality › binop3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $-_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1113) - ) - (i32.const 5) - (i32.const 9) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func -_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.684b6ecb.0.snapshot b/compiler/test/__snapshots__/basic_functionality.684b6ecb.0.snapshot index 2456fd12a..030ca5833 100644 --- a/compiler/test/__snapshots__/basic_functionality.684b6ecb.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.684b6ecb.0.snapshot @@ -1,48 +1,33 @@ basic functionality › binop2.2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $-_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1113) - ) - (i32.const 5) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func -_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.68d08483.0.snapshot b/compiler/test/__snapshots__/basic_functionality.68d08483.0.snapshot index 2ea489865..f2b197d83 100644 --- a/compiler/test/__snapshots__/basic_functionality.68d08483.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.68d08483.0.snapshot @@ -1,48 +1,33 @@ basic functionality › land2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$&\" (global $&_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"&\" (func $&_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $&_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $&_1113) - ) - (i32.const 3) - (i32.const 1) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name &))) (mimp_mod pervasives.gr) (mimp_name &) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name &))) (mimp_mod pervasives.gr) (mimp_name &) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func &_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind &_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.6f9706c2.0.snapshot b/compiler/test/__snapshots__/basic_functionality.6f9706c2.0.snapshot index d17a157cf..0490300ad 100644 --- a/compiler/test/__snapshots__/basic_functionality.6f9706c2.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.6f9706c2.0.snapshot @@ -1,35 +1,13 @@ basic functionality › or1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -2) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.704872bc.0.snapshot b/compiler/test/__snapshots__/basic_functionality.704872bc.0.snapshot index 42f12e1f2..a100bc53c 100644 --- a/compiler/test/__snapshots__/basic_functionality.704872bc.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.704872bc.0.snapshot @@ -1,35 +1,13 @@ basic functionality › assert1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 1879048190) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot b/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot index 2c5df87c4..78404fabe 100644 --- a/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot @@ -1,784 +1,516 @@ basic functionality › pattern_match_unsafe_wasm -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1125 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1125 (param i32 i32 i32) (result i32))) - (global $test_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $test_1113 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (local $7 i32) - (block $compile_block.4 - (block $compile_store.2 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.1 - ) - ) - (drop - (call $foo_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 0) - ) - ) - (drop - (call $foo_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 1) - ) - ) - (drop - (call $foo_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 5) - ) - ) - (drop - (call $foo_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 8) - ) - ) - (block $cleanup.3 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $foo_1114 - (local.get $7) - (i32.const 42) - ) - ) - ) - (func $foo_1114 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (block $compile_block.72 (result i32) - (block $compile_store.6 - (local.set $16 - (i32.or - (i32.shl - (i32.eq - (local.get $1) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.30 - (local.set $17 - (if (result i32) - (i32.shr_u - (local.get $16) - (i32.const 31) - ) - (block $compile_block.7 (result i32) - (i32.const 1) - ) - (block $compile_block.28 (result i32) - (block $compile_store.9 - (local.set $18 - (i32.or - (i32.shl - (i32.eq - (local.get $1) - (i32.const 2) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.8 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $18) - (i32.const 31) - ) - (block $compile_block.10 (result i32) - (i32.const 3) - ) - (block $compile_block.27 (result i32) - (block $compile_store.12 - (local.set $19 - (i32.or - (i32.shl - (i32.eq - (local.get $1) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.11 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $19) - (i32.const 31) - ) - (block $compile_block.13 (result i32) - (i32.const 5) - ) - (block $compile_block.26 (result i32) - (block $compile_store.15 - (local.set $20 - (i32.or - (i32.shl - (i32.eq - (local.get $1) - (i32.const 4) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.14 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $20) - (i32.const 31) - ) - (block $compile_block.16 (result i32) - (i32.const 7) - ) - (block $compile_block.25 (result i32) - (block $compile_store.18 - (local.set $21 - (i32.or - (i32.shl - (i32.eq - (local.get $1) - (i32.const 5) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.17 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $21) - (i32.const 31) - ) - (block $compile_block.19 (result i32) - (i32.const 9) - ) - (block $compile_block.24 (result i32) - (block $compile_store.21 - (local.set $22 - (i32.or - (i32.shl - (i32.eq - (local.get $1) - (i32.const 6) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.20 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $22) - (i32.const 31) - ) - (block $compile_block.22 (result i32) - (i32.const 11) - ) - (block $compile_block.23 (result i32) - (i32.const 13) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) - (block $do_backpatches.29 - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.32_outer (result i32) - (block $switch.32_branch_0 (result i32) - (drop - (block $switch.32_branch_1 (result i32) - (drop - (block $switch.32_branch_2 (result i32) - (drop - (block $switch.32_branch_3 (result i32) - (drop - (block $switch.32_branch_4 (result i32) - (drop - (block $switch.32_branch_5 (result i32) - (drop - (block $switch.32_branch_6 (result i32) - (drop - (block $switch.32_branch_7 (result i32) - (drop - (block $switch.32_default (result i32) - (br_table $switch.32_branch_1 $switch.32_branch_2 $switch.32_branch_3 $switch.32_branch_4 $switch.32_branch_5 $switch.32_branch_6 $switch.32_branch_7 $switch.32_default $switch.32_default - (i32.const 0) - (i32.shr_s - (local.get $17) - (i32.const 1) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.71 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.70 - (block $compile_store.65 - (local.set $14 - (block $allocate_adt.63 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $2) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $2) - (i32.const 0) - ) - (local.get $2) - ) - ) - (block $do_backpatches.64 - ) - ) - (block $compile_store.68 - (local.set $15 - (block $allocate_string.66 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 5) - ) - (i64.store offset=8 - (local.get $2) - (i64.const 491327616111) - ) - (local.get $2) - ) - ) - (block $do_backpatches.67 - ) - ) - (block $cleanup.69 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $print_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) - ) - (local.get $15) - (local.get $14) - ) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.62 - (block $compile_store.60 - (local.set $13 - (block $allocate_adt.58 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $2) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $2) - (i32.const 0) - ) - (local.get $2) - ) - ) - (block $do_backpatches.59 - ) - ) - (block $cleanup.61 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $print_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) - ) - (i32.const 13) - (local.get $13) - ) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.57 - (block $compile_store.55 - (local.set $12 - (block $allocate_adt.53 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $2) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $2) - (i32.const 0) - ) - (local.get $2) - ) - ) - (block $do_backpatches.54 - ) - ) - (block $cleanup.56 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $print_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) - ) - (i32.const 11) - (local.get $12) - ) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.52 - (block $compile_store.50 - (local.set $11 - (block $allocate_adt.48 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $2) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $2) - (i32.const 0) - ) - (local.get $2) - ) - ) - (block $do_backpatches.49 - ) - ) - (block $cleanup.51 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $print_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) - ) - (i32.const 9) - (local.get $11) - ) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.47 - (block $compile_store.45 - (local.set $10 - (block $allocate_adt.43 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $2) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $2) - (i32.const 0) - ) - (local.get $2) - ) - ) - (block $do_backpatches.44 - ) - ) - (block $cleanup.46 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $print_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) - ) - (i32.const 7) - (local.get $10) - ) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.42 - (block $compile_store.40 - (local.set $9 - (block $allocate_adt.38 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $2) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $2) - (i32.const 0) - ) - (local.get $2) - ) - ) - (block $do_backpatches.39 - ) - ) - (block $cleanup.41 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $print_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) - ) - (i32.const 5) - (local.get $9) - ) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.37 - (block $compile_store.35 - (local.set $8 - (block $allocate_adt.33 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $2) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $2) - (i32.const 0) - ) - (local.get $2) - ) - ) - (block $do_backpatches.34 - ) - ) - (block $cleanup.36 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $print_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) - ) - (i32.const 3) - (local.get $8) - ) - ) - ) - ) - ) - (block $cleanup.31 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.75 - (block $compile_store.74 - (global.set $test_1113 - (i32.const 0) - ) - (block $do_backpatches.73 - ) - ) - (return_call $test_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $test_1113) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 386 -) +((functions + (((id ((name test))) (name (test)) (args (Managed)) + (return_type ((Unmanaged WasmI32))) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func foo_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func foo_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 1)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func foo_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 5)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func foo_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 8)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func foo_1114) + (closure + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type (((Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 42)))) + (immediate_analyses ((last_usage Unknown))))))))))) + (stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs (((txt Unsafe))))) + ((id ((name foo))) (name ()) (args (Managed (Unmanaged WasmI32))) + (return_type ((Unmanaged WasmI32))) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MArgBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MArgBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MArgBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 3)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MArgBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 4)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MArgBind 1 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Unknown)))) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstI32 5)))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MArgBind 1 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstI32 6)))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 5))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 6))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))))))))))))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func print_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1125 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (1 + (((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func print_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1125 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (2 + (((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func print_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1125 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func print_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1125 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func print_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1125 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (5 + (((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func print_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1125 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (6 + (((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc (MAllocate (MString other))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func print_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1125 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 8) (stack_size_i32 7) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs (((txt Unsafe))))))) + (imports + (((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind test_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func test_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind test_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() ((Unmanaged WasmI32)))) (args ())))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name test)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.7222ab37.0.snapshot b/compiler/test/__snapshots__/basic_functionality.7222ab37.0.snapshot index 9e228c648..56804653d 100644 --- a/compiler/test/__snapshots__/basic_functionality.7222ab37.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.7222ab37.0.snapshot @@ -1,35 +1,13 @@ basic functionality › tru -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -2) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.7287219f.0.snapshot b/compiler/test/__snapshots__/basic_functionality.7287219f.0.snapshot index 436275562..208bf196d 100644 --- a/compiler/test/__snapshots__/basic_functionality.7287219f.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.7287219f.0.snapshot @@ -1,48 +1,33 @@ basic functionality › asr1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>>\" (global $>>_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">>\" (func $>>_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $>>_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>>_1113) - ) - (i32.const 359) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name >>))) (mimp_mod pervasives.gr) (mimp_name >>) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >>))) (mimp_mod pervasives.gr) (mimp_name >>) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func >>_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind >>_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 179))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.7599b5a6.0.snapshot b/compiler/test/__snapshots__/basic_functionality.7599b5a6.0.snapshot index 95c86e8bb..5f1901cd6 100644 --- a/compiler/test/__snapshots__/basic_functionality.7599b5a6.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.7599b5a6.0.snapshot @@ -1,85 +1,52 @@ basic functionality › assignment1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1117 (param i32 i32 i32) (result i32))) - (global $t_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.2 - (global.set $t_1113 - (i32.const 3) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $t_1113) - ) - (i32.const 5) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_set.5 (result i32) - (global.set $t_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $t_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind t_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name t)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.7848308f.0.snapshot b/compiler/test/__snapshots__/basic_functionality.7848308f.0.snapshot index 42ffcc767..b4e658abf 100644 --- a/compiler/test/__snapshots__/basic_functionality.7848308f.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.7848308f.0.snapshot @@ -1,35 +1,13 @@ basic functionality › or3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -2) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.79ea1ccc.0.snapshot b/compiler/test/__snapshots__/basic_functionality.79ea1ccc.0.snapshot index 5ecd8659d..47ab22b3b 100644 --- a/compiler/test/__snapshots__/basic_functionality.79ea1ccc.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.79ea1ccc.0.snapshot @@ -1,85 +1,52 @@ basic functionality › assignment1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1117 (param i32 i32 i32) (result i32))) - (global $t_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.2 - (global.set $t_1113 - (i32.const 5) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $-_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $t_1113) - ) - (i32.const 5) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_set.5 (result i32) - (global.set $t_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $t_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func -_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind t_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name t)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.7b13e79a.0.snapshot b/compiler/test/__snapshots__/basic_functionality.7b13e79a.0.snapshot index cad7a5960..2630e9ad2 100644 --- a/compiler/test/__snapshots__/basic_functionality.7b13e79a.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.7b13e79a.0.snapshot @@ -1,35 +1,13 @@ basic functionality › and4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 2147483646) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.7bb7b0d4.0.snapshot b/compiler/test/__snapshots__/basic_functionality.7bb7b0d4.0.snapshot index 5f95dbf37..b8da694fa 100644 --- a/compiler/test/__snapshots__/basic_functionality.7bb7b0d4.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.7bb7b0d4.0.snapshot @@ -1,53 +1,9 @@ basic functionality › uint32_1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_uint32.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 11) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 42) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MUint32 42)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.7beffe4d.0.snapshot b/compiler/test/__snapshots__/basic_functionality.7beffe4d.0.snapshot index 8a64f95e1..396e01d17 100644 --- a/compiler/test/__snapshots__/basic_functionality.7beffe4d.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.7beffe4d.0.snapshot @@ -1,57 +1,9 @@ basic functionality › hex_dec_exp5 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (f64.store offset=8 - (local.get $0) - (f64.const 841.25) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MFloat64 4650610929073913856)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.7ccc4940.0.snapshot b/compiler/test/__snapshots__/basic_functionality.7ccc4940.0.snapshot index 231d37298..59781da51 100644 --- a/compiler/test/__snapshots__/basic_functionality.7ccc4940.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.7ccc4940.0.snapshot @@ -1,115 +1,13 @@ basic functionality › division1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.4 (result i32) - (block $allocate_number.3 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $1) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (i64.store offset=16 - (local.get $0) - (i64.const 5) - ) - (local.get $0) - ) - ) - (i32.store offset=12 - (local.get $1) - (block $allocate_number.2 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (i64.store offset=16 - (local.get $0) - (i64.const 2) - ) - (local.get $0) - ) - ) - (local.get $1) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRational (numerator_flags ()) (numerator_limbs (5)) + (denominator_flags ()) (denominator_limbs (2)))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.7d0640b4.0.snapshot b/compiler/test/__snapshots__/basic_functionality.7d0640b4.0.snapshot index 0257d5678..72e554d89 100644 --- a/compiler/test/__snapshots__/basic_functionality.7d0640b4.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.7d0640b4.0.snapshot @@ -1,113 +1,81 @@ basic functionality › if_one_sided2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1117 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>\" (global $>_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1117 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">\" (func $>_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (local.set $7 - (call $>_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>_1114) - ) - (i32.const 7) - (i32.const 9) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.6 - (block $compile_store.5 - (local.set $6 - (block $allocate_adt.3 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.4 - ) - ) - (return_call $print_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1117) - ) - (i32.const 11) - (local.get $6) - ) - ) - (block $compile_block.7 (result i32) - (i32.const 1879048190) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func >_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind >_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MReturnCallKnown (func print_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.83f51526.0.snapshot b/compiler/test/__snapshots__/basic_functionality.83f51526.0.snapshot index d3f39fb41..ae3512172 100644 --- a/compiler/test/__snapshots__/basic_functionality.83f51526.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.83f51526.0.snapshot @@ -1,57 +1,9 @@ basic functionality › hex_dec_exp3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (f64.store offset=8 - (local.get $0) - (f64.const 0.03125) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MFloat64 4584664420663164928)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.86f332c6.0.snapshot b/compiler/test/__snapshots__/basic_functionality.86f332c6.0.snapshot index 635eebae0..6964ec068 100644 --- a/compiler/test/__snapshots__/basic_functionality.86f332c6.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.86f332c6.0.snapshot @@ -1,35 +1,13 @@ basic functionality › bin_neg -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -19) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 -10))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.8c8313f3.0.snapshot b/compiler/test/__snapshots__/basic_functionality.8c8313f3.0.snapshot index b1dfe80c1..9707a9e31 100644 --- a/compiler/test/__snapshots__/basic_functionality.8c8313f3.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.8c8313f3.0.snapshot @@ -1,57 +1,9 @@ basic functionality › hex_dec_exp2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (f64.store offset=8 - (local.get $0) - (f64.const 40) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MFloat64 4630826316843712512)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.8e01d666.0.snapshot b/compiler/test/__snapshots__/basic_functionality.8e01d666.0.snapshot index 9c26197c0..7af3ec568 100644 --- a/compiler/test/__snapshots__/basic_functionality.8e01d666.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.8e01d666.0.snapshot @@ -1,57 +1,9 @@ basic functionality › infinity_neg -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (f64.store offset=8 - (local.get $0) - (f64.const -inf) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MFloat64 -4503599627370496)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.903ff701.0.snapshot b/compiler/test/__snapshots__/basic_functionality.903ff701.0.snapshot index c52ad996f..1e4342590 100644 --- a/compiler/test/__snapshots__/basic_functionality.903ff701.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.903ff701.0.snapshot @@ -1,57 +1,9 @@ basic functionality › hex_dec_exp4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (f64.store offset=8 - (local.get $0) - (f64.const 832) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MFloat64 4650529565213458432)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.9110d0f5.0.snapshot b/compiler/test/__snapshots__/basic_functionality.9110d0f5.0.snapshot index 9414e71f4..b73d83555 100644 --- a/compiler/test/__snapshots__/basic_functionality.9110d0f5.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.9110d0f5.0.snapshot @@ -1,48 +1,34 @@ basic functionality › comp13 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (i32.const -2) - (i32.const -2) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + (((Unmanaged WasmI32) (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.9157dba1.0.snapshot b/compiler/test/__snapshots__/basic_functionality.9157dba1.0.snapshot index adc57c389..dc6776940 100644 --- a/compiler/test/__snapshots__/basic_functionality.9157dba1.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.9157dba1.0.snapshot @@ -1,48 +1,33 @@ basic functionality › andshadow -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $+_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1114) - ) - (i32.const 3) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func +_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.9379df0d.0.snapshot b/compiler/test/__snapshots__/basic_functionality.9379df0d.0.snapshot index 35429d4b8..ed354172e 100644 --- a/compiler/test/__snapshots__/basic_functionality.9379df0d.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.9379df0d.0.snapshot @@ -1,278 +1,95 @@ basic functionality › comp21 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (block $compile_block.20 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_tuple.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.18 - (local.set $11 - (block $allocate_adt.16 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (local.get $9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $10) - ) - (local.get $0) - ) - ) - (block $do_backpatches.17 - ) - ) - (tuple.extract 0 - (tuple.make - (i32.or - (i32.shl - (i32.eq - (local.get $8) - (local.get $11) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - (block $cleanup.19 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 6) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.950b8fda.0.snapshot b/compiler/test/__snapshots__/basic_functionality.950b8fda.0.snapshot index 69cf61785..3ecd5c03b 100644 --- a/compiler/test/__snapshots__/basic_functionality.950b8fda.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.950b8fda.0.snapshot @@ -1,35 +1,13 @@ basic functionality › binop2.3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -3) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 -2))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.970a2a2b.0.snapshot b/compiler/test/__snapshots__/basic_functionality.970a2a2b.0.snapshot index 92753c838..34dca4d97 100644 --- a/compiler/test/__snapshots__/basic_functionality.970a2a2b.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.970a2a2b.0.snapshot @@ -1,35 +1,13 @@ basic functionality › not2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -2) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.974b7936.0.snapshot b/compiler/test/__snapshots__/basic_functionality.974b7936.0.snapshot index 765ff01bb..b3a5c47b2 100644 --- a/compiler/test/__snapshots__/basic_functionality.974b7936.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.974b7936.0.snapshot @@ -1,48 +1,33 @@ basic functionality › lxor3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$^\" (global $^_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"^\" (func $^_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $^_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $^_1113) - ) - (i32.const 1) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name ^))) (mimp_mod pervasives.gr) (mimp_name ^) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ^))) (mimp_mod pervasives.gr) (mimp_name ^) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ^_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ^_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.994117f8.0.snapshot b/compiler/test/__snapshots__/basic_functionality.994117f8.0.snapshot index c39ec9524..f2b9b0402 100644 --- a/compiler/test/__snapshots__/basic_functionality.994117f8.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.994117f8.0.snapshot @@ -1,46 +1,30 @@ basic functionality › incr_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$incr\" (global $incr_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"incr\" (func $incr_1113 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $incr_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $incr_1113) - ) - (i32.const -1) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name incr))) (mimp_mod pervasives.gr) (mimp_name incr) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name incr))) (mimp_mod pervasives.gr) (mimp_name incr) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func incr_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind incr_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 -1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.9b9c7047.0.snapshot b/compiler/test/__snapshots__/basic_functionality.9b9c7047.0.snapshot index be05c133f..e2b66619d 100644 --- a/compiler/test/__snapshots__/basic_functionality.9b9c7047.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.9b9c7047.0.snapshot @@ -1,57 +1,9 @@ basic functionality › void -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MString foo)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.9c18b19d.0.snapshot b/compiler/test/__snapshots__/basic_functionality.9c18b19d.0.snapshot index 4276db4d6..2d21d6110 100644 --- a/compiler/test/__snapshots__/basic_functionality.9c18b19d.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.9c18b19d.0.snapshot @@ -1,93 +1,58 @@ basic functionality › if_one_sided3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<\" (global $<_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<\" (func $<_1116 (param i32 i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $x_1113 - (i32.const 3) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $<_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<_1116) - ) - (i32.const 7) - (i32.const 9) - ) - ) - (block $do_backpatches.3 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.6 (result i32) - (block $compile_set.5 (result i32) - (global.set $x_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.const 5) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $x_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_block.7 (result i32) - (i32.const 1879048190) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func <_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MSet (MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name x)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.9df4a5e0.0.snapshot b/compiler/test/__snapshots__/basic_functionality.9df4a5e0.0.snapshot index 0b162d1e9..0d83cdd05 100644 --- a/compiler/test/__snapshots__/basic_functionality.9df4a5e0.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.9df4a5e0.0.snapshot @@ -1,35 +1,13 @@ basic functionality › and1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -2) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.9fb01eb5.0.snapshot b/compiler/test/__snapshots__/basic_functionality.9fb01eb5.0.snapshot index 0844291c7..a69e5d27f 100644 --- a/compiler/test/__snapshots__/basic_functionality.9fb01eb5.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.9fb01eb5.0.snapshot @@ -1,35 +1,13 @@ basic functionality › simple_max -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 2147483647) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1073741823))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.a0045d1c.0.snapshot b/compiler/test/__snapshots__/basic_functionality.a0045d1c.0.snapshot index 0174f4843..8f40c52db 100644 --- a/compiler/test/__snapshots__/basic_functionality.a0045d1c.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.a0045d1c.0.snapshot @@ -1,48 +1,33 @@ basic functionality › binop1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $+_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1113) - ) - (i32.const 5) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func +_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.a0747361.0.snapshot b/compiler/test/__snapshots__/basic_functionality.a0747361.0.snapshot index f9daffac2..14c14ad85 100644 --- a/compiler/test/__snapshots__/basic_functionality.a0747361.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.a0747361.0.snapshot @@ -1,35 +1,13 @@ basic functionality › hex -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 511) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 255))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.a2e63440.0.snapshot b/compiler/test/__snapshots__/basic_functionality.a2e63440.0.snapshot index bc63392a2..c6433cc32 100644 --- a/compiler/test/__snapshots__/basic_functionality.a2e63440.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.a2e63440.0.snapshot @@ -1,67 +1,48 @@ basic functionality › comp9 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>=\" (global $>=_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">=\" (func $>=_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $>=_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>=_1114) - ) - (i32.const 5) - (i32.const 5) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const 21) - ) - (block $compile_block.4 (result i32) - (i32.const 23) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name >=))) (mimp_mod pervasives.gr) (mimp_name >=) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >=))) (mimp_mod pervasives.gr) (mimp_name >=) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func >=_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind >=_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 10))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 11))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.a3f7e180.0.snapshot b/compiler/test/__snapshots__/basic_functionality.a3f7e180.0.snapshot index 21b4ff882..182b21c4a 100644 --- a/compiler/test/__snapshots__/basic_functionality.a3f7e180.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.a3f7e180.0.snapshot @@ -1,77 +1,37 @@ basic functionality › bigint_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.4 - (block $compile_store.3 - (local.set $6 - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 9223372036854775807) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (return_call $+_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1113) - ) - (local.get $6) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc (MAllocate (MInt64 9223372036854775807))))))))) + ((instr_desc + (MReturnCallKnown (func +_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.a4ec9fca.0.snapshot b/compiler/test/__snapshots__/basic_functionality.a4ec9fca.0.snapshot index 454c7501a..2fee0217e 100644 --- a/compiler/test/__snapshots__/basic_functionality.a4ec9fca.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.a4ec9fca.0.snapshot @@ -1,35 +1,13 @@ basic functionality › andshort2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 2147483646) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.a58a9361.0.snapshot b/compiler/test/__snapshots__/basic_functionality.a58a9361.0.snapshot index 4c82ef240..b9269d16a 100644 --- a/compiler/test/__snapshots__/basic_functionality.a58a9361.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.a58a9361.0.snapshot @@ -1,48 +1,33 @@ basic functionality › lxor2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$^\" (global $^_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"^\" (func $^_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $^_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $^_1113) - ) - (i32.const 3) - (i32.const 1) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name ^))) (mimp_mod pervasives.gr) (mimp_name ^) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ^))) (mimp_mod pervasives.gr) (mimp_name ^) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ^_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ^_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.a5d5182f.0.snapshot b/compiler/test/__snapshots__/basic_functionality.a5d5182f.0.snapshot index baecb81e8..fd346ab50 100644 --- a/compiler/test/__snapshots__/basic_functionality.a5d5182f.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.a5d5182f.0.snapshot @@ -1,67 +1,49 @@ basic functionality › comp2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<=\" (global $<=_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<=\" (func $<=_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $<=_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<=_1114) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const -2) - ) - (block $compile_block.4 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name <=))) (mimp_mod pervasives.gr) (mimp_name <=) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <=))) (mimp_mod pervasives.gr) (mimp_name <=) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func <=_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <=_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.a72898d0.0.snapshot b/compiler/test/__snapshots__/basic_functionality.a72898d0.0.snapshot index 0c4539f63..68656b7de 100644 --- a/compiler/test/__snapshots__/basic_functionality.a72898d0.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.a72898d0.0.snapshot @@ -1,67 +1,48 @@ basic functionality › comp8 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<=\" (global $<=_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<=\" (func $<=_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $<=_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<=_1114) - ) - (i32.const 5) - (i32.const 5) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const 21) - ) - (block $compile_block.4 (result i32) - (i32.const 23) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name <=))) (mimp_mod pervasives.gr) (mimp_name <=) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <=))) (mimp_mod pervasives.gr) (mimp_name <=) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func <=_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <=_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 10))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 11))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.abd9d13c.0.snapshot b/compiler/test/__snapshots__/basic_functionality.abd9d13c.0.snapshot index a6567f401..38ee6772e 100644 --- a/compiler/test/__snapshots__/basic_functionality.abd9d13c.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.abd9d13c.0.snapshot @@ -1,67 +1,48 @@ basic functionality › comp7 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $==_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1114) - ) - (i32.const 5) - (i32.const 5) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const 17) - ) - (block $compile_block.4 (result i32) - (i32.const 19) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 8))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 9))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.b07cc734.0.snapshot b/compiler/test/__snapshots__/basic_functionality.b07cc734.0.snapshot index 1990822d6..871e63ed4 100644 --- a/compiler/test/__snapshots__/basic_functionality.b07cc734.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.b07cc734.0.snapshot @@ -1,113 +1,81 @@ basic functionality › if_one_sided -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1117 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<\" (global $<_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1117 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<\" (func $<_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (local.set $7 - (call $<_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<_1114) - ) - (i32.const 7) - (i32.const 9) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.6 - (block $compile_store.5 - (local.set $6 - (block $allocate_adt.3 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.4 - ) - ) - (return_call $print_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1117) - ) - (i32.const 11) - (local.get $6) - ) - ) - (block $compile_block.7 (result i32) - (i32.const 1879048190) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func <_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MReturnCallKnown (func print_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.b6a1b657.0.snapshot b/compiler/test/__snapshots__/basic_functionality.b6a1b657.0.snapshot index 8bb888f3a..9d988a27c 100644 --- a/compiler/test/__snapshots__/basic_functionality.b6a1b657.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.b6a1b657.0.snapshot @@ -1,48 +1,33 @@ basic functionality › lxor4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$^\" (global $^_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"^\" (func $^_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $^_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $^_1113) - ) - (i32.const 1) - (i32.const 1) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name ^))) (mimp_mod pervasives.gr) (mimp_name ^) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ^))) (mimp_mod pervasives.gr) (mimp_name ^) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ^_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ^_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.b836b89a.0.snapshot b/compiler/test/__snapshots__/basic_functionality.b836b89a.0.snapshot index ffc3d6867..8607e552b 100644 --- a/compiler/test/__snapshots__/basic_functionality.b836b89a.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.b836b89a.0.snapshot @@ -1,114 +1,95 @@ basic functionality › complex1 -(module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1127 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1125 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1120 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1127 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1125 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1120 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.6 - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (drop - (call $print_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1120) - ) - (i32.const 7) - (local.get $6) - ) - ) - (block $compile_store.5 - (local.set $7 - (call $+_1127 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1127) - ) - (i32.const 9) - (i32.const 5) - ) - ) - (block $do_backpatches.4 - ) - ) - (return_call $-_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1125) - ) - (i32.const 7) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1120 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func +_1127) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1127 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func -_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1125 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.bb137371.0.snapshot b/compiler/test/__snapshots__/basic_functionality.bb137371.0.snapshot index f872336d9..a6789a5c0 100644 --- a/compiler/test/__snapshots__/basic_functionality.bb137371.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.bb137371.0.snapshot @@ -1,85 +1,52 @@ basic functionality › assignment1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$/\" (global $/_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"/\" (func $/_1117 (param i32 i32 i32) (result i32))) - (global $t_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.2 - (global.set $t_1113 - (i32.const 5) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $/_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $/_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $t_1113) - ) - (i32.const 5) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_set.5 (result i32) - (global.set $t_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $t_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func /_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind /_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind t_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name t)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.bd891a1f.0.snapshot b/compiler/test/__snapshots__/basic_functionality.bd891a1f.0.snapshot index 72c8fd2a5..e9e1c1d02 100644 --- a/compiler/test/__snapshots__/basic_functionality.bd891a1f.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.bd891a1f.0.snapshot @@ -1,35 +1,13 @@ basic functionality › oct -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 127) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 63))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.bef9449e.0.snapshot b/compiler/test/__snapshots__/basic_functionality.bef9449e.0.snapshot index 29b7676c3..1dd0829db 100644 --- a/compiler/test/__snapshots__/basic_functionality.bef9449e.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.bef9449e.0.snapshot @@ -1,67 +1,49 @@ basic functionality › comp1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<\" (global $<_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<\" (func $<_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $<_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<_1114) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const -2) - ) - (block $compile_block.4 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func <_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.c1554a92.0.snapshot b/compiler/test/__snapshots__/basic_functionality.c1554a92.0.snapshot index 18a423f3b..8583c44da 100644 --- a/compiler/test/__snapshots__/basic_functionality.c1554a92.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.c1554a92.0.snapshot @@ -1,35 +1,13 @@ basic functionality › or2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -2) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.c2c74be4.0.snapshot b/compiler/test/__snapshots__/basic_functionality.c2c74be4.0.snapshot index dea3ec445..3ee849c72 100644 --- a/compiler/test/__snapshots__/basic_functionality.c2c74be4.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.c2c74be4.0.snapshot @@ -1,48 +1,33 @@ basic functionality › lsr2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>>>\" (global $>>>_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">>>\" (func $>>>_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $>>>_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>>>_1113) - ) - (i32.const 1) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name >>>))) (mimp_mod pervasives.gr) (mimp_name >>>) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >>>))) (mimp_mod pervasives.gr) (mimp_name >>>) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func >>>_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind >>>_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.c4090bb1.0.snapshot b/compiler/test/__snapshots__/basic_functionality.c4090bb1.0.snapshot index 572ea64e7..f2ef9aaf9 100644 --- a/compiler/test/__snapshots__/basic_functionality.c4090bb1.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.c4090bb1.0.snapshot @@ -1,307 +1,193 @@ basic functionality › toplevel_statements -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1126 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1120 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1126 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1120 (param i32 i32 i32) (result i32))) - (global $five_1117 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (block $compile_block.19 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (drop - (call $print_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1120) - ) - (i32.const 3) - (local.get $6) - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (drop - (call $print_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1120) - ) - (i32.const 5) - (local.get $7) - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (drop - (call $print_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1120) - ) - (i32.const 7) - (local.get $8) - ) - ) - (block $compile_store.11 - (global.set $five_1117 - (call $+_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1126) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.14 - (local.set $9 - (block $allocate_adt.12 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.13 - ) - ) - (drop - (call $print_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1120) - ) - (i32.const 9) - (local.get $9) - ) - ) - (block $compile_store.17 - (local.set $10 - (block $allocate_adt.15 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.16 - ) - ) - (drop - (call $print_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1120) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $five_1117) - ) - (local.get $10) - ) - ) - (block $allocate_string.18 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 382 -) +((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1120 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1120 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1120 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind five_1117 Managed) + ((instr_desc + (MCallKnown (func +_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1120 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1120 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind five_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc (MAllocate (MString foo)))))) + (main_body_stack_size + ((stack_size_ptr 5) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name five)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.c49928a5.0.snapshot b/compiler/test/__snapshots__/basic_functionality.c49928a5.0.snapshot index 474d01aa2..d343ea96f 100644 --- a/compiler/test/__snapshots__/basic_functionality.c49928a5.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.c49928a5.0.snapshot @@ -1,48 +1,33 @@ basic functionality › lsr1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>>>\" (global $>>>_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">>>\" (func $>>>_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $>>>_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>>>_1113) - ) - (i32.const 15) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name >>>))) (mimp_mod pervasives.gr) (mimp_name >>>) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >>>))) (mimp_mod pervasives.gr) (mimp_name >>>) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func >>>_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind >>>_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 7))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.c55feb83.0.snapshot b/compiler/test/__snapshots__/basic_functionality.c55feb83.0.snapshot index 8446a1ca8..e88e1c8ee 100644 --- a/compiler/test/__snapshots__/basic_functionality.c55feb83.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.c55feb83.0.snapshot @@ -1,48 +1,34 @@ basic functionality › comp14 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (i32.const -2) - (i32.const 2147483646) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + (((Unmanaged WasmI32) (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.c8095f7c.0.snapshot b/compiler/test/__snapshots__/basic_functionality.c8095f7c.0.snapshot index 35dfd430d..730a8b273 100644 --- a/compiler/test/__snapshots__/basic_functionality.c8095f7c.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.c8095f7c.0.snapshot @@ -1,46 +1,30 @@ basic functionality › incr_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$incr\" (global $incr_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"incr\" (func $incr_1113 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $incr_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $incr_1113) - ) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name incr))) (mimp_mod pervasives.gr) (mimp_name incr) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name incr))) (mimp_mod pervasives.gr) (mimp_name incr) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func incr_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind incr_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.c8144b17.0.snapshot b/compiler/test/__snapshots__/basic_functionality.c8144b17.0.snapshot index fdceacd95..454dad58b 100644 --- a/compiler/test/__snapshots__/basic_functionality.c8144b17.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.c8144b17.0.snapshot @@ -1,35 +1,13 @@ basic functionality › bin -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 21) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 10))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.cb9c6c66.0.snapshot b/compiler/test/__snapshots__/basic_functionality.cb9c6c66.0.snapshot index 0c6a4249b..aa6eca1c8 100644 --- a/compiler/test/__snapshots__/basic_functionality.cb9c6c66.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.cb9c6c66.0.snapshot @@ -1,46 +1,30 @@ basic functionality › incr_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$incr\" (global $incr_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"incr\" (func $incr_1113 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $incr_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $incr_1113) - ) - (i32.const 11) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name incr))) (mimp_mod pervasives.gr) (mimp_name incr) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name incr))) (mimp_mod pervasives.gr) (mimp_name incr) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func incr_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind incr_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.cdeddcd2.0.snapshot b/compiler/test/__snapshots__/basic_functionality.cdeddcd2.0.snapshot index bd5e3ee2f..b4b96521e 100644 --- a/compiler/test/__snapshots__/basic_functionality.cdeddcd2.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.cdeddcd2.0.snapshot @@ -1,48 +1,33 @@ basic functionality › modulo3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$%\" (global $%_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"%\" (func $%_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $%_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $%_1113) - ) - (i32.const -33) - (i32.const -7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func %_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind %_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 -17))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 -4))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.cefeb364.0.snapshot b/compiler/test/__snapshots__/basic_functionality.cefeb364.0.snapshot index 46a2039c3..5abcea6ad 100644 --- a/compiler/test/__snapshots__/basic_functionality.cefeb364.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.cefeb364.0.snapshot @@ -1,48 +1,33 @@ basic functionality › lor4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$|\" (global $|_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"|\" (func $|_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $|_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $|_1113) - ) - (i32.const 1) - (i32.const 1) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name |))) (mimp_mod pervasives.gr) (mimp_name |) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name |))) (mimp_mod pervasives.gr) (mimp_name |) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func |_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind |_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.d0c0c62b.0.snapshot b/compiler/test/__snapshots__/basic_functionality.d0c0c62b.0.snapshot index 4df627fd2..653666ee3 100644 --- a/compiler/test/__snapshots__/basic_functionality.d0c0c62b.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.d0c0c62b.0.snapshot @@ -1,48 +1,33 @@ basic functionality › int64_pun_1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $*_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1113) - ) - (i32.const 19999999) - (i32.const 199999999) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func *_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 9999999))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 99999999))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.d0cb4f44.0.snapshot b/compiler/test/__snapshots__/basic_functionality.d0cb4f44.0.snapshot index 907cb6ea2..0fa348122 100644 --- a/compiler/test/__snapshots__/basic_functionality.d0cb4f44.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.d0cb4f44.0.snapshot @@ -1,46 +1,30 @@ basic functionality › decr_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$decr\" (global $decr_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"decr\" (func $decr_1113 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $decr_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $decr_1113) - ) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name decr))) (mimp_mod pervasives.gr) (mimp_name decr) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name decr))) (mimp_mod pervasives.gr) (mimp_name decr) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func decr_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind decr_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.d124f931.0.snapshot b/compiler/test/__snapshots__/basic_functionality.d124f931.0.snapshot index 032be440d..03b2f51df 100644 --- a/compiler/test/__snapshots__/basic_functionality.d124f931.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.d124f931.0.snapshot @@ -1,35 +1,13 @@ basic functionality › nil -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 1879048190) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.d6ca4146.0.snapshot b/compiler/test/__snapshots__/basic_functionality.d6ca4146.0.snapshot index 41e3667f2..91f0814b6 100644 --- a/compiler/test/__snapshots__/basic_functionality.d6ca4146.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.d6ca4146.0.snapshot @@ -1,88 +1,52 @@ basic functionality › andshort1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.4 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (drop - (call $print_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1113) - ) - (i32.const 3) - (local.get $6) - ) - ) - (i32.const 2147483646) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.d8a7dcf9.0.snapshot b/compiler/test/__snapshots__/basic_functionality.d8a7dcf9.0.snapshot index 071a69798..368a8f31a 100644 --- a/compiler/test/__snapshots__/basic_functionality.d8a7dcf9.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.d8a7dcf9.0.snapshot @@ -1,48 +1,33 @@ basic functionality › modulo1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$%\" (global $%_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"%\" (func $%_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $%_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $%_1113) - ) - (i32.const -33) - (i32.const 9) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func %_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind %_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 -17))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.d8f6f027.0.snapshot b/compiler/test/__snapshots__/basic_functionality.d8f6f027.0.snapshot index d7a97c55f..20b2f6782 100644 --- a/compiler/test/__snapshots__/basic_functionality.d8f6f027.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.d8f6f027.0.snapshot @@ -1,57 +1,9 @@ basic functionality › hex_dec_exp1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (f64.store offset=8 - (local.get $0) - (f64.const 32) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MFloat64 4629700416936869888)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.d9fc01df.0.snapshot b/compiler/test/__snapshots__/basic_functionality.d9fc01df.0.snapshot index a15bdbbe7..bbd1afde6 100644 --- a/compiler/test/__snapshots__/basic_functionality.d9fc01df.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.d9fc01df.0.snapshot @@ -1,48 +1,33 @@ basic functionality › land3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$&\" (global $&_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"&\" (func $&_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $&_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $&_1113) - ) - (i32.const 1) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name &))) (mimp_mod pervasives.gr) (mimp_name &) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name &))) (mimp_mod pervasives.gr) (mimp_name &) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func &_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind &_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.dbf5d3ff.0.snapshot b/compiler/test/__snapshots__/basic_functionality.dbf5d3ff.0.snapshot index 935e4d858..1bd882aaf 100644 --- a/compiler/test/__snapshots__/basic_functionality.dbf5d3ff.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.dbf5d3ff.0.snapshot @@ -1,48 +1,33 @@ basic functionality › comp18 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$isnt\" (global $isnt_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"isnt\" (func $isnt_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $isnt_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $isnt_1113) - ) - (i32.const 9) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name isnt))) (mimp_mod pervasives.gr) (mimp_name isnt) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name isnt))) (mimp_mod pervasives.gr) (mimp_name isnt) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func isnt_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind isnt_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.df4cd2bf.0.snapshot b/compiler/test/__snapshots__/basic_functionality.df4cd2bf.0.snapshot index a35d8162c..47afb004c 100644 --- a/compiler/test/__snapshots__/basic_functionality.df4cd2bf.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.df4cd2bf.0.snapshot @@ -1,48 +1,34 @@ basic functionality › comp15 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (i32.const 2147483646) - (i32.const -2) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + (((Unmanaged WasmI32) (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.e2902464.0.snapshot b/compiler/test/__snapshots__/basic_functionality.e2902464.0.snapshot index 967fe61f2..ff77cef93 100644 --- a/compiler/test/__snapshots__/basic_functionality.e2902464.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.e2902464.0.snapshot @@ -1,65 +1,58 @@ basic functionality › comp10 -(module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1119 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1119 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1117 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.3 - (block $compile_store.2 - (local.set $6 - (call $-_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1119) - ) - (i32.const 9) - (i32.const 5) - ) - ) - (block $do_backpatches.1 - ) - ) - (return_call $==_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1117) - ) - (local.get $6) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func -_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1119 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.e3995c7d.0.snapshot b/compiler/test/__snapshots__/basic_functionality.e3995c7d.0.snapshot index 3c5f19327..fa2017075 100644 --- a/compiler/test/__snapshots__/basic_functionality.e3995c7d.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.e3995c7d.0.snapshot @@ -1,96 +1,64 @@ basic functionality › if_one_sided4 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<\" (global $<_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<\" (func $<_1116 (param i32 i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $x_1113 - (i32.const 3) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $<_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<_1116) - ) - (i32.const 7) - (i32.const 9) - ) - ) - (block $do_backpatches.3 - ) - ) - (drop - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.6 (result i32) - (block $compile_set.5 (result i32) - (global.set $x_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.const 5) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $x_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_block.7 (result i32) - (i32.const 1879048190) - ) - ) - ) - (global.get $x_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func <_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MSet (MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name x)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.e56cd2a2.0.snapshot b/compiler/test/__snapshots__/basic_functionality.e56cd2a2.0.snapshot index 2e596f97f..0ab708089 100644 --- a/compiler/test/__snapshots__/basic_functionality.e56cd2a2.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.e56cd2a2.0.snapshot @@ -1,67 +1,48 @@ basic functionality › comp6 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $==_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1114) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const 17) - ) - (block $compile_block.4 (result i32) - (i32.const 19) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 8))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 9))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.e58c3266.0.snapshot b/compiler/test/__snapshots__/basic_functionality.e58c3266.0.snapshot index c5d698b87..3f355b55c 100644 --- a/compiler/test/__snapshots__/basic_functionality.e58c3266.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.e58c3266.0.snapshot @@ -1,48 +1,33 @@ basic functionality › asr2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>>\" (global $>>_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">>\" (func $>>_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $>>_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>>_1113) - ) - (i32.const 1) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name >>))) (mimp_mod pervasives.gr) (mimp_name >>) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >>))) (mimp_mod pervasives.gr) (mimp_name >>) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func >>_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind >>_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.e6ea6b06.0.snapshot b/compiler/test/__snapshots__/basic_functionality.e6ea6b06.0.snapshot index 54e8fca91..f9fd91c21 100644 --- a/compiler/test/__snapshots__/basic_functionality.e6ea6b06.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.e6ea6b06.0.snapshot @@ -1,53 +1,9 @@ basic functionality › int32_1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_int32.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 9) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 42) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MInt32 42)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.e811c1e1.0.snapshot b/compiler/test/__snapshots__/basic_functionality.e811c1e1.0.snapshot index 92723cfb8..ca9b39d59 100644 --- a/compiler/test/__snapshots__/basic_functionality.e811c1e1.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.e811c1e1.0.snapshot @@ -1,48 +1,33 @@ basic functionality › binop2.1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $-_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1113) - ) - (i32.const 5) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func -_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.ee7c0ebc.0.snapshot b/compiler/test/__snapshots__/basic_functionality.ee7c0ebc.0.snapshot index 5475bd103..63fe01a69 100644 --- a/compiler/test/__snapshots__/basic_functionality.ee7c0ebc.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.ee7c0ebc.0.snapshot @@ -1,48 +1,33 @@ basic functionality › modulo2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$%\" (global $%_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"%\" (func $%_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $%_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $%_1113) - ) - (i32.const 35) - (i32.const -7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func %_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind %_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 17))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 -4))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.f132ca8b.0.snapshot b/compiler/test/__snapshots__/basic_functionality.f132ca8b.0.snapshot index 40b0c7922..017a6cdfd 100644 --- a/compiler/test/__snapshots__/basic_functionality.f132ca8b.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.f132ca8b.0.snapshot @@ -1,46 +1,30 @@ basic functionality › decr_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$decr\" (global $decr_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"decr\" (func $decr_1113 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $decr_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $decr_1113) - ) - (i32.const 11) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name decr))) (mimp_mod pervasives.gr) (mimp_name decr) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name decr))) (mimp_mod pervasives.gr) (mimp_name decr) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func decr_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind decr_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.f47797ca.0.snapshot b/compiler/test/__snapshots__/basic_functionality.f47797ca.0.snapshot index f4ce8713e..670548bbb 100644 --- a/compiler/test/__snapshots__/basic_functionality.f47797ca.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.f47797ca.0.snapshot @@ -1,57 +1,9 @@ basic functionality › hex_dec_exp5 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (f64.store offset=8 - (local.get $0) - (f64.const 840) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MFloat64 4650599933957636096)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.f58be537.0.snapshot b/compiler/test/__snapshots__/basic_functionality.f58be537.0.snapshot index 0d283a38d..53f7326bf 100644 --- a/compiler/test/__snapshots__/basic_functionality.f58be537.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.f58be537.0.snapshot @@ -1,310 +1,111 @@ basic functionality › comp19 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (block $compile_block.20 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.18 - (local.set $11 - (block $allocate_adt.16 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $10) - ) - (local.get $0) - ) - ) - (block $do_backpatches.17 - ) - ) - (tuple.extract 0 - (tuple.make - (i32.or - (i32.shl - (i32.eq - (local.get $8) - (local.get $11) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - (block $cleanup.19 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 6) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.f90a3baa.0.snapshot b/compiler/test/__snapshots__/basic_functionality.f90a3baa.0.snapshot index 16c4487ae..09d635aff 100644 --- a/compiler/test/__snapshots__/basic_functionality.f90a3baa.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.f90a3baa.0.snapshot @@ -1,57 +1,9 @@ basic functionality › heap_number_i32_wrapper_max -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 2147483647) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MInt64 2147483647)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.f9743171.0.snapshot b/compiler/test/__snapshots__/basic_functionality.f9743171.0.snapshot index e5af6f203..997ce6d1d 100644 --- a/compiler/test/__snapshots__/basic_functionality.f9743171.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.f9743171.0.snapshot @@ -1,57 +1,9 @@ basic functionality › heap_number_i32_wrapper -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 1073741824) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MInt64 1073741824)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.fd64a58f.0.snapshot b/compiler/test/__snapshots__/basic_functionality.fd64a58f.0.snapshot index 947273f86..efe331610 100644 --- a/compiler/test/__snapshots__/basic_functionality.fd64a58f.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.fd64a58f.0.snapshot @@ -1,48 +1,33 @@ basic functionality › int64_pun_2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $-_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1113) - ) - (i32.const -199999997) - (i32.const 1999999999) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func -_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 -99999999))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 999999999))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.fe19cffe.0.snapshot b/compiler/test/__snapshots__/basic_functionality.fe19cffe.0.snapshot index 84e0ed027..a9ac09db2 100644 --- a/compiler/test/__snapshots__/basic_functionality.fe19cffe.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.fe19cffe.0.snapshot @@ -1,69 +1,12 @@ basic functionality › bigint_2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 32) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (i64.store offset=16 - (local.get $0) - (i64.const -7851998425750883293) - ) - (i64.store offset=24 - (local.get $0) - (i64.const 1164749010670168) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MBigInt (flags ()) (limbs (-7851998425750883293 1164749010670168)))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/basic_functionality.fe88cb04.0.snapshot b/compiler/test/__snapshots__/basic_functionality.fe88cb04.0.snapshot index dfeb70294..5f5af3690 100644 --- a/compiler/test/__snapshots__/basic_functionality.fe88cb04.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.fe88cb04.0.snapshot @@ -1,443 +1,225 @@ basic functionality › func_shadow_and_indirect_call -(module - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1121 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1121 (param i32 i32 i32) (result i32))) - (global $foo_1119 (mut i32) (i32.const 0)) - (global $foo_1117 (mut i32) (i32.const 0)) - (global $foo_1115 (mut i32) (i32.const 0)) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 1)) - (memory $0 0) - (elem $elem (global.get $relocBase_0) $func_1133) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $compile_block.3 (result i32) - (tuple.extract 0 - (tuple.make - (block $allocate_string.2 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $1) - (i64.const 7496034) - ) - (local.get $1) - ) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $foo_1115 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $compile_block.6 (result i32) - (tuple.extract 0 - (tuple.make - (block $allocate_string.5 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $1) - (i64.const 8020322) - ) - (local.get $1) - ) - (block $cleanup.4 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $foo_1117 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $compile_block.9 (result i32) - (tuple.extract 0 - (tuple.make - (block $allocate_closure.8 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $1) - (i32.add - (global.get $relocBase_0) - (i32.const 0) - ) - ) - (i32.store offset=12 - (local.get $1) - (i32.const 0) - ) - (local.get $1) - ) - (block $cleanup.7 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $func_1133 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $closure_elements.16 (result i32) - (block $compile_block.15 (result i32) - (tuple.extract 0 - (tuple.make - (block $allocate_string.14 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $1) - (i64.const 7894385) - ) - (local.get $1) - ) - (block $cleanup.13 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (block $compile_block.41 - (block $compile_store.18 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.21 - (local.set $6 - (block $allocate_adt.19 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.23 - (local.set $7 - (call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - ) - ) - (block $do_backpatches.22 - ) - ) - (drop - (call $print_1121 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1121) - ) - (local.get $7) - (local.get $6) - ) - ) - (block $compile_store.25 - (global.set $foo_1115 - (i32.const 0) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.28 - (local.set $8 - (block $allocate_adt.26 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $compile_store.30 - (local.set $9 - (call $foo_1115 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1115) - ) - ) - ) - (block $do_backpatches.29 - ) - ) - (drop - (call $print_1121 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1121) - ) - (local.get $9) - (local.get $8) - ) - ) - (block $compile_store.32 - (global.set $foo_1117 - (i32.const 0) - ) - (block $do_backpatches.31 - ) - ) - (block $compile_store.34 - (global.set $foo_1119 - (call $foo_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1117) - ) - ) - ) - (block $do_backpatches.33 - ) - ) - (block $compile_store.37 - (local.set $10 - (block $allocate_adt.35 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.36 - ) - ) - (block $compile_store.40 - (local.set $11 - (block $call_lambda.38 (result i32) - (local.set $0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1119) - ) - ) - (call_indirect (type $i32_=>_i32) - (local.get $0) - (i32.load offset=8 - (local.get $0) - ) - ) - ) - ) - (block $do_backpatches.39 - ) - ) - (return_call $print_1121 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1121) - ) - (local.get $11) - (local.get $10) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 385 -) +((functions + (((id ((name foo))) (name (foo)) (args (Managed)) (return_type (Managed)) + (closure ()) + (body + (((instr_desc + (MCleanup (((instr_desc (MAllocate (MString bar))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())) + ((id ((name foo))) (name (foo)) (args (Managed)) (return_type (Managed)) + (closure ()) + (body + (((instr_desc + (MCleanup (((instr_desc (MAllocate (MString baz))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())) + ((id ((name foo))) (name (foo)) (args (Managed)) (return_type (Managed)) + (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MAllocate + (MClosure + ((func_idx (0)) (global_offset function_table_global_1130) + (arity 1) (variables ()))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())) + ((id ((name func))) (name ()) (args (Managed)) (return_type (Managed)) + (closure (0)) + (body + (((instr_desc + (MCleanup (((instr_desc (MAllocate (MString qux))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() (Managed))) (args ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1121) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1121 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind foo_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MCallKnown (func foo_1115) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() (Managed))) (args ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1121) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1121 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind foo_1117 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind foo_1119 Managed) + ((instr_desc + (MCallKnown (func foo_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() (Managed))) (args ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MCallIndirect + (func + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1119 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() (Managed))) (args ()))))))))) + ((instr_desc + (MReturnCallKnown (func print_1121) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1121 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 6) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + ((((name foo)) true Managed ()) (((name foo)) true Managed ()) + (((name foo)) true Managed ()) (((name foo)) true Managed ()))) + (function_table_elements (func_1134)) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/boxes.08fca3f7.0.snapshot b/compiler/test/__snapshots__/boxes.08fca3f7.0.snapshot index 28c3e5a3a..2239eba11 100644 --- a/compiler/test/__snapshots__/boxes.08fca3f7.0.snapshot +++ b/compiler/test/__snapshots__/boxes.08fca3f7.0.snapshot @@ -1,116 +1,58 @@ boxes › box_subtraction1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.9 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $7 - (call $-_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1117) - ) - (local.get $6) - (i32.const 39) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $MTupleSet.8 (result i32) - (i32.store offset=8 - (global.get $b_1113) - (tuple.extract 0 - (tuple.make - (local.get $7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func -_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/boxes.0c59fc4e.0.snapshot b/compiler/test/__snapshots__/boxes.0c59fc4e.0.snapshot index 0fe2e435b..af13b0c2e 100644 --- a/compiler/test/__snapshots__/boxes.0c59fc4e.0.snapshot +++ b/compiler/test/__snapshots__/boxes.0c59fc4e.0.snapshot @@ -1,129 +1,65 @@ boxes › box_multiplication2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.11 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $7 - (call $*_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1117) - ) - (local.get $6) - (i32.const 39) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.10 - (local.set $8 - (block $MTupleSet.8 (result i32) - (i32.store offset=8 - (global.get $b_1113) - (tuple.extract 0 - (tuple.make - (local.get $7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.9 - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func *_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/boxes.17668725.0.snapshot b/compiler/test/__snapshots__/boxes.17668725.0.snapshot index 4734e61af..221199aea 100644 --- a/compiler/test/__snapshots__/boxes.17668725.0.snapshot +++ b/compiler/test/__snapshots__/boxes.17668725.0.snapshot @@ -1,129 +1,65 @@ boxes › box_division2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$/\" (global $/_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"/\" (func $/_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.11 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 153) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $7 - (call $/_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $/_1117) - ) - (local.get $6) - (i32.const 39) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.10 - (local.set $8 - (block $MTupleSet.8 (result i32) - (i32.store offset=8 - (global.get $b_1113) - (tuple.extract 0 - (tuple.make - (local.get $7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.9 - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 76))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func /_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind /_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/boxes.2b56febf.0.snapshot b/compiler/test/__snapshots__/boxes.2b56febf.0.snapshot index f4831e6f9..56ec896b3 100644 --- a/compiler/test/__snapshots__/boxes.2b56febf.0.snapshot +++ b/compiler/test/__snapshots__/boxes.2b56febf.0.snapshot @@ -1,129 +1,65 @@ boxes › box_addition2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.11 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $7 - (call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (local.get $6) - (i32.const 39) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.10 - (local.set $8 - (block $MTupleSet.8 (result i32) - (i32.store offset=8 - (global.get $b_1113) - (tuple.extract 0 - (tuple.make - (local.get $7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.9 - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/boxes.7d564476.0.snapshot b/compiler/test/__snapshots__/boxes.7d564476.0.snapshot index 957fc0520..0f4cafb4f 100644 --- a/compiler/test/__snapshots__/boxes.7d564476.0.snapshot +++ b/compiler/test/__snapshots__/boxes.7d564476.0.snapshot @@ -1,116 +1,58 @@ boxes › box_division1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$/\" (global $/_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"/\" (func $/_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.9 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 153) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $7 - (call $/_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $/_1117) - ) - (local.get $6) - (i32.const 39) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $MTupleSet.8 (result i32) - (i32.store offset=8 - (global.get $b_1113) - (tuple.extract 0 - (tuple.make - (local.get $7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 76))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func /_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind /_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/boxes.9035923e.0.snapshot b/compiler/test/__snapshots__/boxes.9035923e.0.snapshot index f30ca3756..5a1dfd182 100644 --- a/compiler/test/__snapshots__/boxes.9035923e.0.snapshot +++ b/compiler/test/__snapshots__/boxes.9035923e.0.snapshot @@ -1,129 +1,65 @@ boxes › box_subtraction2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.11 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $7 - (call $-_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1117) - ) - (local.get $6) - (i32.const 39) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.10 - (local.set $8 - (block $MTupleSet.8 (result i32) - (i32.store offset=8 - (global.get $b_1113) - (tuple.extract 0 - (tuple.make - (local.get $7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.9 - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func -_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/boxes.adbe1660.0.snapshot b/compiler/test/__snapshots__/boxes.adbe1660.0.snapshot index 1f6ee78a0..8b4c6a2dd 100644 --- a/compiler/test/__snapshots__/boxes.adbe1660.0.snapshot +++ b/compiler/test/__snapshots__/boxes.adbe1660.0.snapshot @@ -1,116 +1,58 @@ boxes › box_addition1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.9 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $7 - (call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (local.get $6) - (i32.const 39) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $MTupleSet.8 (result i32) - (i32.store offset=8 - (global.get $b_1113) - (tuple.extract 0 - (tuple.make - (local.get $7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/boxes.bc258c1b.0.snapshot b/compiler/test/__snapshots__/boxes.bc258c1b.0.snapshot index 21ab39f1b..bc22f7262 100644 --- a/compiler/test/__snapshots__/boxes.bc258c1b.0.snapshot +++ b/compiler/test/__snapshots__/boxes.bc258c1b.0.snapshot @@ -1,116 +1,58 @@ boxes › box_multiplication1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.9 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $7 - (call $*_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1117) - ) - (local.get $6) - (i32.const 39) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $MTupleSet.8 (result i32) - (i32.store offset=8 - (global.get $b_1113) - (tuple.extract 0 - (tuple.make - (local.get $7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func *_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/boxes.eb81e542.0.snapshot b/compiler/test/__snapshots__/boxes.eb81e542.0.snapshot index 6bf1af481..9b0afc2fe 100644 --- a/compiler/test/__snapshots__/boxes.eb81e542.0.snapshot +++ b/compiler/test/__snapshots__/boxes.eb81e542.0.snapshot @@ -1,96 +1,28 @@ boxes › test_set_extra1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (tuple.extract 0 - (tuple.make - (block $MTupleSet.5 (result i32) - (i32.store offset=8 - (local.get $6) - (tuple.extract 0 - (tuple.make - (i32.const 5) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (local.get $6) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - (block $cleanup.4 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/chars.200d9e1a.0.snapshot b/compiler/test/__snapshots__/chars.200d9e1a.0.snapshot index eacb069ae..b1d024cc3 100644 --- a/compiler/test/__snapshots__/chars.200d9e1a.0.snapshot +++ b/compiler/test/__snapshots__/chars.200d9e1a.0.snapshot @@ -1,35 +1,13 @@ chars › char4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 16642) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstChar A))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/chars.259e330c.0.snapshot b/compiler/test/__snapshots__/chars.259e330c.0.snapshot index e670892db..23aaeea0b 100644 --- a/compiler/test/__snapshots__/chars.259e330c.0.snapshot +++ b/compiler/test/__snapshots__/chars.259e330c.0.snapshot @@ -1,35 +1,13 @@ chars › char2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 16642) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstChar A))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/chars.27fb7f30.0.snapshot b/compiler/test/__snapshots__/chars.27fb7f30.0.snapshot index 4c88bebb8..37f70f96f 100644 --- a/compiler/test/__snapshots__/chars.27fb7f30.0.snapshot +++ b/compiler/test/__snapshots__/chars.27fb7f30.0.snapshot @@ -1,35 +1,13 @@ chars › char8 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 2566146) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstChar \"\\226\\156\\168\"))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/chars.51010573.0.snapshot b/compiler/test/__snapshots__/chars.51010573.0.snapshot index e0d2df47c..fadb2cc19 100644 --- a/compiler/test/__snapshots__/chars.51010573.0.snapshot +++ b/compiler/test/__snapshots__/chars.51010573.0.snapshot @@ -1,35 +1,13 @@ chars › char7 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 32718338) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstChar \"\\240\\159\\140\\190\"))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/chars.7e0f68db.0.snapshot b/compiler/test/__snapshots__/chars.7e0f68db.0.snapshot index eedcc3293..aa0381202 100644 --- a/compiler/test/__snapshots__/chars.7e0f68db.0.snapshot +++ b/compiler/test/__snapshots__/chars.7e0f68db.0.snapshot @@ -1,35 +1,13 @@ chars › char6 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 32812802) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstChar \"\\240\\159\\146\\175\"))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/chars.af4b3613.0.snapshot b/compiler/test/__snapshots__/chars.af4b3613.0.snapshot index fa01c9a34..928581c68 100644 --- a/compiler/test/__snapshots__/chars.af4b3613.0.snapshot +++ b/compiler/test/__snapshots__/chars.af4b3613.0.snapshot @@ -1,35 +1,13 @@ chars › char5 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 16642) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstChar A))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/chars.e1cac8cd.0.snapshot b/compiler/test/__snapshots__/chars.e1cac8cd.0.snapshot index 67af1fbca..234bb1e95 100644 --- a/compiler/test/__snapshots__/chars.e1cac8cd.0.snapshot +++ b/compiler/test/__snapshots__/chars.e1cac8cd.0.snapshot @@ -1,35 +1,13 @@ chars › char3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 16642) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstChar A))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/comments.573e549e.0.snapshot b/compiler/test/__snapshots__/comments.573e549e.0.snapshot index 7fcc08f0b..15acdf20f 100644 --- a/compiler/test/__snapshots__/comments.573e549e.0.snapshot +++ b/compiler/test/__snapshots__/comments.573e549e.0.snapshot @@ -1,35 +1,13 @@ comments › comment_alone -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 21) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 10))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/comments.8f52e899.0.snapshot b/compiler/test/__snapshots__/comments.8f52e899.0.snapshot index 5a4e6e383..02b185d8a 100644 --- a/compiler/test/__snapshots__/comments.8f52e899.0.snapshot +++ b/compiler/test/__snapshots__/comments.8f52e899.0.snapshot @@ -1,35 +1,13 @@ comments › comment_block -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 21) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 10))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/comments.ccf5fcf4.0.snapshot b/compiler/test/__snapshots__/comments.ccf5fcf4.0.snapshot index 6cb5e597d..f5a2d9212 100644 --- a/compiler/test/__snapshots__/comments.ccf5fcf4.0.snapshot +++ b/compiler/test/__snapshots__/comments.ccf5fcf4.0.snapshot @@ -1,35 +1,13 @@ comments › comment_shebang -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 21) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 10))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/comments.fd91c233.0.snapshot b/compiler/test/__snapshots__/comments.fd91c233.0.snapshot index 832ff9cad..9634c290e 100644 --- a/compiler/test/__snapshots__/comments.fd91c233.0.snapshot +++ b/compiler/test/__snapshots__/comments.fd91c233.0.snapshot @@ -1,35 +1,13 @@ comments › comment_doc -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 21) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 10))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/early_return.1183a893.0.snapshot b/compiler/test/__snapshots__/early_return.1183a893.0.snapshot index 44bf4e8ec..d2d4f3fe6 100644 --- a/compiler/test/__snapshots__/early_return.1183a893.0.snapshot +++ b/compiler/test/__snapshots__/early_return.1183a893.0.snapshot @@ -1,114 +1,89 @@ early return › early_return3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1116 (param i32 i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"foo\" (func $foo_1113)) - (export \"GRAIN$EXPORT$foo\" (global $foo_1113)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.2 - (local.set $7 - (call $==_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1116) - ) - (i32.const 3) - (i32.const 1) - ) - ) - (block $do_backpatches.1 - ) - ) - (drop - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.4 - (block $cleanup.3 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return - (i32.const -2) - ) - ) - (block $compile_block.5 (result i32) - (i32.const 1879048190) - ) - ) - ) - (block $cleanup.6 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return - (i32.const 2147483646) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.10 (result i32) - (block $compile_store.9 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (i32.const 1879048190) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1000 -) +((functions + (((id ((stamp 1113) (name foo))) (name (foo)) (args (Managed)) + (return_type ((Unmanaged WasmI32))) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturn + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturn + (((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((stamp 1116) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1116) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports + ((WasmFunctionExport (ex_function_name foo) + (ex_function_internal_name foo_1113)) + (WasmGlobalExport (ex_global_name foo) (ex_global_internal_name foo_1113)))) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((stamp 1113) (name foo)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1119) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/enums.aa34084a.0.snapshot b/compiler/test/__snapshots__/enums.aa34084a.0.snapshot index b75fc2c0f..9da66ae65 100644 --- a/compiler/test/__snapshots__/enums.aa34084a.0.snapshot +++ b/compiler/test/__snapshots__/enums.aa34084a.0.snapshot @@ -1,65 +1,19 @@ enums › adt_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 992856951) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 652 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 496428475))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ())))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/enums.ae26523b.0.snapshot b/compiler/test/__snapshots__/enums.ae26523b.0.snapshot index fc7393519..a2e2f1614 100644 --- a/compiler/test/__snapshots__/enums.ae26523b.0.snapshot +++ b/compiler/test/__snapshots__/enums.ae26523b.0.snapshot @@ -1,416 +1,155 @@ enums › enum_recursive_data_definition -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1129 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1129 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (block $compile_block.31 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 6) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 54015209861748) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 6) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 55114721489524) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1215441249) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1675317329) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (local.get $7) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1215441249) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.18 - (local.set $11 - (block $allocate_adt.16 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1215441249) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (local.get $9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $10) - ) - (local.get $0) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.21 - (local.set $12 - (block $allocate_adt.19 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1675317329) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (local.get $11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.24 - (local.set $13 - (block $allocate_adt.22 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1215441249) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.23 - ) - ) - (block $compile_store.27 - (local.set $14 - (block $allocate_adt.25 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1215441249) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (local.get $12) - ) - (i32.store offset=24 - (local.get $0) - (local.get $13) - ) - (local.get $0) - ) - ) - (block $do_backpatches.26 - ) - ) - (block $compile_store.30 - (local.set $15 - (block $allocate_adt.28 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.29 - ) - ) - (return_call $print_1129 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1129) - ) - (local.get $14) - (local.get $15) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 930 -) +((functions ()) + (imports + (((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString \"tree 1\"))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MString \"tree 2\"))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 607720624))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 837658664))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 607720624))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 607720624))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 837658664))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 607720624))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 607720624))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MReturnCallKnown (func print_1129) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1129 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 10) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/exceptions.a68ae348.0.snapshot b/compiler/test/__snapshots__/exceptions.a68ae348.0.snapshot index 1a9cefb89..701095c38 100644 --- a/compiler/test/__snapshots__/exceptions.a68ae348.0.snapshot +++ b/compiler/test/__snapshots__/exceptions.a68ae348.0.snapshot @@ -1,65 +1,19 @@ exceptions › exception_4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1760 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + ())))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/exceptions.ccac3e71.0.snapshot b/compiler/test/__snapshots__/exceptions.ccac3e71.0.snapshot index d62326d06..c1fac147e 100644 --- a/compiler/test/__snapshots__/exceptions.ccac3e71.0.snapshot +++ b/compiler/test/__snapshots__/exceptions.ccac3e71.0.snapshot @@ -1,65 +1,19 @@ exceptions › exception_2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 892 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + ())))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.06134c8a.0.snapshot b/compiler/test/__snapshots__/functions.06134c8a.0.snapshot index 5c6a9cf85..5fa726888 100644 --- a/compiler/test/__snapshots__/functions.06134c8a.0.snapshot +++ b/compiler/test/__snapshots__/functions.06134c8a.0.snapshot @@ -1,78 +1,41 @@ functions › dup_func -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $foo_1117 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1117 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (i32.const 19) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.5 - (block $compile_store.4 - (global.set $foo_1117 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (return_call $foo_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1117) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((name foo))) (name (foo)) (args (Managed)) (return_type (Managed)) + (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 9))) + (immediate_analyses ((last_usage Unknown)))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1117 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() (Managed))) (args ())))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name foo)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.0b8146ea.0.snapshot b/compiler/test/__snapshots__/functions.0b8146ea.0.snapshot index 0b5bf9f59..f096cd421 100644 --- a/compiler/test/__snapshots__/functions.0b8146ea.0.snapshot +++ b/compiler/test/__snapshots__/functions.0b8146ea.0.snapshot @@ -1,85 +1,48 @@ functions › regression_1725 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (local $7 i32) - (block $compile_block.4 - (block $compile_store.2 - (local.tee $7 - (return - (i32.const 11) - ) - ) - (block $do_backpatches.1 - ) - ) - (block $cleanup.3 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return - (i32.const 13) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.7 - (block $compile_store.6 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.5 - ) - ) - (return_call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((name foo))) (name (foo)) (args (Managed)) (return_type (Managed)) + (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MReturn + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturn + (((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() (Managed))) (args ())))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name foo)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.14922a92.0.snapshot b/compiler/test/__snapshots__/functions.14922a92.0.snapshot index 4e5fe1589..3dac22ca2 100644 --- a/compiler/test/__snapshots__/functions.14922a92.0.snapshot +++ b/compiler/test/__snapshots__/functions.14922a92.0.snapshot @@ -1,83 +1,63 @@ functions › shorthand_4 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1115 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1115 (param i32 i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.2 - (block $cleanup.1 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1115 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1115) - ) - (local.get $1) - (i32.const 7) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.5 - (block $compile_store.4 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (return_call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((name foo))) (name (foo)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1115) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name foo)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.1be5ecd5.0.snapshot b/compiler/test/__snapshots__/functions.1be5ecd5.0.snapshot index 5e4798922..f32774fae 100644 --- a/compiler/test/__snapshots__/functions.1be5ecd5.0.snapshot +++ b/compiler/test/__snapshots__/functions.1be5ecd5.0.snapshot @@ -1,78 +1,44 @@ functions › shorthand_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (local.get $1) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.5 - (block $compile_store.4 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (return_call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((name foo))) (name (foo)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name foo)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.23afd9c9.0.snapshot b/compiler/test/__snapshots__/functions.23afd9c9.0.snapshot index b1308be3c..6417d2436 100644 --- a/compiler/test/__snapshots__/functions.23afd9c9.0.snapshot +++ b/compiler/test/__snapshots__/functions.23afd9c9.0.snapshot @@ -1,410 +1,256 @@ functions › lam_destructure_5 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1119 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1119 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $lam_lambda_1118 (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i64) - (local $7 f32) - (local $8 f64) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (block $compile_block.35 - (block $compile_store.2 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.6 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $1) - ) - ) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $1) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $14 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $1) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $cleanup.13 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - ) - (drop - (block $compile_set.14 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.15 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.16 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.18 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $16 - (i32.const 0) - ) - (block $do_backpatches.19 - ) - ) - (block $compile_store.22 - (local.set $17 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $2) - ) - ) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.24 - (local.set $18 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $2) - ) - ) - ) - (block $do_backpatches.23 - ) - ) - (block $cleanup.25 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $2) - ) - ) - ) - (drop - (block $compile_set.26 (result i32) - (local.set $16 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.27 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.29 - (local.set $19 - (call $+_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1119) - ) - (local.get $9) - (local.get $10) - ) - ) - (block $do_backpatches.28 - ) - ) - (block $compile_store.31 - (local.set $20 - (call $+_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1119) - ) - (local.get $19) - (local.get $11) - ) - ) - (block $do_backpatches.30 - ) - ) - (block $compile_store.33 - (local.set $21 - (call $+_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1119) - ) - (local.get $20) - (local.get $15) - ) - ) - (block $do_backpatches.32 - ) - ) - (block $cleanup.34 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1119) - ) - (local.get $21) - (local.get $16) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.44 - (block $compile_store.37 - (local.set $6 - (i32.const 0) - ) - (block $do_backpatches.36 - ) - ) - (block $compile_store.40 - (local.set $7 - (block $allocate_tuple.38 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.39 - ) - ) - (block $compile_store.43 - (local.set $8 - (block $allocate_tuple.41 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.42 - ) - ) - (return_call $lam_lambda_1118 - (local.get $6) - (local.get $7) - (local.get $8) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((name lam_lambda))) (name ()) (args (Managed Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MArgBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MArgBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MCallKnown (func +_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1119 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MCallKnown (func +_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1119 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MCallKnown (func +_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1119 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1119 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 13) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func lam_lambda_1118) + (closure + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.28e0f2b3.0.snapshot b/compiler/test/__snapshots__/functions.28e0f2b3.0.snapshot index 6a6bcd711..3b46e750e 100644 --- a/compiler/test/__snapshots__/functions.28e0f2b3.0.snapshot +++ b/compiler/test/__snapshots__/functions.28e0f2b3.0.snapshot @@ -1,113 +1,49 @@ functions › lambda_pat_any -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $x_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (i32.const 11) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.8 - (block $compile_store.4 - (global.set $x_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $6 - (block $allocate_string.5 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.6 - ) - ) - (return_call $x_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $x_1113) - ) - (local.get $6) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((name x))) (name (x)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))) + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MReturnCallKnown (func x_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name x)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.49ccab54.0.snapshot b/compiler/test/__snapshots__/functions.49ccab54.0.snapshot index 2683530ef..e43257bca 100644 --- a/compiler/test/__snapshots__/functions.49ccab54.0.snapshot +++ b/compiler/test/__snapshots__/functions.49ccab54.0.snapshot @@ -1,169 +1,95 @@ functions › curried_func -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1116 (param i32 i32 i32) (result i32))) - (global $add_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 1)) - (memory $0 0) - (elem $elem (global.get $relocBase_0) $func_1123) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $add_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.3 (result i32) - (tuple.extract 0 - (tuple.make - (block $allocate_closure.2 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $2) - (i32.add - (global.get $relocBase_0) - (i32.const 0) - ) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $2) - (local.get $1) - ) - (local.get $2) - ) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $func_1123 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i64) - (local $7 f32) - (local $8 f64) - (block $closure_elements.8 - (local.set $2 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $0) - ) - ) - ) - (block $compile_block.7 - (block $cleanup.6 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1116) - ) - (local.get $2) - (local.get $1) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.14 - (block $compile_store.10 - (global.set $add_1113 - (i32.const 0) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $6 - (call $add_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $add_1113) - ) - (i32.const 5) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $call_lambda.13 - (local.set $0 - (local.get $6) - ) - (return_call_indirect (type $i32_i32_=>_i32) - (local.get $0) - (i32.const 7) - (i32.load offset=8 - (local.get $0) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((name add))) (name (add)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MAllocate + (MClosure + ((func_idx (0)) (global_offset function_table_global_1122) + (arity 2) + (variables + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())) + ((id ((name func))) (name ()) (args (Managed Managed)) + (return_type (Managed)) (closure (1)) + (body + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MClosureBind 0))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind add_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func add_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind add_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallIndirect + (func + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name add)) true Managed ()))) + (function_table_elements (func_1124)) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.6eacded0.0.snapshot b/compiler/test/__snapshots__/functions.6eacded0.0.snapshot index ad915f582..3d98b63b6 100644 --- a/compiler/test/__snapshots__/functions.6eacded0.0.snapshot +++ b/compiler/test/__snapshots__/functions.6eacded0.0.snapshot @@ -1,481 +1,342 @@ functions › func_recursive_closure -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1137 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1132 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1122 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1137 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1132 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1122 (param i32 i32 i32) (result i32))) - (global $truc_1116 (mut i32) (i32.const 0)) - (global $makeAdder_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 1)) - (memory $0 0) - (elem $elem (global.get $relocBase_0) $func_1145) - (export \"memory\" (memory $0)) - (export \"truc\" (func $truc_1116)) - (export \"GRAIN$EXPORT$truc\" (global $truc_1116)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $makeAdder_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.3 (result i32) - (tuple.extract 0 - (tuple.make - (block $allocate_closure.2 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $2) - (i32.add - (global.get $relocBase_0) - (i32.const 0) - ) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $2) - (local.get $1) - ) - (local.get $2) - ) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $truc_1116 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $cleanup.6 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $foo_1117 - (local.get $7) - (i32.const 11) - ) - ) - ) - (func $func_1145 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i64) - (local $7 f32) - (local $8 f64) - (block $closure_elements.12 - (local.set $2 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $0) - ) - ) - ) - (block $compile_block.11 - (block $cleanup.10 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1122 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1122) - ) - (local.get $1) - (local.get $2) - ) - ) - ) - ) - (func $foo_1117 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (block $compile_block.31 (result i32) - (block $compile_store.14 - (local.set $8 - (call $makeAdder_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $makeAdder_1113) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.17 - (local.set $9 - (block $allocate_closure.15 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $2) - (i32.const -1) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 2) - ) - (local.get $2) - ) - ) - (block $do_backpatches.16 - (local.set $2 - (local.get $9) - ) - (i32.store offset=16 - (local.get $2) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $0) - ) - ) - (i32.store offset=20 - (local.get $2) - (local.get $8) - ) - ) - ) - (block $compile_store.19 - (local.set $11 - (call $==_1132 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1132) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $1) - ) - (i32.const 1) - ) - ) - (block $do_backpatches.18 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $11) - (i32.const 31) - ) - (block $compile_block.21 (result i32) - (i32.const 1) - ) - (block $compile_block.30 - (block $compile_store.23 - (local.set $12 - (call $==_1132 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1132) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $1) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.22 - ) - ) - (if - (i32.shr_u - (local.get $12) - (i32.const 31) - ) - (block $compile_block.25 - (block $cleanup.24 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - ) - (return_call $bar_1120 - (local.get $9) - (i32.const 3) - ) - ) - (block $compile_block.29 - (block $compile_store.27 - (local.set $10 - (call $-_1137 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1137) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $1) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.26 - ) - ) - (block $cleanup.28 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - (return_call $foo_1117 - (local.get $0) - (local.get $10) - ) - ) - ) - ) - ) - (block $cleanup.20 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $bar_1120 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - (local $7 i64) - (local $8 f32) - (local $9 f64) - (local $10 i32) - (local $11 i32) - (block $closure_elements.46 - (local.set $3 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $0) - ) - ) - ) - (local.set $2 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $0) - ) - ) - ) - (block $compile_block.45 - (block $compile_store.40 - (local.set $10 - (call $foo_1117 - (local.get $2) - (i32.const 1) - ) - ) - (block $do_backpatches.39 - ) - ) - (block $compile_store.43 - (local.set $11 - (block $call_lambda.41 (result i32) - (local.set $4 - (local.get $3) - ) - (call_indirect (type $i32_i32_=>_i32) - (local.get $4) - (i32.const 3) - (i32.load offset=8 - (local.get $4) - ) - ) - ) - ) - (block $do_backpatches.42 - ) - ) - (block $cleanup.44 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - ) - (return_call $+_1122 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1122) - ) - (local.get $10) - (local.get $11) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.51 - (block $compile_store.48 - (global.set $makeAdder_1113 - (i32.const 0) - ) - (block $do_backpatches.47 - ) - ) - (block $compile_store.50 - (global.set $truc_1116 - (i32.const 0) - ) - (block $do_backpatches.49 - ) - ) - (return_call $truc_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $truc_1116) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1025 -) +((functions + (((id ((name makeAdder))) (name (makeAdder)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MAllocate + (MClosure + ((func_idx (0)) (global_offset function_table_global_1143) + (arity 2) + (variables + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())) + ((id ((name truc))) (name (truc)) (args (Managed)) (return_type (Managed)) + (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func foo_1117) + (closure + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))))) + (stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())) + ((id ((name func))) (name ()) (args (Managed Managed)) + (return_type (Managed)) (closure (1)) + (body + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1122) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1122 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MClosureBind 0))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())) + ((id ((name foo))) (name ()) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func makeAdder_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind makeAdder_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MClosure + ((func_idx ()) (global_offset function_table_global_1143) + (arity 2) + (variables + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1132) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1132 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1132) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1132 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func bar_1120) + (closure + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MCallKnown (func -_1137) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind -_1137 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func foo_1117) + (closure + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 3) (stack_size_i32 2) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())) + ((id ((name bar))) (name ()) (args (Managed Managed)) + (return_type (Managed)) (closure (2)) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func foo_1117) + (closure + ((immediate_desc (MImmBinding (MClosureBind 0))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallIndirect + (func + ((immediate_desc (MImmBinding (MClosureBind 1))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1122) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1122 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports + ((WasmFunctionExport (ex_function_name truc) + (ex_function_internal_name truc_1116)) + (WasmGlobalExport (ex_global_name truc) + (ex_global_internal_name truc_1116)))) + (main_body + (((instr_desc + (MStore + (((MGlobalBind makeAdder_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind truc_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func truc_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind truc_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() (Managed))) (args ())))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + ((((name truc)) true Managed ()) (((name makeAdder)) true Managed ()))) + (function_table_elements (func_1146)) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.7a8986a5.0.snapshot b/compiler/test/__snapshots__/functions.7a8986a5.0.snapshot index c1720ca67..286a8b41e 100644 --- a/compiler/test/__snapshots__/functions.7a8986a5.0.snapshot +++ b/compiler/test/__snapshots__/functions.7a8986a5.0.snapshot @@ -1,73 +1,41 @@ functions › app_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $lam_lambda_1114 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (local.get $1) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 - (block $compile_store.4 - (local.set $6 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (return_call $lam_lambda_1114 - (local.get $6) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((name lam_lambda))) (name ()) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func lam_lambda_1114) + (closure + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.84b6e84b.0.snapshot b/compiler/test/__snapshots__/functions.84b6e84b.0.snapshot index 3a79d9bc6..506f348f5 100644 --- a/compiler/test/__snapshots__/functions.84b6e84b.0.snapshot +++ b/compiler/test/__snapshots__/functions.84b6e84b.0.snapshot @@ -1,78 +1,44 @@ functions › shorthand_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (local.get $1) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.5 - (block $compile_store.4 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (return_call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((name foo))) (name (foo)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name foo)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.8baf471f.0.snapshot b/compiler/test/__snapshots__/functions.8baf471f.0.snapshot index 92c03b508..0c30f2b4f 100644 --- a/compiler/test/__snapshots__/functions.8baf471f.0.snapshot +++ b/compiler/test/__snapshots__/functions.8baf471f.0.snapshot @@ -1,260 +1,160 @@ functions › lam_destructure_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1117 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $lam_lambda_1116 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (block $compile_block.20 - (block $compile_store.2 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.6 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $1) - ) - ) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $1) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $1) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $cleanup.13 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - ) - (drop - (block $compile_set.14 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.15 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.16 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.18 - (local.set $14 - (call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (local.get $8) - (local.get $9) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $cleanup.19 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (local.get $14) - (local.get $10) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.26 - (block $compile_store.22 - (local.set $6 - (i32.const 0) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.25 - (local.set $7 - (block $allocate_tuple.23 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.24 - ) - ) - (return_call $lam_lambda_1116 - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((name lam_lambda))) (name ()) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 7) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func lam_lambda_1116) + (closure + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.9223245d.0.snapshot b/compiler/test/__snapshots__/functions.9223245d.0.snapshot index e5c7a08c5..16f833864 100644 --- a/compiler/test/__snapshots__/functions.9223245d.0.snapshot +++ b/compiler/test/__snapshots__/functions.9223245d.0.snapshot @@ -1,367 +1,221 @@ functions › lam_destructure_7 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1118 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1118 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $lam_lambda_1117 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (block $compile_block.30 - (block $compile_store.2 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.6 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $1) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $1) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $14 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $1) - ) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $cleanup.15 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - ) - (block $compile_store.17 - (local.set $15 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $14) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $16 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $14) - ) - ) - ) - (block $do_backpatches.18 - ) - ) - (block $cleanup.20 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - (drop - (block $compile_set.21 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.22 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.23 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.24 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.26 - (local.set $17 - (call $+_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1118) - ) - (local.get $8) - (local.get $9) - ) - ) - (block $do_backpatches.25 - ) - ) - (block $compile_store.28 - (local.set $18 - (call $+_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1118) - ) - (local.get $17) - (local.get $10) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $cleanup.29 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1118) - ) - (local.get $18) - (local.get $11) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.39 - (block $compile_store.32 - (local.set $6 - (i32.const 0) - ) - (block $do_backpatches.31 - ) - ) - (block $compile_store.35 - (local.set $7 - (block $allocate_tuple.33 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.34 - ) - ) - (block $compile_store.38 - (local.set $8 - (block $allocate_tuple.36 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.37 - ) - ) - (return_call $lam_lambda_1117 - (local.get $6) - (local.get $8) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((name lam_lambda))) (name ()) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MCallKnown (func +_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1118 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MCallKnown (func +_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1118 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1118 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 11) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MReturnCallKnown (func lam_lambda_1117) + (closure + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.9fd69835.0.snapshot b/compiler/test/__snapshots__/functions.9fd69835.0.snapshot index 4776b9720..80544a2a7 100644 --- a/compiler/test/__snapshots__/functions.9fd69835.0.snapshot +++ b/compiler/test/__snapshots__/functions.9fd69835.0.snapshot @@ -1,83 +1,63 @@ functions › shorthand_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1115 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1115 (param i32 i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.2 - (block $cleanup.1 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1115 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1115) - ) - (local.get $1) - (i32.const 7) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.5 - (block $compile_store.4 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (return_call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((name foo))) (name (foo)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1115) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name foo)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.b37949b2.0.snapshot b/compiler/test/__snapshots__/functions.b37949b2.0.snapshot index f9da9683a..99e3846bc 100644 --- a/compiler/test/__snapshots__/functions.b37949b2.0.snapshot +++ b/compiler/test/__snapshots__/functions.b37949b2.0.snapshot @@ -1,263 +1,163 @@ functions › lam_destructure_4 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1117 (param i32 i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (block $compile_block.20 - (block $compile_store.2 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.6 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $1) - ) - ) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $1) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $1) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $cleanup.13 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - ) - (drop - (block $compile_set.14 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.15 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.16 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.18 - (local.set $14 - (call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (local.get $8) - (local.get $9) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $cleanup.19 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (local.get $14) - (local.get $10) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.26 - (block $compile_store.22 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.25 - (local.set $6 - (block $allocate_tuple.23 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.24 - ) - ) - (return_call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - (local.get $6) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((name foo))) (name (foo)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 7) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name foo)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.b3a8d88b.0.snapshot b/compiler/test/__snapshots__/functions.b3a8d88b.0.snapshot index f53e729a6..c8101ce44 100644 --- a/compiler/test/__snapshots__/functions.b3a8d88b.0.snapshot +++ b/compiler/test/__snapshots__/functions.b3a8d88b.0.snapshot @@ -1,370 +1,224 @@ functions › lam_destructure_8 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1118 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1118 (param i32 i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (block $compile_block.30 - (block $compile_store.2 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.6 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $1) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $1) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $14 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $1) - ) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $cleanup.15 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - ) - (block $compile_store.17 - (local.set $15 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $14) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $16 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $14) - ) - ) - ) - (block $do_backpatches.18 - ) - ) - (block $cleanup.20 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - (drop - (block $compile_set.21 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.22 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.23 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.24 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.26 - (local.set $17 - (call $+_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1118) - ) - (local.get $8) - (local.get $9) - ) - ) - (block $do_backpatches.25 - ) - ) - (block $compile_store.28 - (local.set $18 - (call $+_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1118) - ) - (local.get $17) - (local.get $10) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $cleanup.29 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1118) - ) - (local.get $18) - (local.get $11) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.39 - (block $compile_store.32 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.31 - ) - ) - (block $compile_store.35 - (local.set $6 - (block $allocate_tuple.33 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.34 - ) - ) - (block $compile_store.38 - (local.set $7 - (block $allocate_tuple.36 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.37 - ) - ) - (return_call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((name foo))) (name (foo)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MCallKnown (func +_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1118 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MCallKnown (func +_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1118 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1118 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 11) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name foo)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.b632a2ab.0.snapshot b/compiler/test/__snapshots__/functions.b632a2ab.0.snapshot index b1e84ed43..37c62d92f 100644 --- a/compiler/test/__snapshots__/functions.b632a2ab.0.snapshot +++ b/compiler/test/__snapshots__/functions.b632a2ab.0.snapshot @@ -1,108 +1,46 @@ functions › lam_destructure_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $lam_lambda_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (i32.const 11) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 - (block $compile_store.4 - (local.set $6 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $allocate_string.5 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.6 - ) - ) - (return_call $lam_lambda_1113 - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((name lam_lambda))) (name ()) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))) + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MReturnCallKnown (func lam_lambda_1113) + (closure + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.c6e8a9aa.0.snapshot b/compiler/test/__snapshots__/functions.c6e8a9aa.0.snapshot index ce918b714..0b72aa6a3 100644 --- a/compiler/test/__snapshots__/functions.c6e8a9aa.0.snapshot +++ b/compiler/test/__snapshots__/functions.c6e8a9aa.0.snapshot @@ -1,113 +1,49 @@ functions › lam_destructure_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (i32.const 11) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.8 - (block $compile_store.4 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $6 - (block $allocate_string.5 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.6 - ) - ) - (return_call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - (local.get $6) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((name foo))) (name (foo)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))) + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name foo)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.ce978f54.0.snapshot b/compiler/test/__snapshots__/functions.ce978f54.0.snapshot index 66f683d7f..552e37a9b 100644 --- a/compiler/test/__snapshots__/functions.ce978f54.0.snapshot +++ b/compiler/test/__snapshots__/functions.ce978f54.0.snapshot @@ -1,35 +1,13 @@ functions › multi_bind2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 7) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.d9466880.0.snapshot b/compiler/test/__snapshots__/functions.d9466880.0.snapshot index 8a6c3d20c..5a292b400 100644 --- a/compiler/test/__snapshots__/functions.d9466880.0.snapshot +++ b/compiler/test/__snapshots__/functions.d9466880.0.snapshot @@ -1,239 +1,95 @@ functions › func_record_associativity2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 1)) - (memory $0 0) - (elem $elem (global.get $relocBase_0) $lam_lambda_1121) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $lam_lambda_1121 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $closure_elements.5 (result i32) - (block $compile_block.4 (result i32) - (tuple.extract 0 - (tuple.make - (i32.const 2147483646) - (block $cleanup.3 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (block $compile_block.24 (result i32) - (block $compile_store.8 - (local.set $6 - (block $allocate_closure.6 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.add - (global.get $relocBase_0) - (i32.const 0) - ) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.7 - (local.set $0 - (local.get $6) - ) - ) - ) - (block $compile_store.11 - (local.set $7 - (block $allocate_record.9 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1631403427) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.14 - (local.set $8 - (block $allocate_record.12 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 485893719) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $8) - ) - ) - ) - (block $do_backpatches.15 - ) - ) - (block $cleanup.17 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - (block $compile_store.19 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $9) - ) - ) - ) - (block $do_backpatches.18 - ) - ) - (block $cleanup.20 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - (block $compile_store.23 - (local.set $11 - (block $call_lambda.21 (result i32) - (local.set $0 - (local.get $10) - ) - (call_indirect (type $i32_=>_i32) - (local.get $0) - (i32.load offset=8 - (local.get $0) - ) - ) - ) - ) - (block $do_backpatches.22 - ) - ) - (i32.xor - (local.get $11) - (i32.const -2147483648) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 626 -) +((functions + (((id ((name lam_lambda))) (name ()) (args (Managed)) + (return_type ((Unmanaged WasmI32))) (closure (0)) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MClosure + ((func_idx (0)) (global_offset function_table_global_1125) + (arity 1) (variables ()))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 815701713))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((g) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 242946859))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + (((f) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallIndirect + (func + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type (() ((Unmanaged WasmI32)))) (args ()))))))))) + ((instr_desc + (MPrim1 Not + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 5) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements (lam_lambda_1121)) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.e6c6212b.0.snapshot b/compiler/test/__snapshots__/functions.e6c6212b.0.snapshot index 99de1e8a5..dacc10aa8 100644 --- a/compiler/test/__snapshots__/functions.e6c6212b.0.snapshot +++ b/compiler/test/__snapshots__/functions.e6c6212b.0.snapshot @@ -1,84 +1,65 @@ functions › fn_trailing_comma -(module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1116 (param i32 i32 i32) (result i32))) - (global $testFn_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $testFn_1113 (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i64) - (local $7 f32) - (local $8 f64) - (block $compile_block.2 - (block $cleanup.1 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1116) - ) - (local.get $1) - (local.get $2) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.5 - (block $compile_store.4 - (global.set $testFn_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (return_call $testFn_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $testFn_1113) - ) - (i32.const 5) - (i32.const 7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((name testFn))) (name (testFn)) (args (Managed Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MArgBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind testFn_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func testFn_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind testFn_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name testFn)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.f400bb7b.0.snapshot b/compiler/test/__snapshots__/functions.f400bb7b.0.snapshot index 5ae53c6b0..eeec45e07 100644 --- a/compiler/test/__snapshots__/functions.f400bb7b.0.snapshot +++ b/compiler/test/__snapshots__/functions.f400bb7b.0.snapshot @@ -1,413 +1,259 @@ functions › lam_destructure_6 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1119 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1119 (param i32 i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i64) - (local $7 f32) - (local $8 f64) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (block $compile_block.35 - (block $compile_store.2 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.6 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $1) - ) - ) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $1) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $14 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $1) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $cleanup.13 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - ) - (drop - (block $compile_set.14 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.15 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.16 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.18 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $16 - (i32.const 0) - ) - (block $do_backpatches.19 - ) - ) - (block $compile_store.22 - (local.set $17 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $2) - ) - ) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.24 - (local.set $18 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $2) - ) - ) - ) - (block $do_backpatches.23 - ) - ) - (block $cleanup.25 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $2) - ) - ) - ) - (drop - (block $compile_set.26 (result i32) - (local.set $16 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.27 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.29 - (local.set $19 - (call $+_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1119) - ) - (local.get $9) - (local.get $10) - ) - ) - (block $do_backpatches.28 - ) - ) - (block $compile_store.31 - (local.set $20 - (call $+_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1119) - ) - (local.get $19) - (local.get $11) - ) - ) - (block $do_backpatches.30 - ) - ) - (block $compile_store.33 - (local.set $21 - (call $+_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1119) - ) - (local.get $20) - (local.get $15) - ) - ) - (block $do_backpatches.32 - ) - ) - (block $cleanup.34 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1119) - ) - (local.get $21) - (local.get $16) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.44 - (block $compile_store.37 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.36 - ) - ) - (block $compile_store.40 - (local.set $6 - (block $allocate_tuple.38 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.39 - ) - ) - (block $compile_store.43 - (local.set $7 - (block $allocate_tuple.41 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.42 - ) - ) - (return_call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((name foo))) (name (foo)) (args (Managed Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MArgBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MArgBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MCallKnown (func +_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1119 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MCallKnown (func +_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1119 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MCallKnown (func +_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1119 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1119 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 13) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name foo)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/functions.f647681b.0.snapshot b/compiler/test/__snapshots__/functions.f647681b.0.snapshot index ef38b0765..f38710b80 100644 --- a/compiler/test/__snapshots__/functions.f647681b.0.snapshot +++ b/compiler/test/__snapshots__/functions.f647681b.0.snapshot @@ -1,183 +1,71 @@ functions › func_record_associativity1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 1)) - (memory $0 0) - (elem $elem (global.get $relocBase_0) $lam_lambda_1118) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $lam_lambda_1118 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $closure_elements.5 (result i32) - (block $compile_block.4 (result i32) - (tuple.extract 0 - (tuple.make - (i32.const 2147483646) - (block $cleanup.3 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.18 (result i32) - (block $compile_store.8 - (local.set $6 - (block $allocate_closure.6 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.add - (global.get $relocBase_0) - (i32.const 0) - ) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.7 - (local.set $0 - (local.get $6) - ) - ) - ) - (block $compile_store.11 - (local.set $7 - (block $allocate_record.9 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 485893719) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $cleanup.14 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (block $compile_store.17 - (local.set $9 - (block $call_lambda.15 (result i32) - (local.set $0 - (local.get $8) - ) - (call_indirect (type $i32_=>_i32) - (local.get $0) - (i32.load offset=8 - (local.get $0) - ) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (i32.xor - (local.get $9) - (i32.const -2147483648) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 496 -) +((functions + (((id ((name lam_lambda))) (name ()) (args (Managed)) + (return_type ((Unmanaged WasmI32))) (closure (0)) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MClosure + ((func_idx (0)) (global_offset function_table_global_1121) + (arity 1) (variables ()))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 242946859))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((f) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallIndirect + (func + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type (() ((Unmanaged WasmI32)))) (args ()))))))))) + ((instr_desc + (MPrim1 Not + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements (lam_lambda_1118)) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/includes.1d829099.0.snapshot b/compiler/test/__snapshots__/includes.1d829099.0.snapshot index 4731179f7..9a7cbceb9 100644 --- a/compiler/test/__snapshots__/includes.1d829099.0.snapshot +++ b/compiler/test/__snapshots__/includes.1d829099.0.snapshot @@ -1,36 +1,18 @@ includes › include_relative_path2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$../../test/test-libs/provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1122 (mut i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (global.get $x_1122) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 453 -) +((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod ../../test/test-libs/provideAll.gr) + (mimp_name x) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind x_1122 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/includes.46f78654.0.snapshot b/compiler/test/__snapshots__/includes.46f78654.0.snapshot index cfa601d01..d86c564f4 100644 --- a/compiler/test/__snapshots__/includes.46f78654.0.snapshot +++ b/compiler/test/__snapshots__/includes.46f78654.0.snapshot @@ -1,50 +1,36 @@ includes › include_some_multiple -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1123 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$y\" (global $y_1122 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"y\" (func $y_1122 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $y_1122 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $y_1122) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $x_1123) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func y_1122) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind y_1122 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind x_1123 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/includes.5dfba7dd.0.snapshot b/compiler/test/__snapshots__/includes.5dfba7dd.0.snapshot index 11a9fba19..2f34a20f3 100644 --- a/compiler/test/__snapshots__/includes.5dfba7dd.0.snapshot +++ b/compiler/test/__snapshots__/includes.5dfba7dd.0.snapshot @@ -1,36 +1,18 @@ includes › include_alias -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1122 (mut i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (global.get $x_1122) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind x_1122 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/includes.6c8d23dc.0.snapshot b/compiler/test/__snapshots__/includes.6c8d23dc.0.snapshot index eac4043ae..65be517fc 100644 --- a/compiler/test/__snapshots__/includes.6c8d23dc.0.snapshot +++ b/compiler/test/__snapshots__/includes.6c8d23dc.0.snapshot @@ -1,50 +1,36 @@ includes › include_some_multiple_trailing2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1123 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$y\" (global $y_1122 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"y\" (func $y_1122 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $y_1122 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $y_1122) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $x_1123) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func y_1122) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind y_1122 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind x_1123 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/includes.6e78c003.0.snapshot b/compiler/test/__snapshots__/includes.6e78c003.0.snapshot index 409acc60d..2cd370a1a 100644 --- a/compiler/test/__snapshots__/includes.6e78c003.0.snapshot +++ b/compiler/test/__snapshots__/includes.6e78c003.0.snapshot @@ -1,50 +1,36 @@ includes › include_some_multiple_trailing -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1123 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$y\" (global $y_1122 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"y\" (func $y_1122 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $y_1122 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $y_1122) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $x_1123) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func y_1122) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind y_1122 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind x_1123 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/includes.7afbe731.0.snapshot b/compiler/test/__snapshots__/includes.7afbe731.0.snapshot index 8a1362513..3e6ddfee4 100644 --- a/compiler/test/__snapshots__/includes.7afbe731.0.snapshot +++ b/compiler/test/__snapshots__/includes.7afbe731.0.snapshot @@ -1,36 +1,18 @@ includes › include_some -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1122 (mut i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (global.get $x_1122) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind x_1122 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/includes.8222ee98.0.snapshot b/compiler/test/__snapshots__/includes.8222ee98.0.snapshot index 7027f8dcd..ef665bbda 100644 --- a/compiler/test/__snapshots__/includes.8222ee98.0.snapshot +++ b/compiler/test/__snapshots__/includes.8222ee98.0.snapshot @@ -1,36 +1,18 @@ includes › include_module -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1122 (mut i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (global.get $x_1122) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind x_1122 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/includes.86ff4075.0.snapshot b/compiler/test/__snapshots__/includes.86ff4075.0.snapshot index 5fd103436..cc8fda1b6 100644 --- a/compiler/test/__snapshots__/includes.86ff4075.0.snapshot +++ b/compiler/test/__snapshots__/includes.86ff4075.0.snapshot @@ -1,50 +1,36 @@ includes › include_alias_multiple -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1123 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$y\" (global $y_1122 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"y\" (func $y_1122 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $y_1122 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $y_1122) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $x_1123) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func y_1122) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind y_1122 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind x_1123 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/includes.a3212bd0.0.snapshot b/compiler/test/__snapshots__/includes.a3212bd0.0.snapshot index 45a9450f9..002219a80 100644 --- a/compiler/test/__snapshots__/includes.a3212bd0.0.snapshot +++ b/compiler/test/__snapshots__/includes.a3212bd0.0.snapshot @@ -1,36 +1,18 @@ includes › include_relative_path3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$nested/nested.gr\" \"GRAIN$EXPORT$j\" (global $j_1116 (mut i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (global.get $j_1116) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 435 -) +((functions ()) + (imports + (((mimp_id ((name j))) (mimp_mod nested/nested.gr) (mimp_name j) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind j_1116 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/includes.b3434679.0.snapshot b/compiler/test/__snapshots__/includes.b3434679.0.snapshot index 981458dbf..c80b06659 100644 --- a/compiler/test/__snapshots__/includes.b3434679.0.snapshot +++ b/compiler/test/__snapshots__/includes.b3434679.0.snapshot @@ -1,108 +1,35 @@ includes › include_some_constructor -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 417 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/includes.bd3eb3af.0.snapshot b/compiler/test/__snapshots__/includes.bd3eb3af.0.snapshot index c46804bb9..0a492bea1 100644 --- a/compiler/test/__snapshots__/includes.bd3eb3af.0.snapshot +++ b/compiler/test/__snapshots__/includes.bd3eb3af.0.snapshot @@ -1,126 +1,59 @@ includes › include_some_mixed -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$tlists.gr\" \"GRAIN$EXPORT$sum\" (global $sum_1126 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$tlists.gr\" \"sum\" (func $sum_1126 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $sum_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $sum_1126) - ) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 417 -) +((functions ()) + (imports + (((mimp_id ((name sum))) (mimp_mod tlists.gr) (mimp_name sum) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name sum))) (mimp_mod tlists.gr) (mimp_name sum) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MReturnCallKnown (func sum_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind sum_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/includes.beda767e.0.snapshot b/compiler/test/__snapshots__/includes.beda767e.0.snapshot index f7c605b7f..01fe68ee3 100644 --- a/compiler/test/__snapshots__/includes.beda767e.0.snapshot +++ b/compiler/test/__snapshots__/includes.beda767e.0.snapshot @@ -1,36 +1,18 @@ includes › include_relative_path1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$../test-libs/provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1122 (mut i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (global.get $x_1122) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 446 -) +((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod ../test-libs/provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind x_1122 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/includes.c0c0d5ca.0.snapshot b/compiler/test/__snapshots__/includes.c0c0d5ca.0.snapshot index 92f4e5f89..cf7b1fc9b 100644 --- a/compiler/test/__snapshots__/includes.c0c0d5ca.0.snapshot +++ b/compiler/test/__snapshots__/includes.c0c0d5ca.0.snapshot @@ -1,101 +1,68 @@ includes › include_relative_path4 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$./bar/bar.gr\" \"GRAIN$EXPORT$bar\" (global $bar_1119 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$./bar/bar.gr\" \"bar\" (func $bar_1119 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1116 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.6 - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (call $bar_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $bar_1119) - ) - (i32.const 5) - ) - ) - (block $do_backpatches.4 - ) - ) - (return_call $print_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1116) - ) - (local.get $7) - (local.get $6) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 419 -) +((functions ()) + (imports + (((mimp_id ((name bar))) (mimp_mod ./bar/bar.gr) (mimp_name bar) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name bar))) (mimp_mod ./bar/bar.gr) (mimp_name bar) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func bar_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind bar_1119 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func print_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/includes.c62f45f8.0.snapshot b/compiler/test/__snapshots__/includes.c62f45f8.0.snapshot index 1c4348609..10d256711 100644 --- a/compiler/test/__snapshots__/includes.c62f45f8.0.snapshot +++ b/compiler/test/__snapshots__/includes.c62f45f8.0.snapshot @@ -1,114 +1,43 @@ includes › include_muliple_modules -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1136 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $x_1136) - ) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 470 -) +((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind x_1136 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/includes.cedde8e9.0.snapshot b/compiler/test/__snapshots__/includes.cedde8e9.0.snapshot index 706b117ef..b6e9a9667 100644 --- a/compiler/test/__snapshots__/includes.cedde8e9.0.snapshot +++ b/compiler/test/__snapshots__/includes.cedde8e9.0.snapshot @@ -1,108 +1,35 @@ includes › include_same_module_unify -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 417 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/includes.de6b420f.0.snapshot b/compiler/test/__snapshots__/includes.de6b420f.0.snapshot index 37b3b08a0..1c229012b 100644 --- a/compiler/test/__snapshots__/includes.de6b420f.0.snapshot +++ b/compiler/test/__snapshots__/includes.de6b420f.0.snapshot @@ -1,65 +1,19 @@ includes › annotation_across_import -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 417 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ())))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/includes.f2bf866b.0.snapshot b/compiler/test/__snapshots__/includes.f2bf866b.0.snapshot index d10c38b44..1baab32c2 100644 --- a/compiler/test/__snapshots__/includes.f2bf866b.0.snapshot +++ b/compiler/test/__snapshots__/includes.f2bf866b.0.snapshot @@ -1,108 +1,35 @@ includes › include_all_constructor -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 417 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/includes.f4ba5583.0.snapshot b/compiler/test/__snapshots__/includes.f4ba5583.0.snapshot index 9e852f723..7cb3561b0 100644 --- a/compiler/test/__snapshots__/includes.f4ba5583.0.snapshot +++ b/compiler/test/__snapshots__/includes.f4ba5583.0.snapshot @@ -1,50 +1,36 @@ includes › include_module2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1123 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$y\" (global $y_1122 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"y\" (func $y_1122 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $y_1122 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $y_1122) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $x_1123) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func y_1122) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind y_1122 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind x_1123 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/let_mut.00e05fe2.0.snapshot b/compiler/test/__snapshots__/let_mut.00e05fe2.0.snapshot index 8e8647a68..f47c5a555 100644 --- a/compiler/test/__snapshots__/let_mut.00e05fe2.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.00e05fe2.0.snapshot @@ -1,85 +1,52 @@ let mut › let-mut_division1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$/\" (global $/_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"/\" (func $/_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 153) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $/_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $/_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 76))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func /_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind /_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/let_mut.1176df90.0.snapshot b/compiler/test/__snapshots__/let_mut.1176df90.0.snapshot index 21f3c3cda..24fca54d0 100644 --- a/compiler/test/__snapshots__/let_mut.1176df90.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.1176df90.0.snapshot @@ -1,93 +1,59 @@ let mut › let-mut_multiplication2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $*_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.6 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func *_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/let_mut.3307d5a7.0.snapshot b/compiler/test/__snapshots__/let_mut.3307d5a7.0.snapshot index d61ed4bbf..496ce14bf 100644 --- a/compiler/test/__snapshots__/let_mut.3307d5a7.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.3307d5a7.0.snapshot @@ -1,72 +1,21 @@ let mut › let-mut3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.4 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/let_mut.43f6980c.0.snapshot b/compiler/test/__snapshots__/let_mut.43f6980c.0.snapshot index 087c385be..cdc4c9c8e 100644 --- a/compiler/test/__snapshots__/let_mut.43f6980c.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.43f6980c.0.snapshot @@ -1,93 +1,59 @@ let mut › let-mut_division3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$/\" (global $/_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"/\" (func $/_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 153) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $/_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $/_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.6 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 76))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func /_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind /_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/let_mut.48249b50.0.snapshot b/compiler/test/__snapshots__/let_mut.48249b50.0.snapshot index 41325073a..89b56701d 100644 --- a/compiler/test/__snapshots__/let_mut.48249b50.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.48249b50.0.snapshot @@ -1,93 +1,59 @@ let mut › let-mut5 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $-_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.6 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func -_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/let_mut.4c3f3b2b.0.snapshot b/compiler/test/__snapshots__/let_mut.4c3f3b2b.0.snapshot index cd74f4d8e..e3c5785e4 100644 --- a/compiler/test/__snapshots__/let_mut.4c3f3b2b.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.4c3f3b2b.0.snapshot @@ -1,100 +1,33 @@ let mut › let-mut2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.7 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 13) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (global.set $b_1113 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=12 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/let_mut.4c75261e.0.snapshot b/compiler/test/__snapshots__/let_mut.4c75261e.0.snapshot index 9e8b4d5e1..362e5f3c9 100644 --- a/compiler/test/__snapshots__/let_mut.4c75261e.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.4c75261e.0.snapshot @@ -1,85 +1,52 @@ let mut › let-mut_multiplication1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $*_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func *_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/let_mut.634331f0.0.snapshot b/compiler/test/__snapshots__/let_mut.634331f0.0.snapshot index b99c66a0f..a51731dd2 100644 --- a/compiler/test/__snapshots__/let_mut.634331f0.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.634331f0.0.snapshot @@ -1,93 +1,59 @@ let mut › let-mut_multiplication3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $*_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.6 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func *_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/let_mut.63c16374.0.snapshot b/compiler/test/__snapshots__/let_mut.63c16374.0.snapshot index b4cc9a238..a33750d1f 100644 --- a/compiler/test/__snapshots__/let_mut.63c16374.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.63c16374.0.snapshot @@ -1,72 +1,29 @@ let mut › let-mut4 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.5 - (local.set $6 - (block $compile_set.3 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.const 7) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.4 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/let_mut.6796c72d.0.snapshot b/compiler/test/__snapshots__/let_mut.6796c72d.0.snapshot index 95ffb67ec..0e9ac9ae8 100644 --- a/compiler/test/__snapshots__/let_mut.6796c72d.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.6796c72d.0.snapshot @@ -1,85 +1,52 @@ let mut › let-mut_subtraction1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $-_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func -_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/let_mut.baaea1d3.0.snapshot b/compiler/test/__snapshots__/let_mut.baaea1d3.0.snapshot index ea552860f..e0d8711a8 100644 --- a/compiler/test/__snapshots__/let_mut.baaea1d3.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.baaea1d3.0.snapshot @@ -1,93 +1,59 @@ let mut › let-mut_subtraction2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $-_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.6 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func -_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/let_mut.cbbbaeb4.0.snapshot b/compiler/test/__snapshots__/let_mut.cbbbaeb4.0.snapshot index f77cfefd0..75b69a3a9 100644 --- a/compiler/test/__snapshots__/let_mut.cbbbaeb4.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.cbbbaeb4.0.snapshot @@ -1,93 +1,59 @@ let mut › let-mut_addition2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.6 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/let_mut.d2de286b.0.snapshot b/compiler/test/__snapshots__/let_mut.d2de286b.0.snapshot index 97735a2e4..33f8361b6 100644 --- a/compiler/test/__snapshots__/let_mut.d2de286b.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.d2de286b.0.snapshot @@ -1,85 +1,52 @@ let mut › let-mut_addition1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/let_mut.e90db621.0.snapshot b/compiler/test/__snapshots__/let_mut.e90db621.0.snapshot index 27bf2fafc..40d036fe0 100644 --- a/compiler/test/__snapshots__/let_mut.e90db621.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.e90db621.0.snapshot @@ -1,93 +1,59 @@ let mut › let-mut_subtraction3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $-_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.6 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func -_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/let_mut.f8f208a2.0.snapshot b/compiler/test/__snapshots__/let_mut.f8f208a2.0.snapshot index 42357fccf..f0ccc153c 100644 --- a/compiler/test/__snapshots__/let_mut.f8f208a2.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.f8f208a2.0.snapshot @@ -1,93 +1,59 @@ let mut › let-mut_addition3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.6 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/let_mut.f9e32f30.0.snapshot b/compiler/test/__snapshots__/let_mut.f9e32f30.0.snapshot index a57b08f22..d6ca47808 100644 --- a/compiler/test/__snapshots__/let_mut.f9e32f30.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.f9e32f30.0.snapshot @@ -1,93 +1,59 @@ let mut › let-mut_division2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$/\" (global $/_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"/\" (func $/_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 153) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $/_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $/_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.6 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 76))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func /_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind /_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/let_mut.fcc9c65d.0.snapshot b/compiler/test/__snapshots__/let_mut.fcc9c65d.0.snapshot index d6c372eeb..300b42237 100644 --- a/compiler/test/__snapshots__/let_mut.fcc9c65d.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.fcc9c65d.0.snapshot @@ -1,43 +1,20 @@ let mut › let-mut1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.3 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/lists.884ce894.0.snapshot b/compiler/test/__snapshots__/lists.884ce894.0.snapshot index 52e737b7e..2c5ad2dba 100644 --- a/compiler/test/__snapshots__/lists.884ce894.0.snapshot +++ b/compiler/test/__snapshots__/lists.884ce894.0.snapshot @@ -1,237 +1,83 @@ lists › list_spread -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.14 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $9) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/lists.d9fd46fb.0.snapshot b/compiler/test/__snapshots__/lists.d9fd46fb.0.snapshot index 85cd72277..6fafb863c 100644 --- a/compiler/test/__snapshots__/lists.d9fd46fb.0.snapshot +++ b/compiler/test/__snapshots__/lists.d9fd46fb.0.snapshot @@ -1,194 +1,67 @@ lists › list1_trailing_space -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.11 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/lists.e5378351.0.snapshot b/compiler/test/__snapshots__/lists.e5378351.0.snapshot index 5a371e9f3..74f6f6493 100644 --- a/compiler/test/__snapshots__/lists.e5378351.0.snapshot +++ b/compiler/test/__snapshots__/lists.e5378351.0.snapshot @@ -1,194 +1,67 @@ lists › list1_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.11 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/loops.0a25def1.0.snapshot b/compiler/test/__snapshots__/loops.0a25def1.0.snapshot index 38725f282..6c8b50b94 100644 --- a/compiler/test/__snapshots__/loops.0a25def1.0.snapshot +++ b/compiler/test/__snapshots__/loops.0a25def1.0.snapshot @@ -1,261 +1,156 @@ loops › loop2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>\" (global $>_1128 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1125 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1120 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">\" (func $>_1128 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1125 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1120 (param i32 i32 i32) (result i32))) - (global $count_1114 (mut i32) (i32.const 0)) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (block $compile_block.29 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 25) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (global.set $count_1114 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 1) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.28 - (local.set $11 - (block $MFor.7 (result i32) - (drop - (loop $MFor_loop.8 - (block $MFor_loop_body.26 - (drop - (br_if $MFor.7 - (i32.const 1879048190) - (i32.eqz - (i32.shr_u - (block $compile_block.12 (result i32) - (block $compile_store.11 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (call $>_1128 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>_1128) - ) - (local.get $10) - (i32.const 1) - ) - ) - (i32.const 31) - ) - ) - ) - ) - (block $MFor_continue.9 - (drop - (block $compile_block.25 (result i32) - (block $compile_store.14 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $7 - (call $-_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1120) - ) - (local.get $6) - (i32.const 3) - ) - ) - (block $do_backpatches.15 - ) - ) - (block $compile_store.19 - (local.set $12 - (block $MTupleSet.17 (result i32) - (i32.store offset=8 - (global.get $b_1113) - (tuple.extract 0 - (tuple.make - (local.get $7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.18 - ) - ) - (block $compile_store.21 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $count_1114) - ) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.23 - (local.set $9 - (call $+_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1125) - ) - (local.get $8) - (i32.const 3) - ) - ) - (block $do_backpatches.22 - ) - ) - (block $MTupleSet.24 (result i32) - (i32.store offset=8 - (global.get $count_1114) - (tuple.extract 0 - (tuple.make - (local.get $9) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $count_1114) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (br $MFor_loop.8) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.27 - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $count_1114) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 12))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind count_1114 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MFor + ((((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCallKnown (func >_1128) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind >_1128 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + () + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func -_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind -_1120 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc + (MImmBinding (MGlobalBind count_1114 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MCallKnown (func +_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1125 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc + (MImmBinding (MGlobalBind count_1114 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind count_1114 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 5) (stack_size_i32 2) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name count)) true Managed ()) (((name b)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/loops.0fafc5f0.0.snapshot b/compiler/test/__snapshots__/loops.0fafc5f0.0.snapshot index 19a0a186d..296d4a142 100644 --- a/compiler/test/__snapshots__/loops.0fafc5f0.0.snapshot +++ b/compiler/test/__snapshots__/loops.0fafc5f0.0.snapshot @@ -1,186 +1,139 @@ loops › loop5 -(module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>=\" (global $>=_1126 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1124 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1120 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">=\" (func $>=_1126 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1124 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1120 (param i32 i32 i32) (result i32))) - (global $count_1114 (mut i32) (i32.const 0)) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.21 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 25) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (global.set $count_1114 - (i32.const 1) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.20 - (local.set $8 - (block $MFor.5 (result i32) - (drop - (loop $MFor_loop.6 - (block $MFor_loop_body.18 - (drop - (br_if $MFor.5 - (i32.const 1879048190) - (i32.eqz - (i32.shr_u - (block $compile_block.13 (result i32) - (block $compile_store.9 - (local.set $7 - (call $-_1124 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1124) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $compile_set.10 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.11 - ) - ) - (call $>=_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>=_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 1) - ) - ) - (i32.const 31) - ) - ) - ) - ) - (block $MFor_continue.7 - (drop - (block $compile_block.17 (result i32) - (block $compile_store.15 - (local.set $6 - (call $+_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1120) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $count_1114) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_set.16 (result i32) - (global.set $count_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $count_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (br $MFor_loop.6) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.19 - ) - ) - (global.get $count_1114) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name >=))) (mimp_mod pervasives.gr) (mimp_name >=) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >=))) (mimp_mod pervasives.gr) (mimp_name >=) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 12))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind count_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MFor + ((((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func -_1124) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind -_1124 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MCallKnown (func >=_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind >=_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + () + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func +_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1120 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind count_1114 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind count_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind count_1114 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 2) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name count)) true Managed ()) (((name b)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/loops.c2b7bfc6.0.snapshot b/compiler/test/__snapshots__/loops.c2b7bfc6.0.snapshot index e5fe78617..217661d97 100644 --- a/compiler/test/__snapshots__/loops.c2b7bfc6.0.snapshot +++ b/compiler/test/__snapshots__/loops.c2b7bfc6.0.snapshot @@ -1,134 +1,91 @@ loops › loop3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>\" (global $>_1120 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1118 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">\" (func $>_1120 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1118 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.14 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 7) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.13 - (local.set $7 - (block $MFor.3 (result i32) - (drop - (loop $MFor_loop.4 - (block $MFor_loop_body.11 - (drop - (br_if $MFor.3 - (i32.const 1879048190) - (i32.eqz - (i32.shr_u - (block $compile_block.6 (result i32) - (call $>_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>_1120) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 1) - ) - ) - (i32.const 31) - ) - ) - ) - ) - (block $MFor_continue.5 - (drop - (block $compile_block.10 (result i32) - (block $compile_store.8 - (local.set $6 - (call $-_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1118) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_set.9 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (br $MFor_loop.4) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.12 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MFor + ((((instr_desc + (MCallKnown (func >_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind >_1120 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + () + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func -_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind -_1118 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name b)) true Managed ()))) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/loops.f1c03b79.0.snapshot b/compiler/test/__snapshots__/loops.f1c03b79.0.snapshot index b2f373ac3..3850ba0c8 100644 --- a/compiler/test/__snapshots__/loops.f1c03b79.0.snapshot +++ b/compiler/test/__snapshots__/loops.f1c03b79.0.snapshot @@ -1,186 +1,138 @@ loops › loop4 -(module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>\" (global $>_1126 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1124 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1120 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">\" (func $>_1126 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1124 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1120 (param i32 i32 i32) (result i32))) - (global $count_1114 (mut i32) (i32.const 0)) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.21 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 25) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (global.set $count_1114 - (i32.const 1) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.20 - (local.set $8 - (block $MFor.5 (result i32) - (drop - (loop $MFor_loop.6 - (block $MFor_loop_body.18 - (drop - (br_if $MFor.5 - (i32.const 1879048190) - (i32.eqz - (i32.shr_u - (block $compile_block.8 (result i32) - (call $>_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 1) - ) - ) - (i32.const 31) - ) - ) - ) - ) - (block $MFor_continue.7 - (drop - (block $compile_block.17 (result i32) - (block $compile_store.10 - (local.set $6 - (call $-_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1120) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.13 - (local.set $9 - (block $compile_set.11 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $7 - (call $+_1124 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1124) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $count_1114) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_set.16 (result i32) - (global.set $count_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $count_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (br $MFor_loop.6) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.19 - ) - ) - (global.get $count_1114) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 12))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind count_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MFor + ((((instr_desc + (MCallKnown (func >_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind >_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + () + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func -_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind -_1120 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func +_1124) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1124 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind count_1114 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind count_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind count_1114 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 2) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name count)) true Managed ()) (((name b)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/modules.52d25a2f.0.snapshot b/compiler/test/__snapshots__/modules.52d25a2f.0.snapshot index 52fc1828b..93d336be0 100644 --- a/compiler/test/__snapshots__/modules.52d25a2f.0.snapshot +++ b/compiler/test/__snapshots__/modules.52d25a2f.0.snapshot @@ -1,35 +1,13 @@ modules › smallest_submodule -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 1879048190) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/optimizations.d72b00c6.0.snapshot b/compiler/test/__snapshots__/optimizations.d72b00c6.0.snapshot index b3858414a..43949e05f 100644 --- a/compiler/test/__snapshots__/optimizations.d72b00c6.0.snapshot +++ b/compiler/test/__snapshots__/optimizations.d72b00c6.0.snapshot @@ -1,86 +1,49 @@ optimizations › trs1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $f1_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $f1_1113 (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i64) - (local $7 f32) - (local $8 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (local.get $1) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $2) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.5 - (block $compile_store.4 - (global.set $f1_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (return_call $f1_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $f1_1113) - ) - (i32.const 3) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions + (((id ((stamp 1113) (name f1))) (name (f1)) + (args (Managed Managed Managed)) (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MArgBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind f1_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func f1_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind f1_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((stamp 1113) (name f1)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1125) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/optimizations.ff6d5bfb.0.snapshot b/compiler/test/__snapshots__/optimizations.ff6d5bfb.0.snapshot index 4181471b7..f7d187faf 100644 --- a/compiler/test/__snapshots__/optimizations.ff6d5bfb.0.snapshot +++ b/compiler/test/__snapshots__/optimizations.ff6d5bfb.0.snapshot @@ -1,180 +1,84 @@ optimizations › test_dead_branch_elimination_5 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1126 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1126 (param i32 i32 i32) (result i32))) - (global $y_1114 (mut i32) (i32.const 0)) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.17 - (block $compile_store.3 - (global.set $x_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (global.set $y_1114 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $MTupleSet.7 (result i32) - (i32.store offset=8 - (global.get $x_1113) - (tuple.extract 0 - (tuple.make - (i32.const 7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $x_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $MTupleSet.10 (result i32) - (i32.store offset=8 - (global.get $y_1114) - (tuple.extract 0 - (tuple.make - (i32.const 9) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $y_1114) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $x_1113) - ) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $7 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $y_1114) - ) - ) - ) - (block $do_backpatches.15 - ) - ) - (return_call $+_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1126) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind y_1114 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))) + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((immediate_desc (MImmBinding (MGlobalBind y_1114 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind y_1114 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MReturnCallKnown (func +_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 2) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((name y)) true Managed ()) (((name x)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.0539d13e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0539d13e.0.snapshot index f768a3ae7..a9604da3b 100644 --- a/compiler/test/__snapshots__/pattern_matching.0539d13e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0539d13e.0.snapshot @@ -1,230 +1,117 @@ pattern matching › record_match_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1125 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1125 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (block $compile_block.19 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (i32.const 13) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $cleanup.12 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.13 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.14 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.16_outer (result i32) - (block $switch.16_branch_0 (result i32) - (drop - (block $switch.16_branch_1 (result i32) - (drop - (block $switch.16_default (result i32) - (br_table $switch.16_branch_1 $switch.16_default $switch.16_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.16_outer - (block $compile_block.18 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.16_outer - (block $compile_block.17 - (return_call $+_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1125) - ) - (local.get $7) - (local.get $8) - ) - ) - ) - ) - ) - (block $cleanup.15 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((functions ()) + (imports + (((mimp_id ((stamp 1125) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1125) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))) + ((baz) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MRecordOp (MRecordGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MReturnCallKnown (func +_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1125 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 5) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1126) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot index b0da5a7ec..56fa3a899 100644 --- a/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot @@ -1,351 +1,164 @@ pattern matching › adt_match_deep -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (block $compile_block.36 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $12 - (i32.load offset=12 - (local.get $8) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $13 - (i32.or - (i32.shl - (i32.eq - (local.get $12) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.29 - (local.set $14 - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.22 (result i32) - (block $compile_store.17 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $8) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $10) - ) - ) - ) - (block $do_backpatches.18 - ) - ) - (block $cleanup.20 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - (drop - (block $compile_set.21 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.27 (result i32) - (block $compile_store.24 - (local.set $15 - (i32.or - (i32.shl - (i32.eq - (local.get $12) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.23 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $15) - (i32.const 31) - ) - (block $compile_block.25 (result i32) - (i32.const 1) - ) - (block $compile_block.26 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.28 - ) - ) - (block $cleanup.30 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.32_outer (result i32) - (block $switch.32_branch_0 (result i32) - (drop - (block $switch.32_branch_1 (result i32) - (drop - (block $switch.32_branch_2 (result i32) - (drop - (block $switch.32_default (result i32) - (br_table $switch.32_branch_1 $switch.32_branch_2 $switch.32_default $switch.32_default - (i32.const 0) - (i32.shr_s - (local.get $14) - (i32.const 1) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.35 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.34 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.33 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (block $cleanup.31 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 486 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 6) (stack_size_i32 4) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1130) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot index 4c38937f6..c0e20a930 100644 --- a/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot @@ -1,1260 +1,776 @@ pattern matching › tuple_match_deep4 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1153 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1153 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (local $34 i32) - (local $35 i32) - (local $36 i32) - (local $37 i32) - (local $38 i32) - (local $39 i32) - (local $40 i32) - (local $41 i32) - (block $compile_block.117 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_tuple.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.18 - ) - ) - (block $compile_store.21 - (local.set $14 - (i32.const 0) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.23 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.22 - ) - ) - (block $compile_store.25 - (local.set $16 - (i32.const 0) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $17 - (i32.const 0) - ) - (block $do_backpatches.26 - ) - ) - (block $compile_store.29 - (local.set $18 - (i32.const 0) - ) - (block $do_backpatches.28 - ) - ) - (block $compile_store.31 - (local.set $19 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $8) - ) - ) - ) - (block $do_backpatches.30 - ) - ) - (block $compile_store.33 - (local.set $20 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $8) - ) - ) - ) - (block $do_backpatches.32 - ) - ) - (block $cleanup.34 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - (block $compile_store.36 - (local.set $30 - (i32.load offset=12 - (local.get $20) - ) - ) - (block $do_backpatches.35 - ) - ) - (block $compile_store.38 - (local.set $31 - (i32.or - (i32.shl - (i32.eq - (local.get $30) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.37 - ) - ) - (block $compile_store.98 - (local.set $32 - (if (result i32) - (i32.shr_u - (local.get $31) - (i32.const 31) - ) - (block $compile_block.90 (result i32) - (block $compile_store.40 - (local.set $21 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $20) - ) - ) - ) - (block $do_backpatches.39 - ) - ) - (block $compile_store.42 - (local.set $22 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $20) - ) - ) - ) - (block $do_backpatches.41 - ) - ) - (block $compile_store.44 - (local.set $34 - (i32.load offset=12 - (local.get $22) - ) - ) - (block $do_backpatches.43 - ) - ) - (block $compile_store.46 - (local.set $35 - (i32.or - (i32.shl - (i32.eq - (local.get $34) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.45 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $35) - (i32.const 31) - ) - (block $compile_block.82 (result i32) - (block $compile_store.49 - (local.set $23 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $22) - ) - ) - ) - (block $do_backpatches.48 - ) - ) - (block $compile_store.51 - (local.set $24 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $22) - ) - ) - ) - (block $do_backpatches.50 - ) - ) - (block $compile_store.53 - (local.set $37 - (i32.load offset=12 - (local.get $24) - ) - ) - (block $do_backpatches.52 - ) - ) - (block $compile_store.55 - (local.set $38 - (i32.or - (i32.shl - (i32.eq - (local.get $37) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.54 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $38) - (i32.const 31) - ) - (block $compile_block.73 (result i32) - (block $compile_store.58 - (local.set $25 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $24) - ) - ) - ) - (block $do_backpatches.57 - ) - ) - (block $compile_store.60 - (local.set $26 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $24) - ) - ) - ) - (block $do_backpatches.59 - ) - ) - (block $compile_store.62 - (local.set $40 - (i32.load offset=12 - (local.get $26) - ) - ) - (block $do_backpatches.61 - ) - ) - (block $cleanup.63 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $26) - ) - ) - ) - (block $compile_store.65 - (local.set $41 - (i32.or - (i32.shl - (i32.eq - (local.get $40) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.64 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $41) - (i32.const 31) - ) - (block $compile_block.71 (result i32) - (drop - (block $compile_set.67 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $19) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.68 (result i32) - (local.set $16 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $21) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.69 (result i32) - (local.set $17 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $23) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.70 (result i32) - (local.set $18 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $25) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.72 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.66 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $25) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.81 (result i32) - (block $compile_store.75 - (local.set $39 - (i32.or - (i32.shl - (i32.eq - (local.get $37) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.74 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $39) - (i32.const 31) - ) - (block $compile_block.79 (result i32) - (drop - (block $compile_set.76 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $19) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.77 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $21) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.78 (result i32) - (local.set $14 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $23) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.80 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.56 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $23) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $24) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.89 (result i32) - (block $compile_store.84 - (local.set $36 - (i32.or - (i32.shl - (i32.eq - (local.get $34) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.83 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $36) - (i32.const 31) - ) - (block $compile_block.87 (result i32) - (drop - (block $compile_set.85 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $19) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.86 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $21) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.88 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.47 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $22) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.96 (result i32) - (block $compile_store.92 - (local.set $33 - (i32.or - (i32.shl - (i32.eq - (local.get $30) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.91 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $33) - (i32.const 31) - ) - (block $compile_block.94 (result i32) - (drop - (block $compile_set.93 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $19) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.95 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.97 - ) - ) - (block $cleanup.99 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.101_outer (result i32) - (block $switch.101_branch_0 (result i32) - (drop - (block $switch.101_branch_1 (result i32) - (drop - (block $switch.101_branch_2 (result i32) - (drop - (block $switch.101_branch_3 (result i32) - (drop - (block $switch.101_branch_4 (result i32) - (drop - (block $switch.101_branch_5 (result i32) - (drop - (block $switch.101_default (result i32) - (br_table $switch.101_branch_1 $switch.101_branch_2 $switch.101_branch_3 $switch.101_branch_4 $switch.101_branch_5 $switch.101_default $switch.101_default - (i32.const 0) - (i32.shr_s - (local.get $32) - (i32.const 1) - ) - ) - ) - ) - (br $switch.101_outer - (block $compile_block.116 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.101_outer - (block $compile_block.115 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.101_outer - (block $compile_block.114 - (block $compile_store.110 - (local.set $28 - (call $+_1153 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - ) - ) - (block $do_backpatches.109 - ) - ) - (block $compile_store.112 - (local.set $29 - (call $+_1153 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) - ) - (local.get $28) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - ) - ) - (block $do_backpatches.111 - ) - ) - (block $cleanup.113 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - ) - (return_call $+_1153 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) - ) - (local.get $29) - (local.get $18) - ) - ) - ) - ) - ) - (br $switch.101_outer - (block $compile_block.108 - (block $compile_store.106 - (local.set $27 - (call $+_1153 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - ) - ) - (block $do_backpatches.105 - ) - ) - (block $cleanup.107 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - ) - (return_call $+_1153 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) - ) - (local.get $27) - (local.get $14) - ) - ) - ) - ) - ) - (br $switch.101_outer - (block $compile_block.104 - (block $cleanup.103 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - ) - (return_call $+_1153 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) - ) - (local.get $10) - (local.get $11) - ) - ) - ) - ) - ) - (br $switch.101_outer - (block $compile_block.102 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - ) - ) - ) - ) - (block $cleanup.100 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1153) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1153) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 15 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 16 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 17 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 18 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 19 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 20 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 13 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 15 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 17 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 12 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 19 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 13 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 15 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 17 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1153) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1153 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (2 + (((instr_desc + (MStore + (((MLocalBind 21 Managed) + ((instr_desc + (MCallKnown (func +_1153) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1153 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1153) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1153 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 22 Managed) + ((instr_desc + (MCallKnown (func +_1153) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1153 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 23 Managed) + ((instr_desc + (MCallKnown (func +_1153) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1153 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 22 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1153) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1153 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 23 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 24) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1158) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot index 19bd2aa07..3c1e48906 100644 --- a/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot @@ -1,981 +1,591 @@ pattern matching › adt_match_4 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1149 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1149 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (local $34 i32) - (block $compile_block.98 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 13) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.15 - ) - ) - (block $compile_store.18 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.19 - ) - ) - (block $compile_store.22 - (local.set $14 - (i32.const 0) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.24 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.23 - ) - ) - (block $compile_store.26 - (local.set $23 - (i32.load offset=12 - (local.get $9) - ) - ) - (block $do_backpatches.25 - ) - ) - (block $compile_store.28 - (local.set $24 - (i32.or - (i32.shl - (i32.eq - (local.get $23) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $compile_store.84 - (local.set $25 - (if (result i32) - (i32.shr_u - (local.get $24) - (i32.const 31) - ) - (block $compile_block.77 (result i32) - (block $compile_store.30 - (local.set $16 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $9) - ) - ) - ) - (block $do_backpatches.29 - ) - ) - (block $compile_store.32 - (local.set $17 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $9) - ) - ) - ) - (block $do_backpatches.31 - ) - ) - (block $compile_store.34 - (local.set $27 - (i32.load offset=12 - (local.get $17) - ) - ) - (block $do_backpatches.33 - ) - ) - (block $compile_store.36 - (local.set $28 - (i32.or - (i32.shl - (i32.eq - (local.get $27) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.35 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $28) - (i32.const 31) - ) - (block $compile_block.70 (result i32) - (block $compile_store.39 - (local.set $18 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $17) - ) - ) - ) - (block $do_backpatches.38 - ) - ) - (block $compile_store.41 - (local.set $19 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $17) - ) - ) - ) - (block $do_backpatches.40 - ) - ) - (block $compile_store.43 - (local.set $30 - (i32.load offset=12 - (local.get $19) - ) - ) - (block $do_backpatches.42 - ) - ) - (block $compile_store.45 - (local.set $31 - (i32.or - (i32.shl - (i32.eq - (local.get $30) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.44 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $31) - (i32.const 31) - ) - (block $compile_block.62 (result i32) - (block $compile_store.48 - (local.set $20 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $19) - ) - ) - ) - (block $do_backpatches.47 - ) - ) - (block $compile_store.50 - (local.set $21 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $19) - ) - ) - ) - (block $do_backpatches.49 - ) - ) - (block $compile_store.52 - (local.set $33 - (i32.load offset=12 - (local.get $21) - ) - ) - (block $do_backpatches.51 - ) - ) - (block $cleanup.53 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - ) - (block $compile_store.55 - (local.set $34 - (i32.or - (i32.shl - (i32.eq - (local.get $33) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.54 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $34) - (i32.const 31) - ) - (block $compile_block.60 (result i32) - (drop - (block $compile_set.57 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.58 (result i32) - (local.set $14 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.59 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.61 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.56 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.69 (result i32) - (block $compile_store.64 - (local.set $32 - (i32.or - (i32.shl - (i32.eq - (local.get $30) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.63 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $32) - (i32.const 31) - ) - (block $compile_block.67 (result i32) - (drop - (block $compile_set.65 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.66 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.68 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.46 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.76 (result i32) - (block $compile_store.72 - (local.set $29 - (i32.or - (i32.shl - (i32.eq - (local.get $27) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.71 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $29) - (i32.const 31) - ) - (block $compile_block.74 (result i32) - (drop - (block $compile_set.73 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.75 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.37 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.82 (result i32) - (block $compile_store.79 - (local.set $26 - (i32.or - (i32.shl - (i32.eq - (local.get $23) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.78 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $26) - (i32.const 31) - ) - (block $compile_block.80 (result i32) - (i32.const 1) - ) - (block $compile_block.81 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.83 - ) - ) - (block $cleanup.85 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.87_outer (result i32) - (block $switch.87_branch_0 (result i32) - (drop - (block $switch.87_branch_1 (result i32) - (drop - (block $switch.87_branch_2 (result i32) - (drop - (block $switch.87_branch_3 (result i32) - (drop - (block $switch.87_branch_4 (result i32) - (drop - (block $switch.87_branch_5 (result i32) - (drop - (block $switch.87_default (result i32) - (br_table $switch.87_branch_1 $switch.87_branch_2 $switch.87_branch_3 $switch.87_branch_4 $switch.87_branch_5 $switch.87_default $switch.87_default - (i32.const 0) - (i32.shr_s - (local.get $25) - (i32.const 1) - ) - ) - ) - ) - (br $switch.87_outer - (block $compile_block.97 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.87_outer - (block $compile_block.96 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.87_outer - (block $compile_block.95 - (block $compile_store.93 - (local.set $22 - (call $+_1149 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - ) - ) - (block $do_backpatches.92 - ) - ) - (block $cleanup.94 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - (return_call $+_1149 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) - ) - (local.get $22) - (local.get $15) - ) - ) - ) - ) - ) - (br $switch.87_outer - (block $compile_block.91 - (block $cleanup.90 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - (return_call $+_1149 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) - ) - (local.get $11) - (local.get $12) - ) - ) - ) - ) - ) - (br $switch.87_outer - (block $compile_block.89 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - ) - ) - ) - (br $switch.87_outer - (block $compile_block.88 (result i32) - (i32.const 1) - ) - ) - ) - ) - (block $cleanup.86 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1149) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1149) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 15 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 10 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 12 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 14 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 10 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 12 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1149) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1149 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 16 Managed) + ((instr_desc + (MCallKnown (func +_1149) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1149 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1149) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1149 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 17) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1152) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.0fa61137.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0fa61137.0.snapshot index 5ca2c3fa1..c347dfa26 100644 --- a/compiler/test/__snapshots__/pattern_matching.0fa61137.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0fa61137.0.snapshot @@ -1,242 +1,163 @@ pattern matching › low_level_constant_match_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1116 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (block $compile_block.28 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (select - (i32.const -2) - (i32.const 2147483646) - (i64.eq - (i64.const 1) - (i64.const 0) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.17 - (local.set $8 - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.6 (result i32) - (i32.const 1) - ) - (block $compile_block.15 (result i32) - (block $compile_store.8 - (local.set $9 - (select - (i32.const -2) - (i32.const 2147483646) - (i64.eq - (i64.const 1) - (i64.const 1) - ) - ) - ) - (block $do_backpatches.7 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $9) - (i32.const 31) - ) - (block $compile_block.9 (result i32) - (i32.const 3) - ) - (block $compile_block.14 (result i32) - (block $compile_store.11 - (local.set $10 - (select - (i32.const -2) - (i32.const 2147483646) - (i64.eq - (i64.const 1) - (i64.const 2) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $10) - (i32.const 31) - ) - (block $compile_block.12 (result i32) - (i32.const 5) - ) - (block $compile_block.13 (result i32) - (i32.const 7) - ) - ) - ) - ) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.25 - (local.set $11 - (block $switch.18_outer (result i32) - (block $switch.18_branch_0 (result i32) - (drop - (block $switch.18_branch_1 (result i32) - (drop - (block $switch.18_branch_2 (result i32) - (drop - (block $switch.18_branch_3 (result i32) - (drop - (block $switch.18_branch_4 (result i32) - (drop - (block $switch.18_default (result i32) - (br_table $switch.18_branch_1 $switch.18_branch_2 $switch.18_branch_3 $switch.18_branch_4 $switch.18_default $switch.18_default - (i32.const 0) - (i32.shr_s - (local.get $8) - (i32.const 1) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.23 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.22 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.21 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.20 (result i32) - (i32.const -2) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.19 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $12 - (call $print_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1116) - ) - (local.get $11) - (local.get $6) - ) - ) - (block $do_backpatches.26 - ) - ) - (i32.const 1) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1116) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1116) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 + (WasmBinaryI64 (wasm_op Op_eq_int64) + (arg_types (Wasm_int64 Wasm_int64)) (ret_type Grain_bool)) + ((immediate_desc (MImmConst (MConstLiteral (MConstI64 1)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstI64 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 + (WasmBinaryI64 (wasm_op Op_eq_int64) + (arg_types (Wasm_int64 Wasm_int64)) + (ret_type Grain_bool)) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI64 1)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI64 1)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 + (WasmBinaryI64 (wasm_op Op_eq_int64) + (arg_types (Wasm_int64 Wasm_int64)) + (ret_type Grain_bool)) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI64 1)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI64 2)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (3 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func print_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmI32) Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 6) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1125) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.14dc7554.0.snapshot b/compiler/test/__snapshots__/pattern_matching.14dc7554.0.snapshot index ccb644d83..5fee537e1 100644 --- a/compiler/test/__snapshots__/pattern_matching.14dc7554.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.14dc7554.0.snapshot @@ -1,204 +1,78 @@ pattern matching › record_match_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.17 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $7) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $cleanup.11 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (drop - (block $compile_set.12 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.14_outer (result i32) - (block $switch.14_branch_0 (result i32) - (drop - (block $switch.14_branch_1 (result i32) - (drop - (block $switch.14_default (result i32) - (br_table $switch.14_branch_1 $switch.14_default $switch.14_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.14_outer - (block $compile_block.16 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.14_outer - (block $compile_block.15 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - ) - ) - ) - (block $cleanup.13 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MRecordOp (MRecordGet 1) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1124) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.16cd197e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.16cd197e.0.snapshot index e305b5036..b73348687 100644 --- a/compiler/test/__snapshots__/pattern_matching.16cd197e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.16cd197e.0.snapshot @@ -1,177 +1,65 @@ pattern matching › constant_match_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"GRAIN$EXPORT$equal\" (global $GRAIN$EXPORT$equal_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"equal\" (func $equal_0 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.18 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (local.get $6) - (local.get $7) - ) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.12 - (local.set $9 - (if (result i32) - (i32.shr_u - (local.get $8) - (i32.const 31) - ) - (block $compile_block.9 (result i32) - (i32.const 3) - ) - (block $compile_block.10 (result i32) - (i32.const 5) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $switch.13_outer (result i32) - (block $switch.13_branch_0 (result i32) - (drop - (block $switch.13_branch_1 (result i32) - (drop - (block $switch.13_branch_2 (result i32) - (drop - (block $switch.13_branch_3 (result i32) - (drop - (block $switch.13_default (result i32) - (br_table $switch.13_branch_1 $switch.13_branch_2 $switch.13_branch_3 $switch.13_default $switch.13_default - (i32.const 0) - (i32.shr_s - (local.get $9) - (i32.const 1) - ) - ) - ) - ) - (br $switch.13_outer - (block $compile_block.17 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.13_outer - (block $compile_block.16 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.13_outer - (block $compile_block.15 (result i32) - (i32.const -2) - ) - ) - ) - ) - (br $switch.13_outer - (block $compile_block.14 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + ((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32)))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 2) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1118) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.16eb3dbf.0.snapshot b/compiler/test/__snapshots__/pattern_matching.16eb3dbf.0.snapshot index 18b26529a..ecd1af735 100644 --- a/compiler/test/__snapshots__/pattern_matching.16eb3dbf.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.16eb3dbf.0.snapshot @@ -1,402 +1,217 @@ pattern matching › guarded_match_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1125 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1125 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (block $compile_block.35 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $6) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $cleanup.16 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.17 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.18 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.19 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.21 - (local.set $13 - (call $==_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1125) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.28 - (local.set $14 - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.25 (result i32) - (drop - (block $compile_set.22 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.23 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.24 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.26 (result i32) - (i32.const 3) - ) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $cleanup.29 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.31_outer (result i32) - (block $switch.31_branch_0 (result i32) - (drop - (block $switch.31_branch_1 (result i32) - (drop - (block $switch.31_branch_2 (result i32) - (drop - (block $switch.31_default (result i32) - (br_table $switch.31_branch_1 $switch.31_branch_2 $switch.31_default $switch.31_default - (i32.const 0) - (i32.shr_s - (local.get $14) - (i32.const 1) - ) - ) - ) - ) - (br $switch.31_outer - (block $compile_block.34 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.31_outer - (block $compile_block.33 (result i32) - (i32.const 199) - ) - ) - ) - ) - (br $switch.31_outer - (block $compile_block.32 (result i32) - (i32.const 85) - ) - ) - ) - ) - (block $cleanup.30 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1125) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1125) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1125 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 42))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 99))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 7) (stack_size_i32 2) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1130) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.25930935.0.snapshot b/compiler/test/__snapshots__/pattern_matching.25930935.0.snapshot index 49b0de757..7eb5ca69f 100644 --- a/compiler/test/__snapshots__/pattern_matching.25930935.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.25930935.0.snapshot @@ -1,242 +1,168 @@ pattern matching › low_level_constant_match_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1116 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (block $compile_block.28 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (select - (i32.const -2) - (i32.const 2147483646) - (f32.eq - (f32.const 1) - (f32.const 0) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.17 - (local.set $8 - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.6 (result i32) - (i32.const 1) - ) - (block $compile_block.15 (result i32) - (block $compile_store.8 - (local.set $9 - (select - (i32.const -2) - (i32.const 2147483646) - (f32.eq - (f32.const 1) - (f32.const 1) - ) - ) - ) - (block $do_backpatches.7 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $9) - (i32.const 31) - ) - (block $compile_block.9 (result i32) - (i32.const 3) - ) - (block $compile_block.14 (result i32) - (block $compile_store.11 - (local.set $10 - (select - (i32.const -2) - (i32.const 2147483646) - (f32.eq - (f32.const 1) - (f32.const 2) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $10) - (i32.const 31) - ) - (block $compile_block.12 (result i32) - (i32.const 5) - ) - (block $compile_block.13 (result i32) - (i32.const 7) - ) - ) - ) - ) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.25 - (local.set $11 - (block $switch.18_outer (result i32) - (block $switch.18_branch_0 (result i32) - (drop - (block $switch.18_branch_1 (result i32) - (drop - (block $switch.18_branch_2 (result i32) - (drop - (block $switch.18_branch_3 (result i32) - (drop - (block $switch.18_branch_4 (result i32) - (drop - (block $switch.18_default (result i32) - (br_table $switch.18_branch_1 $switch.18_branch_2 $switch.18_branch_3 $switch.18_branch_4 $switch.18_default $switch.18_default - (i32.const 0) - (i32.shr_s - (local.get $8) - (i32.const 1) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.23 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.22 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.21 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.20 (result i32) - (i32.const -2) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.19 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $12 - (call $print_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1116) - ) - (local.get $11) - (local.get $6) - ) - ) - (block $do_backpatches.26 - ) - ) - (i32.const 1) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1116) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1116) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 + (WasmBinaryF32 (wasm_op Op_eq_float32) + (arg_types (Wasm_float32 Wasm_float32)) (ret_type Grain_bool)) + ((immediate_desc + (MImmConst (MConstLiteral (MConstF32 4607182418800017408)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstF32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 + (WasmBinaryF32 (wasm_op Op_eq_float32) + (arg_types (Wasm_float32 Wasm_float32)) + (ret_type Grain_bool)) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstF32 4607182418800017408)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstF32 4607182418800017408)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 + (WasmBinaryF32 (wasm_op Op_eq_float32) + (arg_types (Wasm_float32 Wasm_float32)) + (ret_type Grain_bool)) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstF32 4607182418800017408)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstF32 4611686018427387904)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (3 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func print_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmI32) Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 6) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1125) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.3722b060.0.snapshot b/compiler/test/__snapshots__/pattern_matching.3722b060.0.snapshot index 685a2a874..f3b9ac582 100644 --- a/compiler/test/__snapshots__/pattern_matching.3722b060.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.3722b060.0.snapshot @@ -1,425 +1,236 @@ pattern matching › tuple_match_deep -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1131 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1131 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (block $compile_block.40 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (local.get $6) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $7) - ) - ) - ) - (block $do_backpatches.15 - ) - ) - (block $compile_store.18 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $7) - ) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $14 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - (block $do_backpatches.19 - ) - ) - (block $cleanup.21 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (block $compile_store.23 - (local.set $15 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $13) - ) - ) - ) - (block $do_backpatches.22 - ) - ) - (block $compile_store.25 - (local.set $16 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $13) - ) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $cleanup.26 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - (drop - (block $compile_set.27 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.28 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.29 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.30 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.32_outer (result i32) - (block $switch.32_branch_0 (result i32) - (drop - (block $switch.32_branch_1 (result i32) - (drop - (block $switch.32_default (result i32) - (br_table $switch.32_branch_1 $switch.32_default $switch.32_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.39 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.38 - (block $compile_store.34 - (local.set $17 - (call $+_1131 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1131) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - ) - (block $do_backpatches.33 - ) - ) - (block $compile_store.36 - (local.set $18 - (call $+_1131 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1131) - ) - (local.get $17) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - ) - ) - (block $do_backpatches.35 - ) - ) - (block $cleanup.37 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - (return_call $+_1131 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1131) - ) - (local.get $18) - (local.get $10) - ) - ) - ) - ) - ) - (block $cleanup.31 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1131) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1131) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MCallKnown (func +_1131) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1131 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MCallKnown (func +_1131) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1131 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1131) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1131 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 13) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1134) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.46f91987.0.snapshot b/compiler/test/__snapshots__/pattern_matching.46f91987.0.snapshot index 2ab39508f..1e7e2f241 100644 --- a/compiler/test/__snapshots__/pattern_matching.46f91987.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.46f91987.0.snapshot @@ -1,204 +1,78 @@ pattern matching › record_match_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.17 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $cleanup.11 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (drop - (block $compile_set.12 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.14_outer (result i32) - (block $switch.14_branch_0 (result i32) - (drop - (block $switch.14_branch_1 (result i32) - (drop - (block $switch.14_default (result i32) - (br_table $switch.14_branch_1 $switch.14_default $switch.14_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.14_outer - (block $compile_block.16 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.14_outer - (block $compile_block.15 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - ) - ) - ) - (block $cleanup.13 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1124) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.5b158103.0.snapshot b/compiler/test/__snapshots__/pattern_matching.5b158103.0.snapshot index 3731854f3..fdd9a7eac 100644 --- a/compiler/test/__snapshots__/pattern_matching.5b158103.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.5b158103.0.snapshot @@ -1,462 +1,226 @@ pattern matching › constant_match_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"GRAIN$EXPORT$equal\" (global $GRAIN$EXPORT$equal_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"equal\" (func $equal_0 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (block $compile_block.53 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (local.get $6) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2147483646) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $7) - ) - ) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $7) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $cleanup.13 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (block $compile_store.16 - (local.set $11 - (block $allocate_string.14 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7496034) - ) - (local.get $0) - ) - ) - (block $do_backpatches.15 - ) - ) - (block $compile_store.18 - (local.set $13 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (local.get $11) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.45 - (local.set $14 - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.27 (result i32) - (block $compile_store.20 - (local.set $18 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (i32.const 11) - ) - ) - (block $do_backpatches.19 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $18) - (i32.const 31) - ) - (block $compile_block.25 (result i32) - (block $compile_store.22 - (local.set $19 - (i32.or - (i32.shl - (i32.eq - (local.get $10) - (i32.const 2147483646) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.21 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $19) - (i32.const 31) - ) - (block $compile_block.23 (result i32) - (i32.const 1) - ) - (block $compile_block.24 (result i32) - (i32.const 7) - ) - ) - ) - (block $compile_block.26 (result i32) - (i32.const 7) - ) - ) - ) - (block $compile_block.43 (result i32) - (block $compile_store.30 - (local.set $12 - (block $allocate_string.28 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.29 - ) - ) - (block $compile_store.32 - (local.set $15 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (local.get $12) - ) - ) - (block $do_backpatches.31 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $15) - (i32.const 31) - ) - (block $compile_block.41 (result i32) - (block $compile_store.34 - (local.set $16 - (i32.or - (i32.shl - (i32.eq - (local.get $10) - (i32.const 2147483646) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.33 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $16) - (i32.const 31) - ) - (block $compile_block.35 (result i32) - (i32.const 5) - ) - (block $compile_block.40 (result i32) - (block $compile_store.37 - (local.set $17 - (i32.or - (i32.shl - (i32.eq - (local.get $10) - (i32.const -2) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.36 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $17) - (i32.const 31) - ) - (block $compile_block.38 (result i32) - (i32.const 3) - ) - (block $compile_block.39 (result i32) - (i32.const 7) - ) - ) - ) - ) - ) - (block $compile_block.42 (result i32) - (i32.const 7) - ) - ) - ) - ) - ) - (block $do_backpatches.44 - ) - ) - (block $cleanup.46 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - (block $switch.47_outer (result i32) - (block $switch.47_branch_0 (result i32) - (drop - (block $switch.47_branch_1 (result i32) - (drop - (block $switch.47_branch_2 (result i32) - (drop - (block $switch.47_branch_3 (result i32) - (drop - (block $switch.47_branch_4 (result i32) - (drop - (block $switch.47_default (result i32) - (br_table $switch.47_branch_1 $switch.47_branch_2 $switch.47_branch_3 $switch.47_branch_4 $switch.47_default $switch.47_default - (i32.const 0) - (i32.shr_s - (local.get $14) - (i32.const 1) - ) - ) - ) - ) - (br $switch.47_outer - (block $compile_block.52 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.47_outer - (block $compile_block.51 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.47_outer - (block $compile_block.50 (result i32) - (i32.const -2) - ) - ) - ) - ) - (br $switch.47_outer - (block $compile_block.49 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.47_outer - (block $compile_block.48 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) ((instr_desc (MAllocate (MString bar))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (3 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32)))))) + (main_body_stack_size + ((stack_size_ptr 7) (stack_size_i32 7) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1134) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.5b6ff2d3.0.snapshot b/compiler/test/__snapshots__/pattern_matching.5b6ff2d3.0.snapshot index 39d17adb6..a2c78a8a4 100644 --- a/compiler/test/__snapshots__/pattern_matching.5b6ff2d3.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.5b6ff2d3.0.snapshot @@ -1,481 +1,276 @@ pattern matching › alias_match_5 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"GRAIN$EXPORT$equal\" (global $GRAIN$EXPORT$equal_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"equal\" (func $equal_0 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (block $compile_block.47 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $10 - (i32.load offset=12 - (local.get $6) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $11 - (i32.or - (i32.shl - (i32.eq - (local.get $10) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.38 - (local.set $12 - (if (result i32) - (i32.shr_u - (local.get $11) - (i32.const 31) - ) - (block $compile_block.13 (result i32) - (drop - (block $compile_set.12 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.36 (result i32) - (block $compile_store.15 - (local.set $13 - (i32.or - (i32.shl - (i32.eq - (local.get $10) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.14 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.34 (result i32) - (block $compile_store.17 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $14 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (i32.const 7) - ) - ) - (block $do_backpatches.18 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $14) - (i32.const 31) - ) - (block $compile_block.22 (result i32) - (drop - (block $compile_set.21 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.33 (result i32) - (block $compile_store.24 - (local.set $15 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (i32.const 9) - ) - ) - (block $do_backpatches.23 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $15) - (i32.const 31) - ) - (block $compile_block.26 (result i32) - (drop - (block $compile_set.25 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.32 (result i32) - (block $compile_store.28 - (local.set $16 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (i32.const 11) - ) - ) - (block $do_backpatches.27 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $16) - (i32.const 31) - ) - (block $compile_block.30 (result i32) - (drop - (block $compile_set.29 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.31 (result i32) - (i32.const 5) - ) - ) - ) - ) - ) - ) - (block $cleanup.20 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.35 (result i32) - (i32.const 5) - ) - ) - ) - ) - ) - (block $do_backpatches.37 - ) - ) - (block $cleanup.39 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.41_outer (result i32) - (block $switch.41_branch_0 (result i32) - (drop - (block $switch.41_branch_1 (result i32) - (drop - (block $switch.41_branch_2 (result i32) - (drop - (block $switch.41_branch_3 (result i32) - (drop - (block $switch.41_default (result i32) - (br_table $switch.41_branch_1 $switch.41_branch_2 $switch.41_branch_3 $switch.41_default $switch.41_default - (i32.const 0) - (i32.shr_s - (local.get $12) - (i32.const 1) - ) - ) - ) - ) - (br $switch.41_outer - (block $compile_block.46 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.41_outer - (block $compile_block.45 (result i32) - (block $allocate_adt.44 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - (br $switch.41_outer - (block $compile_block.43 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - ) - ) - ) - (br $switch.41_outer - (block $compile_block.42 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - ) - ) - ) - ) - (block $cleanup.40 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 0 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstI32 5))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 0 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 7) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1131) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.5ff49e44.0.snapshot b/compiler/test/__snapshots__/pattern_matching.5ff49e44.0.snapshot index 3f9a96e10..db653cacd 100644 --- a/compiler/test/__snapshots__/pattern_matching.5ff49e44.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.5ff49e44.0.snapshot @@ -1,311 +1,173 @@ pattern matching › record_match_4 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1126 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1126 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (block $compile_block.27 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (i32.const 13) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $6) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $cleanup.16 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.17 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.18 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.19 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.21_outer (result i32) - (block $switch.21_branch_0 (result i32) - (drop - (block $switch.21_branch_1 (result i32) - (drop - (block $switch.21_default (result i32) - (br_table $switch.21_branch_1 $switch.21_default $switch.21_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.21_outer - (block $compile_block.26 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.21_outer - (block $compile_block.25 - (block $compile_store.23 - (local.set $13 - (call $+_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - ) - (block $do_backpatches.22 - ) - ) - (block $cleanup.24 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - (return_call $+_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1126) - ) - (local.get $13) - (local.get $9) - ) - ) - ) - ) - ) - (block $cleanup.20 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((functions ()) + (imports + (((mimp_id ((stamp 1126) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1126) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))) + ((baz) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MRecordOp (MRecordGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MRecordOp (MRecordGet 2) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MCallKnown (func +_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1126 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 8) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1128) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.64686134.0.snapshot b/compiler/test/__snapshots__/pattern_matching.64686134.0.snapshot index 7d4ae7b59..bb3d2d698 100644 --- a/compiler/test/__snapshots__/pattern_matching.64686134.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.64686134.0.snapshot @@ -1,335 +1,101 @@ pattern matching › constant_match_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"GRAIN$EXPORT$equal\" (global $GRAIN$EXPORT$equal_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"equal\" (func $equal_0 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (block $compile_block.27 (result i32) - (block $compile_store.5 - (local.set $6 - (block $allocate_number.3 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $1) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (i64.store offset=16 - (local.get $0) - (i64.const 1) - ) - (local.get $0) - ) - ) - (i32.store offset=12 - (local.get $1) - (block $allocate_number.2 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (i64.store offset=16 - (local.get $0) - (i64.const 3) - ) - (local.get $0) - ) - ) - (local.get $1) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (i32.const 11) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.20 - (local.set $9 - (if (result i32) - (i32.shr_u - (local.get $8) - (i32.const 31) - ) - (block $compile_block.8 (result i32) - (i32.const 1) - ) - (block $compile_block.18 (result i32) - (block $compile_store.13 - (local.set $7 - (block $allocate_number.11 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $1) - (block $allocate_number.9 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (i64.store offset=16 - (local.get $0) - (i64.const 1) - ) - (local.get $0) - ) - ) - (i32.store offset=12 - (local.get $1) - (block $allocate_number.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (i64.store offset=16 - (local.get $0) - (i64.const 3) - ) - (local.get $0) - ) - ) - (local.get $1) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $10 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (local.get $7) - ) - ) - (block $do_backpatches.14 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $10) - (i32.const 31) - ) - (block $compile_block.16 (result i32) - (i32.const 3) - ) - (block $compile_block.17 (result i32) - (i32.const 5) - ) - ) - ) - ) - ) - (block $do_backpatches.19 - ) - ) - (block $cleanup.21 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (block $switch.22_outer (result i32) - (block $switch.22_branch_0 (result i32) - (drop - (block $switch.22_branch_1 (result i32) - (drop - (block $switch.22_branch_2 (result i32) - (drop - (block $switch.22_branch_3 (result i32) - (drop - (block $switch.22_default (result i32) - (br_table $switch.22_branch_1 $switch.22_branch_2 $switch.22_branch_3 $switch.22_default $switch.22_default - (i32.const 0) - (i32.shr_s - (local.get $9) - (i32.const 1) - ) - ) - ) - ) - (br $switch.22_outer - (block $compile_block.26 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.22_outer - (block $compile_block.25 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.22_outer - (block $compile_block.24 (result i32) - (i32.const -2) - ) - ) - ) - ) - (br $switch.22_outer - (block $compile_block.23 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRational (numerator_flags ()) (numerator_limbs (1)) + (denominator_flags ()) (denominator_limbs (3))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRational (numerator_flags ()) (numerator_limbs (1)) + (denominator_flags ()) (denominator_limbs (3))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32)))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 3) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1120) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot b/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot index b1799f2bd..0fb80c77f 100644 --- a/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot @@ -1,1346 +1,808 @@ pattern matching › tuple_match_deep6 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1157 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1157 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (local $34 i32) - (local $35 i32) - (local $36 i32) - (local $37 i32) - (local $38 i32) - (local $39 i32) - (local $40 i32) - (local $41 i32) - (local $42 i32) - (local $43 i32) - (block $compile_block.123 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 13) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_tuple.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (local.get $9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.18 - ) - ) - (block $compile_store.21 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.23 - (local.set $14 - (i32.const 0) - ) - (block $do_backpatches.22 - ) - ) - (block $compile_store.25 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $16 - (i32.const 0) - ) - (block $do_backpatches.26 - ) - ) - (block $compile_store.29 - (local.set $17 - (i32.const 0) - ) - (block $do_backpatches.28 - ) - ) - (block $compile_store.31 - (local.set $18 - (i32.const 0) - ) - (block $do_backpatches.30 - ) - ) - (block $compile_store.33 - (local.set $19 - (i32.const 0) - ) - (block $do_backpatches.32 - ) - ) - (block $compile_store.35 - (local.set $20 - (i32.const 0) - ) - (block $do_backpatches.34 - ) - ) - (block $compile_store.37 - (local.set $21 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $10) - ) - ) - ) - (block $do_backpatches.36 - ) - ) - (block $compile_store.39 - (local.set $22 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $10) - ) - ) - ) - (block $do_backpatches.38 - ) - ) - (block $cleanup.40 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - (block $compile_store.42 - (local.set $32 - (i32.load offset=12 - (local.get $22) - ) - ) - (block $do_backpatches.41 - ) - ) - (block $compile_store.44 - (local.set $33 - (i32.or - (i32.shl - (i32.eq - (local.get $32) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.43 - ) - ) - (block $compile_store.104 - (local.set $34 - (if (result i32) - (i32.shr_u - (local.get $33) - (i32.const 31) - ) - (block $compile_block.96 (result i32) - (block $compile_store.46 - (local.set $23 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $22) - ) - ) - ) - (block $do_backpatches.45 - ) - ) - (block $compile_store.48 - (local.set $24 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $22) - ) - ) - ) - (block $do_backpatches.47 - ) - ) - (block $compile_store.50 - (local.set $36 - (i32.load offset=12 - (local.get $24) - ) - ) - (block $do_backpatches.49 - ) - ) - (block $compile_store.52 - (local.set $37 - (i32.or - (i32.shl - (i32.eq - (local.get $36) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.51 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $37) - (i32.const 31) - ) - (block $compile_block.88 (result i32) - (block $compile_store.55 - (local.set $25 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $24) - ) - ) - ) - (block $do_backpatches.54 - ) - ) - (block $compile_store.57 - (local.set $26 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $24) - ) - ) - ) - (block $do_backpatches.56 - ) - ) - (block $compile_store.59 - (local.set $39 - (i32.load offset=12 - (local.get $26) - ) - ) - (block $do_backpatches.58 - ) - ) - (block $compile_store.61 - (local.set $40 - (i32.or - (i32.shl - (i32.eq - (local.get $39) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.60 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $40) - (i32.const 31) - ) - (block $compile_block.79 (result i32) - (block $compile_store.64 - (local.set $27 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $26) - ) - ) - ) - (block $do_backpatches.63 - ) - ) - (block $compile_store.66 - (local.set $28 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $26) - ) - ) - ) - (block $do_backpatches.65 - ) - ) - (block $compile_store.68 - (local.set $42 - (i32.load offset=12 - (local.get $28) - ) - ) - (block $do_backpatches.67 - ) - ) - (block $cleanup.69 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $28) - ) - ) - ) - (block $compile_store.71 - (local.set $43 - (i32.or - (i32.shl - (i32.eq - (local.get $42) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.70 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $43) - (i32.const 31) - ) - (block $compile_block.77 (result i32) - (drop - (block $compile_set.73 (result i32) - (local.set $17 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $21) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.74 (result i32) - (local.set $18 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $23) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.75 (result i32) - (local.set $19 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $25) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.76 (result i32) - (local.set $20 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $27) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.78 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.72 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $27) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.87 (result i32) - (block $compile_store.81 - (local.set $41 - (i32.or - (i32.shl - (i32.eq - (local.get $39) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.80 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $41) - (i32.const 31) - ) - (block $compile_block.85 (result i32) - (drop - (block $compile_set.82 (result i32) - (local.set $14 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $21) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.83 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $23) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.84 (result i32) - (local.set $16 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $25) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.86 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.62 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $25) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $26) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.95 (result i32) - (block $compile_store.90 - (local.set $38 - (i32.or - (i32.shl - (i32.eq - (local.get $36) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.89 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $38) - (i32.const 31) - ) - (block $compile_block.93 (result i32) - (drop - (block $compile_set.91 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $21) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.92 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $23) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.94 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.53 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $23) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $24) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.102 (result i32) - (block $compile_store.98 - (local.set $35 - (i32.or - (i32.shl - (i32.eq - (local.get $32) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.97 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $35) - (i32.const 31) - ) - (block $compile_block.100 (result i32) - (drop - (block $compile_set.99 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $21) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.101 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.103 - ) - ) - (block $cleanup.105 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $22) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.107_outer (result i32) - (block $switch.107_branch_0 (result i32) - (drop - (block $switch.107_branch_1 (result i32) - (drop - (block $switch.107_branch_2 (result i32) - (drop - (block $switch.107_branch_3 (result i32) - (drop - (block $switch.107_branch_4 (result i32) - (drop - (block $switch.107_branch_5 (result i32) - (drop - (block $switch.107_default (result i32) - (br_table $switch.107_branch_1 $switch.107_branch_2 $switch.107_branch_3 $switch.107_branch_4 $switch.107_branch_5 $switch.107_default $switch.107_default - (i32.const 0) - (i32.shr_s - (local.get $34) - (i32.const 1) - ) - ) - ) - ) - (br $switch.107_outer - (block $compile_block.122 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.107_outer - (block $compile_block.121 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.107_outer - (block $compile_block.120 - (block $compile_store.116 - (local.set $30 - (call $+_1157 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - ) - ) - (block $do_backpatches.115 - ) - ) - (block $compile_store.118 - (local.set $31 - (call $+_1157 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) - ) - (local.get $30) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $19) - ) - ) - ) - (block $do_backpatches.117 - ) - ) - (block $cleanup.119 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - ) - (return_call $+_1157 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) - ) - (local.get $31) - (local.get $20) - ) - ) - ) - ) - ) - (br $switch.107_outer - (block $compile_block.114 - (block $compile_store.112 - (local.set $29 - (call $+_1157 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - ) - ) - (block $do_backpatches.111 - ) - ) - (block $cleanup.113 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - ) - (return_call $+_1157 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) - ) - (local.get $29) - (local.get $16) - ) - ) - ) - ) - ) - (br $switch.107_outer - (block $compile_block.110 - (block $cleanup.109 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - ) - (return_call $+_1157 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) - ) - (local.get $12) - (local.get $13) - ) - ) - ) - ) - ) - (br $switch.107_outer - (block $compile_block.108 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - ) - ) - ) - (block $cleanup.106 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1157) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1157) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 15 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 16 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 17 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 18 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 19 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 20 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 21 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 22 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 22 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 22 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 15 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 12 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 17 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 13 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 19 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 14 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 21 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 15 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 17 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 19 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1157) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1157 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (2 + (((instr_desc + (MStore + (((MLocalBind 23 Managed) + ((instr_desc + (MCallKnown (func +_1157) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1157 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1157) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1157 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 23 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 24 Managed) + ((instr_desc + (MCallKnown (func +_1157) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1157 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 25 Managed) + ((instr_desc + (MCallKnown (func +_1157) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1157 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 24 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1157) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1157 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 25 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 26) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1162) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.7082d3ca.0.snapshot b/compiler/test/__snapshots__/pattern_matching.7082d3ca.0.snapshot index 2d56c895d..52198872c 100644 --- a/compiler/test/__snapshots__/pattern_matching.7082d3ca.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.7082d3ca.0.snapshot @@ -1,301 +1,127 @@ pattern matching › tuple_match_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (block $compile_block.28 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 1886351202) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (local.get $6) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2147483646) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $7) - ) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $7) - ) - ) - ) - (block $do_backpatches.15 - ) - ) - (block $compile_store.18 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $cleanup.19 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (drop - (block $compile_set.20 (result i32) - (local.set $13 - (local.get $12) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.21 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.22 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.24_outer (result i32) - (block $switch.24_branch_0 (result i32) - (drop - (block $switch.24_branch_1 (result i32) - (drop - (block $switch.24_default (result i32) - (br_table $switch.24_branch_1 $switch.24_default $switch.24_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.24_outer - (block $compile_block.27 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.24_outer - (block $compile_block.26 (result i32) - (block $allocate_tuple.25 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - (i32.store offset=12 - (local.get $0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - ) - (i32.store offset=16 - (local.get $0) - (local.get $13) - ) - (local.get $0) - ) - ) - ) - ) - ) - (block $cleanup.23 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boop))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MAllocate + (MTuple + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 7) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1124) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot b/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot index 1bce284be..640b3c89e 100644 --- a/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot @@ -1,1217 +1,760 @@ pattern matching › tuple_match_deep3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1151 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1151 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (local $34 i32) - (local $35 i32) - (local $36 i32) - (local $37 i32) - (local $38 i32) - (local $39 i32) - (local $40 i32) - (block $compile_block.114 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.15 - ) - ) - (block $compile_store.18 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $14 - (i32.const 0) - ) - (block $do_backpatches.19 - ) - ) - (block $compile_store.22 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.24 - (local.set $16 - (i32.const 0) - ) - (block $do_backpatches.23 - ) - ) - (block $compile_store.26 - (local.set $17 - (i32.const 0) - ) - (block $do_backpatches.25 - ) - ) - (block $compile_store.28 - (local.set $18 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $7) - ) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $compile_store.30 - (local.set $19 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $7) - ) - ) - ) - (block $do_backpatches.29 - ) - ) - (block $cleanup.31 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (block $compile_store.33 - (local.set $29 - (i32.load offset=12 - (local.get $19) - ) - ) - (block $do_backpatches.32 - ) - ) - (block $compile_store.35 - (local.set $30 - (i32.or - (i32.shl - (i32.eq - (local.get $29) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.34 - ) - ) - (block $compile_store.95 - (local.set $31 - (if (result i32) - (i32.shr_u - (local.get $30) - (i32.const 31) - ) - (block $compile_block.87 (result i32) - (block $compile_store.37 - (local.set $20 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $19) - ) - ) - ) - (block $do_backpatches.36 - ) - ) - (block $compile_store.39 - (local.set $21 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $19) - ) - ) - ) - (block $do_backpatches.38 - ) - ) - (block $compile_store.41 - (local.set $33 - (i32.load offset=12 - (local.get $21) - ) - ) - (block $do_backpatches.40 - ) - ) - (block $compile_store.43 - (local.set $34 - (i32.or - (i32.shl - (i32.eq - (local.get $33) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.42 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $34) - (i32.const 31) - ) - (block $compile_block.79 (result i32) - (block $compile_store.46 - (local.set $22 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $21) - ) - ) - ) - (block $do_backpatches.45 - ) - ) - (block $compile_store.48 - (local.set $23 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $21) - ) - ) - ) - (block $do_backpatches.47 - ) - ) - (block $compile_store.50 - (local.set $36 - (i32.load offset=12 - (local.get $23) - ) - ) - (block $do_backpatches.49 - ) - ) - (block $compile_store.52 - (local.set $37 - (i32.or - (i32.shl - (i32.eq - (local.get $36) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.51 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $37) - (i32.const 31) - ) - (block $compile_block.70 (result i32) - (block $compile_store.55 - (local.set $24 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $23) - ) - ) - ) - (block $do_backpatches.54 - ) - ) - (block $compile_store.57 - (local.set $25 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $23) - ) - ) - ) - (block $do_backpatches.56 - ) - ) - (block $compile_store.59 - (local.set $39 - (i32.load offset=12 - (local.get $25) - ) - ) - (block $do_backpatches.58 - ) - ) - (block $cleanup.60 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $25) - ) - ) - ) - (block $compile_store.62 - (local.set $40 - (i32.or - (i32.shl - (i32.eq - (local.get $39) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.61 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $40) - (i32.const 31) - ) - (block $compile_block.68 (result i32) - (drop - (block $compile_set.64 (result i32) - (local.set $14 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.65 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.66 (result i32) - (local.set $16 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.67 (result i32) - (local.set $17 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $24) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.69 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.63 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $24) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.78 (result i32) - (block $compile_store.72 - (local.set $38 - (i32.or - (i32.shl - (i32.eq - (local.get $36) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.71 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $38) - (i32.const 31) - ) - (block $compile_block.76 (result i32) - (drop - (block $compile_set.73 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.74 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.75 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.77 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.53 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $22) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $23) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.86 (result i32) - (block $compile_store.81 - (local.set $35 - (i32.or - (i32.shl - (i32.eq - (local.get $33) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.80 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $35) - (i32.const 31) - ) - (block $compile_block.84 (result i32) - (drop - (block $compile_set.82 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.83 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.85 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.44 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.93 (result i32) - (block $compile_store.89 - (local.set $32 - (i32.or - (i32.shl - (i32.eq - (local.get $29) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.88 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $32) - (i32.const 31) - ) - (block $compile_block.91 (result i32) - (drop - (block $compile_set.90 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.92 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.94 - ) - ) - (block $cleanup.96 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.98_outer (result i32) - (block $switch.98_branch_0 (result i32) - (drop - (block $switch.98_branch_1 (result i32) - (drop - (block $switch.98_branch_2 (result i32) - (drop - (block $switch.98_branch_3 (result i32) - (drop - (block $switch.98_branch_4 (result i32) - (drop - (block $switch.98_branch_5 (result i32) - (drop - (block $switch.98_default (result i32) - (br_table $switch.98_branch_1 $switch.98_branch_2 $switch.98_branch_3 $switch.98_branch_4 $switch.98_branch_5 $switch.98_default $switch.98_default - (i32.const 0) - (i32.shr_s - (local.get $31) - (i32.const 1) - ) - ) - ) - ) - (br $switch.98_outer - (block $compile_block.113 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.98_outer - (block $compile_block.112 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.98_outer - (block $compile_block.111 - (block $compile_store.107 - (local.set $27 - (call $+_1151 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - ) - ) - (block $do_backpatches.106 - ) - ) - (block $compile_store.109 - (local.set $28 - (call $+_1151 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) - ) - (local.get $27) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - ) - ) - (block $do_backpatches.108 - ) - ) - (block $cleanup.110 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - (return_call $+_1151 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) - ) - (local.get $28) - (local.get $17) - ) - ) - ) - ) - ) - (br $switch.98_outer - (block $compile_block.105 - (block $compile_store.103 - (local.set $26 - (call $+_1151 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - ) - (block $do_backpatches.102 - ) - ) - (block $cleanup.104 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - ) - (return_call $+_1151 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) - ) - (local.get $26) - (local.get $13) - ) - ) - ) - ) - ) - (br $switch.98_outer - (block $compile_block.101 - (block $cleanup.100 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - ) - (return_call $+_1151 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) - ) - (local.get $9) - (local.get $10) - ) - ) - ) - ) - ) - (br $switch.98_outer - (block $compile_block.99 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - ) - ) - ) - (block $cleanup.97 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1151) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1151) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 15 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 16 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 17 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 18 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 19 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 12 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 14 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 16 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 18 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 12 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 14 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 16 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1151) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1151 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (2 + (((instr_desc + (MStore + (((MLocalBind 20 Managed) + ((instr_desc + (MCallKnown (func +_1151) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1151 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1151) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1151 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 21 Managed) + ((instr_desc + (MCallKnown (func +_1151) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1151 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 22 Managed) + ((instr_desc + (MCallKnown (func +_1151) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1151 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1151) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1151 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 22 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 23) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1156) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.7f7fe4ef.0.snapshot b/compiler/test/__snapshots__/pattern_matching.7f7fe4ef.0.snapshot index aaf65d1a7..bbaee7995 100644 --- a/compiler/test/__snapshots__/pattern_matching.7f7fe4ef.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.7f7fe4ef.0.snapshot @@ -1,79 +1,39 @@ pattern matching › alias_match_1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.7 (result i32) - (block $compile_store.2 - (local.set $6 - (i32.const 0) - ) - (block $do_backpatches.1 - ) - ) - (drop - (block $compile_set.3 (result i32) - (local.set $6 - (i32.const -2) - ) - (i32.const 1879048190) - ) - ) - (block $switch.4_outer (result i32) - (block $switch.4_branch_0 (result i32) - (drop - (block $switch.4_branch_1 (result i32) - (drop - (block $switch.4_default (result i32) - (br_table $switch.4_branch_1 $switch.4_default $switch.4_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.4_outer - (block $compile_block.6 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.4_outer - (block $compile_block.5 (result i32) - (local.get $6) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1115) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.8614dff3.0.snapshot b/compiler/test/__snapshots__/pattern_matching.8614dff3.0.snapshot index dc72edb08..4ce15ec14 100644 --- a/compiler/test/__snapshots__/pattern_matching.8614dff3.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.8614dff3.0.snapshot @@ -1,106 +1,64 @@ pattern matching › alias_match_2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.12 (result i32) - (block $compile_store.2 - (local.set $6 - (i32.const 0) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (drop - (block $compile_set.5 (result i32) - (local.set $7 - (i32.const -2) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.6 (result i32) - (local.set $6 - (i32.const -2) - ) - (i32.const 1879048190) - ) - ) - (block $switch.7_outer (result i32) - (block $switch.7_branch_0 (result i32) - (drop - (block $switch.7_branch_1 (result i32) - (drop - (block $switch.7_default (result i32) - (br_table $switch.7_branch_1 $switch.7_default $switch.7_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.7_outer - (block $compile_block.11 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.7_outer - (block $compile_block.10 (result i32) - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.8 (result i32) - (local.get $6) - ) - (block $compile_block.9 (result i32) - (local.get $7) - ) - ) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 2) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot b/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot index c7631c500..808474ed2 100644 --- a/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot @@ -1,852 +1,543 @@ pattern matching › adt_match_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1143 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1143 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (block $compile_block.89 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $20 - (i32.load offset=12 - (local.get $6) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $21 - (i32.or - (i32.shl - (i32.eq - (local.get $20) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.18 - ) - ) - (block $compile_store.75 - (local.set $22 - (if (result i32) - (i32.shr_u - (local.get $21) - (i32.const 31) - ) - (block $compile_block.68 (result i32) - (block $compile_store.21 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.23 - (local.set $14 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $6) - ) - ) - ) - (block $do_backpatches.22 - ) - ) - (block $compile_store.25 - (local.set $24 - (i32.load offset=12 - (local.get $14) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $25 - (i32.or - (i32.shl - (i32.eq - (local.get $24) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.26 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $25) - (i32.const 31) - ) - (block $compile_block.61 (result i32) - (block $compile_store.30 - (local.set $15 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $14) - ) - ) - ) - (block $do_backpatches.29 - ) - ) - (block $compile_store.32 - (local.set $16 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $14) - ) - ) - ) - (block $do_backpatches.31 - ) - ) - (block $compile_store.34 - (local.set $27 - (i32.load offset=12 - (local.get $16) - ) - ) - (block $do_backpatches.33 - ) - ) - (block $compile_store.36 - (local.set $28 - (i32.or - (i32.shl - (i32.eq - (local.get $27) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.35 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $28) - (i32.const 31) - ) - (block $compile_block.53 (result i32) - (block $compile_store.39 - (local.set $17 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $16) - ) - ) - ) - (block $do_backpatches.38 - ) - ) - (block $compile_store.41 - (local.set $18 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $16) - ) - ) - ) - (block $do_backpatches.40 - ) - ) - (block $compile_store.43 - (local.set $30 - (i32.load offset=12 - (local.get $18) - ) - ) - (block $do_backpatches.42 - ) - ) - (block $cleanup.44 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - ) - (block $compile_store.46 - (local.set $31 - (i32.or - (i32.shl - (i32.eq - (local.get $30) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.45 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $31) - (i32.const 31) - ) - (block $compile_block.51 (result i32) - (drop - (block $compile_set.48 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.49 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.50 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.52 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.47 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.60 (result i32) - (block $compile_store.55 - (local.set $29 - (i32.or - (i32.shl - (i32.eq - (local.get $27) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.54 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $29) - (i32.const 31) - ) - (block $compile_block.58 (result i32) - (drop - (block $compile_set.56 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.57 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.59 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.37 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.67 (result i32) - (block $compile_store.63 - (local.set $26 - (i32.or - (i32.shl - (i32.eq - (local.get $24) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.62 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $26) - (i32.const 31) - ) - (block $compile_block.65 (result i32) - (drop - (block $compile_set.64 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.66 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.28 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.73 (result i32) - (block $compile_store.70 - (local.set $23 - (i32.or - (i32.shl - (i32.eq - (local.get $20) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.69 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $23) - (i32.const 31) - ) - (block $compile_block.71 (result i32) - (i32.const 1) - ) - (block $compile_block.72 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.74 - ) - ) - (block $cleanup.76 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.78_outer (result i32) - (block $switch.78_branch_0 (result i32) - (drop - (block $switch.78_branch_1 (result i32) - (drop - (block $switch.78_branch_2 (result i32) - (drop - (block $switch.78_branch_3 (result i32) - (drop - (block $switch.78_branch_4 (result i32) - (drop - (block $switch.78_branch_5 (result i32) - (drop - (block $switch.78_default (result i32) - (br_table $switch.78_branch_1 $switch.78_branch_2 $switch.78_branch_3 $switch.78_branch_4 $switch.78_branch_5 $switch.78_default $switch.78_default - (i32.const 0) - (i32.shr_s - (local.get $22) - (i32.const 1) - ) - ) - ) - ) - (br $switch.78_outer - (block $compile_block.88 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.78_outer - (block $compile_block.87 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.78_outer - (block $compile_block.86 - (block $compile_store.84 - (local.set $19 - (call $+_1143 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1143) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - ) - (block $do_backpatches.83 - ) - ) - (block $cleanup.85 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - (return_call $+_1143 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1143) - ) - (local.get $19) - (local.get $12) - ) - ) - ) - ) - ) - (br $switch.78_outer - (block $compile_block.82 - (block $cleanup.81 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - (return_call $+_1143 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1143) - ) - (local.get $8) - (local.get $9) - ) - ) - ) - ) - ) - (br $switch.78_outer - (block $compile_block.80 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - ) - ) - ) - ) - (br $switch.78_outer - (block $compile_block.79 (result i32) - (i32.const 1) - ) - ) - ) - ) - (block $cleanup.77 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1143) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1143) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 7 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 9 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 11 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 7 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 9 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1143) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1143 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MCallKnown (func +_1143) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1143 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1143) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1143 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 14) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1146) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.9561763b.0.snapshot b/compiler/test/__snapshots__/pattern_matching.9561763b.0.snapshot index 6572cce0a..f11f48d59 100644 --- a/compiler/test/__snapshots__/pattern_matching.9561763b.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.9561763b.0.snapshot @@ -1,791 +1,446 @@ pattern matching › tuple_match_deep2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1149 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1149 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (block $compile_block.79 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 13) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 15) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=16 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_tuple.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_tuple.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_tuple.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (local.get $9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.18 - ) - ) - (block $compile_store.21 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.23 - (local.set $14 - (i32.const 0) - ) - (block $do_backpatches.22 - ) - ) - (block $compile_store.25 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $16 - (i32.const 0) - ) - (block $do_backpatches.26 - ) - ) - (block $compile_store.29 - (local.set $17 - (i32.const 0) - ) - (block $do_backpatches.28 - ) - ) - (block $compile_store.31 - (local.set $18 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $10) - ) - ) - ) - (block $do_backpatches.30 - ) - ) - (block $compile_store.33 - (local.set $19 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $10) - ) - ) - ) - (block $do_backpatches.32 - ) - ) - (block $cleanup.34 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - (block $compile_store.36 - (local.set $20 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $19) - ) - ) - ) - (block $do_backpatches.35 - ) - ) - (block $compile_store.38 - (local.set $21 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $19) - ) - ) - ) - (block $do_backpatches.37 - ) - ) - (block $cleanup.39 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - ) - (block $compile_store.41 - (local.set $22 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $21) - ) - ) - ) - (block $do_backpatches.40 - ) - ) - (block $compile_store.43 - (local.set $23 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $21) - ) - ) - ) - (block $do_backpatches.42 - ) - ) - (block $cleanup.44 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - ) - (block $compile_store.46 - (local.set $24 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $23) - ) - ) - ) - (block $do_backpatches.45 - ) - ) - (block $compile_store.48 - (local.set $25 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $23) - ) - ) - ) - (block $do_backpatches.47 - ) - ) - (block $compile_store.50 - (local.set $26 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $23) - ) - ) - ) - (block $do_backpatches.49 - ) - ) - (block $cleanup.51 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $23) - ) - ) - ) - (block $compile_store.53 - (local.set $27 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $26) - ) - ) - ) - (block $do_backpatches.52 - ) - ) - (block $compile_store.55 - (local.set $28 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $26) - ) - ) - ) - (block $do_backpatches.54 - ) - ) - (block $cleanup.56 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $26) - ) - ) - ) - (drop - (block $compile_set.57 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.58 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.59 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.60 (result i32) - (local.set $14 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $24) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.61 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $25) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.62 (result i32) - (local.set $17 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $28) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.63 (result i32) - (local.set $16 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $27) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.65_outer (result i32) - (block $switch.65_branch_0 (result i32) - (drop - (block $switch.65_branch_1 (result i32) - (drop - (block $switch.65_default (result i32) - (br_table $switch.65_branch_1 $switch.65_default $switch.65_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.65_outer - (block $compile_block.78 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.65_outer - (block $compile_block.77 - (block $compile_store.67 - (local.set $29 - (call $+_1149 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - ) - (block $do_backpatches.66 - ) - ) - (block $compile_store.69 - (local.set $30 - (call $+_1149 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) - ) - (local.get $29) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - ) - ) - (block $do_backpatches.68 - ) - ) - (block $compile_store.71 - (local.set $31 - (call $+_1149 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) - ) - (local.get $30) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - ) - ) - (block $do_backpatches.70 - ) - ) - (block $compile_store.73 - (local.set $32 - (call $+_1149 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) - ) - (local.get $31) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - ) - ) - (block $do_backpatches.72 - ) - ) - (block $compile_store.75 - (local.set $33 - (call $+_1149 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) - ) - (local.get $32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - ) - ) - (block $do_backpatches.74 - ) - ) - (block $cleanup.76 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - (return_call $+_1149 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) - ) - (local.get $33) - (local.get $17) - ) - ) - ) - ) - ) - (block $cleanup.64 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1149) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1149) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 7))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 15 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 16 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 17 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 18 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 19 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 20 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 21 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 22 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 22 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MStore + (((MLocalBind 23 Managed) + ((instr_desc + (MCallKnown (func +_1149) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1149 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 24 Managed) + ((instr_desc + (MCallKnown (func +_1149) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1149 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 23 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 25 Managed) + ((instr_desc + (MCallKnown (func +_1149) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1149 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 24 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 26 Managed) + ((instr_desc + (MCallKnown (func +_1149) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1149 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 25 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 27 Managed) + ((instr_desc + (MCallKnown (func +_1149) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1149 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 26 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1149) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1149 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 27 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 28) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1155) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.98756c45.0.snapshot b/compiler/test/__snapshots__/pattern_matching.98756c45.0.snapshot index 46e652003..a62c665e7 100644 --- a/compiler/test/__snapshots__/pattern_matching.98756c45.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.98756c45.0.snapshot @@ -1,225 +1,93 @@ pattern matching › record_match_deep -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (block $compile_block.20 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 610197211) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $cleanup.11 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (block $compile_store.13 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $9) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $cleanup.14 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - (drop - (block $compile_set.15 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.17_outer (result i32) - (block $switch.17_branch_0 (result i32) - (drop - (block $switch.17_branch_1 (result i32) - (drop - (block $switch.17_default (result i32) - (br_table $switch.17_branch_1 $switch.17_default $switch.17_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.17_outer - (block $compile_block.19 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.17_outer - (block $compile_block.18 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - ) - ) - ) - (block $cleanup.16 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 606 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 305098605))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + (((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 5) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1125) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.9ffaa7a7.0.snapshot b/compiler/test/__snapshots__/pattern_matching.9ffaa7a7.0.snapshot index fd6241d72..40e5c01e4 100644 --- a/compiler/test/__snapshots__/pattern_matching.9ffaa7a7.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.9ffaa7a7.0.snapshot @@ -1,242 +1,168 @@ pattern matching › low_level_constant_match_4 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1116 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (block $compile_block.28 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (select - (i32.const -2) - (i32.const 2147483646) - (f64.eq - (f64.const 1) - (f64.const 0) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.17 - (local.set $8 - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.6 (result i32) - (i32.const 1) - ) - (block $compile_block.15 (result i32) - (block $compile_store.8 - (local.set $9 - (select - (i32.const -2) - (i32.const 2147483646) - (f64.eq - (f64.const 1) - (f64.const 1) - ) - ) - ) - (block $do_backpatches.7 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $9) - (i32.const 31) - ) - (block $compile_block.9 (result i32) - (i32.const 3) - ) - (block $compile_block.14 (result i32) - (block $compile_store.11 - (local.set $10 - (select - (i32.const -2) - (i32.const 2147483646) - (f64.eq - (f64.const 1) - (f64.const 2) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $10) - (i32.const 31) - ) - (block $compile_block.12 (result i32) - (i32.const 5) - ) - (block $compile_block.13 (result i32) - (i32.const 7) - ) - ) - ) - ) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.25 - (local.set $11 - (block $switch.18_outer (result i32) - (block $switch.18_branch_0 (result i32) - (drop - (block $switch.18_branch_1 (result i32) - (drop - (block $switch.18_branch_2 (result i32) - (drop - (block $switch.18_branch_3 (result i32) - (drop - (block $switch.18_branch_4 (result i32) - (drop - (block $switch.18_default (result i32) - (br_table $switch.18_branch_1 $switch.18_branch_2 $switch.18_branch_3 $switch.18_branch_4 $switch.18_default $switch.18_default - (i32.const 0) - (i32.shr_s - (local.get $8) - (i32.const 1) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.23 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.22 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.21 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.20 (result i32) - (i32.const -2) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.19 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $12 - (call $print_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1116) - ) - (local.get $11) - (local.get $6) - ) - ) - (block $do_backpatches.26 - ) - ) - (i32.const 1) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1116) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1116) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 + (WasmBinaryF64 (wasm_op Op_eq_float64) + (arg_types (Wasm_float64 Wasm_float64)) (ret_type Grain_bool)) + ((immediate_desc + (MImmConst (MConstLiteral (MConstF64 4607182418800017408)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstF64 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 + (WasmBinaryF64 (wasm_op Op_eq_float64) + (arg_types (Wasm_float64 Wasm_float64)) + (ret_type Grain_bool)) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstF64 4607182418800017408)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstF64 4607182418800017408)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 + (WasmBinaryF64 (wasm_op Op_eq_float64) + (arg_types (Wasm_float64 Wasm_float64)) + (ret_type Grain_bool)) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstF64 4607182418800017408)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstF64 4611686018427387904)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (3 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func print_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmI32) Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 6) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1125) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.aa8d2963.0.snapshot b/compiler/test/__snapshots__/pattern_matching.aa8d2963.0.snapshot index 5a15c3c93..5292523a2 100644 --- a/compiler/test/__snapshots__/pattern_matching.aa8d2963.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.aa8d2963.0.snapshot @@ -1,431 +1,247 @@ pattern matching › guarded_match_4 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1126 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1126 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (block $compile_block.39 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 17) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $6) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $cleanup.16 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.17 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.18 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.19 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.21 - (local.set $13 - (call $==_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 5) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.25 - (local.set $14 - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.22 (result i32) - (call $==_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (i32.const 7) - ) - ) - (block $compile_block.23 (result i32) - (local.get $13) - ) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.32 - (local.set $15 - (if (result i32) - (i32.shr_u - (local.get $14) - (i32.const 31) - ) - (block $compile_block.29 (result i32) - (drop - (block $compile_set.26 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.27 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.28 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.30 (result i32) - (i32.const 3) - ) - ) - ) - (block $do_backpatches.31 - ) - ) - (block $cleanup.33 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.35_outer (result i32) - (block $switch.35_branch_0 (result i32) - (drop - (block $switch.35_branch_1 (result i32) - (drop - (block $switch.35_branch_2 (result i32) - (drop - (block $switch.35_default (result i32) - (br_table $switch.35_branch_1 $switch.35_branch_2 $switch.35_default $switch.35_default - (i32.const 0) - (i32.shr_s - (local.get $15) - (i32.const 1) - ) - ) - ) - ) - (br $switch.35_outer - (block $compile_block.38 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.35_outer - (block $compile_block.37 (result i32) - (i32.const 199) - ) - ) - ) - ) - (br $switch.35_outer - (block $compile_block.36 (result i32) - (i32.const 85) - ) - ) - ) - ) - (block $cleanup.34 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1126) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1126) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 8))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1126 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + (((instr_desc + (MCallKnown (func ==_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 42))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 99))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 7) (stack_size_i32 3) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1132) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.ac58ffc3.0.snapshot b/compiler/test/__snapshots__/pattern_matching.ac58ffc3.0.snapshot index 4ee68d69f..ff105cd71 100644 --- a/compiler/test/__snapshots__/pattern_matching.ac58ffc3.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.ac58ffc3.0.snapshot @@ -1,402 +1,217 @@ pattern matching › guarded_match_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1125 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1125 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (block $compile_block.35 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $6) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $cleanup.16 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.17 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.18 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.19 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.21 - (local.set $13 - (call $==_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1125) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.28 - (local.set $14 - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.25 (result i32) - (drop - (block $compile_set.22 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.23 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.24 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.26 (result i32) - (i32.const 3) - ) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $cleanup.29 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.31_outer (result i32) - (block $switch.31_branch_0 (result i32) - (drop - (block $switch.31_branch_1 (result i32) - (drop - (block $switch.31_branch_2 (result i32) - (drop - (block $switch.31_default (result i32) - (br_table $switch.31_branch_1 $switch.31_branch_2 $switch.31_default $switch.31_default - (i32.const 0) - (i32.shr_s - (local.get $14) - (i32.const 1) - ) - ) - ) - ) - (br $switch.31_outer - (block $compile_block.34 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.31_outer - (block $compile_block.33 (result i32) - (i32.const 199) - ) - ) - ) - ) - (br $switch.31_outer - (block $compile_block.32 (result i32) - (i32.const 85) - ) - ) - ) - ) - (block $cleanup.30 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1125) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1125) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1125 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 42))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 99))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 7) (stack_size_i32 2) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1130) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot b/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot index 1bfcf1ba1..5b47d0fc4 100644 --- a/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot @@ -1,895 +1,559 @@ pattern matching › adt_match_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1145 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1145 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (block $compile_block.92 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.15 - ) - ) - (block $compile_store.18 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $21 - (i32.load offset=12 - (local.get $7) - ) - ) - (block $do_backpatches.19 - ) - ) - (block $compile_store.22 - (local.set $22 - (i32.or - (i32.shl - (i32.eq - (local.get $21) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.78 - (local.set $23 - (if (result i32) - (i32.shr_u - (local.get $22) - (i32.const 31) - ) - (block $compile_block.71 (result i32) - (block $compile_store.24 - (local.set $14 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $7) - ) - ) - ) - (block $do_backpatches.23 - ) - ) - (block $compile_store.26 - (local.set $15 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $7) - ) - ) - ) - (block $do_backpatches.25 - ) - ) - (block $compile_store.28 - (local.set $25 - (i32.load offset=12 - (local.get $15) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $compile_store.30 - (local.set $26 - (i32.or - (i32.shl - (i32.eq - (local.get $25) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.29 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $26) - (i32.const 31) - ) - (block $compile_block.64 (result i32) - (block $compile_store.33 - (local.set $16 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $15) - ) - ) - ) - (block $do_backpatches.32 - ) - ) - (block $compile_store.35 - (local.set $17 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $15) - ) - ) - ) - (block $do_backpatches.34 - ) - ) - (block $compile_store.37 - (local.set $28 - (i32.load offset=12 - (local.get $17) - ) - ) - (block $do_backpatches.36 - ) - ) - (block $compile_store.39 - (local.set $29 - (i32.or - (i32.shl - (i32.eq - (local.get $28) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.38 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $29) - (i32.const 31) - ) - (block $compile_block.56 (result i32) - (block $compile_store.42 - (local.set $18 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $17) - ) - ) - ) - (block $do_backpatches.41 - ) - ) - (block $compile_store.44 - (local.set $19 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $17) - ) - ) - ) - (block $do_backpatches.43 - ) - ) - (block $compile_store.46 - (local.set $31 - (i32.load offset=12 - (local.get $19) - ) - ) - (block $do_backpatches.45 - ) - ) - (block $cleanup.47 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - ) - (block $compile_store.49 - (local.set $32 - (i32.or - (i32.shl - (i32.eq - (local.get $31) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.48 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $32) - (i32.const 31) - ) - (block $compile_block.54 (result i32) - (drop - (block $compile_set.51 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.52 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.53 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.55 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.50 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.63 (result i32) - (block $compile_store.58 - (local.set $30 - (i32.or - (i32.shl - (i32.eq - (local.get $28) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.57 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $30) - (i32.const 31) - ) - (block $compile_block.61 (result i32) - (drop - (block $compile_set.59 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.60 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.62 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.40 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.70 (result i32) - (block $compile_store.66 - (local.set $27 - (i32.or - (i32.shl - (i32.eq - (local.get $25) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.65 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $27) - (i32.const 31) - ) - (block $compile_block.68 (result i32) - (drop - (block $compile_set.67 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.69 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.31 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.76 (result i32) - (block $compile_store.73 - (local.set $24 - (i32.or - (i32.shl - (i32.eq - (local.get $21) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.72 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $24) - (i32.const 31) - ) - (block $compile_block.74 (result i32) - (i32.const 1) - ) - (block $compile_block.75 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.77 - ) - ) - (block $cleanup.79 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.81_outer (result i32) - (block $switch.81_branch_0 (result i32) - (drop - (block $switch.81_branch_1 (result i32) - (drop - (block $switch.81_branch_2 (result i32) - (drop - (block $switch.81_branch_3 (result i32) - (drop - (block $switch.81_branch_4 (result i32) - (drop - (block $switch.81_branch_5 (result i32) - (drop - (block $switch.81_default (result i32) - (br_table $switch.81_branch_1 $switch.81_branch_2 $switch.81_branch_3 $switch.81_branch_4 $switch.81_branch_5 $switch.81_default $switch.81_default - (i32.const 0) - (i32.shr_s - (local.get $23) - (i32.const 1) - ) - ) - ) - ) - (br $switch.81_outer - (block $compile_block.91 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.81_outer - (block $compile_block.90 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.81_outer - (block $compile_block.89 - (block $compile_store.87 - (local.set $20 - (call $+_1145 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1145) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - ) - (block $do_backpatches.86 - ) - ) - (block $cleanup.88 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - (return_call $+_1145 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1145) - ) - (local.get $20) - (local.get $13) - ) - ) - ) - ) - ) - (br $switch.81_outer - (block $compile_block.85 - (block $cleanup.84 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - (return_call $+_1145 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1145) - ) - (local.get $9) - (local.get $10) - ) - ) - ) - ) - ) - (br $switch.81_outer - (block $compile_block.83 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - ) - ) - ) - (br $switch.81_outer - (block $compile_block.82 (result i32) - (i32.const 1) - ) - ) - ) - ) - (block $cleanup.80 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1145) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1145) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 8 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 10 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 12 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 8 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 10 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1145) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1145 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MCallKnown (func +_1145) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1145 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1145) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1145 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 15) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1148) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.b9db0dd9.0.snapshot b/compiler/test/__snapshots__/pattern_matching.b9db0dd9.0.snapshot index 55e79a2ae..f27708616 100644 --- a/compiler/test/__snapshots__/pattern_matching.b9db0dd9.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.b9db0dd9.0.snapshot @@ -1,431 +1,247 @@ pattern matching › guarded_match_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1126 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1126 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (block $compile_block.39 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $6) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $cleanup.16 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.17 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.18 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.19 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.21 - (local.set $13 - (call $==_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 5) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.25 - (local.set $14 - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.22 (result i32) - (call $==_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (i32.const 7) - ) - ) - (block $compile_block.23 (result i32) - (local.get $13) - ) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.32 - (local.set $15 - (if (result i32) - (i32.shr_u - (local.get $14) - (i32.const 31) - ) - (block $compile_block.29 (result i32) - (drop - (block $compile_set.26 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.27 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.28 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.30 (result i32) - (i32.const 3) - ) - ) - ) - (block $do_backpatches.31 - ) - ) - (block $cleanup.33 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.35_outer (result i32) - (block $switch.35_branch_0 (result i32) - (drop - (block $switch.35_branch_1 (result i32) - (drop - (block $switch.35_branch_2 (result i32) - (drop - (block $switch.35_default (result i32) - (br_table $switch.35_branch_1 $switch.35_branch_2 $switch.35_default $switch.35_default - (i32.const 0) - (i32.shr_s - (local.get $15) - (i32.const 1) - ) - ) - ) - ) - (br $switch.35_outer - (block $compile_block.38 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.35_outer - (block $compile_block.37 (result i32) - (i32.const 199) - ) - ) - ) - ) - (br $switch.35_outer - (block $compile_block.36 (result i32) - (i32.const 85) - ) - ) - ) - ) - (block $cleanup.34 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1126) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1126) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1126 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + (((instr_desc + (MCallKnown (func ==_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 42))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 99))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 7) (stack_size_i32 3) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1132) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.be46eb0e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.be46eb0e.0.snapshot index 5bd625281..ccce6e3c9 100644 --- a/compiler/test/__snapshots__/pattern_matching.be46eb0e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.be46eb0e.0.snapshot @@ -1,248 +1,155 @@ pattern matching › low_level_constant_match_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1116 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (block $compile_block.28 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.or - (i32.shl - (i32.eq - (i32.const 1) - (i32.const 0) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.17 - (local.set $8 - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.6 (result i32) - (i32.const 1) - ) - (block $compile_block.15 (result i32) - (block $compile_store.8 - (local.set $9 - (i32.or - (i32.shl - (i32.eq - (i32.const 1) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.7 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $9) - (i32.const 31) - ) - (block $compile_block.9 (result i32) - (i32.const 3) - ) - (block $compile_block.14 (result i32) - (block $compile_store.11 - (local.set $10 - (i32.or - (i32.shl - (i32.eq - (i32.const 1) - (i32.const 2) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.10 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $10) - (i32.const 31) - ) - (block $compile_block.12 (result i32) - (i32.const 5) - ) - (block $compile_block.13 (result i32) - (i32.const 7) - ) - ) - ) - ) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.25 - (local.set $11 - (block $switch.18_outer (result i32) - (block $switch.18_branch_0 (result i32) - (drop - (block $switch.18_branch_1 (result i32) - (drop - (block $switch.18_branch_2 (result i32) - (drop - (block $switch.18_branch_3 (result i32) - (drop - (block $switch.18_branch_4 (result i32) - (drop - (block $switch.18_default (result i32) - (br_table $switch.18_branch_1 $switch.18_branch_2 $switch.18_branch_3 $switch.18_branch_4 $switch.18_default $switch.18_default - (i32.const 0) - (i32.shr_s - (local.get $8) - (i32.const 1) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.23 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.22 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.21 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.20 (result i32) - (i32.const -2) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.19 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $12 - (call $print_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1116) - ) - (local.get $11) - (local.get $6) - ) - ) - (block $do_backpatches.26 - ) - ) - (i32.const 1) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1116) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1116) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (3 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func print_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmI32) Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 6) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1125) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot b/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot index 84517d7d6..3843458f8 100644 --- a/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot @@ -1,938 +1,575 @@ pattern matching › adt_match_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1147 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1147 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (block $compile_block.95 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.18 - ) - ) - (block $compile_store.21 - (local.set $14 - (i32.const 0) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.23 - (local.set $22 - (i32.load offset=12 - (local.get $8) - ) - ) - (block $do_backpatches.22 - ) - ) - (block $compile_store.25 - (local.set $23 - (i32.or - (i32.shl - (i32.eq - (local.get $22) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.81 - (local.set $24 - (if (result i32) - (i32.shr_u - (local.get $23) - (i32.const 31) - ) - (block $compile_block.74 (result i32) - (block $compile_store.27 - (local.set $15 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $8) - ) - ) - ) - (block $do_backpatches.26 - ) - ) - (block $compile_store.29 - (local.set $16 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $8) - ) - ) - ) - (block $do_backpatches.28 - ) - ) - (block $compile_store.31 - (local.set $26 - (i32.load offset=12 - (local.get $16) - ) - ) - (block $do_backpatches.30 - ) - ) - (block $compile_store.33 - (local.set $27 - (i32.or - (i32.shl - (i32.eq - (local.get $26) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.32 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $27) - (i32.const 31) - ) - (block $compile_block.67 (result i32) - (block $compile_store.36 - (local.set $17 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $16) - ) - ) - ) - (block $do_backpatches.35 - ) - ) - (block $compile_store.38 - (local.set $18 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $16) - ) - ) - ) - (block $do_backpatches.37 - ) - ) - (block $compile_store.40 - (local.set $29 - (i32.load offset=12 - (local.get $18) - ) - ) - (block $do_backpatches.39 - ) - ) - (block $compile_store.42 - (local.set $30 - (i32.or - (i32.shl - (i32.eq - (local.get $29) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.41 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $30) - (i32.const 31) - ) - (block $compile_block.59 (result i32) - (block $compile_store.45 - (local.set $19 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $18) - ) - ) - ) - (block $do_backpatches.44 - ) - ) - (block $compile_store.47 - (local.set $20 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $18) - ) - ) - ) - (block $do_backpatches.46 - ) - ) - (block $compile_store.49 - (local.set $32 - (i32.load offset=12 - (local.get $20) - ) - ) - (block $do_backpatches.48 - ) - ) - (block $cleanup.50 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - ) - (block $compile_store.52 - (local.set $33 - (i32.or - (i32.shl - (i32.eq - (local.get $32) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.51 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $33) - (i32.const 31) - ) - (block $compile_block.57 (result i32) - (drop - (block $compile_set.54 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.55 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.56 (result i32) - (local.set $14 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $19) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.58 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.53 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.66 (result i32) - (block $compile_store.61 - (local.set $31 - (i32.or - (i32.shl - (i32.eq - (local.get $29) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.60 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $31) - (i32.const 31) - ) - (block $compile_block.64 (result i32) - (drop - (block $compile_set.62 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.63 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.65 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.43 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.73 (result i32) - (block $compile_store.69 - (local.set $28 - (i32.or - (i32.shl - (i32.eq - (local.get $26) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.68 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $28) - (i32.const 31) - ) - (block $compile_block.71 (result i32) - (drop - (block $compile_set.70 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.72 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.34 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.79 (result i32) - (block $compile_store.76 - (local.set $25 - (i32.or - (i32.shl - (i32.eq - (local.get $22) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.75 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $25) - (i32.const 31) - ) - (block $compile_block.77 (result i32) - (i32.const 1) - ) - (block $compile_block.78 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.80 - ) - ) - (block $cleanup.82 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.84_outer (result i32) - (block $switch.84_branch_0 (result i32) - (drop - (block $switch.84_branch_1 (result i32) - (drop - (block $switch.84_branch_2 (result i32) - (drop - (block $switch.84_branch_3 (result i32) - (drop - (block $switch.84_branch_4 (result i32) - (drop - (block $switch.84_branch_5 (result i32) - (drop - (block $switch.84_default (result i32) - (br_table $switch.84_branch_1 $switch.84_branch_2 $switch.84_branch_3 $switch.84_branch_4 $switch.84_branch_5 $switch.84_default $switch.84_default - (i32.const 0) - (i32.shr_s - (local.get $24) - (i32.const 1) - ) - ) - ) - ) - (br $switch.84_outer - (block $compile_block.94 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.84_outer - (block $compile_block.93 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.84_outer - (block $compile_block.92 - (block $compile_store.90 - (local.set $21 - (call $+_1147 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1147) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - ) - ) - (block $do_backpatches.89 - ) - ) - (block $cleanup.91 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - (return_call $+_1147 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1147) - ) - (local.get $21) - (local.get $14) - ) - ) - ) - ) - ) - (br $switch.84_outer - (block $compile_block.88 - (block $cleanup.87 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - (return_call $+_1147 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1147) - ) - (local.get $10) - (local.get $11) - ) - ) - ) - ) - ) - (br $switch.84_outer - (block $compile_block.86 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - ) - ) - ) - ) - (br $switch.84_outer - (block $compile_block.85 (result i32) - (i32.const 1) - ) - ) - ) - ) - (block $cleanup.83 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1147) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1147) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 9 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 11 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 13 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 9 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 11 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1147) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1147 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 15 Managed) + ((instr_desc + (MCallKnown (func +_1147) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1147 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1147) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1147 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 16) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1150) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.c9582b6d.0.snapshot b/compiler/test/__snapshots__/pattern_matching.c9582b6d.0.snapshot index 7c85f281a..b4ba4736d 100644 --- a/compiler/test/__snapshots__/pattern_matching.c9582b6d.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.c9582b6d.0.snapshot @@ -1,364 +1,200 @@ pattern matching › alias_match_4 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"GRAIN$EXPORT$equal\" (global $GRAIN$EXPORT$equal_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"equal\" (func $equal_0 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (block $compile_block.38 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $9 - (i32.load offset=12 - (local.get $6) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $10 - (i32.or - (i32.shl - (i32.eq - (local.get $9) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.30 - (local.set $11 - (if (result i32) - (i32.shr_u - (local.get $10) - (i32.const 31) - ) - (block $compile_block.10 (result i32) - (i32.const 3) - ) - (block $compile_block.28 (result i32) - (block $compile_store.12 - (local.set $12 - (i32.or - (i32.shl - (i32.eq - (local.get $9) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.11 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $12) - (i32.const 31) - ) - (block $compile_block.26 (result i32) - (block $compile_store.14 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $13 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (i32.const 7) - ) - ) - (block $do_backpatches.15 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.19 (result i32) - (drop - (block $compile_set.18 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.25 (result i32) - (block $compile_store.21 - (local.set $14 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (i32.const 9) - ) - ) - (block $do_backpatches.20 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $14) - (i32.const 31) - ) - (block $compile_block.23 (result i32) - (drop - (block $compile_set.22 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.24 (result i32) - (i32.const 3) - ) - ) - ) - ) - (block $cleanup.17 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.27 (result i32) - (i32.const 5) - ) - ) - ) - ) - ) - (block $do_backpatches.29 - ) - ) - (block $cleanup.31 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.33_outer (result i32) - (block $switch.33_branch_0 (result i32) - (drop - (block $switch.33_branch_1 (result i32) - (drop - (block $switch.33_branch_2 (result i32) - (drop - (block $switch.33_branch_3 (result i32) - (drop - (block $switch.33_default (result i32) - (br_table $switch.33_branch_1 $switch.33_branch_2 $switch.33_branch_3 $switch.33_default $switch.33_default - (i32.const 0) - (i32.shr_s - (local.get $11) - (i32.const 1) - ) - ) - ) - ) - (br $switch.33_outer - (block $compile_block.37 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.33_outer - (block $compile_block.36 (result i32) - (i32.const 13) - ) - ) - ) - ) - (br $switch.33_outer - (block $compile_block.35 (result i32) - (i32.const 11) - ) - ) - ) - ) - (br $switch.33_outer - (block $compile_block.34 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - ) - ) - ) - ) - (block $cleanup.32 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 2 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 6) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1129) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot b/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot index 95070d137..7c7eb0ffb 100644 --- a/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot @@ -1,1024 +1,607 @@ pattern matching › adt_match_5 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1151 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1151 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (local $34 i32) - (local $35 i32) - (block $compile_block.101 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 15) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 13) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.18 - ) - ) - (block $compile_store.21 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.23 - (local.set $14 - (i32.const 0) - ) - (block $do_backpatches.22 - ) - ) - (block $compile_store.25 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $16 - (i32.const 0) - ) - (block $do_backpatches.26 - ) - ) - (block $compile_store.29 - (local.set $24 - (i32.load offset=12 - (local.get $10) - ) - ) - (block $do_backpatches.28 - ) - ) - (block $compile_store.31 - (local.set $25 - (i32.or - (i32.shl - (i32.eq - (local.get $24) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.30 - ) - ) - (block $compile_store.87 - (local.set $26 - (if (result i32) - (i32.shr_u - (local.get $25) - (i32.const 31) - ) - (block $compile_block.80 (result i32) - (block $compile_store.33 - (local.set $17 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $10) - ) - ) - ) - (block $do_backpatches.32 - ) - ) - (block $compile_store.35 - (local.set $18 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $10) - ) - ) - ) - (block $do_backpatches.34 - ) - ) - (block $compile_store.37 - (local.set $28 - (i32.load offset=12 - (local.get $18) - ) - ) - (block $do_backpatches.36 - ) - ) - (block $compile_store.39 - (local.set $29 - (i32.or - (i32.shl - (i32.eq - (local.get $28) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.38 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $29) - (i32.const 31) - ) - (block $compile_block.73 (result i32) - (block $compile_store.42 - (local.set $19 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $18) - ) - ) - ) - (block $do_backpatches.41 - ) - ) - (block $compile_store.44 - (local.set $20 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $18) - ) - ) - ) - (block $do_backpatches.43 - ) - ) - (block $compile_store.46 - (local.set $31 - (i32.load offset=12 - (local.get $20) - ) - ) - (block $do_backpatches.45 - ) - ) - (block $compile_store.48 - (local.set $32 - (i32.or - (i32.shl - (i32.eq - (local.get $31) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.47 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $32) - (i32.const 31) - ) - (block $compile_block.65 (result i32) - (block $compile_store.51 - (local.set $21 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $20) - ) - ) - ) - (block $do_backpatches.50 - ) - ) - (block $compile_store.53 - (local.set $22 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $20) - ) - ) - ) - (block $do_backpatches.52 - ) - ) - (block $compile_store.55 - (local.set $34 - (i32.load offset=12 - (local.get $22) - ) - ) - (block $do_backpatches.54 - ) - ) - (block $cleanup.56 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $22) - ) - ) - ) - (block $compile_store.58 - (local.set $35 - (i32.or - (i32.shl - (i32.eq - (local.get $34) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.57 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $35) - (i32.const 31) - ) - (block $compile_block.63 (result i32) - (drop - (block $compile_set.60 (result i32) - (local.set $14 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.61 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $19) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.62 (result i32) - (local.set $16 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $21) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.64 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.59 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.72 (result i32) - (block $compile_store.67 - (local.set $33 - (i32.or - (i32.shl - (i32.eq - (local.get $31) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.66 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $33) - (i32.const 31) - ) - (block $compile_block.70 (result i32) - (drop - (block $compile_set.68 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.69 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $19) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.71 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.49 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.79 (result i32) - (block $compile_store.75 - (local.set $30 - (i32.or - (i32.shl - (i32.eq - (local.get $28) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.74 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $30) - (i32.const 31) - ) - (block $compile_block.77 (result i32) - (drop - (block $compile_set.76 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.78 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.40 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.85 (result i32) - (block $compile_store.82 - (local.set $27 - (i32.or - (i32.shl - (i32.eq - (local.get $24) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.81 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $27) - (i32.const 31) - ) - (block $compile_block.83 (result i32) - (i32.const 1) - ) - (block $compile_block.84 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.86 - ) - ) - (block $cleanup.88 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.90_outer (result i32) - (block $switch.90_branch_0 (result i32) - (drop - (block $switch.90_branch_1 (result i32) - (drop - (block $switch.90_branch_2 (result i32) - (drop - (block $switch.90_branch_3 (result i32) - (drop - (block $switch.90_branch_4 (result i32) - (drop - (block $switch.90_branch_5 (result i32) - (drop - (block $switch.90_default (result i32) - (br_table $switch.90_branch_1 $switch.90_branch_2 $switch.90_branch_3 $switch.90_branch_4 $switch.90_branch_5 $switch.90_default $switch.90_default - (i32.const 0) - (i32.shr_s - (local.get $26) - (i32.const 1) - ) - ) - ) - ) - (br $switch.90_outer - (block $compile_block.100 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.90_outer - (block $compile_block.99 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.90_outer - (block $compile_block.98 - (block $compile_store.96 - (local.set $23 - (call $+_1151 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - ) - ) - (block $do_backpatches.95 - ) - ) - (block $cleanup.97 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - (return_call $+_1151 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) - ) - (local.get $23) - (local.get $16) - ) - ) - ) - ) - ) - (br $switch.90_outer - (block $compile_block.94 - (block $cleanup.93 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - (return_call $+_1151 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) - ) - (local.get $12) - (local.get $13) - ) - ) - ) - ) - ) - (br $switch.90_outer - (block $compile_block.92 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - ) - ) - ) - (br $switch.90_outer - (block $compile_block.91 (result i32) - (i32.const 1) - ) - ) - ) - ) - (block $cleanup.89 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1151) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1151) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 7))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 15 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 16 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 11 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 13 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 15 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 11 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 13 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1151) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1151 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 17 Managed) + ((instr_desc + (MCallKnown (func +_1151) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1151 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1151) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1151 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 18) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1154) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.e17bcd61.0.snapshot b/compiler/test/__snapshots__/pattern_matching.e17bcd61.0.snapshot index 36b12463d..2e078d462 100644 --- a/compiler/test/__snapshots__/pattern_matching.e17bcd61.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.e17bcd61.0.snapshot @@ -1,127 +1,68 @@ pattern matching › or_match_4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.14 (result i32) - (block $compile_store.2 - (local.set $6 - (i32.or - (i32.shl - (i32.eq - (i32.const -2) - (i32.const 2147483646) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.10 - (local.set $7 - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const 1) - ) - (block $compile_block.8 (result i32) - (block $compile_store.5 - (local.set $8 - (i32.or - (i32.shl - (i32.eq - (i32.const -2) - (i32.const -2) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.4 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $8) - (i32.const 31) - ) - (block $compile_block.6 (result i32) - (i32.const 1) - ) - (block $compile_block.7 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $switch.11_outer (result i32) - (block $switch.11_branch_0 (result i32) - (drop - (block $switch.11_branch_1 (result i32) - (drop - (block $switch.11_default (result i32) - (br_table $switch.11_branch_1 $switch.11_default $switch.11_default - (i32.const 0) - (i32.shr_s - (local.get $7) - (i32.const 1) - ) - ) - ) - ) - (br $switch.11_outer - (block $compile_block.13 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.11_outer - (block $compile_block.12 (result i32) - (i32.const 7) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 3) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1118) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot index 8d2cd1933..6bffceb37 100644 --- a/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot @@ -1,1303 +1,792 @@ pattern matching › tuple_match_deep5 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1155 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1155 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (local $34 i32) - (local $35 i32) - (local $36 i32) - (local $37 i32) - (local $38 i32) - (local $39 i32) - (local $40 i32) - (local $41 i32) - (local $42 i32) - (block $compile_block.120 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_tuple.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.15 - ) - ) - (block $compile_store.18 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.19 - ) - ) - (block $compile_store.22 - (local.set $14 - (i32.const 0) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.24 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.23 - ) - ) - (block $compile_store.26 - (local.set $16 - (i32.const 0) - ) - (block $do_backpatches.25 - ) - ) - (block $compile_store.28 - (local.set $17 - (i32.const 0) - ) - (block $do_backpatches.27 - ) - ) - (block $compile_store.30 - (local.set $18 - (i32.const 0) - ) - (block $do_backpatches.29 - ) - ) - (block $compile_store.32 - (local.set $19 - (i32.const 0) - ) - (block $do_backpatches.31 - ) - ) - (block $compile_store.34 - (local.set $20 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $9) - ) - ) - ) - (block $do_backpatches.33 - ) - ) - (block $compile_store.36 - (local.set $21 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $9) - ) - ) - ) - (block $do_backpatches.35 - ) - ) - (block $cleanup.37 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - (block $compile_store.39 - (local.set $31 - (i32.load offset=12 - (local.get $21) - ) - ) - (block $do_backpatches.38 - ) - ) - (block $compile_store.41 - (local.set $32 - (i32.or - (i32.shl - (i32.eq - (local.get $31) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.40 - ) - ) - (block $compile_store.101 - (local.set $33 - (if (result i32) - (i32.shr_u - (local.get $32) - (i32.const 31) - ) - (block $compile_block.93 (result i32) - (block $compile_store.43 - (local.set $22 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $21) - ) - ) - ) - (block $do_backpatches.42 - ) - ) - (block $compile_store.45 - (local.set $23 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $21) - ) - ) - ) - (block $do_backpatches.44 - ) - ) - (block $compile_store.47 - (local.set $35 - (i32.load offset=12 - (local.get $23) - ) - ) - (block $do_backpatches.46 - ) - ) - (block $compile_store.49 - (local.set $36 - (i32.or - (i32.shl - (i32.eq - (local.get $35) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.48 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $36) - (i32.const 31) - ) - (block $compile_block.85 (result i32) - (block $compile_store.52 - (local.set $24 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $23) - ) - ) - ) - (block $do_backpatches.51 - ) - ) - (block $compile_store.54 - (local.set $25 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $23) - ) - ) - ) - (block $do_backpatches.53 - ) - ) - (block $compile_store.56 - (local.set $38 - (i32.load offset=12 - (local.get $25) - ) - ) - (block $do_backpatches.55 - ) - ) - (block $compile_store.58 - (local.set $39 - (i32.or - (i32.shl - (i32.eq - (local.get $38) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.57 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $39) - (i32.const 31) - ) - (block $compile_block.76 (result i32) - (block $compile_store.61 - (local.set $26 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $25) - ) - ) - ) - (block $do_backpatches.60 - ) - ) - (block $compile_store.63 - (local.set $27 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $25) - ) - ) - ) - (block $do_backpatches.62 - ) - ) - (block $compile_store.65 - (local.set $41 - (i32.load offset=12 - (local.get $27) - ) - ) - (block $do_backpatches.64 - ) - ) - (block $cleanup.66 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $27) - ) - ) - ) - (block $compile_store.68 - (local.set $42 - (i32.or - (i32.shl - (i32.eq - (local.get $41) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.67 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $42) - (i32.const 31) - ) - (block $compile_block.74 (result i32) - (drop - (block $compile_set.70 (result i32) - (local.set $16 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.71 (result i32) - (local.set $17 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.72 (result i32) - (local.set $18 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $24) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.73 (result i32) - (local.set $19 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $26) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.75 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.69 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $26) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.84 (result i32) - (block $compile_store.78 - (local.set $40 - (i32.or - (i32.shl - (i32.eq - (local.get $38) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.77 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $40) - (i32.const 31) - ) - (block $compile_block.82 (result i32) - (drop - (block $compile_set.79 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.80 (result i32) - (local.set $14 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.81 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $24) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.83 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.59 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $24) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $25) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.92 (result i32) - (block $compile_store.87 - (local.set $37 - (i32.or - (i32.shl - (i32.eq - (local.get $35) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.86 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $37) - (i32.const 31) - ) - (block $compile_block.90 (result i32) - (drop - (block $compile_set.88 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.89 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.91 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.50 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $22) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $23) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.99 (result i32) - (block $compile_store.95 - (local.set $34 - (i32.or - (i32.shl - (i32.eq - (local.get $31) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.94 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $34) - (i32.const 31) - ) - (block $compile_block.97 (result i32) - (drop - (block $compile_set.96 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.98 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.100 - ) - ) - (block $cleanup.102 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.104_outer (result i32) - (block $switch.104_branch_0 (result i32) - (drop - (block $switch.104_branch_1 (result i32) - (drop - (block $switch.104_branch_2 (result i32) - (drop - (block $switch.104_branch_3 (result i32) - (drop - (block $switch.104_branch_4 (result i32) - (drop - (block $switch.104_branch_5 (result i32) - (drop - (block $switch.104_default (result i32) - (br_table $switch.104_branch_1 $switch.104_branch_2 $switch.104_branch_3 $switch.104_branch_4 $switch.104_branch_5 $switch.104_default $switch.104_default - (i32.const 0) - (i32.shr_s - (local.get $33) - (i32.const 1) - ) - ) - ) - ) - (br $switch.104_outer - (block $compile_block.119 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.104_outer - (block $compile_block.118 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.104_outer - (block $compile_block.117 - (block $compile_store.113 - (local.set $29 - (call $+_1155 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - ) - ) - (block $do_backpatches.112 - ) - ) - (block $compile_store.115 - (local.set $30 - (call $+_1155 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) - ) - (local.get $29) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - ) - ) - (block $do_backpatches.114 - ) - ) - (block $cleanup.116 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - ) - (return_call $+_1155 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) - ) - (local.get $30) - (local.get $19) - ) - ) - ) - ) - ) - (br $switch.104_outer - (block $compile_block.111 - (block $compile_store.109 - (local.set $28 - (call $+_1155 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - ) - ) - (block $do_backpatches.108 - ) - ) - (block $cleanup.110 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - ) - (return_call $+_1155 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) - ) - (local.get $28) - (local.get $15) - ) - ) - ) - ) - ) - (br $switch.104_outer - (block $compile_block.107 - (block $cleanup.106 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - ) - (return_call $+_1155 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) - ) - (local.get $11) - (local.get $12) - ) - ) - ) - ) - ) - (br $switch.104_outer - (block $compile_block.105 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - ) - ) - ) - (block $cleanup.103 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1155) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1155) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 15 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 16 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 17 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 18 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 19 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 20 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 21 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 14 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 16 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 12 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 18 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 13 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 20 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 14 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 16 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 18 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1155) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1155 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (2 + (((instr_desc + (MStore + (((MLocalBind 22 Managed) + ((instr_desc + (MCallKnown (func +_1155) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1155 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1155) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1155 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 22 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 23 Managed) + ((instr_desc + (MCallKnown (func +_1155) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1155 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 24 Managed) + ((instr_desc + (MCallKnown (func +_1155) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1155 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 23 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1155) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1155 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 24 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 25) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1160) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.eb4334e1.0.snapshot b/compiler/test/__snapshots__/pattern_matching.eb4334e1.0.snapshot index 5904371f3..c08ac43ea 100644 --- a/compiler/test/__snapshots__/pattern_matching.eb4334e1.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.eb4334e1.0.snapshot @@ -1,473 +1,267 @@ pattern matching › constant_match_4 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"GRAIN$EXPORT$equal\" (global $GRAIN$EXPORT$equal_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1126 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"equal\" (func $equal_0 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1126 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (block $compile_block.49 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (local.get $6) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $7) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $7) - ) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $cleanup.15 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (block $compile_store.18 - (local.set $12 - (block $allocate_string.16 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $13 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (local.get $10) - (local.get $12) - ) - ) - (block $do_backpatches.19 - ) - ) - (block $compile_store.40 - (local.set $14 - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.37 (result i32) - (drop - (block $compile_set.21 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.23 - (local.set $15 - (call $==_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (i32.const 15) - ) - ) - (block $do_backpatches.22 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $15) - (i32.const 31) - ) - (block $compile_block.25 (result i32) - (drop - (block $compile_set.24 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.36 (result i32) - (block $compile_store.27 - (local.set $16 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - (i32.const 19) - ) - ) - (block $do_backpatches.26 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $16) - (i32.const 31) - ) - (block $compile_block.28 (result i32) - (i32.const 3) - ) - (block $compile_block.35 (result i32) - (drop - (block $compile_set.29 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.31 - (local.set $17 - (call $==_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (i32.const 11) - ) - ) - (block $do_backpatches.30 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $17) - (i32.const 31) - ) - (block $compile_block.33 (result i32) - (drop - (block $compile_set.32 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.34 (result i32) - (i32.const 7) - ) - ) - ) - ) - ) - ) - ) - (block $compile_block.38 (result i32) - (i32.const 7) - ) - ) - ) - (block $do_backpatches.39 - ) - ) - (block $cleanup.41 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.43_outer (result i32) - (block $switch.43_branch_0 (result i32) - (drop - (block $switch.43_branch_1 (result i32) - (drop - (block $switch.43_branch_2 (result i32) - (drop - (block $switch.43_branch_3 (result i32) - (drop - (block $switch.43_branch_4 (result i32) - (drop - (block $switch.43_default (result i32) - (br_table $switch.43_branch_1 $switch.43_branch_2 $switch.43_branch_3 $switch.43_branch_4 $switch.43_default $switch.43_default - (i32.const 0) - (i32.shr_s - (local.get $14) - (i32.const 1) - ) - ) - ) - ) - (br $switch.43_outer - (block $compile_block.48 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.43_outer - (block $compile_block.47 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.43_outer - (block $compile_block.46 (result i32) - (i32.const -2) - ) - ) - ) - ) - (br $switch.43_outer - (block $compile_block.45 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.43_outer - (block $compile_block.44 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (block $cleanup.42 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1126) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1126) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1126 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 7))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 9))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (3 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32))))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 7) (stack_size_i32 5) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1135) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot b/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot index 2a8dc8d2f..a1dae6bae 100644 --- a/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot @@ -1,1389 +1,824 @@ pattern matching › tuple_match_deep7 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1159 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1159 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (local $34 i32) - (local $35 i32) - (local $36 i32) - (local $37 i32) - (local $38 i32) - (local $39 i32) - (local $40 i32) - (local $41 i32) - (local $42 i32) - (local $43 i32) - (local $44 i32) - (block $compile_block.126 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 15) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 13) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.18 - (local.set $11 - (block $allocate_tuple.16 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (local.get $10) - ) - (local.get $0) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.19 - ) - ) - (block $compile_store.22 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.24 - (local.set $14 - (i32.const 0) - ) - (block $do_backpatches.23 - ) - ) - (block $compile_store.26 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.25 - ) - ) - (block $compile_store.28 - (local.set $16 - (i32.const 0) - ) - (block $do_backpatches.27 - ) - ) - (block $compile_store.30 - (local.set $17 - (i32.const 0) - ) - (block $do_backpatches.29 - ) - ) - (block $compile_store.32 - (local.set $18 - (i32.const 0) - ) - (block $do_backpatches.31 - ) - ) - (block $compile_store.34 - (local.set $19 - (i32.const 0) - ) - (block $do_backpatches.33 - ) - ) - (block $compile_store.36 - (local.set $20 - (i32.const 0) - ) - (block $do_backpatches.35 - ) - ) - (block $compile_store.38 - (local.set $21 - (i32.const 0) - ) - (block $do_backpatches.37 - ) - ) - (block $compile_store.40 - (local.set $22 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $11) - ) - ) - ) - (block $do_backpatches.39 - ) - ) - (block $compile_store.42 - (local.set $23 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $11) - ) - ) - ) - (block $do_backpatches.41 - ) - ) - (block $cleanup.43 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - (block $compile_store.45 - (local.set $33 - (i32.load offset=12 - (local.get $23) - ) - ) - (block $do_backpatches.44 - ) - ) - (block $compile_store.47 - (local.set $34 - (i32.or - (i32.shl - (i32.eq - (local.get $33) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.46 - ) - ) - (block $compile_store.107 - (local.set $35 - (if (result i32) - (i32.shr_u - (local.get $34) - (i32.const 31) - ) - (block $compile_block.99 (result i32) - (block $compile_store.49 - (local.set $24 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $23) - ) - ) - ) - (block $do_backpatches.48 - ) - ) - (block $compile_store.51 - (local.set $25 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $23) - ) - ) - ) - (block $do_backpatches.50 - ) - ) - (block $compile_store.53 - (local.set $37 - (i32.load offset=12 - (local.get $25) - ) - ) - (block $do_backpatches.52 - ) - ) - (block $compile_store.55 - (local.set $38 - (i32.or - (i32.shl - (i32.eq - (local.get $37) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.54 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $38) - (i32.const 31) - ) - (block $compile_block.91 (result i32) - (block $compile_store.58 - (local.set $26 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $25) - ) - ) - ) - (block $do_backpatches.57 - ) - ) - (block $compile_store.60 - (local.set $27 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $25) - ) - ) - ) - (block $do_backpatches.59 - ) - ) - (block $compile_store.62 - (local.set $40 - (i32.load offset=12 - (local.get $27) - ) - ) - (block $do_backpatches.61 - ) - ) - (block $compile_store.64 - (local.set $41 - (i32.or - (i32.shl - (i32.eq - (local.get $40) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.63 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $41) - (i32.const 31) - ) - (block $compile_block.82 (result i32) - (block $compile_store.67 - (local.set $28 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $27) - ) - ) - ) - (block $do_backpatches.66 - ) - ) - (block $compile_store.69 - (local.set $29 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $27) - ) - ) - ) - (block $do_backpatches.68 - ) - ) - (block $compile_store.71 - (local.set $43 - (i32.load offset=12 - (local.get $29) - ) - ) - (block $do_backpatches.70 - ) - ) - (block $cleanup.72 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $29) - ) - ) - ) - (block $compile_store.74 - (local.set $44 - (i32.or - (i32.shl - (i32.eq - (local.get $43) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.73 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $44) - (i32.const 31) - ) - (block $compile_block.80 (result i32) - (drop - (block $compile_set.76 (result i32) - (local.set $18 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.77 (result i32) - (local.set $19 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $24) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.78 (result i32) - (local.set $20 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $26) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.79 (result i32) - (local.set $21 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $28) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.81 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.75 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $28) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.90 (result i32) - (block $compile_store.84 - (local.set $42 - (i32.or - (i32.shl - (i32.eq - (local.get $40) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.83 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $42) - (i32.const 31) - ) - (block $compile_block.88 (result i32) - (drop - (block $compile_set.85 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.86 (result i32) - (local.set $16 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $24) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.87 (result i32) - (local.set $17 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $26) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.89 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.65 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $26) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $27) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.98 (result i32) - (block $compile_store.93 - (local.set $39 - (i32.or - (i32.shl - (i32.eq - (local.get $37) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.92 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $39) - (i32.const 31) - ) - (block $compile_block.96 (result i32) - (drop - (block $compile_set.94 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.95 (result i32) - (local.set $14 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $24) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.97 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.56 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $24) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $25) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.105 (result i32) - (block $compile_store.101 - (local.set $36 - (i32.or - (i32.shl - (i32.eq - (local.get $33) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.100 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $36) - (i32.const 31) - ) - (block $compile_block.103 (result i32) - (drop - (block $compile_set.102 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.104 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.106 - ) - ) - (block $cleanup.108 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $22) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $23) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.110_outer (result i32) - (block $switch.110_branch_0 (result i32) - (drop - (block $switch.110_branch_1 (result i32) - (drop - (block $switch.110_branch_2 (result i32) - (drop - (block $switch.110_branch_3 (result i32) - (drop - (block $switch.110_branch_4 (result i32) - (drop - (block $switch.110_branch_5 (result i32) - (drop - (block $switch.110_default (result i32) - (br_table $switch.110_branch_1 $switch.110_branch_2 $switch.110_branch_3 $switch.110_branch_4 $switch.110_branch_5 $switch.110_default $switch.110_default - (i32.const 0) - (i32.shr_s - (local.get $35) - (i32.const 1) - ) - ) - ) - ) - (br $switch.110_outer - (block $compile_block.125 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.110_outer - (block $compile_block.124 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.110_outer - (block $compile_block.123 - (block $compile_store.119 - (local.set $31 - (call $+_1159 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $19) - ) - ) - ) - (block $do_backpatches.118 - ) - ) - (block $compile_store.121 - (local.set $32 - (call $+_1159 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) - ) - (local.get $31) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - ) - ) - (block $do_backpatches.120 - ) - ) - (block $cleanup.122 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - ) - (return_call $+_1159 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) - ) - (local.get $32) - (local.get $21) - ) - ) - ) - ) - ) - (br $switch.110_outer - (block $compile_block.117 - (block $compile_store.115 - (local.set $30 - (call $+_1159 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - ) - ) - (block $do_backpatches.114 - ) - ) - (block $cleanup.116 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - ) - (return_call $+_1159 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) - ) - (local.get $30) - (local.get $17) - ) - ) - ) - ) - ) - (br $switch.110_outer - (block $compile_block.113 - (block $cleanup.112 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - ) - (return_call $+_1159 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) - ) - (local.get $13) - (local.get $14) - ) - ) - ) - ) - ) - (br $switch.110_outer - (block $compile_block.111 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - ) - ) - ) - (block $cleanup.109 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1159) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1159) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 7))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 15 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 16 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 17 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 18 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 19 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 20 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 21 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 22 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 23 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 23 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 23 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 12 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 16 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 13 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 18 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 14 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 20 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 15 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 22 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 22 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 16 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 18 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 20 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1159) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1159 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (2 + (((instr_desc + (MStore + (((MLocalBind 24 Managed) + ((instr_desc + (MCallKnown (func +_1159) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1159 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1159) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1159 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 24 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 25 Managed) + ((instr_desc + (MCallKnown (func +_1159) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1159 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 26 Managed) + ((instr_desc + (MCallKnown (func +_1159) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1159 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 25 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1159) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1159 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 26 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 27) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1164) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.f25e0163.0.snapshot b/compiler/test/__snapshots__/pattern_matching.f25e0163.0.snapshot index efc203dd1..01893af2e 100644 --- a/compiler/test/__snapshots__/pattern_matching.f25e0163.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.f25e0163.0.snapshot @@ -1,579 +1,339 @@ pattern matching › or_match_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (block $compile_block.65 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $14 - (i32.load offset=12 - (local.get $7) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $15 - (i32.or - (i32.shl - (i32.eq - (local.get $14) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.58 - (local.set $16 - (if (result i32) - (i32.shr_u - (local.get $15) - (i32.const 31) - ) - (block $compile_block.55 (result i32) - (block $compile_store.14 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $7) - ) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $7) - ) - ) - ) - (block $do_backpatches.15 - ) - ) - (block $compile_store.18 - (local.set $17 - (i32.load offset=12 - (local.get $10) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $18 - (i32.or - (i32.shl - (i32.eq - (local.get $17) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.19 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $18) - (i32.const 31) - ) - (block $compile_block.48 (result i32) - (block $compile_store.23 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $10) - ) - ) - ) - (block $do_backpatches.22 - ) - ) - (block $compile_store.25 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $10) - ) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $20 - (i32.load offset=12 - (local.get $12) - ) - ) - (block $do_backpatches.26 - ) - ) - (block $compile_store.29 - (local.set $21 - (i32.or - (i32.shl - (i32.eq - (local.get $20) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.28 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $21) - (i32.const 31) - ) - (block $compile_block.41 (result i32) - (block $compile_store.32 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $12) - ) - ) - ) - (block $do_backpatches.31 - ) - ) - (block $compile_store.34 - (local.set $23 - (i32.load offset=12 - (local.get $13) - ) - ) - (block $do_backpatches.33 - ) - ) - (block $cleanup.35 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - (block $compile_store.37 - (local.set $24 - (i32.or - (i32.shl - (i32.eq - (local.get $23) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.36 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $24) - (i32.const 31) - ) - (block $compile_block.39 (result i32) - (drop - (block $compile_set.38 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.40 (result i32) - (i32.const 3) - ) - ) - ) - (block $compile_block.47 (result i32) - (block $compile_store.43 - (local.set $22 - (i32.or - (i32.shl - (i32.eq - (local.get $20) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.42 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $22) - (i32.const 31) - ) - (block $compile_block.45 (result i32) - (drop - (block $compile_set.44 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.46 (result i32) - (i32.const 3) - ) - ) - ) - ) - (block $cleanup.30 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.54 (result i32) - (block $compile_store.50 - (local.set $19 - (i32.or - (i32.shl - (i32.eq - (local.get $17) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.49 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $19) - (i32.const 31) - ) - (block $compile_block.52 (result i32) - (drop - (block $compile_set.51 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.53 (result i32) - (i32.const 3) - ) - ) - ) - ) - (block $cleanup.21 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.56 (result i32) - (i32.const 3) - ) - ) - ) - (block $do_backpatches.57 - ) - ) - (block $cleanup.59 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.61_outer (result i32) - (block $switch.61_branch_0 (result i32) - (drop - (block $switch.61_branch_1 (result i32) - (drop - (block $switch.61_branch_2 (result i32) - (drop - (block $switch.61_default (result i32) - (br_table $switch.61_branch_1 $switch.61_branch_2 $switch.61_default $switch.61_default - (i32.const 0) - (i32.shr_s - (local.get $16) - (i32.const 1) - ) - ) - ) - ) - (br $switch.61_outer - (block $compile_block.64 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.61_outer - (block $compile_block.63 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.61_outer - (block $compile_block.62 (result i32) - (i32.const -2) - ) - ) - ) - ) - (block $cleanup.60 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 5 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 0))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 3 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 0))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32))))) + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 8) (stack_size_i32 11) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1140) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.f3d48b0e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.f3d48b0e.0.snapshot index a84858cc7..f01296df5 100644 --- a/compiler/test/__snapshots__/pattern_matching.f3d48b0e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.f3d48b0e.0.snapshot @@ -1,127 +1,68 @@ pattern matching › or_match_1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.14 (result i32) - (block $compile_store.2 - (local.set $6 - (i32.or - (i32.shl - (i32.eq - (i32.const -2) - (i32.const 2147483646) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.10 - (local.set $7 - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const 1) - ) - (block $compile_block.8 (result i32) - (block $compile_store.5 - (local.set $8 - (i32.or - (i32.shl - (i32.eq - (i32.const -2) - (i32.const -2) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.4 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $8) - (i32.const 31) - ) - (block $compile_block.6 (result i32) - (i32.const 1) - ) - (block $compile_block.7 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $switch.11_outer (result i32) - (block $switch.11_branch_0 (result i32) - (drop - (block $switch.11_branch_1 (result i32) - (drop - (block $switch.11_default (result i32) - (br_table $switch.11_branch_1 $switch.11_default $switch.11_default - (i32.const 0) - (i32.shr_s - (local.get $7) - (i32.const 1) - ) - ) - ) - ) - (br $switch.11_outer - (block $compile_block.13 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.11_outer - (block $compile_block.12 (result i32) - (i32.const 7) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 3) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1118) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/pattern_matching.f6c9c89c.0.snapshot b/compiler/test/__snapshots__/pattern_matching.f6c9c89c.0.snapshot index d8eaa83cb..906a67584 100644 --- a/compiler/test/__snapshots__/pattern_matching.f6c9c89c.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.f6c9c89c.0.snapshot @@ -1,325 +1,191 @@ pattern matching › or_match_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"GRAIN$EXPORT$equal\" (global $GRAIN$EXPORT$equal_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"equal\" (func $equal_0 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (block $compile_block.37 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $8 - (i32.load offset=12 - (local.get $6) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $9 - (i32.or - (i32.shl - (i32.eq - (local.get $8) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.30 - (local.set $10 - (if (result i32) - (i32.shr_u - (local.get $9) - (i32.const 31) - ) - (block $compile_block.8 (result i32) - (i32.const 3) - ) - (block $compile_block.28 (result i32) - (block $compile_store.10 - (local.set $11 - (i32.or - (i32.shl - (i32.eq - (local.get $8) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.9 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $11) - (i32.const 31) - ) - (block $compile_block.26 (result i32) - (block $compile_store.12 - (local.set $7 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $12 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 7) - ) - ) - (block $do_backpatches.13 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $12) - (i32.const 31) - ) - (block $compile_block.16 (result i32) - (i32.const 1) - ) - (block $compile_block.25 (result i32) - (block $compile_store.18 - (local.set $13 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 9) - ) - ) - (block $do_backpatches.17 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.19 (result i32) - (i32.const 1) - ) - (block $compile_block.24 (result i32) - (block $compile_store.21 - (local.set $14 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 11) - ) - ) - (block $do_backpatches.20 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $14) - (i32.const 31) - ) - (block $compile_block.22 (result i32) - (i32.const 3) - ) - (block $compile_block.23 (result i32) - (i32.const 5) - ) - ) - ) - ) - ) - ) - (block $cleanup.15 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.27 (result i32) - (i32.const 5) - ) - ) - ) - ) - ) - (block $do_backpatches.29 - ) - ) - (block $cleanup.31 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (block $switch.32_outer (result i32) - (block $switch.32_branch_0 (result i32) - (drop - (block $switch.32_branch_1 (result i32) - (drop - (block $switch.32_branch_2 (result i32) - (drop - (block $switch.32_branch_3 (result i32) - (drop - (block $switch.32_default (result i32) - (br_table $switch.32_branch_1 $switch.32_branch_2 $switch.32_branch_3 $switch.32_default $switch.32_default - (i32.const 0) - (i32.shr_s - (local.get $10) - (i32.const 1) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.36 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.35 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.34 (result i32) - (i32.const -2) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.33 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstI32 5))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32)))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 7) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1128) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/provides.0ef7e7b3.0.snapshot b/compiler/test/__snapshots__/provides.0ef7e7b3.0.snapshot index abec48340..96f45ca76 100644 --- a/compiler/test/__snapshots__/provides.0ef7e7b3.0.snapshot +++ b/compiler/test/__snapshots__/provides.0ef7e7b3.0.snapshot @@ -1,36 +1,18 @@ provides › provide7 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1122 (mut i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (global.get $x_1122) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((functions ()) + (imports + (((mimp_id ((stamp 1122) (name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind x_1122 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1123) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/provides.10f4f118.0.snapshot b/compiler/test/__snapshots__/provides.10f4f118.0.snapshot index 15e820e4f..52660b1da 100644 --- a/compiler/test/__snapshots__/provides.10f4f118.0.snapshot +++ b/compiler/test/__snapshots__/provides.10f4f118.0.snapshot @@ -1,50 +1,36 @@ provides › provide9 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$z\" (global $z_1123 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$y\" (global $y_1122 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"y\" (func $y_1122 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $y_1122 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $y_1122) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $z_1123) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((functions ()) + (imports + (((mimp_id ((stamp 1123) (name z))) (mimp_mod provideAll.gr) (mimp_name z) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((stamp 1122) (name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1122) (name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func y_1122) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind y_1122 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind z_1123 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1124) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/provides.2a5f527b.0.snapshot b/compiler/test/__snapshots__/provides.2a5f527b.0.snapshot index ce34cf02e..cdbb52a1b 100644 --- a/compiler/test/__snapshots__/provides.2a5f527b.0.snapshot +++ b/compiler/test/__snapshots__/provides.2a5f527b.0.snapshot @@ -1,45 +1,24 @@ provides › multiple_provides_8 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"GRAIN$EXPORT$bar\" (global $foo_1113)) - (export \"GRAIN$EXPORT$foo\" (global $foo_1113)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.3 (result i32) - (block $compile_store.2 - (global.set $foo_1113 - (i32.const 3) - ) - (block $do_backpatches.1 - ) - ) - (i32.const 1879048190) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1435 -) +((functions ()) (imports ()) + (exports + ((WasmGlobalExport (ex_global_name bar) (ex_global_internal_name foo_1113)) + (WasmGlobalExport (ex_global_name foo) (ex_global_internal_name foo_1113)))) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((stamp 1113) (name foo)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/provides.30cbc409.0.snapshot b/compiler/test/__snapshots__/provides.30cbc409.0.snapshot index 2da57f3f2..e985f358f 100644 --- a/compiler/test/__snapshots__/provides.30cbc409.0.snapshot +++ b/compiler/test/__snapshots__/provides.30cbc409.0.snapshot @@ -1,213 +1,110 @@ provides › provide_start_function -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1115 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1115 (param i32 i32 i32) (result i32))) - (global $_start_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_start\" (func $_start_1113)) - (export \"GRAIN$EXPORT$_start\" (global $_start_1113)) - (export \"_gmain\" (func $_gmain)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_start_1113 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (local $7 i32) - (local $8 i32) - (block $compile_block.8 - (block $compile_store.3 - (local.set $7 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $1) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $1) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $1) - (i32.const 0) - ) - (local.get $1) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $8 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 11) - ) - (i64.store offset=8 - (local.get $1) - (i64.const 7453010382200861811) - ) - (i64.store offset=16 - (local.get $1) - (i64.const 7370016) - ) - (local.get $1) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $cleanup.7 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $print_1115 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1115) - ) - (local.get $8) - (local.get $7) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.17 (result i32) - (block $compile_store.11 - (local.set $6 - (block $allocate_adt.9 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.14 - (local.set $7 - (block $allocate_string.12 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 1953066601) - ) - (local.get $0) - ) - ) - (block $do_backpatches.13 - ) - ) - (drop - (call $print_1115 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1115) - ) - (local.get $7) - (local.get $6) - ) - ) - (block $compile_store.16 - (global.set $_start_1113 - (i32.const 0) - ) - (block $do_backpatches.15 - ) - ) - (i32.const 1879048190) - ) - ) - ;; custom section \"cmi\", size 1021 -) +((functions + (((id ((stamp 1113) (name _start))) (name (_start)) (args (Managed)) + (return_type ((Unmanaged WasmI32))) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc (MAllocate (MString \"starting up\"))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func print_1115) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((stamp 1115) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1115) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports + ((WasmFunctionExport (ex_function_name _start) + (ex_function_internal_name _start_1113)) + (WasmGlobalExport (ex_global_name _start) + (ex_global_internal_name _start_1113)))) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MString init))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1115) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind _start_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((stamp 1113) (name _start)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1120) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/provides.82c10ab4.0.snapshot b/compiler/test/__snapshots__/provides.82c10ab4.0.snapshot index 10189488d..90bc3f9b8 100644 --- a/compiler/test/__snapshots__/provides.82c10ab4.0.snapshot +++ b/compiler/test/__snapshots__/provides.82c10ab4.0.snapshot @@ -1,186 +1,91 @@ provides › provide12 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1203 (mut i32))) - (import \"GRAIN$MODULE$providedType.gr\" \"GRAIN$EXPORT$apply\" (global $apply_1201 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1203 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$providedType.gr\" \"apply\" (func $apply_1201 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 1)) - (memory $0 0) - (elem $elem (global.get $relocBase_0) $lam_lambda_1202) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $lam_lambda_1202 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (local $8 i32) - (local $9 i32) - (block $closure_elements.17 - (block $compile_block.16 - (block $compile_store.11 - (local.set $8 - (block $allocate_adt.9 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $2) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $2) - (i32.const 0) - ) - (local.get $2) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.14 - (local.set $9 - (block $allocate_string.12 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 2) - ) - (i64.store offset=8 - (local.get $2) - (i64.const 27503) - ) - (local.get $2) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $cleanup.15 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - ) - (return_call $print_1203 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1203) - ) - (local.get $9) - (local.get $8) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.21 - (block $compile_store.20 - (local.set $6 - (block $allocate_closure.18 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.add - (global.get $relocBase_0) - (i32.const 0) - ) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.19 - (local.set $0 - (local.get $6) - ) - ) - ) - (return_call $apply_1201 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $apply_1201) - ) - (local.get $6) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 423 -) +((functions + (((id ((stamp 1202) (name lam_lambda))) (name ()) (args (Managed Managed)) + (return_type ((Unmanaged WasmI32))) (closure (0)) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MString ok))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func print_1203) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1203 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((stamp 1203) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1203) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((stamp 1201) (name apply))) (mimp_mod providedType.gr) + (mimp_name apply) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1201) (name apply))) (mimp_mod providedType.gr) + (mimp_name apply) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MClosure + ((func_idx (0)) (global_offset function_table_global_1207) + (arity 2) (variables ()))))))))))) + ((instr_desc + (MReturnCallKnown (func apply_1201) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind apply_1201 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements (lam_lambda_1202)) + (global_function_table_offset ((stamp 1207) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/provides.c3bb4eff.0.snapshot b/compiler/test/__snapshots__/provides.c3bb4eff.0.snapshot index bb49a490e..1072c16e2 100644 --- a/compiler/test/__snapshots__/provides.c3bb4eff.0.snapshot +++ b/compiler/test/__snapshots__/provides.c3bb4eff.0.snapshot @@ -1,68 +1,61 @@ provides › provide8 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$y\" (global $y_1125 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1123 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1122 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"y\" (func $y_1125 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1122 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.3 - (block $compile_store.2 - (local.set $6 - (call $y_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $y_1125) - ) - (i32.const 9) - ) - ) - (block $do_backpatches.1 - ) - ) - (return_call $+_1122 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1122) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $x_1123) - ) - (local.get $6) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((functions ()) + (imports + (((mimp_id ((stamp 1125) (name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1125) (name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((stamp 1123) (name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((stamp 1122) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1122) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func y_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind y_1125 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func +_1122) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1122 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind x_1123 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1127) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/provides.c6bf4567.0.snapshot b/compiler/test/__snapshots__/provides.c6bf4567.0.snapshot index 69c76d999..fe2aff9aa 100644 --- a/compiler/test/__snapshots__/provides.c6bf4567.0.snapshot +++ b/compiler/test/__snapshots__/provides.c6bf4567.0.snapshot @@ -1,73 +1,41 @@ provides › let_rec_provide -(module - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"foo\" (func $foo_1113)) - (export \"GRAIN$EXPORT$foo\" (global $foo_1113)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (i32.const 11) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.5 (result i32) - (block $compile_store.4 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (i32.const 1879048190) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1005 -) +((functions + (((id ((stamp 1113) (name foo))) (name (foo)) (args (Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) + (exports + ((WasmFunctionExport (ex_function_name foo) + (ex_function_internal_name foo_1113)) + (WasmGlobalExport (ex_global_name foo) (ex_global_internal_name foo_1113)))) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((stamp 1113) (name foo)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/provides.f378d570.0.snapshot b/compiler/test/__snapshots__/provides.f378d570.0.snapshot index 13ab88e83..a4baa325b 100644 --- a/compiler/test/__snapshots__/provides.f378d570.0.snapshot +++ b/compiler/test/__snapshots__/provides.f378d570.0.snapshot @@ -1,36 +1,18 @@ provides › provide4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$onlyXProvided.gr\" \"GRAIN$EXPORT$x\" (global $x_1116 (mut i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (global.get $x_1116) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 424 -) +((functions ()) + (imports + (((mimp_id ((stamp 1116) (name x))) (mimp_mod onlyXProvided.gr) + (mimp_name x) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind x_1116 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.012b017b.0.snapshot b/compiler/test/__snapshots__/records.012b017b.0.snapshot index 789b61a65..a41dcea52 100644 --- a/compiler/test/__snapshots__/records.012b017b.0.snapshot +++ b/compiler/test/__snapshots__/records.012b017b.0.snapshot @@ -1,35 +1,13 @@ records › record_spread_2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 1879048190) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 562 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1122) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.02742729.0.snapshot b/compiler/test/__snapshots__/records.02742729.0.snapshot index 55c1d7fc9..55e351521 100644 --- a/compiler/test/__snapshots__/records.02742729.0.snapshot +++ b/compiler/test/__snapshots__/records.02742729.0.snapshot @@ -1,125 +1,67 @@ records › record_get_multiple -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1118 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1118 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.9 - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 447924047) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 19) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $cleanup.8 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (return_call $+_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1118) - ) - (local.get $7) - (local.get $8) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 562 -) +((functions ()) + (imports + (((mimp_id ((stamp 1118) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1118) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 223962023))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstI32 9))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MRecordOp (MRecordGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1118 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1121) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.02af5946.0.snapshot b/compiler/test/__snapshots__/records.02af5946.0.snapshot index e3087d5ed..43d718a36 100644 --- a/compiler/test/__snapshots__/records.02af5946.0.snapshot +++ b/compiler/test/__snapshots__/records.02af5946.0.snapshot @@ -1,65 +1,19 @@ records › record_definition_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1272 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.2dc39420.0.snapshot b/compiler/test/__snapshots__/records.2dc39420.0.snapshot index 2e4b2a5e8..aa6a9f988 100644 --- a/compiler/test/__snapshots__/records.2dc39420.0.snapshot +++ b/compiler/test/__snapshots__/records.2dc39420.0.snapshot @@ -1,65 +1,19 @@ records › record_pun -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1208 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.49dfc6ff.0.snapshot b/compiler/test/__snapshots__/records.49dfc6ff.0.snapshot index beda98bf0..0edcf705e 100644 --- a/compiler/test/__snapshots__/records.49dfc6ff.0.snapshot +++ b/compiler/test/__snapshots__/records.49dfc6ff.0.snapshot @@ -1,160 +1,62 @@ records › record_destruct_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $foo_1114 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.13 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (global.set $foo_1114 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $cleanup.11 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (drop - (block $compile_set.12 (result i32) - (global.set $foo_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $foo_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (global.get $foo_1114) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind foo_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind foo_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind foo_1114 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((stamp 1114) (name foo)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1123) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.54f5977c.0.snapshot b/compiler/test/__snapshots__/records.54f5977c.0.snapshot index 8c1a0c3d5..6e45e65d7 100644 --- a/compiler/test/__snapshots__/records.54f5977c.0.snapshot +++ b/compiler/test/__snapshots__/records.54f5977c.0.snapshot @@ -1,247 +1,154 @@ records › record_destruct_4 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1126 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1126 (param i32 i32 i32) (result i32))) - (global $bar_1115 (mut i32) (i32.const 0)) - (global $foo_1114 (mut i32) (i32.const 0)) - (global $baz_1116 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (block $compile_block.22 - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (i32.const 13) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (global.set $foo_1114 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (global.set $bar_1115 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (global.set $baz_1116 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $7 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $6) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $cleanup.16 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.17 (result i32) - (global.set $baz_1116 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $baz_1116) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.18 (result i32) - (global.set $bar_1115 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $bar_1115) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.19 (result i32) - (global.set $foo_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $foo_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.21 - (local.set $10 - (call $+_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1114) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $bar_1115) - ) - ) - ) - (block $do_backpatches.20 - ) - ) - (return_call $+_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1126) - ) - (local.get $10) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $baz_1116) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((functions ()) + (imports + (((mimp_id ((stamp 1126) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1126) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))) + ((baz) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind foo_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind bar_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind baz_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MRecordOp (MRecordGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MRecordOp (MRecordGet 2) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind baz_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind bar_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind foo_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MCallKnown (func +_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1126 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind foo_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind bar_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func +_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind baz_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 5) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + ((((stamp 1115) (name bar)) true Managed ()) + (((stamp 1114) (name foo)) true Managed ()) + (((stamp 1116) (name baz)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1128) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.5f340064.0.snapshot b/compiler/test/__snapshots__/records.5f340064.0.snapshot index 0d2e67f59..2afd99faa 100644 --- a/compiler/test/__snapshots__/records.5f340064.0.snapshot +++ b/compiler/test/__snapshots__/records.5f340064.0.snapshot @@ -1,65 +1,19 @@ records › record_value_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1252 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.60c0a141.0.snapshot b/compiler/test/__snapshots__/records.60c0a141.0.snapshot index 7c405aa26..fd68454ca 100644 --- a/compiler/test/__snapshots__/records.60c0a141.0.snapshot +++ b/compiler/test/__snapshots__/records.60c0a141.0.snapshot @@ -1,316 +1,113 @@ records › record_recursive_data_definition -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (block $compile_block.24 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 610197211) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_record.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=20 - (local.get $0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.18 - (local.set $12 - (block $record_set.16 (result i32) - (i32.store offset=16 - (local.get $7) - (tuple.extract 0 - (tuple.make - (local.get $10) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.21 - (local.set $11 - (block $allocate_adt.19 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=20 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.20 - ) - ) - (tuple.extract 0 - (tuple.make - (block $record_set.23 (result i32) - (i32.store offset=16 - (local.get $9) - (tuple.extract 0 - (tuple.make - (local.get $11) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=16 - (local.get $9) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - (block $cleanup.22 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 606 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 305098605))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + (((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MRecordOp + (MRecordSet 0 + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MRecordOp + (MRecordSet 0 + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 6) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1125) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.60c7acc4.0.snapshot b/compiler/test/__snapshots__/records.60c7acc4.0.snapshot index 2652845e5..c42524f49 100644 --- a/compiler/test/__snapshots__/records.60c7acc4.0.snapshot +++ b/compiler/test/__snapshots__/records.60c7acc4.0.snapshot @@ -1,69 +1,22 @@ records › record_pun_mixed_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 447924047) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 2147483646) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1702 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 223962023))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.63a951b8.0.snapshot b/compiler/test/__snapshots__/records.63a951b8.0.snapshot index b55a5d821..641f2c1f9 100644 --- a/compiler/test/__snapshots__/records.63a951b8.0.snapshot +++ b/compiler/test/__snapshots__/records.63a951b8.0.snapshot @@ -1,160 +1,62 @@ records › record_destruct_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $bar_1114 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.13 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (global.set $bar_1114 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $7) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $cleanup.11 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (drop - (block $compile_set.12 (result i32) - (global.set $bar_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $bar_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (global.get $bar_1114) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind bar_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MRecordOp (MRecordGet 1) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind bar_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind bar_1114 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((stamp 1114) (name bar)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1123) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.89d08e01.0.snapshot b/compiler/test/__snapshots__/records.89d08e01.0.snapshot index 6d79ebb27..2da461001 100644 --- a/compiler/test/__snapshots__/records.89d08e01.0.snapshot +++ b/compiler/test/__snapshots__/records.89d08e01.0.snapshot @@ -1,65 +1,19 @@ records › record_pun_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1244 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.98824516.0.snapshot b/compiler/test/__snapshots__/records.98824516.0.snapshot index b5995c044..7cffabb69 100644 --- a/compiler/test/__snapshots__/records.98824516.0.snapshot +++ b/compiler/test/__snapshots__/records.98824516.0.snapshot @@ -1,181 +1,77 @@ records › record_destruct_deep -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $foo_1115 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.16 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 610197211) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (global.set $foo_1115 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $cleanup.11 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (block $compile_store.13 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $8) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $cleanup.14 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - (drop - (block $compile_set.15 (result i32) - (global.set $foo_1115 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $foo_1115) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (global.get $foo_1115) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 606 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 305098605))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + (((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind foo_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind foo_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind foo_1115 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ((((stamp 1115) (name foo)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1124) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.a3299dd2.0.snapshot b/compiler/test/__snapshots__/records.a3299dd2.0.snapshot index 5fd798c84..cd12ed637 100644 --- a/compiler/test/__snapshots__/records.a3299dd2.0.snapshot +++ b/compiler/test/__snapshots__/records.a3299dd2.0.snapshot @@ -1,189 +1,109 @@ records › record_destruct_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1125 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1125 (param i32 i32 i32) (result i32))) - (global $bar_1115 (mut i32) (i32.const 0)) - (global $foo_1114 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.15 - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (i32.const 13) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (global.set $foo_1114 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (global.set $bar_1115 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $7 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $cleanup.12 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.13 (result i32) - (global.set $bar_1115 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $bar_1115) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.14 (result i32) - (global.set $foo_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $foo_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (return_call $+_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1125) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1114) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $bar_1115) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((functions ()) + (imports + (((mimp_id ((stamp 1125) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1125) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))) + ((baz) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind foo_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind bar_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MRecordOp (MRecordGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind bar_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind foo_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MReturnCallKnown (func +_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1125 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind bar_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + ((((stamp 1115) (name bar)) true Managed ()) + (((stamp 1114) (name foo)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1126) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.a702778a.0.snapshot b/compiler/test/__snapshots__/records.a702778a.0.snapshot index 2da4a3d91..ecbb85b4d 100644 --- a/compiler/test/__snapshots__/records.a702778a.0.snapshot +++ b/compiler/test/__snapshots__/records.a702778a.0.snapshot @@ -1,155 +1,57 @@ records › record_get_multilevel -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.11 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 447924047) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 19) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1956346849) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - (block $do_backpatches.7 - ) - ) - (block $cleanup.9 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $8) - ) - ) - (block $cleanup.10 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 682 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 223962023))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstI32 9))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 978173424))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + (((baz) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MRecordOp (MRecordGet 1) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1122) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.a9c472b1.0.snapshot b/compiler/test/__snapshots__/records.a9c472b1.0.snapshot index 4cc32e711..f04e315e8 100644 --- a/compiler/test/__snapshots__/records.a9c472b1.0.snapshot +++ b/compiler/test/__snapshots__/records.a9c472b1.0.snapshot @@ -1,100 +1,28 @@ records › record_multiple_fields_definition_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 2279 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.b50d234d.0.snapshot b/compiler/test/__snapshots__/records.b50d234d.0.snapshot index debc2f64e..58a84fd0c 100644 --- a/compiler/test/__snapshots__/records.b50d234d.0.snapshot +++ b/compiler/test/__snapshots__/records.b50d234d.0.snapshot @@ -1,95 +1,30 @@ records › record_get_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - (block $cleanup.4 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 486 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.d34c4740.0.snapshot b/compiler/test/__snapshots__/records.d34c4740.0.snapshot index 1dbe4be57..c4fcda791 100644 --- a/compiler/test/__snapshots__/records.d34c4740.0.snapshot +++ b/compiler/test/__snapshots__/records.d34c4740.0.snapshot @@ -1,69 +1,22 @@ records › record_pun_mixed -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 447924047) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 2147483646) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1648 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 223962023))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.d393173c.0.snapshot b/compiler/test/__snapshots__/records.d393173c.0.snapshot index 983becb25..8b29b9c97 100644 --- a/compiler/test/__snapshots__/records.d393173c.0.snapshot +++ b/compiler/test/__snapshots__/records.d393173c.0.snapshot @@ -1,247 +1,154 @@ records › record_destruct_trailing -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1126 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1126 (param i32 i32 i32) (result i32))) - (global $bar_1115 (mut i32) (i32.const 0)) - (global $foo_1114 (mut i32) (i32.const 0)) - (global $baz_1116 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (block $compile_block.22 - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (i32.const 13) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (global.set $foo_1114 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (global.set $bar_1115 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (global.set $baz_1116 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $7 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $6) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $cleanup.16 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.17 (result i32) - (global.set $baz_1116 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $baz_1116) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.18 (result i32) - (global.set $bar_1115 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $bar_1115) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.19 (result i32) - (global.set $foo_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $foo_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.21 - (local.set $10 - (call $+_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1114) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $bar_1115) - ) - ) - ) - (block $do_backpatches.20 - ) - ) - (return_call $+_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1126) - ) - (local.get $10) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $baz_1116) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((functions ()) + (imports + (((mimp_id ((stamp 1126) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1126) (name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))) + ((baz) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind foo_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind bar_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind baz_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MRecordOp (MRecordGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MRecordOp (MRecordGet 2) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind baz_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind bar_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind foo_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MCallKnown (func +_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1126 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind foo_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind bar_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func +_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind baz_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 5) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + ((((stamp 1115) (name bar)) true Managed ()) + (((stamp 1114) (name foo)) true Managed ()) + (((stamp 1116) (name baz)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1128) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.d44e8007.0.snapshot b/compiler/test/__snapshots__/records.d44e8007.0.snapshot index e58a07ab5..a046d5547 100644 --- a/compiler/test/__snapshots__/records.d44e8007.0.snapshot +++ b/compiler/test/__snapshots__/records.d44e8007.0.snapshot @@ -1,69 +1,22 @@ records › record_pun_mixed_2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 447924047) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 2147483646) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1660 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 223962023))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.e4326567.0.snapshot b/compiler/test/__snapshots__/records.e4326567.0.snapshot index edabd34e9..a3733108b 100644 --- a/compiler/test/__snapshots__/records.e4326567.0.snapshot +++ b/compiler/test/__snapshots__/records.e4326567.0.snapshot @@ -1,100 +1,28 @@ records › record_multiple_fields_both_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 2231 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.e5b56da8.0.snapshot b/compiler/test/__snapshots__/records.e5b56da8.0.snapshot index 312fe16b2..5e2e536e2 100644 --- a/compiler/test/__snapshots__/records.e5b56da8.0.snapshot +++ b/compiler/test/__snapshots__/records.e5b56da8.0.snapshot @@ -1,65 +1,19 @@ records › record_both_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1248 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.e705a980.0.snapshot b/compiler/test/__snapshots__/records.e705a980.0.snapshot index 932be8528..b80468e2b 100644 --- a/compiler/test/__snapshots__/records.e705a980.0.snapshot +++ b/compiler/test/__snapshots__/records.e705a980.0.snapshot @@ -1,69 +1,22 @@ records › record_pun_multiple -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 447924047) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 2147483646) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1666 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 223962023))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1118) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.f6e43cdb.0.snapshot b/compiler/test/__snapshots__/records.f6e43cdb.0.snapshot index 8a6e10a22..28930fb9c 100644 --- a/compiler/test/__snapshots__/records.f6e43cdb.0.snapshot +++ b/compiler/test/__snapshots__/records.f6e43cdb.0.snapshot @@ -1,69 +1,22 @@ records › record_pun_multiple_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 447924047) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 2147483646) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1720 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 223962023))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1118) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.f6feee77.0.snapshot b/compiler/test/__snapshots__/records.f6feee77.0.snapshot index ed098ed63..41d4a77fa 100644 --- a/compiler/test/__snapshots__/records.f6feee77.0.snapshot +++ b/compiler/test/__snapshots__/records.f6feee77.0.snapshot @@ -1,100 +1,28 @@ records › record_multiple_fields_value_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 2239 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/records.fae50a8e.0.snapshot b/compiler/test/__snapshots__/records.fae50a8e.0.snapshot index 05099a271..be2a3b261 100644 --- a/compiler/test/__snapshots__/records.fae50a8e.0.snapshot +++ b/compiler/test/__snapshots__/records.fae50a8e.0.snapshot @@ -1,69 +1,22 @@ records › record_pun_mixed_2_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 447924047) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 2147483646) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1714 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 223962023))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.179d20b9.0.snapshot b/compiler/test/__snapshots__/stdlib.179d20b9.0.snapshot index 66b90f4c4..79a0d13d2 100644 --- a/compiler/test/__snapshots__/stdlib.179d20b9.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.179d20b9.0.snapshot @@ -1,48 +1,34 @@ stdlib › stdlib_equal_4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (i32.const 3) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.1c0b04b7.0.snapshot b/compiler/test/__snapshots__/stdlib.1c0b04b7.0.snapshot index cedd34bb2..e7edb7170 100644 --- a/compiler/test/__snapshots__/stdlib.1c0b04b7.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.1c0b04b7.0.snapshot @@ -1,190 +1,78 @@ stdlib › stdlib_equal_20 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.13 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_string.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7496034) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_record.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $8) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (return_call $==_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1114) - ) - (local.get $7) - (local.get $9) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((functions ()) + (imports + (((mimp_id ((stamp 1114) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1114) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) ((instr_desc (MAllocate (MString bar))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1121) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.24cb9bbf.0.snapshot b/compiler/test/__snapshots__/stdlib.24cb9bbf.0.snapshot index ec38f730b..27720634b 100644 --- a/compiler/test/__snapshots__/stdlib.24cb9bbf.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.24cb9bbf.0.snapshot @@ -1,104 +1,42 @@ stdlib › stdlib_equal_18 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 8) - ) - (i64.store offset=8 - (local.get $0) - (i64.const -9036296798633758874) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 8) - ) - (i64.store offset=8 - (local.get $0) - (i64.const -8891900135581192346) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc (MAllocate (MString \"foo \\240\\159\\152\\130\"))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc (MAllocate (MString \"foo \\240\\159\\153\\132\"))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.323e410a.0.snapshot b/compiler/test/__snapshots__/stdlib.323e410a.0.snapshot index 09a369e7e..ee9e992bc 100644 --- a/compiler/test/__snapshots__/stdlib.323e410a.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.323e410a.0.snapshot @@ -1,130 +1,41 @@ stdlib › stdlib_equal_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (tuple.extract 0 - (tuple.make - (i32.or - (i32.shl - (i32.eq - (local.get $6) - (local.get $7) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - (block $cleanup.7 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1119) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.37483d2d.0.snapshot b/compiler/test/__snapshots__/stdlib.37483d2d.0.snapshot index 2581e25af..44360685d 100644 --- a/compiler/test/__snapshots__/stdlib.37483d2d.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.37483d2d.0.snapshot @@ -1,194 +1,67 @@ stdlib › stdlib_cons -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.11 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1120) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.4a5061c2.0.snapshot b/compiler/test/__snapshots__/stdlib.4a5061c2.0.snapshot index f83220a0c..582805e94 100644 --- a/compiler/test/__snapshots__/stdlib.4a5061c2.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.4a5061c2.0.snapshot @@ -1,190 +1,78 @@ stdlib › stdlib_equal_19 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.13 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_string.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_record.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $8) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (return_call $==_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1114) - ) - (local.get $7) - (local.get $9) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((functions ()) + (imports + (((mimp_id ((stamp 1114) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1114) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1121) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.5fe88631.0.snapshot b/compiler/test/__snapshots__/stdlib.5fe88631.0.snapshot index 9c9c5dea1..a6fff3956 100644 --- a/compiler/test/__snapshots__/stdlib.5fe88631.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.5fe88631.0.snapshot @@ -1,104 +1,40 @@ stdlib › stdlib_equal_16 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.648f406e.0.snapshot b/compiler/test/__snapshots__/stdlib.648f406e.0.snapshot index 44eb181a1..0d4eee214 100644 --- a/compiler/test/__snapshots__/stdlib.648f406e.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.648f406e.0.snapshot @@ -1,128 +1,62 @@ stdlib › stdlib_equal_12 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_array.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1124) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.69635cff.0.snapshot b/compiler/test/__snapshots__/stdlib.69635cff.0.snapshot index 51ead1b95..605435af2 100644 --- a/compiler/test/__snapshots__/stdlib.69635cff.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.69635cff.0.snapshot @@ -1,190 +1,78 @@ stdlib › stdlib_equal_21 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.13 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_string.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_record.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 157) - ) - (i32.store offset=20 - (local.get $0) - (local.get $8) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (return_call $==_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1114) - ) - (local.get $7) - (local.get $9) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((functions ()) + (imports + (((mimp_id ((stamp 1114) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1114) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 78))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1121) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.6bf88430.0.snapshot b/compiler/test/__snapshots__/stdlib.6bf88430.0.snapshot index 9fc3d8c01..b741f8f2e 100644 --- a/compiler/test/__snapshots__/stdlib.6bf88430.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.6bf88430.0.snapshot @@ -1,100 +1,40 @@ stdlib › stdlib_equal_15 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 102) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString f))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MString \"\"))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.6de47be2.0.snapshot b/compiler/test/__snapshots__/stdlib.6de47be2.0.snapshot index d157d5d81..333745fed 100644 --- a/compiler/test/__snapshots__/stdlib.6de47be2.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.6de47be2.0.snapshot @@ -1,100 +1,40 @@ stdlib › stdlib_equal_14 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 32) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString \" \"))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MString \"\"))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot b/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot index cccebc51b..51672f1b2 100644 --- a/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot @@ -1,378 +1,156 @@ stdlib › stdlib_equal_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (block $compile_block.25 - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.18 - (local.set $11 - (block $allocate_adt.16 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=24 - (local.get $0) - (local.get $10) - ) - (local.get $0) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.21 - (local.set $12 - (block $allocate_adt.19 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.24 - (local.set $13 - (block $allocate_adt.22 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $12) - ) - (local.get $0) - ) - ) - (block $do_backpatches.23 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $9) - (local.get $13) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 8) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1128) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.91a94037.0.snapshot b/compiler/test/__snapshots__/stdlib.91a94037.0.snapshot index cdbdfc76a..7ec08b696 100644 --- a/compiler/test/__snapshots__/stdlib.91a94037.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.91a94037.0.snapshot @@ -1,108 +1,52 @@ stdlib › stdlib_equal_11 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_array.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1119) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.a70e79ca.0.snapshot b/compiler/test/__snapshots__/stdlib.a70e79ca.0.snapshot index a11b7ab88..d7fc4a4c0 100644 --- a/compiler/test/__snapshots__/stdlib.a70e79ca.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.a70e79ca.0.snapshot @@ -1,100 +1,45 @@ stdlib › stdlib_equal_9 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_array.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MArray ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.b30d7785.0.snapshot b/compiler/test/__snapshots__/stdlib.b30d7785.0.snapshot index 3ccae1ee7..c5e0ea094 100644 --- a/compiler/test/__snapshots__/stdlib.b30d7785.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.b30d7785.0.snapshot @@ -1,112 +1,54 @@ stdlib › stdlib_equal_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1120) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.c09a513a.0.snapshot b/compiler/test/__snapshots__/stdlib.c09a513a.0.snapshot index 90c01a2a8..d25adafe2 100644 --- a/compiler/test/__snapshots__/stdlib.c09a513a.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.c09a513a.0.snapshot @@ -1,48 +1,35 @@ stdlib › stdlib_equal_6 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (i32.const -2) - (i32.const -2) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + (((Unmanaged WasmI32) (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1114) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.cbf0318e.0.snapshot b/compiler/test/__snapshots__/stdlib.cbf0318e.0.snapshot index eacd026e8..19fdb44b4 100644 --- a/compiler/test/__snapshots__/stdlib.cbf0318e.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.cbf0318e.0.snapshot @@ -1,190 +1,79 @@ stdlib › stdlib_equal_22 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.13 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_string.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_record.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $8) - ) - (i32.store offset=24 - (local.get $0) - (i32.const 2147483646) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (return_call $==_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1114) - ) - (local.get $7) - (local.get $9) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((functions ()) + (imports + (((mimp_id ((stamp 1114) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1114) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1121) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.d28dee65.0.snapshot b/compiler/test/__snapshots__/stdlib.d28dee65.0.snapshot index 3f42a7ba6..20aff6826 100644 --- a/compiler/test/__snapshots__/stdlib.d28dee65.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.d28dee65.0.snapshot @@ -1,104 +1,50 @@ stdlib › stdlib_equal_10 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_array.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1118) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.d4faa5bf.0.snapshot b/compiler/test/__snapshots__/stdlib.d4faa5bf.0.snapshot index 7791c712b..58015d232 100644 --- a/compiler/test/__snapshots__/stdlib.d4faa5bf.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.d4faa5bf.0.snapshot @@ -1,96 +1,40 @@ stdlib › stdlib_equal_13 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString \"\"))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MString \"\"))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.d887bb04.0.snapshot b/compiler/test/__snapshots__/stdlib.d887bb04.0.snapshot index 4b35e0581..ea2c8cb84 100644 --- a/compiler/test/__snapshots__/stdlib.d887bb04.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.d887bb04.0.snapshot @@ -1,48 +1,35 @@ stdlib › stdlib_equal_7 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (i32.const -2) - (i32.const 2147483646) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + (((Unmanaged WasmI32) (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1114) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.dae8b12a.0.snapshot b/compiler/test/__snapshots__/stdlib.dae8b12a.0.snapshot index 182200a61..d78f70b6b 100644 --- a/compiler/test/__snapshots__/stdlib.dae8b12a.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.dae8b12a.0.snapshot @@ -1,48 +1,34 @@ stdlib › stdlib_equal_5 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (i32.const 3) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.e306600a.0.snapshot b/compiler/test/__snapshots__/stdlib.e306600a.0.snapshot index b78f955ff..fe63af8b7 100644 --- a/compiler/test/__snapshots__/stdlib.e306600a.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.e306600a.0.snapshot @@ -1,96 +1,40 @@ stdlib › stdlib_equal_8 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_array.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MArray ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MArray ()))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/stdlib.e6349872.0.snapshot b/compiler/test/__snapshots__/stdlib.e6349872.0.snapshot index 106abb642..d5a827836 100644 --- a/compiler/test/__snapshots__/stdlib.e6349872.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.e6349872.0.snapshot @@ -1,104 +1,42 @@ stdlib › stdlib_equal_17 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 8) - ) - (i64.store offset=8 - (local.get $0) - (i64.const -9036296798633758874) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 8) - ) - (i64.store offset=8 - (local.get $0) - (i64.const -9036296798633758874) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc (MAllocate (MString \"foo \\240\\159\\152\\130\"))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc (MAllocate (MString \"foo \\240\\159\\152\\130\"))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/strings.434adad0.0.snapshot b/compiler/test/__snapshots__/strings.434adad0.0.snapshot index 7cd70f853..48ae29518 100644 --- a/compiler/test/__snapshots__/strings.434adad0.0.snapshot +++ b/compiler/test/__snapshots__/strings.434adad0.0.snapshot @@ -1,57 +1,9 @@ strings › string2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 2945622000) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MString \"\\240\\159\\146\\175\")))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1114) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/strings.a67428df.0.snapshot b/compiler/test/__snapshots__/strings.a67428df.0.snapshot index efb0c5357..a2edd33aa 100644 --- a/compiler/test/__snapshots__/strings.a67428df.0.snapshot +++ b/compiler/test/__snapshots__/strings.a67428df.0.snapshot @@ -1,57 +1,9 @@ strings › string1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MString foo)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1114) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/strings.b2ad5a89.0.snapshot b/compiler/test/__snapshots__/strings.b2ad5a89.0.snapshot index 40504cc52..faa092d40 100644 --- a/compiler/test/__snapshots__/strings.b2ad5a89.0.snapshot +++ b/compiler/test/__snapshots__/strings.b2ad5a89.0.snapshot @@ -1,73 +1,10 @@ strings › string3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 48) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 36) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7863398673301594477) - ) - (i64.store offset=16 - (local.get $0) - (i64.const 8026576141579395193) - ) - (i64.store offset=24 - (local.get $0) - (i64.const 2318349367439027831) - ) - (i64.store offset=32 - (local.get $0) - (i64.const 2334956330867777911) - ) - (i64.store offset=40 - (local.get $0) - (i64.const 1953718630) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc (MAllocate (MString \"making my way downtown, walking fast\")))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1114) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/strings.fb85549f.0.snapshot b/compiler/test/__snapshots__/strings.fb85549f.0.snapshot index 53992937e..5fa56d772 100644 --- a/compiler/test/__snapshots__/strings.fb85549f.0.snapshot +++ b/compiler/test/__snapshots__/strings.fb85549f.0.snapshot @@ -1,104 +1,40 @@ strings › concat -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$++\" (global $++_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"++\" (func $++_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7496034) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $++_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $++_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ++))) (mimp_mod pervasives.gr) + (mimp_name ++) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ++))) (mimp_mod pervasives.gr) + (mimp_name ++) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MString bar))))))))) + ((instr_desc + (MReturnCallKnown (func ++_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ++_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/tuples.1451773e.0.snapshot b/compiler/test/__snapshots__/tuples.1451773e.0.snapshot index a614ea782..8f9686480 100644 --- a/compiler/test/__snapshots__/tuples.1451773e.0.snapshot +++ b/compiler/test/__snapshots__/tuples.1451773e.0.snapshot @@ -1,322 +1,154 @@ tuples › nested_tup_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $b_1116 (mut i32) (i32.const 0)) - (global $a_1115 (mut i32) (i32.const 0)) - (global $y_1114 (mut i32) (i32.const 0)) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (block $compile_block.34 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_tuple.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (local.get $6) - ) - (i32.store offset=12 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (global.set $x_1113 - (i32.const 0) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (global.set $y_1114 - (i32.const 0) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $8) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $8) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $cleanup.18 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - (drop - (block $compile_set.19 (result i32) - (global.set $y_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $y_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.20 (result i32) - (global.set $x_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $x_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.22 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $y_1114) - ) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.24 - (global.set $a_1115 - (i32.const 0) - ) - (block $do_backpatches.23 - ) - ) - (block $compile_store.26 - (global.set $b_1116 - (i32.const 0) - ) - (block $do_backpatches.25 - ) - ) - (block $compile_store.28 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $11) - ) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $compile_store.30 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $11) - ) - ) - ) - (block $do_backpatches.29 - ) - ) - (block $cleanup.31 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - (drop - (block $compile_set.32 (result i32) - (global.set $b_1116 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1116) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.33 (result i32) - (global.set $a_1115 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $a_1115) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (global.get $a_1115) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind y_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind y_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind y_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind a_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind b_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind b_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind a_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind a_1115 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 8) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + ((((stamp 1116) (name b)) true Managed ()) + (((stamp 1115) (name a)) true Managed ()) + (((stamp 1114) (name y)) true Managed ()) + (((stamp 1113) (name x)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1131) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/tuples.1d60b40c.0.snapshot b/compiler/test/__snapshots__/tuples.1d60b40c.0.snapshot index 511917541..8b89cd814 100644 --- a/compiler/test/__snapshots__/tuples.1d60b40c.0.snapshot +++ b/compiler/test/__snapshots__/tuples.1d60b40c.0.snapshot @@ -1,223 +1,94 @@ tuples › nested_tup_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $b_1114 (mut i32) (i32.const 0)) - (global $a_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (block $compile_block.21 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_tuple.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (local.get $6) - ) - (i32.store offset=12 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (global.set $a_1113 - (i32.const 0) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (global.set $b_1114 - (i32.const 0) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $8) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $8) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $cleanup.18 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - (drop - (block $compile_set.19 (result i32) - (global.set $b_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.20 (result i32) - (global.set $a_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $a_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (global.get $a_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind a_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind b_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind b_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind a_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind a_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 5) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + ((((stamp 1114) (name b)) true Managed ()) + (((stamp 1113) (name a)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1125) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/tuples.2c91b91d.0.snapshot b/compiler/test/__snapshots__/tuples.2c91b91d.0.snapshot index 2de95ddb6..f892a7921 100644 --- a/compiler/test/__snapshots__/tuples.2c91b91d.0.snapshot +++ b/compiler/test/__snapshots__/tuples.2c91b91d.0.snapshot @@ -1,205 +1,99 @@ tuples › tup1_destruct_trailing -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $a_1113 (mut i32) (i32.const 0)) - (global $c_1115 (mut i32) (i32.const 0)) - (global $b_1114 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.20 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (global.set $a_1113 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (global.set $b_1114 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (global.set $c_1115 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $7 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $6) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $cleanup.16 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.17 (result i32) - (global.set $c_1115 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $c_1115) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.18 (result i32) - (global.set $b_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.19 (result i32) - (global.set $a_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $a_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind a_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind b_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind c_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind c_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind b_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind a_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + ((((stamp 1113) (name a)) true Managed ()) + (((stamp 1115) (name c)) true Managed ()) + (((stamp 1114) (name b)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1124) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/tuples.8d1f0463.0.snapshot b/compiler/test/__snapshots__/tuples.8d1f0463.0.snapshot index 93890627e..899941523 100644 --- a/compiler/test/__snapshots__/tuples.8d1f0463.0.snapshot +++ b/compiler/test/__snapshots__/tuples.8d1f0463.0.snapshot @@ -1,65 +1,18 @@ tuples › tup1_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/tuples.a34621a0.0.snapshot b/compiler/test/__snapshots__/tuples.a34621a0.0.snapshot index fa6830fda..0357ba126 100644 --- a/compiler/test/__snapshots__/tuples.a34621a0.0.snapshot +++ b/compiler/test/__snapshots__/tuples.a34621a0.0.snapshot @@ -1,249 +1,124 @@ tuples › big_tup_access -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $a_1113 (mut i32) (i32.const 0)) - (global $d_1116 (mut i32) (i32.const 0)) - (global $c_1115 (mut i32) (i32.const 0)) - (global $b_1114 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (block $compile_block.25 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (global.set $a_1113 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (global.set $b_1114 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (global.set $c_1115 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (global.set $d_1116 - (i32.const 0) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $7 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $6) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $6) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.18 - ) - ) - (block $cleanup.20 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.21 (result i32) - (global.set $d_1116 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $d_1116) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.22 (result i32) - (global.set $c_1115 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $c_1115) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.23 (result i32) - (global.set $b_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.24 (result i32) - (global.set $a_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $a_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (global.get $c_1115) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind a_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind b_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind c_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind d_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 3) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind d_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind c_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind b_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind a_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind c_1115 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 5) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + ((((stamp 1113) (name a)) true Managed ()) + (((stamp 1116) (name d)) true Managed ()) + (((stamp 1115) (name c)) true Managed ()) + (((stamp 1114) (name b)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1127) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/tuples.b4f702d8.0.snapshot b/compiler/test/__snapshots__/tuples.b4f702d8.0.snapshot index 332d91f8e..77a9daad7 100644 --- a/compiler/test/__snapshots__/tuples.b4f702d8.0.snapshot +++ b/compiler/test/__snapshots__/tuples.b4f702d8.0.snapshot @@ -1,35 +1,13 @@ tuples › no_non_trailing_comma_singleton_tup -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 3) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1114) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/tuples.c1eb0a50.0.snapshot b/compiler/test/__snapshots__/tuples.c1eb0a50.0.snapshot index 29f8fc8d6..9ab54346a 100644 --- a/compiler/test/__snapshots__/tuples.c1eb0a50.0.snapshot +++ b/compiler/test/__snapshots__/tuples.c1eb0a50.0.snapshot @@ -1,322 +1,154 @@ tuples › nested_tup_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $a_1113 (mut i32) (i32.const 0)) - (global $d_1116 (mut i32) (i32.const 0)) - (global $c_1115 (mut i32) (i32.const 0)) - (global $b_1114 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (block $compile_block.34 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_tuple.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (local.get $6) - ) - (i32.store offset=12 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (global.set $a_1113 - (i32.const 0) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (global.set $b_1114 - (i32.const 0) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $8) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $8) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $cleanup.18 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - (drop - (block $compile_set.19 (result i32) - (global.set $b_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.20 (result i32) - (global.set $a_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $a_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.22 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1114) - ) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.24 - (global.set $c_1115 - (i32.const 0) - ) - (block $do_backpatches.23 - ) - ) - (block $compile_store.26 - (global.set $d_1116 - (i32.const 0) - ) - (block $do_backpatches.25 - ) - ) - (block $compile_store.28 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $11) - ) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $compile_store.30 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $11) - ) - ) - ) - (block $do_backpatches.29 - ) - ) - (block $cleanup.31 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - (drop - (block $compile_set.32 (result i32) - (global.set $d_1116 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $d_1116) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.33 (result i32) - (global.set $c_1115 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $c_1115) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (global.get $d_1116) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind a_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind b_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind b_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind a_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind b_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind c_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind d_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind d_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind c_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind d_1116 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 8) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + ((((stamp 1113) (name a)) true Managed ()) + (((stamp 1116) (name d)) true Managed ()) + (((stamp 1115) (name c)) true Managed ()) + (((stamp 1114) (name b)) true Managed ()))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1131) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata )) diff --git a/compiler/test/__snapshots__/tuples.f206002b.0.snapshot b/compiler/test/__snapshots__/tuples.f206002b.0.snapshot index 714f171f6..d9909a8ac 100644 --- a/compiler/test/__snapshots__/tuples.f206002b.0.snapshot +++ b/compiler/test/__snapshots__/tuples.f206002b.0.snapshot @@ -1,65 +1,18 @@ tuples › tup1_trailing_space -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (signature ) (type_metadata ))