From f9e73eb1a1f94a6d02170a33e0b2ed1ca51a1b5a Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Tue, 8 Oct 2024 19:57:47 -0400 Subject: [PATCH 01/10] feat(compiler): Improve constant pattern matching --- compiler/src/middle_end/matchcomp.re | 188 +++++++++++++++++++++++---- 1 file changed, 164 insertions(+), 24 deletions(-) diff --git a/compiler/src/middle_end/matchcomp.re b/compiler/src/middle_end/matchcomp.re index c1275ad5b..4c92c577a 100644 --- a/compiler/src/middle_end/matchcomp.re +++ b/compiler/src/middle_end/matchcomp.re @@ -57,6 +57,7 @@ type decision_tree = with an optional default branch. */ Switch( switch_type, + option(Ident.t), list((int, decision_tree)), option(decision_tree), ) @@ -84,6 +85,12 @@ and matrix_type = | ConstantMatrix and switch_type = + | CharSwitch + | Int8Switch + | Int16Switch + | UInt8Switch + | UInt16Switch + | WasmI32Switch | ConstructorSwitch | ArraySwitch @@ -556,6 +563,20 @@ let equality_type = | Const_wasmf32(_) => PhysicalEquality(WasmF32) | Const_wasmf64(_) => PhysicalEquality(WasmF64); +let get_constant_tag = const => + switch (const) { + | Const_char(char) => + let uchar = List.hd @@ Utf8.decodeUtf8String(char); + let uchar_int: int = Utf8__Uchar.toInt(uchar); + Some((CharSwitch, uchar_int)); + | Const_int8(i) => Some((Int8Switch, Int32.to_int(i))) + | Const_int16(i) => Some((Int16Switch, Int32.to_int(i))) + | Const_uint8(i) => Some((UInt8Switch, Int32.to_int(i))) + | Const_uint16(i) => Some((UInt16Switch, Int32.to_int(i))) + | Const_wasmi32(i) => Some((WasmI32Switch, Int32.to_int(i))) + | _ => None + }; + let rec compile_matrix = mtx => switch (mtx) { | [] => Fail /* No branches to match. */ @@ -606,7 +627,7 @@ let rec compile_matrix = mtx => } else { None; }; - Switch(ArraySwitch, switch_branches, default_tree); + Switch(ArraySwitch, None, switch_branches, default_tree); }; | RecordMatrix(labels) => let mtx = flatten_matrix(Array.length(labels), alias, mtx); @@ -661,11 +682,12 @@ let rec compile_matrix = mtx => } else { None; }; - Switch(ConstructorSwitch, switch_branches, default_tree); + Switch(ConstructorSwitch, None, switch_branches, default_tree); }; | ConstantMatrix => let constants = matrix_head_constants(mtx); - let equality_type = equality_type(List.hd(constants)); + let constant_type = List.hd(constants); + let equality_type = equality_type(constant_type); // TODO(#1185): Optimize physical equality checks into a switch. // We can also do partial switches on Numbers if some of the @@ -682,15 +704,51 @@ let rec compile_matrix = mtx => Fail; }; - List.fold_right( - (const, acc) => { - let specialized = specialize_constant_matrix(const, alias, mtx); - let result = compile_matrix(specialized); - Conditional((equality_type, const), alias, result, acc); - }, - constants, - default_tree, - ); + switch (constant_type) { + | Const_char(_) + | Const_int8(_) + | Const_int16(_) + | Const_uint8(_) + | Const_uint16(_) + | Const_wasmi32(_) => + let switch_type = + switch (get_constant_tag(constant_type)) { + | Some((tag, _)) => tag + | None => + failwith( + "Internal error: compile_matrix: no tag found for constant", + ) + }; + let cases = + List.fold_right( + (const, acc) => { + let specialized = specialize_constant_matrix(const, alias, mtx); + let result = compile_matrix(specialized); + let tag = + switch (get_constant_tag(const)) { + | Some((_, tag)) => tag + | None => + failwith( + "Internal error: compile_matrix: no tag found for constant", + ) + }; + [(tag, result), ...acc]; + }, + constants, + [], + ); + Switch(switch_type, Some(alias), cases, Some(default_tree)); + | _ => + List.fold_right( + (const, acc) => { + let specialized = specialize_constant_matrix(const, alias, mtx); + let result = compile_matrix(specialized); + Conditional((equality_type, const), alias, result, acc); + }, + constants, + default_tree, + ) + }; }; | _ => /* Adjust stack so non-wildcard column is on top */ @@ -1141,8 +1199,8 @@ module MatchTreeCompiler = { helpI, helpConst, ) - | Switch(switch_type, cases, default_tree) => - let (cur_value, rest_values) = + | Switch(switch_type, alias, cases, default_tree) => + let (cur_value, _) = switch (values) { | [] => failwith("Impossible (compile_tree_help): Empty value stack") | [hd, ...tl] => (hd, tl) @@ -1175,19 +1233,86 @@ module MatchTreeCompiler = { ArrayLength, cur_value, ) + | CharSwitch => + Comp.prim1( + ~loc=Location.dummy_loc, + ~allocation_type=Unmanaged(WasmI32), + UntagChar, + cur_value, + ) + | Int8Switch => + Comp.prim1( + ~loc=Location.dummy_loc, + ~allocation_type=Unmanaged(WasmI32), + UntagInt8, + cur_value, + ) + | Int16Switch => + Comp.prim1( + ~loc=Location.dummy_loc, + ~allocation_type=Unmanaged(WasmI32), + UntagInt16, + cur_value, + ) + | UInt8Switch => + Comp.prim1( + ~loc=Location.dummy_loc, + ~allocation_type=Unmanaged(WasmI32), + UntagUint8, + cur_value, + ) + | UInt16Switch => + Comp.prim1( + ~loc=Location.dummy_loc, + ~allocation_type=Unmanaged(WasmI32), + UntagUint16, + cur_value, + ) + | WasmI32Switch => + Comp.imm( + ~loc=Location.dummy_loc, + ~allocation_type=Unmanaged(WasmI32), + cur_value, + ) }; /* Fold left should be safe here, since there should be at most one branch - per constructor */ + per value */ + // TODO: optimize for a jump table, Comp.switch + // TODO: We need to check what percentage of our range is full + // TODO: branch_condition needs to be extracted into a switch + // TODO: body needs to be the switch code path + // TODO: Base becomes default let (switch_body_ans, switch_body_setup) = List.fold_left( ((body_ans, body_setup), (tag, tree)) => { - let cmp_id_name = Ident.create("match_cmp_constructors"); + let cmp_id_name = Ident.create("match_cmp_values"); let cmp_id = Imm.id(~loc=Location.dummy_loc, cmp_id_name); - /* If the constructor has the correct tag, execute this branch. + /* If the value has the correct tag, execute this branch. Otherwise continue. */ - let setup = [ - BLet( - cmp_id_name, + let branch_condition = + switch (switch_type) { + | CharSwitch + | Int8Switch + | Int16Switch + | UInt8Switch + | UInt16Switch + | WasmI32Switch => + Comp.prim2( + ~loc=Location.dummy_loc, + ~allocation_type=Unmanaged(WasmI32), + WasmBinaryI32({ + wasm_op: Op_eq_int32, + arg_types: (Wasm_int32, Wasm_int32), + ret_type: Grain_bool, + }), + value_constr_id, + Imm.const( + ~loc=Location.dummy_loc, + Const_wasmi32(Int32.of_int(tag)), + ), + ) + | ConstructorSwitch + | ArraySwitch => Comp.prim2( ~loc=Location.dummy_loc, ~allocation_type=Unmanaged(WasmI32), @@ -1197,10 +1322,9 @@ module MatchTreeCompiler = { ~loc=Location.dummy_loc, Const_number(Const_number_int(Int64.of_int(tag))), ), - ), - Nonglobal, - ), - ]; + ) + }; + let setup = [BLet(cmp_id_name, branch_condition, Nonglobal)]; let (tree_ans, tree_setup) = compile_tree_help( ~loc, @@ -1225,6 +1349,22 @@ module MatchTreeCompiler = { base, cases, ); + let switch_body_setup = + switch (alias) { + | Some(alias) => [ + BLet( + alias, + Comp.imm( + ~loc=Location.dummy_loc, + ~allocation_type=Managed, + cur_value, + ), + Nonglobal, + ), + ...switch_body_setup, + ] + | None => switch_body_setup + }; ( switch_body_ans, [ From 8f0afaffce3d419a7b19ee5bfab3052045e5e160 Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Tue, 8 Oct 2024 20:02:30 -0400 Subject: [PATCH 02/10] chore: Update snapshot tests --- .../basic_functionality.711a4824.0.snapshot | 128 ++++++++---------- .../pattern_matching.be46eb0e.0.snapshot | 46 +++---- 2 files changed, 78 insertions(+), 96 deletions(-) diff --git a/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot b/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot index 2c5df87c4..5a3eaae20 100644 --- a/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot @@ -14,11 +14,11 @@ basic functionality › pattern_match_unsafe_wasm (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$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_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\" \"print\" (func $print_1125 (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1126 (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) @@ -118,15 +118,13 @@ basic functionality › pattern_match_unsafe_wasm (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) - ) + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $1) + (i32.const 6) + ) ) ) (block $do_backpatches.5 @@ -140,20 +138,18 @@ basic functionality › pattern_match_unsafe_wasm (i32.const 31) ) (block $compile_block.7 (result i32) - (i32.const 1) + (i32.const 11) ) (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) - ) + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $1) + (i32.const 5) + ) ) ) (block $do_backpatches.8 @@ -165,20 +161,18 @@ basic functionality › pattern_match_unsafe_wasm (i32.const 31) ) (block $compile_block.10 (result i32) - (i32.const 3) + (i32.const 9) ) (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) - ) + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $1) + (i32.const 4) + ) ) ) (block $do_backpatches.11 @@ -190,20 +184,18 @@ basic functionality › pattern_match_unsafe_wasm (i32.const 31) ) (block $compile_block.13 (result i32) - (i32.const 5) + (i32.const 7) ) (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) - ) + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $1) + (i32.const 3) + ) ) ) (block $do_backpatches.14 @@ -215,20 +207,18 @@ basic functionality › pattern_match_unsafe_wasm (i32.const 31) ) (block $compile_block.16 (result i32) - (i32.const 7) + (i32.const 5) ) (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) - ) + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $1) + (i32.const 2) + ) ) ) (block $do_backpatches.17 @@ -240,20 +230,18 @@ basic functionality › pattern_match_unsafe_wasm (i32.const 31) ) (block $compile_block.19 (result i32) - (i32.const 9) + (i32.const 3) ) (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) - ) + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $1) + (i32.const 1) + ) ) ) (block $do_backpatches.20 @@ -265,7 +253,7 @@ basic functionality › pattern_match_unsafe_wasm (i32.const 31) ) (block $compile_block.22 (result i32) - (i32.const 11) + (i32.const 1) ) (block $compile_block.23 (result i32) (i32.const 13) @@ -391,10 +379,10 @@ basic functionality › pattern_match_unsafe_wasm ) ) ) - (return_call $print_1125 + (return_call $print_1126 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) + (global.get $print_1126) ) (local.get $15) (local.get $14) @@ -447,10 +435,10 @@ basic functionality › pattern_match_unsafe_wasm ) ) ) - (return_call $print_1125 + (return_call $print_1126 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) + (global.get $print_1126) ) (i32.const 13) (local.get $13) @@ -503,10 +491,10 @@ basic functionality › pattern_match_unsafe_wasm ) ) ) - (return_call $print_1125 + (return_call $print_1126 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) + (global.get $print_1126) ) (i32.const 11) (local.get $12) @@ -559,10 +547,10 @@ basic functionality › pattern_match_unsafe_wasm ) ) ) - (return_call $print_1125 + (return_call $print_1126 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) + (global.get $print_1126) ) (i32.const 9) (local.get $11) @@ -615,10 +603,10 @@ basic functionality › pattern_match_unsafe_wasm ) ) ) - (return_call $print_1125 + (return_call $print_1126 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) + (global.get $print_1126) ) (i32.const 7) (local.get $10) @@ -671,10 +659,10 @@ basic functionality › pattern_match_unsafe_wasm ) ) ) - (return_call $print_1125 + (return_call $print_1126 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) + (global.get $print_1126) ) (i32.const 5) (local.get $9) @@ -727,10 +715,10 @@ basic functionality › pattern_match_unsafe_wasm ) ) ) - (return_call $print_1125 + (return_call $print_1126 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) + (global.get $print_1126) ) (i32.const 3) (local.get $8) diff --git a/compiler/test/__snapshots__/pattern_matching.be46eb0e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.be46eb0e.0.snapshot index 5bd625281..c456acee8 100644 --- a/compiler/test/__snapshots__/pattern_matching.be46eb0e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.be46eb0e.0.snapshot @@ -74,15 +74,13 @@ pattern matching › low_level_constant_match_1 ) (block $compile_store.5 (local.set $7 - (i32.or - (i32.shl - (i32.eq - (i32.const 1) - (i32.const 0) - ) - (i32.const 31) - ) + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (i32.const 1) + (i32.const 2) + ) ) ) (block $do_backpatches.4 @@ -96,20 +94,18 @@ pattern matching › low_level_constant_match_1 (i32.const 31) ) (block $compile_block.6 (result i32) - (i32.const 1) + (i32.const 5) ) (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) - ) + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (i32.const 1) + (i32.const 1) + ) ) ) (block $do_backpatches.7 @@ -126,15 +122,13 @@ pattern matching › low_level_constant_match_1 (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) - ) + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (i32.const 1) + (i32.const 0) + ) ) ) (block $do_backpatches.10 @@ -146,7 +140,7 @@ pattern matching › low_level_constant_match_1 (i32.const 31) ) (block $compile_block.12 (result i32) - (i32.const 5) + (i32.const 1) ) (block $compile_block.13 (result i32) (i32.const 7) From a3443c7af8932e5d3c9ead59e271aee3a0ec50b3 Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Wed, 9 Oct 2024 00:50:27 -0400 Subject: [PATCH 03/10] feat: Treat low level switch as wasm32 --- compiler/src/codegen/compcore.re | 2 +- compiler/src/middle_end/matchcomp.re | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/src/codegen/compcore.re b/compiler/src/codegen/compcore.re index a645ad537..be91b24c0 100644 --- a/compiler/src/codegen/compcore.re +++ b/compiler/src/codegen/compcore.re @@ -2839,7 +2839,7 @@ and compile_switch = (wasm_mod, env, arg, branches, default, ty) => { wasm_mod, create_table(stack), default_label, - untag_number(wasm_mod, compile_imm(wasm_mod, env, arg)), + compile_imm(wasm_mod, env, arg), default_value, ); let default_block_body = diff --git a/compiler/src/middle_end/matchcomp.re b/compiler/src/middle_end/matchcomp.re index 4c92c577a..3bc20baf7 100644 --- a/compiler/src/middle_end/matchcomp.re +++ b/compiler/src/middle_end/matchcomp.re @@ -906,7 +906,7 @@ module MatchTreeCompiler = { ~allocation_type=Unmanaged(WasmI32), Imm.const( ~loc=Location.dummy_loc, - Const_number(Const_number_int(Int64.of_int(i))), + Const_wasmi32(Int32.of_int(i)), ), ), get_bindings(~mut_boxing, env, patterns, values, aliases), From 9f8da61a6986cb3ec4c5deb56ac0586f0c6ed61a Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Wed, 9 Oct 2024 00:51:05 -0400 Subject: [PATCH 04/10] chore: Update snapshot tests and smallest program --- .../basic_functionality.711a4824.0.snapshot | 19 ++++++++----------- .../pattern_matching.0539d13e.0.snapshot | 5 +---- .../pattern_matching.05b60a1e.0.snapshot | 9 +++------ .../pattern_matching.0ad4ac05.0.snapshot | 19 ++++++++----------- .../pattern_matching.0bb6923e.0.snapshot | 19 ++++++++----------- .../pattern_matching.0fa61137.0.snapshot | 15 ++++++--------- .../pattern_matching.14dc7554.0.snapshot | 5 +---- .../pattern_matching.16cd197e.0.snapshot | 9 +++------ .../pattern_matching.16eb3dbf.0.snapshot | 9 +++------ .../pattern_matching.25930935.0.snapshot | 15 ++++++--------- .../pattern_matching.3722b060.0.snapshot | 5 +---- .../pattern_matching.46f91987.0.snapshot | 5 +---- .../pattern_matching.5b158103.0.snapshot | 19 ++++++++----------- .../pattern_matching.5b6ff2d3.0.snapshot | 17 +++++++---------- .../pattern_matching.5ff49e44.0.snapshot | 5 +---- .../pattern_matching.64686134.0.snapshot | 11 ++++------- .../pattern_matching.702ed9b0.0.snapshot | 19 ++++++++----------- .../pattern_matching.7082d3ca.0.snapshot | 5 +---- .../pattern_matching.79346fef.0.snapshot | 19 ++++++++----------- .../pattern_matching.7f7fe4ef.0.snapshot | 5 +---- .../pattern_matching.8614dff3.0.snapshot | 5 +---- .../pattern_matching.8c0dc67a.0.snapshot | 19 ++++++++----------- .../pattern_matching.9561763b.0.snapshot | 5 +---- .../pattern_matching.98756c45.0.snapshot | 5 +---- .../pattern_matching.9ffaa7a7.0.snapshot | 15 ++++++--------- .../pattern_matching.aa8d2963.0.snapshot | 9 +++------ .../pattern_matching.ac58ffc3.0.snapshot | 9 +++------ .../pattern_matching.b1b060ad.0.snapshot | 19 ++++++++----------- .../pattern_matching.b9db0dd9.0.snapshot | 9 +++------ .../pattern_matching.be46eb0e.0.snapshot | 15 ++++++--------- .../pattern_matching.c91eac29.0.snapshot | 19 ++++++++----------- .../pattern_matching.c9582b6d.0.snapshot | 15 ++++++--------- .../pattern_matching.d048ece0.0.snapshot | 19 ++++++++----------- .../pattern_matching.e17bcd61.0.snapshot | 9 +++------ .../pattern_matching.e41ad64e.0.snapshot | 19 ++++++++----------- .../pattern_matching.eb4334e1.0.snapshot | 15 ++++++--------- .../pattern_matching.f0c08ea4.0.snapshot | 19 ++++++++----------- .../pattern_matching.f25e0163.0.snapshot | 19 ++++++++----------- .../pattern_matching.f3d48b0e.0.snapshot | 9 +++------ .../pattern_matching.f6c9c89c.0.snapshot | 17 +++++++---------- .../__snapshots__/tuples.2c91b91d.0.snapshot | 2 +- compiler/test/suites/basic_functionality.re | 2 +- 42 files changed, 194 insertions(+), 314 deletions(-) diff --git a/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot b/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot index 5a3eaae20..ba4d5189c 100644 --- a/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot @@ -138,7 +138,7 @@ basic functionality › pattern_match_unsafe_wasm (i32.const 31) ) (block $compile_block.7 (result i32) - (i32.const 11) + (i32.const 5) ) (block $compile_block.28 (result i32) (block $compile_store.9 @@ -161,7 +161,7 @@ basic functionality › pattern_match_unsafe_wasm (i32.const 31) ) (block $compile_block.10 (result i32) - (i32.const 9) + (i32.const 4) ) (block $compile_block.27 (result i32) (block $compile_store.12 @@ -184,7 +184,7 @@ basic functionality › pattern_match_unsafe_wasm (i32.const 31) ) (block $compile_block.13 (result i32) - (i32.const 7) + (i32.const 3) ) (block $compile_block.26 (result i32) (block $compile_store.15 @@ -207,7 +207,7 @@ basic functionality › pattern_match_unsafe_wasm (i32.const 31) ) (block $compile_block.16 (result i32) - (i32.const 5) + (i32.const 2) ) (block $compile_block.25 (result i32) (block $compile_store.18 @@ -230,7 +230,7 @@ basic functionality › pattern_match_unsafe_wasm (i32.const 31) ) (block $compile_block.19 (result i32) - (i32.const 3) + (i32.const 1) ) (block $compile_block.24 (result i32) (block $compile_store.21 @@ -253,10 +253,10 @@ basic functionality › pattern_match_unsafe_wasm (i32.const 31) ) (block $compile_block.22 (result i32) - (i32.const 1) + (i32.const 0) ) (block $compile_block.23 (result i32) - (i32.const 13) + (i32.const 6) ) ) ) @@ -295,10 +295,7 @@ basic functionality › pattern_match_unsafe_wasm (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) - ) + (local.get $17) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.0539d13e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0539d13e.0.snapshot index f768a3ae7..4c804f7fa 100644 --- a/compiler/test/__snapshots__/pattern_matching.0539d13e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0539d13e.0.snapshot @@ -174,10 +174,7 @@ pattern matching › record_match_3 (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) - ) + (i32.const 0) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot index b0da5a7ec..c0062a663 100644 --- a/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot @@ -241,7 +241,7 @@ pattern matching › adt_match_deep (i32.const 1879048190) ) ) - (i32.const 3) + (i32.const 1) ) (block $compile_block.27 (result i32) (block $compile_store.24 @@ -266,7 +266,7 @@ pattern matching › adt_match_deep (i32.const 31) ) (block $compile_block.25 (result i32) - (i32.const 1) + (i32.const 0) ) (block $compile_block.26 (unreachable) @@ -298,10 +298,7 @@ pattern matching › adt_match_deep (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) - ) + (local.get $14) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot index 4c38937f6..979cffa47 100644 --- a/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot @@ -577,10 +577,10 @@ pattern matching › tuple_match_deep4 (i32.const 1879048190) ) ) - (i32.const 7) + (i32.const 3) ) (block $compile_block.72 (result i32) - (i32.const 9) + (i32.const 4) ) ) (block $cleanup.66 (result i32) @@ -684,10 +684,10 @@ pattern matching › tuple_match_deep4 (i32.const 1879048190) ) ) - (i32.const 5) + (i32.const 2) ) (block $compile_block.80 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -777,10 +777,10 @@ pattern matching › tuple_match_deep4 (i32.const 1879048190) ) ) - (i32.const 3) + (i32.const 1) ) (block $compile_block.88 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -848,7 +848,7 @@ pattern matching › tuple_match_deep4 (i32.const 1879048190) ) ) - (i32.const 1) + (i32.const 0) ) (block $compile_block.95 (unreachable) @@ -892,10 +892,7 @@ pattern matching › tuple_match_deep4 (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) - ) + (local.get $32) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot index 19bd2aa07..9bae9c5bc 100644 --- a/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot @@ -542,10 +542,10 @@ pattern matching › adt_match_4 (i32.const 1879048190) ) ) - (i32.const 7) + (i32.const 3) ) (block $compile_block.61 (result i32) - (i32.const 9) + (i32.const 4) ) ) (block $cleanup.56 (result i32) @@ -627,10 +627,10 @@ pattern matching › adt_match_4 (i32.const 1879048190) ) ) - (i32.const 5) + (i32.const 2) ) (block $compile_block.68 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -698,10 +698,10 @@ pattern matching › adt_match_4 (i32.const 1879048190) ) ) - (i32.const 3) + (i32.const 1) ) (block $compile_block.75 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -747,7 +747,7 @@ pattern matching › adt_match_4 (i32.const 31) ) (block $compile_block.80 (result i32) - (i32.const 1) + (i32.const 0) ) (block $compile_block.81 (unreachable) @@ -785,10 +785,7 @@ pattern matching › adt_match_4 (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) - ) + (local.get $25) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.0fa61137.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0fa61137.0.snapshot index 5ca2c3fa1..c8c4361cc 100644 --- a/compiler/test/__snapshots__/pattern_matching.0fa61137.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0fa61137.0.snapshot @@ -94,7 +94,7 @@ pattern matching › low_level_constant_match_2 (i32.const 31) ) (block $compile_block.6 (result i32) - (i32.const 1) + (i32.const 0) ) (block $compile_block.15 (result i32) (block $compile_store.8 @@ -117,7 +117,7 @@ pattern matching › low_level_constant_match_2 (i32.const 31) ) (block $compile_block.9 (result i32) - (i32.const 3) + (i32.const 1) ) (block $compile_block.14 (result i32) (block $compile_store.11 @@ -140,10 +140,10 @@ pattern matching › low_level_constant_match_2 (i32.const 31) ) (block $compile_block.12 (result i32) - (i32.const 5) + (i32.const 2) ) (block $compile_block.13 (result i32) - (i32.const 7) + (i32.const 3) ) ) ) @@ -170,10 +170,7 @@ pattern matching › low_level_constant_match_2 (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) - ) + (local.get $8) ) ) ) @@ -230,7 +227,7 @@ pattern matching › low_level_constant_match_2 (block $do_backpatches.26 ) ) - (i32.const 1) + (i32.const 0) ) ) (func $_start diff --git a/compiler/test/__snapshots__/pattern_matching.14dc7554.0.snapshot b/compiler/test/__snapshots__/pattern_matching.14dc7554.0.snapshot index ccb644d83..23bee98b9 100644 --- a/compiler/test/__snapshots__/pattern_matching.14dc7554.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.14dc7554.0.snapshot @@ -158,10 +158,7 @@ pattern matching › record_match_2 (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) - ) + (i32.const 0) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.16cd197e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.16cd197e.0.snapshot index e305b5036..a8f1de8fb 100644 --- a/compiler/test/__snapshots__/pattern_matching.16cd197e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.16cd197e.0.snapshot @@ -109,10 +109,10 @@ pattern matching › constant_match_3 (i32.const 31) ) (block $compile_block.9 (result i32) - (i32.const 3) + (i32.const 1) ) (block $compile_block.10 (result i32) - (i32.const 5) + (i32.const 2) ) ) ) @@ -131,10 +131,7 @@ pattern matching › constant_match_3 (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) - ) + (local.get $9) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.16eb3dbf.0.snapshot b/compiler/test/__snapshots__/pattern_matching.16eb3dbf.0.snapshot index 18b26529a..c884f56ae 100644 --- a/compiler/test/__snapshots__/pattern_matching.16eb3dbf.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.16eb3dbf.0.snapshot @@ -298,10 +298,10 @@ pattern matching › guarded_match_2 (i32.const 1879048190) ) ) - (i32.const 1) + (i32.const 0) ) (block $compile_block.26 (result i32) - (i32.const 3) + (i32.const 1) ) ) ) @@ -340,10 +340,7 @@ pattern matching › guarded_match_2 (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) - ) + (local.get $14) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.25930935.0.snapshot b/compiler/test/__snapshots__/pattern_matching.25930935.0.snapshot index 49b0de757..ffaaebe8c 100644 --- a/compiler/test/__snapshots__/pattern_matching.25930935.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.25930935.0.snapshot @@ -94,7 +94,7 @@ pattern matching › low_level_constant_match_3 (i32.const 31) ) (block $compile_block.6 (result i32) - (i32.const 1) + (i32.const 0) ) (block $compile_block.15 (result i32) (block $compile_store.8 @@ -117,7 +117,7 @@ pattern matching › low_level_constant_match_3 (i32.const 31) ) (block $compile_block.9 (result i32) - (i32.const 3) + (i32.const 1) ) (block $compile_block.14 (result i32) (block $compile_store.11 @@ -140,10 +140,10 @@ pattern matching › low_level_constant_match_3 (i32.const 31) ) (block $compile_block.12 (result i32) - (i32.const 5) + (i32.const 2) ) (block $compile_block.13 (result i32) - (i32.const 7) + (i32.const 3) ) ) ) @@ -170,10 +170,7 @@ pattern matching › low_level_constant_match_3 (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) - ) + (local.get $8) ) ) ) @@ -230,7 +227,7 @@ pattern matching › low_level_constant_match_3 (block $do_backpatches.26 ) ) - (i32.const 1) + (i32.const 0) ) ) (func $_start diff --git a/compiler/test/__snapshots__/pattern_matching.3722b060.0.snapshot b/compiler/test/__snapshots__/pattern_matching.3722b060.0.snapshot index 685a2a874..1faacf06d 100644 --- a/compiler/test/__snapshots__/pattern_matching.3722b060.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.3722b060.0.snapshot @@ -300,10 +300,7 @@ pattern matching › tuple_match_deep (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) - ) + (i32.const 0) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.46f91987.0.snapshot b/compiler/test/__snapshots__/pattern_matching.46f91987.0.snapshot index 2ab39508f..d33412175 100644 --- a/compiler/test/__snapshots__/pattern_matching.46f91987.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.46f91987.0.snapshot @@ -158,10 +158,7 @@ pattern matching › record_match_1 (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) - ) + (i32.const 0) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.5b158103.0.snapshot b/compiler/test/__snapshots__/pattern_matching.5b158103.0.snapshot index 3731854f3..371b8ada6 100644 --- a/compiler/test/__snapshots__/pattern_matching.5b158103.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.5b158103.0.snapshot @@ -247,15 +247,15 @@ pattern matching › constant_match_2 (i32.const 31) ) (block $compile_block.23 (result i32) - (i32.const 1) + (i32.const 0) ) (block $compile_block.24 (result i32) - (i32.const 7) + (i32.const 3) ) ) ) (block $compile_block.26 (result i32) - (i32.const 7) + (i32.const 3) ) ) ) @@ -331,7 +331,7 @@ pattern matching › constant_match_2 (i32.const 31) ) (block $compile_block.35 (result i32) - (i32.const 5) + (i32.const 2) ) (block $compile_block.40 (result i32) (block $compile_store.37 @@ -356,17 +356,17 @@ pattern matching › constant_match_2 (i32.const 31) ) (block $compile_block.38 (result i32) - (i32.const 3) + (i32.const 1) ) (block $compile_block.39 (result i32) - (i32.const 7) + (i32.const 3) ) ) ) ) ) (block $compile_block.42 (result i32) - (i32.const 7) + (i32.const 3) ) ) ) @@ -409,10 +409,7 @@ pattern matching › constant_match_2 (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) - ) + (local.get $14) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.5b6ff2d3.0.snapshot b/compiler/test/__snapshots__/pattern_matching.5b6ff2d3.0.snapshot index 39d17adb6..b709044de 100644 --- a/compiler/test/__snapshots__/pattern_matching.5b6ff2d3.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.5b6ff2d3.0.snapshot @@ -151,7 +151,7 @@ pattern matching › alias_match_5 (i32.const 1879048190) ) ) - (i32.const 3) + (i32.const 1) ) (block $compile_block.36 (result i32) (block $compile_store.15 @@ -235,7 +235,7 @@ pattern matching › alias_match_5 (i32.const 1879048190) ) ) - (i32.const 1) + (i32.const 0) ) (block $compile_block.33 (result i32) (block $compile_store.24 @@ -283,7 +283,7 @@ pattern matching › alias_match_5 (i32.const 1879048190) ) ) - (i32.const 1) + (i32.const 0) ) (block $compile_block.32 (result i32) (block $compile_store.28 @@ -331,10 +331,10 @@ pattern matching › alias_match_5 (i32.const 1879048190) ) ) - (i32.const 3) + (i32.const 1) ) (block $compile_block.31 (result i32) - (i32.const 5) + (i32.const 2) ) ) ) @@ -354,7 +354,7 @@ pattern matching › alias_match_5 ) ) (block $compile_block.35 (result i32) - (i32.const 5) + (i32.const 2) ) ) ) @@ -385,10 +385,7 @@ pattern matching › alias_match_5 (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) - ) + (local.get $12) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.5ff49e44.0.snapshot b/compiler/test/__snapshots__/pattern_matching.5ff49e44.0.snapshot index 3f9a96e10..d4adc07f0 100644 --- a/compiler/test/__snapshots__/pattern_matching.5ff49e44.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.5ff49e44.0.snapshot @@ -215,10 +215,7 @@ pattern matching › record_match_4 (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) - ) + (i32.const 0) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.64686134.0.snapshot b/compiler/test/__snapshots__/pattern_matching.64686134.0.snapshot index 7d4ae7b59..810d1ac70 100644 --- a/compiler/test/__snapshots__/pattern_matching.64686134.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.64686134.0.snapshot @@ -147,7 +147,7 @@ pattern matching › constant_match_1 (i32.const 31) ) (block $compile_block.8 (result i32) - (i32.const 1) + (i32.const 0) ) (block $compile_block.18 (result i32) (block $compile_store.13 @@ -257,10 +257,10 @@ pattern matching › constant_match_1 (i32.const 31) ) (block $compile_block.16 (result i32) - (i32.const 3) + (i32.const 1) ) (block $compile_block.17 (result i32) - (i32.const 5) + (i32.const 2) ) ) ) @@ -289,10 +289,7 @@ pattern matching › constant_match_1 (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) - ) + (local.get $9) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot b/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot index b1799f2bd..d1239ef01 100644 --- a/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot @@ -663,10 +663,10 @@ pattern matching › tuple_match_deep6 (i32.const 1879048190) ) ) - (i32.const 7) + (i32.const 3) ) (block $compile_block.78 (result i32) - (i32.const 9) + (i32.const 4) ) ) (block $cleanup.72 (result i32) @@ -770,10 +770,10 @@ pattern matching › tuple_match_deep6 (i32.const 1879048190) ) ) - (i32.const 5) + (i32.const 2) ) (block $compile_block.86 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -863,10 +863,10 @@ pattern matching › tuple_match_deep6 (i32.const 1879048190) ) ) - (i32.const 3) + (i32.const 1) ) (block $compile_block.94 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -934,7 +934,7 @@ pattern matching › tuple_match_deep6 (i32.const 1879048190) ) ) - (i32.const 1) + (i32.const 0) ) (block $compile_block.101 (unreachable) @@ -978,10 +978,7 @@ pattern matching › tuple_match_deep6 (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) - ) + (local.get $34) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.7082d3ca.0.snapshot b/compiler/test/__snapshots__/pattern_matching.7082d3ca.0.snapshot index 2d56c895d..bf7ee7bd8 100644 --- a/compiler/test/__snapshots__/pattern_matching.7082d3ca.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.7082d3ca.0.snapshot @@ -219,10 +219,7 @@ pattern matching › tuple_match_3 (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) - ) + (i32.const 0) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot b/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot index 1bce284be..0857c8680 100644 --- a/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot @@ -534,10 +534,10 @@ pattern matching › tuple_match_deep3 (i32.const 1879048190) ) ) - (i32.const 7) + (i32.const 3) ) (block $compile_block.69 (result i32) - (i32.const 9) + (i32.const 4) ) ) (block $cleanup.63 (result i32) @@ -641,10 +641,10 @@ pattern matching › tuple_match_deep3 (i32.const 1879048190) ) ) - (i32.const 5) + (i32.const 2) ) (block $compile_block.77 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -734,10 +734,10 @@ pattern matching › tuple_match_deep3 (i32.const 1879048190) ) ) - (i32.const 3) + (i32.const 1) ) (block $compile_block.85 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -805,7 +805,7 @@ pattern matching › tuple_match_deep3 (i32.const 1879048190) ) ) - (i32.const 1) + (i32.const 0) ) (block $compile_block.92 (unreachable) @@ -849,10 +849,7 @@ pattern matching › tuple_match_deep3 (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) - ) + (local.get $31) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.7f7fe4ef.0.snapshot b/compiler/test/__snapshots__/pattern_matching.7f7fe4ef.0.snapshot index aaf65d1a7..3ce11e7b1 100644 --- a/compiler/test/__snapshots__/pattern_matching.7f7fe4ef.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.7f7fe4ef.0.snapshot @@ -47,10 +47,7 @@ pattern matching › alias_match_1 (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) - ) + (i32.const 0) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.8614dff3.0.snapshot b/compiler/test/__snapshots__/pattern_matching.8614dff3.0.snapshot index dc72edb08..a466f7021 100644 --- a/compiler/test/__snapshots__/pattern_matching.8614dff3.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.8614dff3.0.snapshot @@ -63,10 +63,7 @@ pattern matching › alias_match_2 (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) - ) + (i32.const 0) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot b/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot index c7631c500..3c8ab6d54 100644 --- a/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot @@ -413,10 +413,10 @@ pattern matching › adt_match_1 (i32.const 1879048190) ) ) - (i32.const 7) + (i32.const 3) ) (block $compile_block.52 (result i32) - (i32.const 9) + (i32.const 4) ) ) (block $cleanup.47 (result i32) @@ -498,10 +498,10 @@ pattern matching › adt_match_1 (i32.const 1879048190) ) ) - (i32.const 5) + (i32.const 2) ) (block $compile_block.59 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -569,10 +569,10 @@ pattern matching › adt_match_1 (i32.const 1879048190) ) ) - (i32.const 3) + (i32.const 1) ) (block $compile_block.66 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -618,7 +618,7 @@ pattern matching › adt_match_1 (i32.const 31) ) (block $compile_block.71 (result i32) - (i32.const 1) + (i32.const 0) ) (block $compile_block.72 (unreachable) @@ -656,10 +656,7 @@ pattern matching › adt_match_1 (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) - ) + (local.get $22) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.9561763b.0.snapshot b/compiler/test/__snapshots__/pattern_matching.9561763b.0.snapshot index 6572cce0a..8dc22a456 100644 --- a/compiler/test/__snapshots__/pattern_matching.9561763b.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.9561763b.0.snapshot @@ -579,10 +579,7 @@ pattern matching › tuple_match_deep2 (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) - ) + (i32.const 0) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.98756c45.0.snapshot b/compiler/test/__snapshots__/pattern_matching.98756c45.0.snapshot index 46e652003..9b3630fcf 100644 --- a/compiler/test/__snapshots__/pattern_matching.98756c45.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.98756c45.0.snapshot @@ -179,10 +179,7 @@ pattern matching › record_match_deep (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) - ) + (i32.const 0) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.9ffaa7a7.0.snapshot b/compiler/test/__snapshots__/pattern_matching.9ffaa7a7.0.snapshot index fd6241d72..eb0eab99e 100644 --- a/compiler/test/__snapshots__/pattern_matching.9ffaa7a7.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.9ffaa7a7.0.snapshot @@ -94,7 +94,7 @@ pattern matching › low_level_constant_match_4 (i32.const 31) ) (block $compile_block.6 (result i32) - (i32.const 1) + (i32.const 0) ) (block $compile_block.15 (result i32) (block $compile_store.8 @@ -117,7 +117,7 @@ pattern matching › low_level_constant_match_4 (i32.const 31) ) (block $compile_block.9 (result i32) - (i32.const 3) + (i32.const 1) ) (block $compile_block.14 (result i32) (block $compile_store.11 @@ -140,10 +140,10 @@ pattern matching › low_level_constant_match_4 (i32.const 31) ) (block $compile_block.12 (result i32) - (i32.const 5) + (i32.const 2) ) (block $compile_block.13 (result i32) - (i32.const 7) + (i32.const 3) ) ) ) @@ -170,10 +170,7 @@ pattern matching › low_level_constant_match_4 (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) - ) + (local.get $8) ) ) ) @@ -230,7 +227,7 @@ pattern matching › low_level_constant_match_4 (block $do_backpatches.26 ) ) - (i32.const 1) + (i32.const 0) ) ) (func $_start diff --git a/compiler/test/__snapshots__/pattern_matching.aa8d2963.0.snapshot b/compiler/test/__snapshots__/pattern_matching.aa8d2963.0.snapshot index 5a15c3c93..3da7cb6d7 100644 --- a/compiler/test/__snapshots__/pattern_matching.aa8d2963.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.aa8d2963.0.snapshot @@ -327,10 +327,10 @@ pattern matching › guarded_match_4 (i32.const 1879048190) ) ) - (i32.const 1) + (i32.const 0) ) (block $compile_block.30 (result i32) - (i32.const 3) + (i32.const 1) ) ) ) @@ -369,10 +369,7 @@ pattern matching › guarded_match_4 (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) - ) + (local.get $15) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.ac58ffc3.0.snapshot b/compiler/test/__snapshots__/pattern_matching.ac58ffc3.0.snapshot index 4ee68d69f..b09681678 100644 --- a/compiler/test/__snapshots__/pattern_matching.ac58ffc3.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.ac58ffc3.0.snapshot @@ -298,10 +298,10 @@ pattern matching › guarded_match_1 (i32.const 1879048190) ) ) - (i32.const 1) + (i32.const 0) ) (block $compile_block.26 (result i32) - (i32.const 3) + (i32.const 1) ) ) ) @@ -340,10 +340,7 @@ pattern matching › guarded_match_1 (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) - ) + (local.get $14) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot b/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot index 1bfcf1ba1..78fe793c4 100644 --- a/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot @@ -456,10 +456,10 @@ pattern matching › adt_match_2 (i32.const 1879048190) ) ) - (i32.const 7) + (i32.const 3) ) (block $compile_block.55 (result i32) - (i32.const 9) + (i32.const 4) ) ) (block $cleanup.50 (result i32) @@ -541,10 +541,10 @@ pattern matching › adt_match_2 (i32.const 1879048190) ) ) - (i32.const 5) + (i32.const 2) ) (block $compile_block.62 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -612,10 +612,10 @@ pattern matching › adt_match_2 (i32.const 1879048190) ) ) - (i32.const 3) + (i32.const 1) ) (block $compile_block.69 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -661,7 +661,7 @@ pattern matching › adt_match_2 (i32.const 31) ) (block $compile_block.74 (result i32) - (i32.const 1) + (i32.const 0) ) (block $compile_block.75 (unreachable) @@ -699,10 +699,7 @@ pattern matching › adt_match_2 (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) - ) + (local.get $23) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.b9db0dd9.0.snapshot b/compiler/test/__snapshots__/pattern_matching.b9db0dd9.0.snapshot index 55e79a2ae..dd098c76a 100644 --- a/compiler/test/__snapshots__/pattern_matching.b9db0dd9.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.b9db0dd9.0.snapshot @@ -327,10 +327,10 @@ pattern matching › guarded_match_3 (i32.const 1879048190) ) ) - (i32.const 1) + (i32.const 0) ) (block $compile_block.30 (result i32) - (i32.const 3) + (i32.const 1) ) ) ) @@ -369,10 +369,7 @@ pattern matching › guarded_match_3 (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) - ) + (local.get $15) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.be46eb0e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.be46eb0e.0.snapshot index c456acee8..b13834563 100644 --- a/compiler/test/__snapshots__/pattern_matching.be46eb0e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.be46eb0e.0.snapshot @@ -94,7 +94,7 @@ pattern matching › low_level_constant_match_1 (i32.const 31) ) (block $compile_block.6 (result i32) - (i32.const 5) + (i32.const 2) ) (block $compile_block.15 (result i32) (block $compile_store.8 @@ -117,7 +117,7 @@ pattern matching › low_level_constant_match_1 (i32.const 31) ) (block $compile_block.9 (result i32) - (i32.const 3) + (i32.const 1) ) (block $compile_block.14 (result i32) (block $compile_store.11 @@ -140,10 +140,10 @@ pattern matching › low_level_constant_match_1 (i32.const 31) ) (block $compile_block.12 (result i32) - (i32.const 1) + (i32.const 0) ) (block $compile_block.13 (result i32) - (i32.const 7) + (i32.const 3) ) ) ) @@ -170,10 +170,7 @@ pattern matching › low_level_constant_match_1 (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) - ) + (local.get $8) ) ) ) @@ -230,7 +227,7 @@ pattern matching › low_level_constant_match_1 (block $do_backpatches.26 ) ) - (i32.const 1) + (i32.const 0) ) ) (func $_start diff --git a/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot b/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot index 84517d7d6..3ebf6dcb1 100644 --- a/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot @@ -499,10 +499,10 @@ pattern matching › adt_match_3 (i32.const 1879048190) ) ) - (i32.const 7) + (i32.const 3) ) (block $compile_block.58 (result i32) - (i32.const 9) + (i32.const 4) ) ) (block $cleanup.53 (result i32) @@ -584,10 +584,10 @@ pattern matching › adt_match_3 (i32.const 1879048190) ) ) - (i32.const 5) + (i32.const 2) ) (block $compile_block.65 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -655,10 +655,10 @@ pattern matching › adt_match_3 (i32.const 1879048190) ) ) - (i32.const 3) + (i32.const 1) ) (block $compile_block.72 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -704,7 +704,7 @@ pattern matching › adt_match_3 (i32.const 31) ) (block $compile_block.77 (result i32) - (i32.const 1) + (i32.const 0) ) (block $compile_block.78 (unreachable) @@ -742,10 +742,7 @@ pattern matching › adt_match_3 (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) - ) + (local.get $24) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.c9582b6d.0.snapshot b/compiler/test/__snapshots__/pattern_matching.c9582b6d.0.snapshot index 7c85f281a..f1a8af1bb 100644 --- a/compiler/test/__snapshots__/pattern_matching.c9582b6d.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.c9582b6d.0.snapshot @@ -120,7 +120,7 @@ pattern matching › alias_match_4 (i32.const 31) ) (block $compile_block.10 (result i32) - (i32.const 3) + (i32.const 1) ) (block $compile_block.28 (result i32) (block $compile_store.12 @@ -204,7 +204,7 @@ pattern matching › alias_match_4 (i32.const 1879048190) ) ) - (i32.const 1) + (i32.const 0) ) (block $compile_block.25 (result i32) (block $compile_store.21 @@ -252,10 +252,10 @@ pattern matching › alias_match_4 (i32.const 1879048190) ) ) - (i32.const 1) + (i32.const 0) ) (block $compile_block.24 (result i32) - (i32.const 3) + (i32.const 1) ) ) ) @@ -273,7 +273,7 @@ pattern matching › alias_match_4 ) ) (block $compile_block.27 (result i32) - (i32.const 5) + (i32.const 2) ) ) ) @@ -304,10 +304,7 @@ pattern matching › alias_match_4 (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) - ) + (local.get $11) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot b/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot index 95070d137..d2c4d5574 100644 --- a/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot @@ -585,10 +585,10 @@ pattern matching › adt_match_5 (i32.const 1879048190) ) ) - (i32.const 7) + (i32.const 3) ) (block $compile_block.64 (result i32) - (i32.const 9) + (i32.const 4) ) ) (block $cleanup.59 (result i32) @@ -670,10 +670,10 @@ pattern matching › adt_match_5 (i32.const 1879048190) ) ) - (i32.const 5) + (i32.const 2) ) (block $compile_block.71 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -741,10 +741,10 @@ pattern matching › adt_match_5 (i32.const 1879048190) ) ) - (i32.const 3) + (i32.const 1) ) (block $compile_block.78 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -790,7 +790,7 @@ pattern matching › adt_match_5 (i32.const 31) ) (block $compile_block.83 (result i32) - (i32.const 1) + (i32.const 0) ) (block $compile_block.84 (unreachable) @@ -828,10 +828,7 @@ pattern matching › adt_match_5 (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) - ) + (local.get $26) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.e17bcd61.0.snapshot b/compiler/test/__snapshots__/pattern_matching.e17bcd61.0.snapshot index 36b12463d..8c82ac970 100644 --- a/compiler/test/__snapshots__/pattern_matching.e17bcd61.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.e17bcd61.0.snapshot @@ -50,7 +50,7 @@ pattern matching › or_match_4 (i32.const 31) ) (block $compile_block.3 (result i32) - (i32.const 1) + (i32.const 0) ) (block $compile_block.8 (result i32) (block $compile_store.5 @@ -75,7 +75,7 @@ pattern matching › or_match_4 (i32.const 31) ) (block $compile_block.6 (result i32) - (i32.const 1) + (i32.const 0) ) (block $compile_block.7 (unreachable) @@ -95,10 +95,7 @@ pattern matching › or_match_4 (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) - ) + (local.get $7) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot index 8d2cd1933..047e61787 100644 --- a/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot @@ -620,10 +620,10 @@ pattern matching › tuple_match_deep5 (i32.const 1879048190) ) ) - (i32.const 7) + (i32.const 3) ) (block $compile_block.75 (result i32) - (i32.const 9) + (i32.const 4) ) ) (block $cleanup.69 (result i32) @@ -727,10 +727,10 @@ pattern matching › tuple_match_deep5 (i32.const 1879048190) ) ) - (i32.const 5) + (i32.const 2) ) (block $compile_block.83 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -820,10 +820,10 @@ pattern matching › tuple_match_deep5 (i32.const 1879048190) ) ) - (i32.const 3) + (i32.const 1) ) (block $compile_block.91 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -891,7 +891,7 @@ pattern matching › tuple_match_deep5 (i32.const 1879048190) ) ) - (i32.const 1) + (i32.const 0) ) (block $compile_block.98 (unreachable) @@ -935,10 +935,7 @@ pattern matching › tuple_match_deep5 (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) - ) + (local.get $33) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.eb4334e1.0.snapshot b/compiler/test/__snapshots__/pattern_matching.eb4334e1.0.snapshot index 5904371f3..6a8065486 100644 --- a/compiler/test/__snapshots__/pattern_matching.eb4334e1.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.eb4334e1.0.snapshot @@ -264,7 +264,7 @@ pattern matching › constant_match_4 (i32.const 1879048190) ) ) - (i32.const 1) + (i32.const 0) ) (block $compile_block.36 (result i32) (block $compile_store.27 @@ -290,7 +290,7 @@ pattern matching › constant_match_4 (i32.const 31) ) (block $compile_block.28 (result i32) - (i32.const 3) + (i32.const 1) ) (block $compile_block.35 (result i32) (drop @@ -360,10 +360,10 @@ pattern matching › constant_match_4 (i32.const 1879048190) ) ) - (i32.const 5) + (i32.const 2) ) (block $compile_block.34 (result i32) - (i32.const 7) + (i32.const 3) ) ) ) @@ -372,7 +372,7 @@ pattern matching › constant_match_4 ) ) (block $compile_block.38 (result i32) - (i32.const 7) + (i32.const 3) ) ) ) @@ -403,10 +403,7 @@ pattern matching › constant_match_4 (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) - ) + (local.get $14) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot b/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot index 2a8dc8d2f..7219cae2d 100644 --- a/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot @@ -706,10 +706,10 @@ pattern matching › tuple_match_deep7 (i32.const 1879048190) ) ) - (i32.const 7) + (i32.const 3) ) (block $compile_block.81 (result i32) - (i32.const 9) + (i32.const 4) ) ) (block $cleanup.75 (result i32) @@ -813,10 +813,10 @@ pattern matching › tuple_match_deep7 (i32.const 1879048190) ) ) - (i32.const 5) + (i32.const 2) ) (block $compile_block.89 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -906,10 +906,10 @@ pattern matching › tuple_match_deep7 (i32.const 1879048190) ) ) - (i32.const 3) + (i32.const 1) ) (block $compile_block.97 (result i32) - (i32.const 9) + (i32.const 4) ) ) ) @@ -977,7 +977,7 @@ pattern matching › tuple_match_deep7 (i32.const 1879048190) ) ) - (i32.const 1) + (i32.const 0) ) (block $compile_block.104 (unreachable) @@ -1021,10 +1021,7 @@ pattern matching › tuple_match_deep7 (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) - ) + (local.get $35) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.f25e0163.0.snapshot b/compiler/test/__snapshots__/pattern_matching.f25e0163.0.snapshot index efc203dd1..db1a0163f 100644 --- a/compiler/test/__snapshots__/pattern_matching.f25e0163.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.f25e0163.0.snapshot @@ -352,10 +352,10 @@ pattern matching › or_match_3 (i32.const 1879048190) ) ) - (i32.const 1) + (i32.const 0) ) (block $compile_block.40 (result i32) - (i32.const 3) + (i32.const 1) ) ) ) @@ -404,10 +404,10 @@ pattern matching › or_match_3 (i32.const 1879048190) ) ) - (i32.const 1) + (i32.const 0) ) (block $compile_block.46 (result i32) - (i32.const 3) + (i32.const 1) ) ) ) @@ -475,10 +475,10 @@ pattern matching › or_match_3 (i32.const 1879048190) ) ) - (i32.const 1) + (i32.const 0) ) (block $compile_block.53 (result i32) - (i32.const 3) + (i32.const 1) ) ) ) @@ -502,7 +502,7 @@ pattern matching › or_match_3 ) ) (block $compile_block.56 (result i32) - (i32.const 3) + (i32.const 1) ) ) ) @@ -529,10 +529,7 @@ pattern matching › or_match_3 (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) - ) + (local.get $16) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.f3d48b0e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.f3d48b0e.0.snapshot index a84858cc7..2c7bdc828 100644 --- a/compiler/test/__snapshots__/pattern_matching.f3d48b0e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.f3d48b0e.0.snapshot @@ -50,7 +50,7 @@ pattern matching › or_match_1 (i32.const 31) ) (block $compile_block.3 (result i32) - (i32.const 1) + (i32.const 0) ) (block $compile_block.8 (result i32) (block $compile_store.5 @@ -75,7 +75,7 @@ pattern matching › or_match_1 (i32.const 31) ) (block $compile_block.6 (result i32) - (i32.const 1) + (i32.const 0) ) (block $compile_block.7 (unreachable) @@ -95,10 +95,7 @@ pattern matching › or_match_1 (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) - ) + (local.get $7) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.f6c9c89c.0.snapshot b/compiler/test/__snapshots__/pattern_matching.f6c9c89c.0.snapshot index d8eaa83cb..576982f48 100644 --- a/compiler/test/__snapshots__/pattern_matching.f6c9c89c.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.f6c9c89c.0.snapshot @@ -113,7 +113,7 @@ pattern matching › or_match_2 (i32.const 31) ) (block $compile_block.8 (result i32) - (i32.const 3) + (i32.const 1) ) (block $compile_block.28 (result i32) (block $compile_store.10 @@ -175,7 +175,7 @@ pattern matching › or_match_2 (i32.const 31) ) (block $compile_block.16 (result i32) - (i32.const 1) + (i32.const 0) ) (block $compile_block.25 (result i32) (block $compile_store.18 @@ -201,7 +201,7 @@ pattern matching › or_match_2 (i32.const 31) ) (block $compile_block.19 (result i32) - (i32.const 1) + (i32.const 0) ) (block $compile_block.24 (result i32) (block $compile_store.21 @@ -227,10 +227,10 @@ pattern matching › or_match_2 (i32.const 31) ) (block $compile_block.22 (result i32) - (i32.const 3) + (i32.const 1) ) (block $compile_block.23 (result i32) - (i32.const 5) + (i32.const 2) ) ) ) @@ -250,7 +250,7 @@ pattern matching › or_match_2 ) ) (block $compile_block.27 (result i32) - (i32.const 5) + (i32.const 2) ) ) ) @@ -279,10 +279,7 @@ pattern matching › or_match_2 (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) - ) + (local.get $10) ) ) ) diff --git a/compiler/test/__snapshots__/tuples.2c91b91d.0.snapshot b/compiler/test/__snapshots__/tuples.2c91b91d.0.snapshot index 2de95ddb6..af0e6c6bb 100644 --- a/compiler/test/__snapshots__/tuples.2c91b91d.0.snapshot +++ b/compiler/test/__snapshots__/tuples.2c91b91d.0.snapshot @@ -193,7 +193,7 @@ tuples › tup1_destruct_trailing (i32.const 1879048190) ) ) - (i32.const 1) + (i32.const 0) ) ) (func $_start diff --git a/compiler/test/suites/basic_functionality.re b/compiler/test/suites/basic_functionality.re index dd75d7118..58d190f72 100644 --- a/compiler/test/suites/basic_functionality.re +++ b/compiler/test/suites/basic_functionality.re @@ -377,6 +377,6 @@ describe("basic functionality", ({test, testSkip}) => { ~config_fn=smallestFileConfig, "smallest_grain_program", "", - 4750, + 4741, ); }); From 5f7b03e1c64444e19ec91c7745705afa7b408447 Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Thu, 10 Oct 2024 17:00:10 -0400 Subject: [PATCH 05/10] chore: Cleanup impl --- compiler/src/middle_end/matchcomp.re | 353 +++++++++++++++------------ 1 file changed, 197 insertions(+), 156 deletions(-) diff --git a/compiler/src/middle_end/matchcomp.re b/compiler/src/middle_end/matchcomp.re index 3bc20baf7..0b2a04711 100644 --- a/compiler/src/middle_end/matchcomp.re +++ b/compiler/src/middle_end/matchcomp.re @@ -85,12 +85,7 @@ and matrix_type = | ConstantMatrix and switch_type = - | CharSwitch - | Int8Switch - | Int16Switch - | UInt8Switch - | UInt16Switch - | WasmI32Switch + | ConstantSwitch(constant) | ConstructorSwitch | ArraySwitch @@ -568,12 +563,12 @@ let get_constant_tag = const => | Const_char(char) => let uchar = List.hd @@ Utf8.decodeUtf8String(char); let uchar_int: int = Utf8__Uchar.toInt(uchar); - Some((CharSwitch, uchar_int)); - | Const_int8(i) => Some((Int8Switch, Int32.to_int(i))) - | Const_int16(i) => Some((Int16Switch, Int32.to_int(i))) - | Const_uint8(i) => Some((UInt8Switch, Int32.to_int(i))) - | Const_uint16(i) => Some((UInt16Switch, Int32.to_int(i))) - | Const_wasmi32(i) => Some((WasmI32Switch, Int32.to_int(i))) + Some(uchar_int); + | Const_int8(i) => Some(Int32.to_int(i)) + | Const_int16(i) => Some(Int32.to_int(i)) + | Const_uint8(i) => Some(Int32.to_int(i)) + | Const_uint16(i) => Some(Int32.to_int(i)) + | Const_wasmi32(i) => Some(Int32.to_int(i)) | _ => None }; @@ -711,14 +706,6 @@ let rec compile_matrix = mtx => | Const_uint8(_) | Const_uint16(_) | Const_wasmi32(_) => - let switch_type = - switch (get_constant_tag(constant_type)) { - | Some((tag, _)) => tag - | None => - failwith( - "Internal error: compile_matrix: no tag found for constant", - ) - }; let cases = List.fold_right( (const, acc) => { @@ -726,7 +713,7 @@ let rec compile_matrix = mtx => let result = compile_matrix(specialized); let tag = switch (get_constant_tag(const)) { - | Some((_, tag)) => tag + | Some(tag) => tag | None => failwith( "Internal error: compile_matrix: no tag found for constant", @@ -737,7 +724,12 @@ let rec compile_matrix = mtx => constants, [], ); - Switch(switch_type, Some(alias), cases, Some(default_tree)); + Switch( + ConstantSwitch(constant_type), + Some(alias), + cases, + default_tree == Fail ? None : Some(default_tree), + ); | _ => List.fold_right( (const, acc) => { @@ -1219,136 +1211,191 @@ module MatchTreeCompiler = { helpI, helpConst, ); - let value_constr_name = Ident.create("match_constructor"); - let value_constr_id = - Imm.id(~loc=Location.dummy_loc, value_constr_name); - let value_constr = + // TODO: Convert array tag and constructor tag to ConstantSwitch on an int32 and untag alternatively we could use low level get functions or primitives + let (switch_content, switch_setup) = switch (switch_type) { - | ConstructorSwitch => - Comp.adt_get_tag(~loc=Location.dummy_loc, cur_value) + | ConstructorSwitch | ArraySwitch => - Comp.prim1( - ~loc=Location.dummy_loc, - ~allocation_type=Unmanaged(WasmI32), - ArrayLength, - cur_value, - ) - | CharSwitch => - Comp.prim1( - ~loc=Location.dummy_loc, - ~allocation_type=Unmanaged(WasmI32), - UntagChar, - cur_value, - ) - | Int8Switch => - Comp.prim1( - ~loc=Location.dummy_loc, - ~allocation_type=Unmanaged(WasmI32), - UntagInt8, - cur_value, - ) - | Int16Switch => - Comp.prim1( - ~loc=Location.dummy_loc, - ~allocation_type=Unmanaged(WasmI32), - UntagInt16, - cur_value, - ) - | UInt8Switch => - Comp.prim1( - ~loc=Location.dummy_loc, - ~allocation_type=Unmanaged(WasmI32), - UntagUint8, - cur_value, - ) - | UInt16Switch => - Comp.prim1( - ~loc=Location.dummy_loc, - ~allocation_type=Unmanaged(WasmI32), - UntagUint16, - cur_value, - ) - | WasmI32Switch => - Comp.imm( - ~loc=Location.dummy_loc, - ~allocation_type=Unmanaged(WasmI32), - cur_value, - ) - }; - /* Fold left should be safe here, since there should be at most one branch - per value */ - // TODO: optimize for a jump table, Comp.switch - // TODO: We need to check what percentage of our range is full - // TODO: branch_condition needs to be extracted into a switch - // TODO: body needs to be the switch code path - // TODO: Base becomes default - let (switch_body_ans, switch_body_setup) = - List.fold_left( - ((body_ans, body_setup), (tag, tree)) => { - let cmp_id_name = Ident.create("match_cmp_values"); - let cmp_id = Imm.id(~loc=Location.dummy_loc, cmp_id_name); - /* If the value has the correct tag, execute this branch. - Otherwise continue. */ - let branch_condition = - switch (switch_type) { - | CharSwitch - | Int8Switch - | Int16Switch - | UInt8Switch - | UInt16Switch - | WasmI32Switch => - Comp.prim2( - ~loc=Location.dummy_loc, - ~allocation_type=Unmanaged(WasmI32), - WasmBinaryI32({ - wasm_op: Op_eq_int32, - arg_types: (Wasm_int32, Wasm_int32), - ret_type: Grain_bool, - }), - value_constr_id, - Imm.const( + let value_constr_name = Ident.create("match_constructor"); + let value_constr_id = + Imm.id(~loc=Location.dummy_loc, value_constr_name); + let value_constr = + switch (switch_type) { + | ConstantSwitch(_) => failwith("Impossible") + | ConstructorSwitch => + Comp.adt_get_tag(~loc=Location.dummy_loc, cur_value) + | ArraySwitch => + Comp.prim1( + ~loc=Location.dummy_loc, + ~allocation_type=Unmanaged(WasmI32), + ArrayLength, + cur_value, + ) + }; + /* Fold left should be safe here, since there should be at most one branch + per value */ + let (switch_body_ans, switch_body_setup) = + List.fold_left( + ((body_ans, body_setup), (tag, tree)) => { + let cmp_id_name = Ident.create("match_cmp_values"); + let cmp_id = Imm.id(~loc=Location.dummy_loc, cmp_id_name); + /* If the value has the correct tag, execute this branch. + Otherwise continue. */ + let branch_condition = + Comp.prim2( ~loc=Location.dummy_loc, - Const_wasmi32(Int32.of_int(tag)), - ), - ) - | ConstructorSwitch - | ArraySwitch => - Comp.prim2( - ~loc=Location.dummy_loc, - ~allocation_type=Unmanaged(WasmI32), - Is, - value_constr_id, - Imm.const( + ~allocation_type=Unmanaged(WasmI32), + Is, + value_constr_id, + Imm.const( + ~loc=Location.dummy_loc, + Const_number(Const_number_int(Int64.of_int(tag))), + ), + ); + let setup = [BLet(cmp_id_name, branch_condition, Nonglobal)]; + let (tree_ans, tree_setup) = + compile_tree_help( + ~loc, + ~env, + ~mut_boxing, + tree, + values, + expr, + helpI, + helpConst, + ); + let ans = + Comp.if_( ~loc=Location.dummy_loc, - Const_number(Const_number_int(Int64.of_int(tag))), - ), - ) - }; - let setup = [BLet(cmp_id_name, branch_condition, Nonglobal)]; - let (tree_ans, tree_setup) = - compile_tree_help( - ~loc, - ~env, - ~mut_boxing, - tree, - values, - expr, - helpI, - helpConst, - ); - let ans = - Comp.if_( + ~allocation_type=tree_ans.comp_allocation_type, + cmp_id, + fold_tree(tree_setup, tree_ans), + fold_tree(body_setup, body_ans), + ); + (ans, setup); + }, + base, + cases, + ); + ( + switch_body_ans, + [ + BLet(value_constr_name, value_constr, Nonglobal), + ...switch_body_setup, + ], + ); + | ConstantSwitch(const) => + // Get Value Constructor + let compile_cond_i32 = v => + Imm.const( + ~loc=Location.dummy_loc, + Const_wasmi32(Int32.of_int(v)), + ); + let (value_op, value_typ, compile_cond) = + switch (const) { + | Const_char(_) => (Some(UntagChar), WasmI32, compile_cond_i32) + | Const_int8(_) => (Some(UntagInt8), WasmI32, compile_cond_i32) + | Const_int16(_) => (Some(UntagInt16), WasmI32, compile_cond_i32) + | Const_uint8(_) => (Some(UntagUint8), WasmI32, compile_cond_i32) + | Const_uint16(_) => ( + Some(UntagUint16), + WasmI32, + compile_cond_i32, + ) + | Const_wasmi32(_) => (None, WasmI32, compile_cond_i32) + | _ => + failwith("Impossible: should fall back to equality matching") + }; + let cond_name = Ident.create("match_cond"); + let cond_id = Imm.id(~loc=Location.dummy_loc, cond_name); + let condition = + switch (value_op) { + | Some(tag_op) => + Comp.prim1( ~loc=Location.dummy_loc, - ~allocation_type=tree_ans.comp_allocation_type, - cmp_id, - fold_tree(tree_setup, tree_ans), - fold_tree(body_setup, body_ans), - ); - (ans, setup); - }, - base, - cases, - ); + ~allocation_type=Unmanaged(value_typ), + tag_op, + cur_value, + ) + | None => + Comp.imm( + ~loc=Location.dummy_loc, + ~allocation_type=Unmanaged(value_typ), + cur_value, + ) + }; + let equality_op = + switch (value_typ) { + | WasmI32 => + WasmBinaryI32({ + wasm_op: Op_eq_int32, + arg_types: (Wasm_int32, Wasm_int32), + ret_type: Grain_bool, + }) + | WasmI64 => + WasmBinaryI64({ + wasm_op: Op_eq_int64, + arg_types: (Wasm_int64, Wasm_int64), + ret_type: Grain_bool, + }) + | WasmF32 => + WasmBinaryF32({ + wasm_op: Op_eq_float32, + arg_types: (Wasm_float32, Wasm_float32), + ret_type: Grain_bool, + }) + | WasmF64 => + WasmBinaryF64({ + wasm_op: Op_eq_float64, + arg_types: (Wasm_float64, Wasm_float64), + ret_type: Grain_bool, + }) + }; + /* Fold left should be safe here, since there should be at most one branch + per value */ + let (switch_body_ans, switch_body_setup) = + List.fold_left( + ((body_ans, body_setup), (tag, tree)) => { + let cmp_id_name = Ident.create("match_cmp_values"); + let cmp_id = Imm.id(~loc=Location.dummy_loc, cmp_id_name); + let branch_condition = + Comp.prim2( + ~loc=Location.dummy_loc, + ~allocation_type=Unmanaged(WasmI32), + equality_op, + cond_id, + compile_cond(tag), + ); + let setup = [BLet(cmp_id_name, branch_condition, Nonglobal)]; + let (tree_ans, tree_setup) = + compile_tree_help( + ~loc, + ~env, + ~mut_boxing, + tree, + values, + expr, + helpI, + helpConst, + ); + let ans = + Comp.if_( + ~loc=Location.dummy_loc, + ~allocation_type=tree_ans.comp_allocation_type, + cmp_id, + fold_tree(tree_setup, tree_ans), + fold_tree(body_setup, body_ans), + ); + (ans, setup); + }, + base, + cases, + ); + ( + switch_body_ans, + [BLet(cond_name, condition, Nonglobal), ...switch_body_setup], + ); + }; let switch_body_setup = switch (alias) { | Some(alias) => [ @@ -1361,17 +1408,11 @@ module MatchTreeCompiler = { ), Nonglobal, ), - ...switch_body_setup, + ...switch_setup, ] - | None => switch_body_setup + | None => switch_setup }; - ( - switch_body_ans, - [ - BLet(value_constr_name, value_constr, Nonglobal), - ...switch_body_setup, - ], - ); + (switch_content, switch_body_setup); }; }; From 31141846ecfa6793516f2cd10ef6e6e7f2f1eb3d Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Thu, 10 Oct 2024 19:18:07 -0400 Subject: [PATCH 06/10] feat: Compile Constructors and Arrays the same way --- compiler/src/middle_end/matchcomp.re | 364 ++++++++-------- .../pattern_matching.05b60a1e.0.snapshot | 107 ++--- .../pattern_matching.0ad4ac05.0.snapshot | 392 ++++++++++-------- .../pattern_matching.0bb6923e.0.snapshot | 362 ++++++++-------- .../pattern_matching.0fa61137.0.snapshot | 8 +- .../pattern_matching.5b6ff2d3.0.snapshot | 153 +++---- .../pattern_matching.702ed9b0.0.snapshot | 392 ++++++++++-------- .../pattern_matching.79346fef.0.snapshot | 392 ++++++++++-------- .../pattern_matching.8c0dc67a.0.snapshot | 362 ++++++++-------- .../pattern_matching.b1b060ad.0.snapshot | 362 ++++++++-------- .../pattern_matching.c91eac29.0.snapshot | 362 ++++++++-------- .../pattern_matching.c9582b6d.0.snapshot | 135 +++--- .../pattern_matching.d048ece0.0.snapshot | 362 ++++++++-------- .../pattern_matching.e41ad64e.0.snapshot | 392 ++++++++++-------- .../pattern_matching.f0c08ea4.0.snapshot | 392 ++++++++++-------- .../pattern_matching.f25e0163.0.snapshot | 282 +++++++------ .../pattern_matching.f6c9c89c.0.snapshot | 141 ++++--- compiler/test/suites/basic_functionality.re | 2 +- 18 files changed, 2654 insertions(+), 2308 deletions(-) diff --git a/compiler/src/middle_end/matchcomp.re b/compiler/src/middle_end/matchcomp.re index 0b2a04711..b36b4d2fe 100644 --- a/compiler/src/middle_end/matchcomp.re +++ b/compiler/src/middle_end/matchcomp.re @@ -566,9 +566,14 @@ let get_constant_tag = const => Some(uchar_int); | Const_int8(i) => Some(Int32.to_int(i)) | Const_int16(i) => Some(Int32.to_int(i)) + | Const_int32(i) => Some(Int32.to_int(i)) + | Const_int64(i) => Some(Int64.to_int(i)) | Const_uint8(i) => Some(Int32.to_int(i)) | Const_uint16(i) => Some(Int32.to_int(i)) + | Const_uint32(i) => Some(Int32.to_int(i)) + | Const_uint64(i) => Some(Int64.to_int(i)) | Const_wasmi32(i) => Some(Int32.to_int(i)) + | Const_wasmi64(i) => Some(Int64.to_int(i)) | _ => None }; @@ -682,7 +687,6 @@ let rec compile_matrix = mtx => | ConstantMatrix => let constants = matrix_head_constants(mtx); let constant_type = List.hd(constants); - let equality_type = equality_type(constant_type); // TODO(#1185): Optimize physical equality checks into a switch. // We can also do partial switches on Numbers if some of the @@ -699,13 +703,8 @@ let rec compile_matrix = mtx => Fail; }; - switch (constant_type) { - | Const_char(_) - | Const_int8(_) - | Const_int16(_) - | Const_uint8(_) - | Const_uint16(_) - | Const_wasmi32(_) => + switch (get_constant_tag(constant_type)) { + | Some(_) => let cases = List.fold_right( (const, acc) => { @@ -730,7 +729,8 @@ let rec compile_matrix = mtx => cases, default_tree == Fail ? None : Some(default_tree), ); - | _ => + | None => + let equality_type = equality_type(constant_type); List.fold_right( (const, acc) => { let specialized = specialize_constant_matrix(const, alias, mtx); @@ -739,7 +739,7 @@ let rec compile_matrix = mtx => }, constants, default_tree, - ) + ); }; }; | _ => @@ -767,6 +767,12 @@ module MatchTreeCompiler = { open Anftree; open Anf_helper; + type constant_value_op = + | Prim1(prim1) + | Prim2(prim2, int) + | Constructor + | Constant; + let pattern_could_contain_binding = patt => switch (patt.pat_desc) { | TPatConstant(_) @@ -1211,191 +1217,171 @@ module MatchTreeCompiler = { helpI, helpConst, ); - // TODO: Convert array tag and constructor tag to ConstantSwitch on an int32 and untag alternatively we could use low level get functions or primitives - let (switch_content, switch_setup) = + // Get Value Constructor + let comp_cond_i32 = v => + Imm.const(~loc=Location.dummy_loc, Const_wasmi32(Int32.of_int(v))); + let comp_cond_i64 = v => + Imm.const(~loc=Location.dummy_loc, Const_wasmi64(Int64.of_int(v))); + let (value_op, value_typ, compile_cond) = switch (switch_type) { - | ConstructorSwitch - | ArraySwitch => - let value_constr_name = Ident.create("match_constructor"); - let value_constr_id = - Imm.id(~loc=Location.dummy_loc, value_constr_name); - let value_constr = - switch (switch_type) { - | ConstantSwitch(_) => failwith("Impossible") - | ConstructorSwitch => - Comp.adt_get_tag(~loc=Location.dummy_loc, cur_value) - | ArraySwitch => - Comp.prim1( - ~loc=Location.dummy_loc, - ~allocation_type=Unmanaged(WasmI32), - ArrayLength, - cur_value, - ) - }; - /* Fold left should be safe here, since there should be at most one branch - per value */ - let (switch_body_ans, switch_body_setup) = - List.fold_left( - ((body_ans, body_setup), (tag, tree)) => { - let cmp_id_name = Ident.create("match_cmp_values"); - let cmp_id = Imm.id(~loc=Location.dummy_loc, cmp_id_name); - /* If the value has the correct tag, execute this branch. - Otherwise continue. */ - let branch_condition = - Comp.prim2( - ~loc=Location.dummy_loc, - ~allocation_type=Unmanaged(WasmI32), - Is, - value_constr_id, - Imm.const( - ~loc=Location.dummy_loc, - Const_number(Const_number_int(Int64.of_int(tag))), - ), - ); - let setup = [BLet(cmp_id_name, branch_condition, Nonglobal)]; - let (tree_ans, tree_setup) = - compile_tree_help( - ~loc, - ~env, - ~mut_boxing, - tree, - values, - expr, - helpI, - helpConst, - ); - let ans = - Comp.if_( - ~loc=Location.dummy_loc, - ~allocation_type=tree_ans.comp_allocation_type, - cmp_id, - fold_tree(tree_setup, tree_ans), - fold_tree(body_setup, body_ans), - ); - (ans, setup); - }, - base, - cases, - ); - ( - switch_body_ans, - [ - BLet(value_constr_name, value_constr, Nonglobal), - ...switch_body_setup, - ], - ); | ConstantSwitch(const) => - // Get Value Constructor - let compile_cond_i32 = v => - Imm.const( + switch (const) { + | Const_char(_) => (Prim1(UntagChar), WasmI32, comp_cond_i32) + | Const_int8(_) => (Prim1(UntagInt8), WasmI32, comp_cond_i32) + | Const_int16(_) => (Prim1(UntagInt16), WasmI32, comp_cond_i32) + | Const_int32(_) => ( + Prim2(WasmLoadI32({sz: 4, signed: true}), 4), + WasmI32, + comp_cond_i32, + ) + | Const_int64(_) => ( + Prim2(WasmLoadI64({sz: 8, signed: true}), 8), + WasmI64, + comp_cond_i64, + ) + | Const_uint8(_) => (Prim1(UntagUint8), WasmI32, comp_cond_i32) + | Const_uint16(_) => (Prim1(UntagUint16), WasmI32, comp_cond_i32) + | Const_uint32(_) => ( + Prim2(WasmLoadI32({sz: 4, signed: false}), 4), + WasmI32, + comp_cond_i32, + ) + | Const_uint64(_) => ( + Prim2(WasmLoadI64({sz: 8, signed: false}), 8), + WasmI64, + comp_cond_i64, + ) + | Const_wasmi32(_) => (Constant, WasmI32, comp_cond_i32) + | Const_wasmi64(_) => (Constant, WasmI64, comp_cond_i64) + | _ => failwith("Impossible: should fall back to equality matching") + } + | ArraySwitch => ( + Prim2(WasmLoadI32({sz: 4, signed: false}), 4), + WasmI32, + comp_cond_i32, + ) + | ConstructorSwitch => (Constructor, WasmI32, comp_cond_i32) + }; + let cond_name = Ident.create("match_cond"); + let cond_id = Imm.id(~loc=Location.dummy_loc, cond_name); + let (cond, cond_binds) = + switch (value_op) { + | Prim1(op) => ( + Comp.prim1( ~loc=Location.dummy_loc, - Const_wasmi32(Int32.of_int(v)), - ); - let (value_op, value_typ, compile_cond) = - switch (const) { - | Const_char(_) => (Some(UntagChar), WasmI32, compile_cond_i32) - | Const_int8(_) => (Some(UntagInt8), WasmI32, compile_cond_i32) - | Const_int16(_) => (Some(UntagInt16), WasmI32, compile_cond_i32) - | Const_uint8(_) => (Some(UntagUint8), WasmI32, compile_cond_i32) - | Const_uint16(_) => ( - Some(UntagUint16), - WasmI32, - compile_cond_i32, - ) - | Const_wasmi32(_) => (None, WasmI32, compile_cond_i32) - | _ => - failwith("Impossible: should fall back to equality matching") - }; - let cond_name = Ident.create("match_cond"); - let cond_id = Imm.id(~loc=Location.dummy_loc, cond_name); - let condition = - switch (value_op) { - | Some(tag_op) => - Comp.prim1( - ~loc=Location.dummy_loc, - ~allocation_type=Unmanaged(value_typ), - tag_op, - cur_value, - ) - | None => - Comp.imm( - ~loc=Location.dummy_loc, - ~allocation_type=Unmanaged(value_typ), - cur_value, - ) - }; - let equality_op = - switch (value_typ) { - | WasmI32 => - WasmBinaryI32({ - wasm_op: Op_eq_int32, - arg_types: (Wasm_int32, Wasm_int32), - ret_type: Grain_bool, - }) - | WasmI64 => - WasmBinaryI64({ - wasm_op: Op_eq_int64, - arg_types: (Wasm_int64, Wasm_int64), - ret_type: Grain_bool, - }) - | WasmF32 => - WasmBinaryF32({ - wasm_op: Op_eq_float32, - arg_types: (Wasm_float32, Wasm_float32), - ret_type: Grain_bool, - }) - | WasmF64 => - WasmBinaryF64({ - wasm_op: Op_eq_float64, - arg_types: (Wasm_float64, Wasm_float64), - ret_type: Grain_bool, - }) - }; - /* Fold left should be safe here, since there should be at most one branch - per value */ - let (switch_body_ans, switch_body_setup) = - List.fold_left( - ((body_ans, body_setup), (tag, tree)) => { - let cmp_id_name = Ident.create("match_cmp_values"); - let cmp_id = Imm.id(~loc=Location.dummy_loc, cmp_id_name); - let branch_condition = - Comp.prim2( - ~loc=Location.dummy_loc, - ~allocation_type=Unmanaged(WasmI32), - equality_op, - cond_id, - compile_cond(tag), - ); - let setup = [BLet(cmp_id_name, branch_condition, Nonglobal)]; - let (tree_ans, tree_setup) = - compile_tree_help( - ~loc, - ~env, - ~mut_boxing, - tree, - values, - expr, - helpI, - helpConst, - ); - let ans = - Comp.if_( - ~loc=Location.dummy_loc, - ~allocation_type=tree_ans.comp_allocation_type, - cmp_id, - fold_tree(tree_setup, tree_ans), - fold_tree(body_setup, body_ans), - ); - (ans, setup); - }, - base, - cases, + ~allocation_type=Unmanaged(value_typ), + op, + cur_value, + ), + [], + ) + | Prim2(op, p) => ( + Comp.prim2( + ~loc=Location.dummy_loc, + ~allocation_type=Unmanaged(value_typ), + op, + cur_value, + comp_cond_i32(p), + ), + [], + ) + | Constructor => + let match_cstr_tag = Ident.create("match_cstr_tag"); + let match_cstr_id = Imm.id(~loc=Location.dummy_loc, match_cstr_tag); + let cstr_tag = + Comp.prim1( + ~loc=Location.dummy_loc, + ~allocation_type=Unmanaged(value_typ), + LoadAdtVariant, + cur_value, ); ( - switch_body_ans, - [BLet(cond_name, condition, Nonglobal), ...switch_body_setup], + Comp.prim1( + ~loc=Location.dummy_loc, + ~allocation_type=Unmanaged(value_typ), + UntagSimpleNumber, + match_cstr_id, + ), + [BLet(match_cstr_tag, cstr_tag, Nonglobal)], ); + | Constant => ( + Comp.imm( + ~loc=Location.dummy_loc, + ~allocation_type=Unmanaged(value_typ), + cur_value, + ), + [], + ) + }; + let equality_op = + switch (value_typ) { + | WasmI32 => + WasmBinaryI32({ + wasm_op: Op_eq_int32, + arg_types: (Wasm_int32, Wasm_int32), + ret_type: Grain_bool, + }) + | WasmI64 => + WasmBinaryI64({ + wasm_op: Op_eq_int64, + arg_types: (Wasm_int64, Wasm_int64), + ret_type: Grain_bool, + }) + | WasmF32 => + WasmBinaryF32({ + wasm_op: Op_eq_float32, + arg_types: (Wasm_float32, Wasm_float32), + ret_type: Grain_bool, + }) + | WasmF64 => + WasmBinaryF64({ + wasm_op: Op_eq_float64, + arg_types: (Wasm_float64, Wasm_float64), + ret_type: Grain_bool, + }) }; + /* Fold left should be safe here, since there should be at most one branch + per value */ + let (switch_body_ans, switch_body_setup) = + List.fold_left( + ((body_ans, body_setup), (tag, tree)) => { + let cmp_id_name = Ident.create("match_cmp_values"); + let cmp_id = Imm.id(~loc=Location.dummy_loc, cmp_id_name); + let branch_condition = + Comp.prim2( + ~loc=Location.dummy_loc, + ~allocation_type=Unmanaged(WasmI32), + equality_op, + cond_id, + compile_cond(tag), + ); + let setup = [BLet(cmp_id_name, branch_condition, Nonglobal)]; + let (tree_ans, tree_setup) = + compile_tree_help( + ~loc, + ~env, + ~mut_boxing, + tree, + values, + expr, + helpI, + helpConst, + ); + let ans = + Comp.if_( + ~loc=Location.dummy_loc, + ~allocation_type=tree_ans.comp_allocation_type, + cmp_id, + fold_tree(tree_setup, tree_ans), + fold_tree(body_setup, body_ans), + ); + (ans, setup); + }, + base, + cases, + ); + let switch_setup = + cond_binds @ [BLet(cond_name, cond, Nonglobal), ...switch_body_setup]; let switch_body_setup = switch (alias) { | Some(alias) => [ @@ -1412,7 +1398,7 @@ module MatchTreeCompiler = { ] | None => switch_setup }; - (switch_content, switch_body_setup); + (switch_body_ans, switch_body_setup); }; }; diff --git a/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot index c0062a663..b478fbde3 100644 --- a/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot @@ -39,7 +39,8 @@ pattern matching › adt_match_deep (local $13 i32) (local $14 i32) (local $15 i32) - (block $compile_block.36 (result i32) + (local $16 i32) + (block $compile_block.38 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_record.1 (result i32) @@ -168,29 +169,37 @@ pattern matching › adt_match_deep ) (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) + (i32.shr_s + (local.get $12) + (i32.const 1) ) ) (block $do_backpatches.14 ) ) - (block $compile_store.29 + (block $compile_store.17 (local.set $14 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $13) + (i32.const 0) + ) + ) + ) + (block $do_backpatches.16 + ) + ) + (block $compile_store.31 + (local.set $15 (if (result i32) (i32.shr_u - (local.get $13) + (local.get $14) (i32.const 31) ) - (block $compile_block.22 (result i32) - (block $compile_store.17 + (block $compile_block.24 (result i32) + (block $compile_store.19 (local.set $10 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -199,10 +208,10 @@ pattern matching › adt_match_deep ) ) ) - (block $do_backpatches.16 + (block $do_backpatches.18 ) ) - (block $compile_store.19 + (block $compile_store.21 (local.set $11 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -211,10 +220,10 @@ pattern matching › adt_match_deep ) ) ) - (block $do_backpatches.18 + (block $do_backpatches.20 ) ) - (block $cleanup.20 + (block $cleanup.22 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -223,7 +232,7 @@ pattern matching › adt_match_deep ) ) (drop - (block $compile_set.21 (result i32) + (block $compile_set.23 (result i32) (local.set $9 (tuple.extract 0 (tuple.make @@ -243,42 +252,40 @@ pattern matching › adt_match_deep ) (i32.const 1) ) - (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) - ) + (block $compile_block.29 (result i32) + (block $compile_store.26 + (local.set $16 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $13) + (i32.const 1) + ) ) ) - (block $do_backpatches.23 + (block $do_backpatches.25 ) ) (if (result i32) (i32.shr_u - (local.get $15) + (local.get $16) (i32.const 31) ) - (block $compile_block.25 (result i32) + (block $compile_block.27 (result i32) (i32.const 0) ) - (block $compile_block.26 + (block $compile_block.28 (unreachable) ) ) ) ) ) - (block $do_backpatches.28 + (block $do_backpatches.30 ) ) - (block $cleanup.30 + (block $cleanup.32 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -288,29 +295,29 @@ pattern matching › adt_match_deep ) (tuple.extract 0 (tuple.make - (block $switch.32_outer (result i32) - (block $switch.32_branch_0 (result i32) + (block $switch.34_outer (result i32) + (block $switch.34_branch_0 (result i32) (drop - (block $switch.32_branch_1 (result i32) + (block $switch.34_branch_1 (result i32) (drop - (block $switch.32_branch_2 (result i32) + (block $switch.34_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 + (block $switch.34_default (result i32) + (br_table $switch.34_branch_1 $switch.34_branch_2 $switch.34_default $switch.34_default (i32.const 0) - (local.get $14) + (local.get $15) ) ) ) - (br $switch.32_outer - (block $compile_block.35 (result i32) + (br $switch.34_outer + (block $compile_block.37 (result i32) (unreachable) ) ) ) ) - (br $switch.32_outer - (block $compile_block.34 (result i32) + (br $switch.34_outer + (block $compile_block.36 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $9) @@ -319,14 +326,14 @@ pattern matching › adt_match_deep ) ) ) - (br $switch.32_outer - (block $compile_block.33 (result i32) + (br $switch.34_outer + (block $compile_block.35 (result i32) (i32.const 1999) ) ) ) ) - (block $cleanup.31 (result i32) + (block $cleanup.33 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot index 979cffa47..56ba5ace1 100644 --- a/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot @@ -13,11 +13,11 @@ pattern matching › tuple_match_deep4 (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$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 $+_1153 (param i32 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)) @@ -68,7 +68,11 @@ pattern matching › tuple_match_deep4 (local $39 i32) (local $40 i32) (local $41 i32) - (block $compile_block.117 (result i32) + (local $42 i32) + (local $43 i32) + (local $44 i32) + (local $45 i32) + (block $compile_block.125 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -288,29 +292,37 @@ pattern matching › tuple_match_deep4 ) (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) + (i32.shr_s + (local.get $30) + (i32.const 1) ) ) (block $do_backpatches.37 ) ) - (block $compile_store.98 + (block $compile_store.40 (local.set $32 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $31) + (i32.const 0) + ) + ) + ) + (block $do_backpatches.39 + ) + ) + (block $compile_store.106 + (local.set $33 (if (result i32) (i32.shr_u - (local.get $31) + (local.get $32) (i32.const 31) ) - (block $compile_block.90 (result i32) - (block $compile_store.40 + (block $compile_block.98 (result i32) + (block $compile_store.42 (local.set $21 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -319,10 +331,10 @@ pattern matching › tuple_match_deep4 ) ) ) - (block $do_backpatches.39 + (block $do_backpatches.41 ) ) - (block $compile_store.42 + (block $compile_store.44 (local.set $22 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -331,43 +343,51 @@ pattern matching › tuple_match_deep4 ) ) ) - (block $do_backpatches.41 + (block $do_backpatches.43 ) ) - (block $compile_store.44 - (local.set $34 + (block $compile_store.46 + (local.set $35 (i32.load offset=12 (local.get $22) ) ) - (block $do_backpatches.43 + (block $do_backpatches.45 ) ) - (block $compile_store.46 - (local.set $35 - (i32.or - (i32.shl - (i32.eq - (local.get $34) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.48 + (local.set $36 + (i32.shr_s + (local.get $35) + (i32.const 1) + ) + ) + (block $do_backpatches.47 + ) + ) + (block $compile_store.50 + (local.set $37 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $36) + (i32.const 0) + ) ) ) - (block $do_backpatches.45 + (block $do_backpatches.49 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $35) + (local.get $37) (i32.const 31) ) - (block $compile_block.82 (result i32) - (block $compile_store.49 + (block $compile_block.90 (result i32) + (block $compile_store.53 (local.set $23 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -376,10 +396,10 @@ pattern matching › tuple_match_deep4 ) ) ) - (block $do_backpatches.48 + (block $do_backpatches.52 ) ) - (block $compile_store.51 + (block $compile_store.55 (local.set $24 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -388,43 +408,51 @@ pattern matching › tuple_match_deep4 ) ) ) - (block $do_backpatches.50 + (block $do_backpatches.54 ) ) - (block $compile_store.53 - (local.set $37 + (block $compile_store.57 + (local.set $39 (i32.load offset=12 (local.get $24) ) ) - (block $do_backpatches.52 + (block $do_backpatches.56 ) ) - (block $compile_store.55 - (local.set $38 - (i32.or - (i32.shl - (i32.eq - (local.get $37) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.59 + (local.set $40 + (i32.shr_s + (local.get $39) + (i32.const 1) + ) + ) + (block $do_backpatches.58 + ) + ) + (block $compile_store.61 + (local.set $41 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $40) + (i32.const 0) + ) ) ) - (block $do_backpatches.54 + (block $do_backpatches.60 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $38) + (local.get $41) (i32.const 31) ) - (block $compile_block.73 (result i32) - (block $compile_store.58 + (block $compile_block.81 (result i32) + (block $compile_store.64 (local.set $25 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -433,10 +461,10 @@ pattern matching › tuple_match_deep4 ) ) ) - (block $do_backpatches.57 + (block $do_backpatches.63 ) ) - (block $compile_store.60 + (block $compile_store.66 (local.set $26 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -445,19 +473,19 @@ pattern matching › tuple_match_deep4 ) ) ) - (block $do_backpatches.59 + (block $do_backpatches.65 ) ) - (block $compile_store.62 - (local.set $40 + (block $compile_store.68 + (local.set $43 (i32.load offset=12 (local.get $26) ) ) - (block $do_backpatches.61 + (block $do_backpatches.67 ) ) - (block $cleanup.63 + (block $cleanup.69 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -465,32 +493,40 @@ pattern matching › tuple_match_deep4 ) ) ) - (block $compile_store.65 - (local.set $41 - (i32.or - (i32.shl - (i32.eq - (local.get $40) - (i32.const 3) - ) - (i32.const 31) - ) + (block $compile_store.71 + (local.set $44 + (i32.shr_s + (local.get $43) + (i32.const 1) + ) + ) + (block $do_backpatches.70 + ) + ) + (block $compile_store.73 + (local.set $45 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $44) + (i32.const 1) + ) ) ) - (block $do_backpatches.64 + (block $do_backpatches.72 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $41) + (local.get $45) (i32.const 31) ) - (block $compile_block.71 (result i32) + (block $compile_block.79 (result i32) (drop - (block $compile_set.67 (result i32) + (block $compile_set.75 (result i32) (local.set $15 (tuple.extract 0 (tuple.make @@ -512,7 +548,7 @@ pattern matching › tuple_match_deep4 ) ) (drop - (block $compile_set.68 (result i32) + (block $compile_set.76 (result i32) (local.set $16 (tuple.extract 0 (tuple.make @@ -534,7 +570,7 @@ pattern matching › tuple_match_deep4 ) ) (drop - (block $compile_set.69 (result i32) + (block $compile_set.77 (result i32) (local.set $17 (tuple.extract 0 (tuple.make @@ -556,7 +592,7 @@ pattern matching › tuple_match_deep4 ) ) (drop - (block $compile_set.70 (result i32) + (block $compile_set.78 (result i32) (local.set $18 (tuple.extract 0 (tuple.make @@ -579,11 +615,11 @@ pattern matching › tuple_match_deep4 ) (i32.const 3) ) - (block $compile_block.72 (result i32) + (block $compile_block.80 (result i32) (i32.const 4) ) ) - (block $cleanup.66 (result i32) + (block $cleanup.74 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -595,31 +631,29 @@ pattern matching › tuple_match_deep4 ) ) ) - (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) - ) + (block $compile_block.89 (result i32) + (block $compile_store.83 + (local.set $42 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $40) + (i32.const 1) + ) ) ) - (block $do_backpatches.74 + (block $do_backpatches.82 ) ) (if (result i32) (i32.shr_u - (local.get $39) + (local.get $42) (i32.const 31) ) - (block $compile_block.79 (result i32) + (block $compile_block.87 (result i32) (drop - (block $compile_set.76 (result i32) + (block $compile_set.84 (result i32) (local.set $12 (tuple.extract 0 (tuple.make @@ -641,7 +675,7 @@ pattern matching › tuple_match_deep4 ) ) (drop - (block $compile_set.77 (result i32) + (block $compile_set.85 (result i32) (local.set $13 (tuple.extract 0 (tuple.make @@ -663,7 +697,7 @@ pattern matching › tuple_match_deep4 ) ) (drop - (block $compile_set.78 (result i32) + (block $compile_set.86 (result i32) (local.set $14 (tuple.extract 0 (tuple.make @@ -686,13 +720,13 @@ pattern matching › tuple_match_deep4 ) (i32.const 2) ) - (block $compile_block.80 (result i32) + (block $compile_block.88 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.56 (result i32) + (block $cleanup.62 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -710,31 +744,29 @@ pattern matching › tuple_match_deep4 ) ) ) - (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) - ) + (block $compile_block.97 (result i32) + (block $compile_store.92 + (local.set $38 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $36) + (i32.const 1) + ) ) ) - (block $do_backpatches.83 + (block $do_backpatches.91 ) ) (if (result i32) (i32.shr_u - (local.get $36) + (local.get $38) (i32.const 31) ) - (block $compile_block.87 (result i32) + (block $compile_block.95 (result i32) (drop - (block $compile_set.85 (result i32) + (block $compile_set.93 (result i32) (local.set $10 (tuple.extract 0 (tuple.make @@ -756,7 +788,7 @@ pattern matching › tuple_match_deep4 ) ) (drop - (block $compile_set.86 (result i32) + (block $compile_set.94 (result i32) (local.set $11 (tuple.extract 0 (tuple.make @@ -779,13 +811,13 @@ pattern matching › tuple_match_deep4 ) (i32.const 1) ) - (block $compile_block.88 (result i32) + (block $compile_block.96 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.47 (result i32) + (block $cleanup.51 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -803,31 +835,29 @@ pattern matching › tuple_match_deep4 ) ) ) - (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) - ) + (block $compile_block.104 (result i32) + (block $compile_store.100 + (local.set $34 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $31) + (i32.const 1) + ) ) ) - (block $do_backpatches.91 + (block $do_backpatches.99 ) ) (if (result i32) (i32.shr_u - (local.get $33) + (local.get $34) (i32.const 31) ) - (block $compile_block.94 (result i32) + (block $compile_block.102 (result i32) (drop - (block $compile_set.93 (result i32) + (block $compile_set.101 (result i32) (local.set $9 (tuple.extract 0 (tuple.make @@ -850,17 +880,17 @@ pattern matching › tuple_match_deep4 ) (i32.const 0) ) - (block $compile_block.95 + (block $compile_block.103 (unreachable) ) ) ) ) ) - (block $do_backpatches.97 + (block $do_backpatches.105 ) ) - (block $cleanup.99 + (block $cleanup.107 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -876,48 +906,48 @@ pattern matching › tuple_match_deep4 ) (tuple.extract 0 (tuple.make - (block $switch.101_outer (result i32) - (block $switch.101_branch_0 (result i32) + (block $switch.109_outer (result i32) + (block $switch.109_branch_0 (result i32) (drop - (block $switch.101_branch_1 (result i32) + (block $switch.109_branch_1 (result i32) (drop - (block $switch.101_branch_2 (result i32) + (block $switch.109_branch_2 (result i32) (drop - (block $switch.101_branch_3 (result i32) + (block $switch.109_branch_3 (result i32) (drop - (block $switch.101_branch_4 (result i32) + (block $switch.109_branch_4 (result i32) (drop - (block $switch.101_branch_5 (result i32) + (block $switch.109_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 + (block $switch.109_default (result i32) + (br_table $switch.109_branch_1 $switch.109_branch_2 $switch.109_branch_3 $switch.109_branch_4 $switch.109_branch_5 $switch.109_default $switch.109_default (i32.const 0) - (local.get $32) + (local.get $33) ) ) ) - (br $switch.101_outer - (block $compile_block.116 (result i32) + (br $switch.109_outer + (block $compile_block.124 (result i32) (unreachable) ) ) ) ) - (br $switch.101_outer - (block $compile_block.115 (result i32) + (br $switch.109_outer + (block $compile_block.123 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.101_outer - (block $compile_block.114 - (block $compile_store.110 + (br $switch.109_outer + (block $compile_block.122 + (block $compile_store.118 (local.set $28 - (call $+_1153 + (call $+_1157 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) + (global.get $+_1157) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -929,15 +959,15 @@ pattern matching › tuple_match_deep4 ) ) ) - (block $do_backpatches.109 + (block $do_backpatches.117 ) ) - (block $compile_store.112 + (block $compile_store.120 (local.set $29 - (call $+_1153 + (call $+_1157 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) + (global.get $+_1157) ) (local.get $28) (call $incRef_0 @@ -946,10 +976,10 @@ pattern matching › tuple_match_deep4 ) ) ) - (block $do_backpatches.111 + (block $do_backpatches.119 ) ) - (block $cleanup.113 + (block $cleanup.121 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1005,10 +1035,10 @@ pattern matching › tuple_match_deep4 ) ) ) - (return_call $+_1153 + (return_call $+_1157 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) + (global.get $+_1157) ) (local.get $29) (local.get $18) @@ -1017,14 +1047,14 @@ pattern matching › tuple_match_deep4 ) ) ) - (br $switch.101_outer - (block $compile_block.108 - (block $compile_store.106 + (br $switch.109_outer + (block $compile_block.116 + (block $compile_store.114 (local.set $27 - (call $+_1153 + (call $+_1157 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) + (global.get $+_1157) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -1036,10 +1066,10 @@ pattern matching › tuple_match_deep4 ) ) ) - (block $do_backpatches.105 + (block $do_backpatches.113 ) ) - (block $cleanup.107 + (block $cleanup.115 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1095,10 +1125,10 @@ pattern matching › tuple_match_deep4 ) ) ) - (return_call $+_1153 + (return_call $+_1157 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) + (global.get $+_1157) ) (local.get $27) (local.get $14) @@ -1107,9 +1137,9 @@ pattern matching › tuple_match_deep4 ) ) ) - (br $switch.101_outer - (block $compile_block.104 - (block $cleanup.103 + (br $switch.109_outer + (block $compile_block.112 + (block $cleanup.111 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1159,10 +1189,10 @@ pattern matching › tuple_match_deep4 ) ) ) - (return_call $+_1153 + (return_call $+_1157 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) + (global.get $+_1157) ) (local.get $10) (local.get $11) @@ -1171,8 +1201,8 @@ pattern matching › tuple_match_deep4 ) ) ) - (br $switch.101_outer - (block $compile_block.102 (result i32) + (br $switch.109_outer + (block $compile_block.110 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $9) @@ -1181,7 +1211,7 @@ pattern matching › tuple_match_deep4 ) ) ) - (block $cleanup.100 (result i32) + (block $cleanup.108 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot index 9bae9c5bc..80dd3ad19 100644 --- a/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot @@ -13,11 +13,11 @@ pattern matching › adt_match_4 (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$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 $+_1149 (param i32 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)) @@ -61,7 +61,11 @@ pattern matching › adt_match_4 (local $32 i32) (local $33 i32) (local $34 i32) - (block $compile_block.98 (result i32) + (local $35 i32) + (local $36 i32) + (local $37 i32) + (local $38 i32) + (block $compile_block.106 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -275,29 +279,37 @@ pattern matching › adt_match_4 ) (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) + (i32.shr_s + (local.get $23) + (i32.const 1) ) ) (block $do_backpatches.27 ) ) - (block $compile_store.84 + (block $compile_store.30 (local.set $25 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $24) + (i32.const 0) + ) + ) + ) + (block $do_backpatches.29 + ) + ) + (block $compile_store.92 + (local.set $26 (if (result i32) (i32.shr_u - (local.get $24) + (local.get $25) (i32.const 31) ) - (block $compile_block.77 (result i32) - (block $compile_store.30 + (block $compile_block.85 (result i32) + (block $compile_store.32 (local.set $16 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -306,10 +318,10 @@ pattern matching › adt_match_4 ) ) ) - (block $do_backpatches.29 + (block $do_backpatches.31 ) ) - (block $compile_store.32 + (block $compile_store.34 (local.set $17 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -318,43 +330,51 @@ pattern matching › adt_match_4 ) ) ) - (block $do_backpatches.31 + (block $do_backpatches.33 ) ) - (block $compile_store.34 - (local.set $27 + (block $compile_store.36 + (local.set $28 (i32.load offset=12 (local.get $17) ) ) - (block $do_backpatches.33 + (block $do_backpatches.35 ) ) - (block $compile_store.36 - (local.set $28 - (i32.or - (i32.shl - (i32.eq - (local.get $27) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.38 + (local.set $29 + (i32.shr_s + (local.get $28) + (i32.const 1) + ) + ) + (block $do_backpatches.37 + ) + ) + (block $compile_store.40 + (local.set $30 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $29) + (i32.const 0) + ) ) ) - (block $do_backpatches.35 + (block $do_backpatches.39 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $28) + (local.get $30) (i32.const 31) ) - (block $compile_block.70 (result i32) - (block $compile_store.39 + (block $compile_block.78 (result i32) + (block $compile_store.43 (local.set $18 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -363,10 +383,10 @@ pattern matching › adt_match_4 ) ) ) - (block $do_backpatches.38 + (block $do_backpatches.42 ) ) - (block $compile_store.41 + (block $compile_store.45 (local.set $19 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -375,43 +395,51 @@ pattern matching › adt_match_4 ) ) ) - (block $do_backpatches.40 + (block $do_backpatches.44 ) ) - (block $compile_store.43 - (local.set $30 + (block $compile_store.47 + (local.set $32 (i32.load offset=12 (local.get $19) ) ) - (block $do_backpatches.42 + (block $do_backpatches.46 ) ) - (block $compile_store.45 - (local.set $31 - (i32.or - (i32.shl - (i32.eq - (local.get $30) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.49 + (local.set $33 + (i32.shr_s + (local.get $32) + (i32.const 1) + ) + ) + (block $do_backpatches.48 + ) + ) + (block $compile_store.51 + (local.set $34 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $33) + (i32.const 0) + ) ) ) - (block $do_backpatches.44 + (block $do_backpatches.50 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $31) + (local.get $34) (i32.const 31) ) - (block $compile_block.62 (result i32) - (block $compile_store.48 + (block $compile_block.70 (result i32) + (block $compile_store.54 (local.set $20 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -420,10 +448,10 @@ pattern matching › adt_match_4 ) ) ) - (block $do_backpatches.47 + (block $do_backpatches.53 ) ) - (block $compile_store.50 + (block $compile_store.56 (local.set $21 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -432,19 +460,19 @@ pattern matching › adt_match_4 ) ) ) - (block $do_backpatches.49 + (block $do_backpatches.55 ) ) - (block $compile_store.52 - (local.set $33 + (block $compile_store.58 + (local.set $36 (i32.load offset=12 (local.get $21) ) ) - (block $do_backpatches.51 + (block $do_backpatches.57 ) ) - (block $cleanup.53 + (block $cleanup.59 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -452,32 +480,40 @@ pattern matching › adt_match_4 ) ) ) - (block $compile_store.55 - (local.set $34 - (i32.or - (i32.shl - (i32.eq - (local.get $33) - (i32.const 3) - ) - (i32.const 31) - ) + (block $compile_store.61 + (local.set $37 + (i32.shr_s + (local.get $36) + (i32.const 1) + ) + ) + (block $do_backpatches.60 + ) + ) + (block $compile_store.63 + (local.set $38 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $37) + (i32.const 1) + ) ) ) - (block $do_backpatches.54 + (block $do_backpatches.62 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $34) + (local.get $38) (i32.const 31) ) - (block $compile_block.60 (result i32) + (block $compile_block.68 (result i32) (drop - (block $compile_set.57 (result i32) + (block $compile_set.65 (result i32) (local.set $13 (tuple.extract 0 (tuple.make @@ -499,7 +535,7 @@ pattern matching › adt_match_4 ) ) (drop - (block $compile_set.58 (result i32) + (block $compile_set.66 (result i32) (local.set $14 (tuple.extract 0 (tuple.make @@ -521,7 +557,7 @@ pattern matching › adt_match_4 ) ) (drop - (block $compile_set.59 (result i32) + (block $compile_set.67 (result i32) (local.set $15 (tuple.extract 0 (tuple.make @@ -544,11 +580,11 @@ pattern matching › adt_match_4 ) (i32.const 3) ) - (block $compile_block.61 (result i32) + (block $compile_block.69 (result i32) (i32.const 4) ) ) - (block $cleanup.56 (result i32) + (block $cleanup.64 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -560,31 +596,29 @@ pattern matching › adt_match_4 ) ) ) - (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) - ) + (block $compile_block.77 (result i32) + (block $compile_store.72 + (local.set $35 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $33) + (i32.const 1) + ) ) ) - (block $do_backpatches.63 + (block $do_backpatches.71 ) ) (if (result i32) (i32.shr_u - (local.get $32) + (local.get $35) (i32.const 31) ) - (block $compile_block.67 (result i32) + (block $compile_block.75 (result i32) (drop - (block $compile_set.65 (result i32) + (block $compile_set.73 (result i32) (local.set $11 (tuple.extract 0 (tuple.make @@ -606,7 +640,7 @@ pattern matching › adt_match_4 ) ) (drop - (block $compile_set.66 (result i32) + (block $compile_set.74 (result i32) (local.set $12 (tuple.extract 0 (tuple.make @@ -629,13 +663,13 @@ pattern matching › adt_match_4 ) (i32.const 2) ) - (block $compile_block.68 (result i32) + (block $compile_block.76 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.46 (result i32) + (block $cleanup.52 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -653,31 +687,29 @@ pattern matching › adt_match_4 ) ) ) - (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) - ) + (block $compile_block.84 (result i32) + (block $compile_store.80 + (local.set $31 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $29) + (i32.const 1) + ) ) ) - (block $do_backpatches.71 + (block $do_backpatches.79 ) ) (if (result i32) (i32.shr_u - (local.get $29) + (local.get $31) (i32.const 31) ) - (block $compile_block.74 (result i32) + (block $compile_block.82 (result i32) (drop - (block $compile_set.73 (result i32) + (block $compile_set.81 (result i32) (local.set $10 (tuple.extract 0 (tuple.make @@ -700,13 +732,13 @@ pattern matching › adt_match_4 ) (i32.const 1) ) - (block $compile_block.75 (result i32) + (block $compile_block.83 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.37 (result i32) + (block $cleanup.41 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -724,42 +756,40 @@ pattern matching › adt_match_4 ) ) ) - (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) - ) + (block $compile_block.90 (result i32) + (block $compile_store.87 + (local.set $27 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $24) + (i32.const 1) + ) ) ) - (block $do_backpatches.78 + (block $do_backpatches.86 ) ) (if (result i32) (i32.shr_u - (local.get $26) + (local.get $27) (i32.const 31) ) - (block $compile_block.80 (result i32) + (block $compile_block.88 (result i32) (i32.const 0) ) - (block $compile_block.81 + (block $compile_block.89 (unreachable) ) ) ) ) ) - (block $do_backpatches.83 + (block $do_backpatches.91 ) ) - (block $cleanup.85 + (block $cleanup.93 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -769,48 +799,48 @@ pattern matching › adt_match_4 ) (tuple.extract 0 (tuple.make - (block $switch.87_outer (result i32) - (block $switch.87_branch_0 (result i32) + (block $switch.95_outer (result i32) + (block $switch.95_branch_0 (result i32) (drop - (block $switch.87_branch_1 (result i32) + (block $switch.95_branch_1 (result i32) (drop - (block $switch.87_branch_2 (result i32) + (block $switch.95_branch_2 (result i32) (drop - (block $switch.87_branch_3 (result i32) + (block $switch.95_branch_3 (result i32) (drop - (block $switch.87_branch_4 (result i32) + (block $switch.95_branch_4 (result i32) (drop - (block $switch.87_branch_5 (result i32) + (block $switch.95_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 + (block $switch.95_default (result i32) + (br_table $switch.95_branch_1 $switch.95_branch_2 $switch.95_branch_3 $switch.95_branch_4 $switch.95_branch_5 $switch.95_default $switch.95_default (i32.const 0) - (local.get $25) + (local.get $26) ) ) ) - (br $switch.87_outer - (block $compile_block.97 (result i32) + (br $switch.95_outer + (block $compile_block.105 (result i32) (unreachable) ) ) ) ) - (br $switch.87_outer - (block $compile_block.96 (result i32) + (br $switch.95_outer + (block $compile_block.104 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.87_outer - (block $compile_block.95 - (block $compile_store.93 + (br $switch.95_outer + (block $compile_block.103 + (block $compile_store.101 (local.set $22 - (call $+_1149 + (call $+_1153 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) + (global.get $+_1153) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -822,10 +852,10 @@ pattern matching › adt_match_4 ) ) ) - (block $do_backpatches.92 + (block $do_backpatches.100 ) ) - (block $cleanup.94 + (block $cleanup.102 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -857,10 +887,10 @@ pattern matching › adt_match_4 ) ) ) - (return_call $+_1149 + (return_call $+_1153 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) + (global.get $+_1153) ) (local.get $22) (local.get $15) @@ -869,9 +899,9 @@ pattern matching › adt_match_4 ) ) ) - (br $switch.87_outer - (block $compile_block.91 - (block $cleanup.90 + (br $switch.95_outer + (block $compile_block.99 + (block $cleanup.98 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -897,10 +927,10 @@ pattern matching › adt_match_4 ) ) ) - (return_call $+_1149 + (return_call $+_1153 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) + (global.get $+_1153) ) (local.get $11) (local.get $12) @@ -909,8 +939,8 @@ pattern matching › adt_match_4 ) ) ) - (br $switch.87_outer - (block $compile_block.89 (result i32) + (br $switch.95_outer + (block $compile_block.97 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $10) @@ -919,14 +949,14 @@ pattern matching › adt_match_4 ) ) ) - (br $switch.87_outer - (block $compile_block.88 (result i32) + (br $switch.95_outer + (block $compile_block.96 (result i32) (i32.const 1) ) ) ) ) - (block $cleanup.86 (result i32) + (block $cleanup.94 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.0fa61137.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0fa61137.0.snapshot index c8c4361cc..b75e1887d 100644 --- a/compiler/test/__snapshots__/pattern_matching.0fa61137.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0fa61137.0.snapshot @@ -79,7 +79,7 @@ pattern matching › low_level_constant_match_2 (i32.const 2147483646) (i64.eq (i64.const 1) - (i64.const 0) + (i64.const 2) ) ) ) @@ -94,7 +94,7 @@ pattern matching › low_level_constant_match_2 (i32.const 31) ) (block $compile_block.6 (result i32) - (i32.const 0) + (i32.const 2) ) (block $compile_block.15 (result i32) (block $compile_store.8 @@ -127,7 +127,7 @@ pattern matching › low_level_constant_match_2 (i32.const 2147483646) (i64.eq (i64.const 1) - (i64.const 2) + (i64.const 0) ) ) ) @@ -140,7 +140,7 @@ pattern matching › low_level_constant_match_2 (i32.const 31) ) (block $compile_block.12 (result i32) - (i32.const 2) + (i32.const 0) ) (block $compile_block.13 (result i32) (i32.const 3) diff --git a/compiler/test/__snapshots__/pattern_matching.5b6ff2d3.0.snapshot b/compiler/test/__snapshots__/pattern_matching.5b6ff2d3.0.snapshot index b709044de..69bfb00f7 100644 --- a/compiler/test/__snapshots__/pattern_matching.5b6ff2d3.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.5b6ff2d3.0.snapshot @@ -43,7 +43,8 @@ pattern matching › alias_match_5 (local $14 i32) (local $15 i32) (local $16 i32) - (block $compile_block.47 (result i32) + (local $17 i32) + (block $compile_block.49 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -107,30 +108,38 @@ pattern matching › alias_match_5 ) (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) + (i32.shr_s + (local.get $10) + (i32.const 1) ) ) (block $do_backpatches.10 ) ) - (block $compile_store.38 + (block $compile_store.13 (local.set $12 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $11) + (i32.const 1) + ) + ) + ) + (block $do_backpatches.12 + ) + ) + (block $compile_store.40 + (local.set $13 (if (result i32) (i32.shr_u - (local.get $11) + (local.get $12) (i32.const 31) ) - (block $compile_block.13 (result i32) + (block $compile_block.15 (result i32) (drop - (block $compile_set.12 (result i32) + (block $compile_set.14 (result i32) (local.set $8 (tuple.extract 0 (tuple.make @@ -153,30 +162,28 @@ pattern matching › alias_match_5 ) (i32.const 1) ) - (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) - ) + (block $compile_block.38 (result i32) + (block $compile_store.17 + (local.set $14 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $11) + (i32.const 0) + ) ) ) - (block $do_backpatches.14 + (block $do_backpatches.16 ) ) (if (result i32) (i32.shr_u - (local.get $13) + (local.get $14) (i32.const 31) ) - (block $compile_block.34 (result i32) - (block $compile_store.17 + (block $compile_block.36 (result i32) + (block $compile_store.19 (local.set $9 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -185,11 +192,11 @@ pattern matching › alias_match_5 ) ) ) - (block $do_backpatches.16 + (block $do_backpatches.18 ) ) - (block $compile_store.19 - (local.set $14 + (block $compile_store.21 + (local.set $15 (call $equal_0 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -202,19 +209,19 @@ pattern matching › alias_match_5 (i32.const 7) ) ) - (block $do_backpatches.18 + (block $do_backpatches.20 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $14) + (local.get $15) (i32.const 31) ) - (block $compile_block.22 (result i32) + (block $compile_block.24 (result i32) (drop - (block $compile_set.21 (result i32) + (block $compile_set.23 (result i32) (local.set $7 (tuple.extract 0 (tuple.make @@ -237,9 +244,9 @@ pattern matching › alias_match_5 ) (i32.const 0) ) - (block $compile_block.33 (result i32) - (block $compile_store.24 - (local.set $15 + (block $compile_block.35 (result i32) + (block $compile_store.26 + (local.set $16 (call $equal_0 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -252,17 +259,17 @@ pattern matching › alias_match_5 (i32.const 9) ) ) - (block $do_backpatches.23 + (block $do_backpatches.25 ) ) (if (result i32) (i32.shr_u - (local.get $15) + (local.get $16) (i32.const 31) ) - (block $compile_block.26 (result i32) + (block $compile_block.28 (result i32) (drop - (block $compile_set.25 (result i32) + (block $compile_set.27 (result i32) (local.set $7 (tuple.extract 0 (tuple.make @@ -285,9 +292,9 @@ pattern matching › alias_match_5 ) (i32.const 0) ) - (block $compile_block.32 (result i32) - (block $compile_store.28 - (local.set $16 + (block $compile_block.34 (result i32) + (block $compile_store.30 + (local.set $17 (call $equal_0 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -300,17 +307,17 @@ pattern matching › alias_match_5 (i32.const 11) ) ) - (block $do_backpatches.27 + (block $do_backpatches.29 ) ) (if (result i32) (i32.shr_u - (local.get $16) + (local.get $17) (i32.const 31) ) - (block $compile_block.30 (result i32) + (block $compile_block.32 (result i32) (drop - (block $compile_set.29 (result i32) + (block $compile_set.31 (result i32) (local.set $8 (tuple.extract 0 (tuple.make @@ -333,7 +340,7 @@ pattern matching › alias_match_5 ) (i32.const 1) ) - (block $compile_block.31 (result i32) + (block $compile_block.33 (result i32) (i32.const 2) ) ) @@ -341,7 +348,7 @@ pattern matching › alias_match_5 ) ) ) - (block $cleanup.20 (result i32) + (block $cleanup.22 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -353,17 +360,17 @@ pattern matching › alias_match_5 ) ) ) - (block $compile_block.35 (result i32) + (block $compile_block.37 (result i32) (i32.const 2) ) ) ) ) ) - (block $do_backpatches.37 + (block $do_backpatches.39 ) ) - (block $cleanup.39 + (block $cleanup.41 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -373,32 +380,32 @@ pattern matching › alias_match_5 ) (tuple.extract 0 (tuple.make - (block $switch.41_outer (result i32) - (block $switch.41_branch_0 (result i32) + (block $switch.43_outer (result i32) + (block $switch.43_branch_0 (result i32) (drop - (block $switch.41_branch_1 (result i32) + (block $switch.43_branch_1 (result i32) (drop - (block $switch.41_branch_2 (result i32) + (block $switch.43_branch_2 (result i32) (drop - (block $switch.41_branch_3 (result i32) + (block $switch.43_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 + (block $switch.43_default (result i32) + (br_table $switch.43_branch_1 $switch.43_branch_2 $switch.43_branch_3 $switch.43_default $switch.43_default (i32.const 0) - (local.get $12) + (local.get $13) ) ) ) - (br $switch.41_outer - (block $compile_block.46 (result i32) + (br $switch.43_outer + (block $compile_block.48 (result i32) (unreachable) ) ) ) ) - (br $switch.41_outer - (block $compile_block.45 (result i32) - (block $allocate_adt.44 (result i32) + (br $switch.43_outer + (block $compile_block.47 (result i32) + (block $allocate_adt.46 (result i32) (i32.store (local.tee $0 (call $malloc_0 @@ -430,8 +437,8 @@ pattern matching › alias_match_5 ) ) ) - (br $switch.41_outer - (block $compile_block.43 (result i32) + (br $switch.43_outer + (block $compile_block.45 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $8) @@ -440,8 +447,8 @@ pattern matching › alias_match_5 ) ) ) - (br $switch.41_outer - (block $compile_block.42 (result i32) + (br $switch.43_outer + (block $compile_block.44 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $7) @@ -450,7 +457,7 @@ pattern matching › alias_match_5 ) ) ) - (block $cleanup.40 (result i32) + (block $cleanup.42 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot b/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot index d1239ef01..5d1393bbe 100644 --- a/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot @@ -13,11 +13,11 @@ pattern matching › tuple_match_deep6 (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$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1161 (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))) + (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1161 (param i32 i32 i32) (result i32))) (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) (memory $0 0) (elem $elem (global.get $relocBase_0)) @@ -70,7 +70,11 @@ pattern matching › tuple_match_deep6 (local $41 i32) (local $42 i32) (local $43 i32) - (block $compile_block.123 (result i32) + (local $44 i32) + (local $45 i32) + (local $46 i32) + (local $47 i32) + (block $compile_block.131 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -374,29 +378,37 @@ pattern matching › tuple_match_deep6 ) (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) + (i32.shr_s + (local.get $32) + (i32.const 1) ) ) (block $do_backpatches.43 ) ) - (block $compile_store.104 + (block $compile_store.46 (local.set $34 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $33) + (i32.const 0) + ) + ) + ) + (block $do_backpatches.45 + ) + ) + (block $compile_store.112 + (local.set $35 (if (result i32) (i32.shr_u - (local.get $33) + (local.get $34) (i32.const 31) ) - (block $compile_block.96 (result i32) - (block $compile_store.46 + (block $compile_block.104 (result i32) + (block $compile_store.48 (local.set $23 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -405,10 +417,10 @@ pattern matching › tuple_match_deep6 ) ) ) - (block $do_backpatches.45 + (block $do_backpatches.47 ) ) - (block $compile_store.48 + (block $compile_store.50 (local.set $24 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -417,43 +429,51 @@ pattern matching › tuple_match_deep6 ) ) ) - (block $do_backpatches.47 + (block $do_backpatches.49 ) ) - (block $compile_store.50 - (local.set $36 + (block $compile_store.52 + (local.set $37 (i32.load offset=12 (local.get $24) ) ) - (block $do_backpatches.49 + (block $do_backpatches.51 ) ) - (block $compile_store.52 - (local.set $37 - (i32.or - (i32.shl - (i32.eq - (local.get $36) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.54 + (local.set $38 + (i32.shr_s + (local.get $37) + (i32.const 1) + ) + ) + (block $do_backpatches.53 + ) + ) + (block $compile_store.56 + (local.set $39 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $38) + (i32.const 0) + ) ) ) - (block $do_backpatches.51 + (block $do_backpatches.55 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $37) + (local.get $39) (i32.const 31) ) - (block $compile_block.88 (result i32) - (block $compile_store.55 + (block $compile_block.96 (result i32) + (block $compile_store.59 (local.set $25 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -462,10 +482,10 @@ pattern matching › tuple_match_deep6 ) ) ) - (block $do_backpatches.54 + (block $do_backpatches.58 ) ) - (block $compile_store.57 + (block $compile_store.61 (local.set $26 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -474,43 +494,51 @@ pattern matching › tuple_match_deep6 ) ) ) - (block $do_backpatches.56 + (block $do_backpatches.60 ) ) - (block $compile_store.59 - (local.set $39 + (block $compile_store.63 + (local.set $41 (i32.load offset=12 (local.get $26) ) ) - (block $do_backpatches.58 + (block $do_backpatches.62 ) ) - (block $compile_store.61 - (local.set $40 - (i32.or - (i32.shl - (i32.eq - (local.get $39) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.65 + (local.set $42 + (i32.shr_s + (local.get $41) + (i32.const 1) + ) + ) + (block $do_backpatches.64 + ) + ) + (block $compile_store.67 + (local.set $43 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $42) + (i32.const 0) + ) ) ) - (block $do_backpatches.60 + (block $do_backpatches.66 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $40) + (local.get $43) (i32.const 31) ) - (block $compile_block.79 (result i32) - (block $compile_store.64 + (block $compile_block.87 (result i32) + (block $compile_store.70 (local.set $27 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -519,10 +547,10 @@ pattern matching › tuple_match_deep6 ) ) ) - (block $do_backpatches.63 + (block $do_backpatches.69 ) ) - (block $compile_store.66 + (block $compile_store.72 (local.set $28 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -531,19 +559,19 @@ pattern matching › tuple_match_deep6 ) ) ) - (block $do_backpatches.65 + (block $do_backpatches.71 ) ) - (block $compile_store.68 - (local.set $42 + (block $compile_store.74 + (local.set $45 (i32.load offset=12 (local.get $28) ) ) - (block $do_backpatches.67 + (block $do_backpatches.73 ) ) - (block $cleanup.69 + (block $cleanup.75 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -551,32 +579,40 @@ pattern matching › tuple_match_deep6 ) ) ) - (block $compile_store.71 - (local.set $43 - (i32.or - (i32.shl - (i32.eq - (local.get $42) - (i32.const 3) - ) - (i32.const 31) - ) + (block $compile_store.77 + (local.set $46 + (i32.shr_s + (local.get $45) + (i32.const 1) + ) + ) + (block $do_backpatches.76 + ) + ) + (block $compile_store.79 + (local.set $47 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $46) + (i32.const 1) + ) ) ) - (block $do_backpatches.70 + (block $do_backpatches.78 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $43) + (local.get $47) (i32.const 31) ) - (block $compile_block.77 (result i32) + (block $compile_block.85 (result i32) (drop - (block $compile_set.73 (result i32) + (block $compile_set.81 (result i32) (local.set $17 (tuple.extract 0 (tuple.make @@ -598,7 +634,7 @@ pattern matching › tuple_match_deep6 ) ) (drop - (block $compile_set.74 (result i32) + (block $compile_set.82 (result i32) (local.set $18 (tuple.extract 0 (tuple.make @@ -620,7 +656,7 @@ pattern matching › tuple_match_deep6 ) ) (drop - (block $compile_set.75 (result i32) + (block $compile_set.83 (result i32) (local.set $19 (tuple.extract 0 (tuple.make @@ -642,7 +678,7 @@ pattern matching › tuple_match_deep6 ) ) (drop - (block $compile_set.76 (result i32) + (block $compile_set.84 (result i32) (local.set $20 (tuple.extract 0 (tuple.make @@ -665,11 +701,11 @@ pattern matching › tuple_match_deep6 ) (i32.const 3) ) - (block $compile_block.78 (result i32) + (block $compile_block.86 (result i32) (i32.const 4) ) ) - (block $cleanup.72 (result i32) + (block $cleanup.80 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -681,31 +717,29 @@ pattern matching › tuple_match_deep6 ) ) ) - (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) - ) + (block $compile_block.95 (result i32) + (block $compile_store.89 + (local.set $44 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $42) + (i32.const 1) + ) ) ) - (block $do_backpatches.80 + (block $do_backpatches.88 ) ) (if (result i32) (i32.shr_u - (local.get $41) + (local.get $44) (i32.const 31) ) - (block $compile_block.85 (result i32) + (block $compile_block.93 (result i32) (drop - (block $compile_set.82 (result i32) + (block $compile_set.90 (result i32) (local.set $14 (tuple.extract 0 (tuple.make @@ -727,7 +761,7 @@ pattern matching › tuple_match_deep6 ) ) (drop - (block $compile_set.83 (result i32) + (block $compile_set.91 (result i32) (local.set $15 (tuple.extract 0 (tuple.make @@ -749,7 +783,7 @@ pattern matching › tuple_match_deep6 ) ) (drop - (block $compile_set.84 (result i32) + (block $compile_set.92 (result i32) (local.set $16 (tuple.extract 0 (tuple.make @@ -772,13 +806,13 @@ pattern matching › tuple_match_deep6 ) (i32.const 2) ) - (block $compile_block.86 (result i32) + (block $compile_block.94 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.62 (result i32) + (block $cleanup.68 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -796,31 +830,29 @@ pattern matching › tuple_match_deep6 ) ) ) - (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) - ) + (block $compile_block.103 (result i32) + (block $compile_store.98 + (local.set $40 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $38) + (i32.const 1) + ) ) ) - (block $do_backpatches.89 + (block $do_backpatches.97 ) ) (if (result i32) (i32.shr_u - (local.get $38) + (local.get $40) (i32.const 31) ) - (block $compile_block.93 (result i32) + (block $compile_block.101 (result i32) (drop - (block $compile_set.91 (result i32) + (block $compile_set.99 (result i32) (local.set $12 (tuple.extract 0 (tuple.make @@ -842,7 +874,7 @@ pattern matching › tuple_match_deep6 ) ) (drop - (block $compile_set.92 (result i32) + (block $compile_set.100 (result i32) (local.set $13 (tuple.extract 0 (tuple.make @@ -865,13 +897,13 @@ pattern matching › tuple_match_deep6 ) (i32.const 1) ) - (block $compile_block.94 (result i32) + (block $compile_block.102 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.53 (result i32) + (block $cleanup.57 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -889,31 +921,29 @@ pattern matching › tuple_match_deep6 ) ) ) - (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) - ) + (block $compile_block.110 (result i32) + (block $compile_store.106 + (local.set $36 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $33) + (i32.const 1) + ) ) ) - (block $do_backpatches.97 + (block $do_backpatches.105 ) ) (if (result i32) (i32.shr_u - (local.get $35) + (local.get $36) (i32.const 31) ) - (block $compile_block.100 (result i32) + (block $compile_block.108 (result i32) (drop - (block $compile_set.99 (result i32) + (block $compile_set.107 (result i32) (local.set $11 (tuple.extract 0 (tuple.make @@ -936,17 +966,17 @@ pattern matching › tuple_match_deep6 ) (i32.const 0) ) - (block $compile_block.101 + (block $compile_block.109 (unreachable) ) ) ) ) ) - (block $do_backpatches.103 + (block $do_backpatches.111 ) ) - (block $cleanup.105 + (block $cleanup.113 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -962,48 +992,48 @@ pattern matching › tuple_match_deep6 ) (tuple.extract 0 (tuple.make - (block $switch.107_outer (result i32) - (block $switch.107_branch_0 (result i32) + (block $switch.115_outer (result i32) + (block $switch.115_branch_0 (result i32) (drop - (block $switch.107_branch_1 (result i32) + (block $switch.115_branch_1 (result i32) (drop - (block $switch.107_branch_2 (result i32) + (block $switch.115_branch_2 (result i32) (drop - (block $switch.107_branch_3 (result i32) + (block $switch.115_branch_3 (result i32) (drop - (block $switch.107_branch_4 (result i32) + (block $switch.115_branch_4 (result i32) (drop - (block $switch.107_branch_5 (result i32) + (block $switch.115_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 + (block $switch.115_default (result i32) + (br_table $switch.115_branch_1 $switch.115_branch_2 $switch.115_branch_3 $switch.115_branch_4 $switch.115_branch_5 $switch.115_default $switch.115_default (i32.const 0) - (local.get $34) + (local.get $35) ) ) ) - (br $switch.107_outer - (block $compile_block.122 (result i32) + (br $switch.115_outer + (block $compile_block.130 (result i32) (unreachable) ) ) ) ) - (br $switch.107_outer - (block $compile_block.121 (result i32) + (br $switch.115_outer + (block $compile_block.129 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.107_outer - (block $compile_block.120 - (block $compile_store.116 + (br $switch.115_outer + (block $compile_block.128 + (block $compile_store.124 (local.set $30 - (call $+_1157 + (call $+_1161 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) + (global.get $+_1161) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -1015,15 +1045,15 @@ pattern matching › tuple_match_deep6 ) ) ) - (block $do_backpatches.115 + (block $do_backpatches.123 ) ) - (block $compile_store.118 + (block $compile_store.126 (local.set $31 - (call $+_1157 + (call $+_1161 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) + (global.get $+_1161) ) (local.get $30) (call $incRef_0 @@ -1032,10 +1062,10 @@ pattern matching › tuple_match_deep6 ) ) ) - (block $do_backpatches.117 + (block $do_backpatches.125 ) ) - (block $cleanup.119 + (block $cleanup.127 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1091,10 +1121,10 @@ pattern matching › tuple_match_deep6 ) ) ) - (return_call $+_1157 + (return_call $+_1161 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) + (global.get $+_1161) ) (local.get $31) (local.get $20) @@ -1103,14 +1133,14 @@ pattern matching › tuple_match_deep6 ) ) ) - (br $switch.107_outer - (block $compile_block.114 - (block $compile_store.112 + (br $switch.115_outer + (block $compile_block.122 + (block $compile_store.120 (local.set $29 - (call $+_1157 + (call $+_1161 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) + (global.get $+_1161) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -1122,10 +1152,10 @@ pattern matching › tuple_match_deep6 ) ) ) - (block $do_backpatches.111 + (block $do_backpatches.119 ) ) - (block $cleanup.113 + (block $cleanup.121 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1181,10 +1211,10 @@ pattern matching › tuple_match_deep6 ) ) ) - (return_call $+_1157 + (return_call $+_1161 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) + (global.get $+_1161) ) (local.get $29) (local.get $16) @@ -1193,9 +1223,9 @@ pattern matching › tuple_match_deep6 ) ) ) - (br $switch.107_outer - (block $compile_block.110 - (block $cleanup.109 + (br $switch.115_outer + (block $compile_block.118 + (block $cleanup.117 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1245,10 +1275,10 @@ pattern matching › tuple_match_deep6 ) ) ) - (return_call $+_1157 + (return_call $+_1161 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) + (global.get $+_1161) ) (local.get $12) (local.get $13) @@ -1257,8 +1287,8 @@ pattern matching › tuple_match_deep6 ) ) ) - (br $switch.107_outer - (block $compile_block.108 (result i32) + (br $switch.115_outer + (block $compile_block.116 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $11) @@ -1267,7 +1297,7 @@ pattern matching › tuple_match_deep6 ) ) ) - (block $cleanup.106 (result i32) + (block $cleanup.114 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot b/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot index 0857c8680..c18cdaf5b 100644 --- a/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot @@ -13,11 +13,11 @@ pattern matching › tuple_match_deep3 (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$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 $+_1151 (param i32 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)) @@ -67,7 +67,11 @@ pattern matching › tuple_match_deep3 (local $38 i32) (local $39 i32) (local $40 i32) - (block $compile_block.114 (result i32) + (local $41 i32) + (local $42 i32) + (local $43 i32) + (local $44 i32) + (block $compile_block.122 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -245,29 +249,37 @@ pattern matching › tuple_match_deep3 ) (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) + (i32.shr_s + (local.get $29) + (i32.const 1) ) ) (block $do_backpatches.34 ) ) - (block $compile_store.95 + (block $compile_store.37 (local.set $31 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $30) + (i32.const 0) + ) + ) + ) + (block $do_backpatches.36 + ) + ) + (block $compile_store.103 + (local.set $32 (if (result i32) (i32.shr_u - (local.get $30) + (local.get $31) (i32.const 31) ) - (block $compile_block.87 (result i32) - (block $compile_store.37 + (block $compile_block.95 (result i32) + (block $compile_store.39 (local.set $20 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -276,10 +288,10 @@ pattern matching › tuple_match_deep3 ) ) ) - (block $do_backpatches.36 + (block $do_backpatches.38 ) ) - (block $compile_store.39 + (block $compile_store.41 (local.set $21 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -288,43 +300,51 @@ pattern matching › tuple_match_deep3 ) ) ) - (block $do_backpatches.38 + (block $do_backpatches.40 ) ) - (block $compile_store.41 - (local.set $33 + (block $compile_store.43 + (local.set $34 (i32.load offset=12 (local.get $21) ) ) - (block $do_backpatches.40 + (block $do_backpatches.42 ) ) - (block $compile_store.43 - (local.set $34 - (i32.or - (i32.shl - (i32.eq - (local.get $33) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.45 + (local.set $35 + (i32.shr_s + (local.get $34) + (i32.const 1) + ) + ) + (block $do_backpatches.44 + ) + ) + (block $compile_store.47 + (local.set $36 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $35) + (i32.const 0) + ) ) ) - (block $do_backpatches.42 + (block $do_backpatches.46 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $34) + (local.get $36) (i32.const 31) ) - (block $compile_block.79 (result i32) - (block $compile_store.46 + (block $compile_block.87 (result i32) + (block $compile_store.50 (local.set $22 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -333,10 +353,10 @@ pattern matching › tuple_match_deep3 ) ) ) - (block $do_backpatches.45 + (block $do_backpatches.49 ) ) - (block $compile_store.48 + (block $compile_store.52 (local.set $23 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -345,43 +365,51 @@ pattern matching › tuple_match_deep3 ) ) ) - (block $do_backpatches.47 + (block $do_backpatches.51 ) ) - (block $compile_store.50 - (local.set $36 + (block $compile_store.54 + (local.set $38 (i32.load offset=12 (local.get $23) ) ) - (block $do_backpatches.49 + (block $do_backpatches.53 ) ) - (block $compile_store.52 - (local.set $37 - (i32.or - (i32.shl - (i32.eq - (local.get $36) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.56 + (local.set $39 + (i32.shr_s + (local.get $38) + (i32.const 1) + ) + ) + (block $do_backpatches.55 + ) + ) + (block $compile_store.58 + (local.set $40 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $39) + (i32.const 0) + ) ) ) - (block $do_backpatches.51 + (block $do_backpatches.57 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $37) + (local.get $40) (i32.const 31) ) - (block $compile_block.70 (result i32) - (block $compile_store.55 + (block $compile_block.78 (result i32) + (block $compile_store.61 (local.set $24 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -390,10 +418,10 @@ pattern matching › tuple_match_deep3 ) ) ) - (block $do_backpatches.54 + (block $do_backpatches.60 ) ) - (block $compile_store.57 + (block $compile_store.63 (local.set $25 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -402,19 +430,19 @@ pattern matching › tuple_match_deep3 ) ) ) - (block $do_backpatches.56 + (block $do_backpatches.62 ) ) - (block $compile_store.59 - (local.set $39 + (block $compile_store.65 + (local.set $42 (i32.load offset=12 (local.get $25) ) ) - (block $do_backpatches.58 + (block $do_backpatches.64 ) ) - (block $cleanup.60 + (block $cleanup.66 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -422,32 +450,40 @@ pattern matching › tuple_match_deep3 ) ) ) - (block $compile_store.62 - (local.set $40 - (i32.or - (i32.shl - (i32.eq - (local.get $39) - (i32.const 3) - ) - (i32.const 31) - ) + (block $compile_store.68 + (local.set $43 + (i32.shr_s + (local.get $42) + (i32.const 1) + ) + ) + (block $do_backpatches.67 + ) + ) + (block $compile_store.70 + (local.set $44 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $43) + (i32.const 1) + ) ) ) - (block $do_backpatches.61 + (block $do_backpatches.69 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $40) + (local.get $44) (i32.const 31) ) - (block $compile_block.68 (result i32) + (block $compile_block.76 (result i32) (drop - (block $compile_set.64 (result i32) + (block $compile_set.72 (result i32) (local.set $14 (tuple.extract 0 (tuple.make @@ -469,7 +505,7 @@ pattern matching › tuple_match_deep3 ) ) (drop - (block $compile_set.65 (result i32) + (block $compile_set.73 (result i32) (local.set $15 (tuple.extract 0 (tuple.make @@ -491,7 +527,7 @@ pattern matching › tuple_match_deep3 ) ) (drop - (block $compile_set.66 (result i32) + (block $compile_set.74 (result i32) (local.set $16 (tuple.extract 0 (tuple.make @@ -513,7 +549,7 @@ pattern matching › tuple_match_deep3 ) ) (drop - (block $compile_set.67 (result i32) + (block $compile_set.75 (result i32) (local.set $17 (tuple.extract 0 (tuple.make @@ -536,11 +572,11 @@ pattern matching › tuple_match_deep3 ) (i32.const 3) ) - (block $compile_block.69 (result i32) + (block $compile_block.77 (result i32) (i32.const 4) ) ) - (block $cleanup.63 (result i32) + (block $cleanup.71 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -552,31 +588,29 @@ pattern matching › tuple_match_deep3 ) ) ) - (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) - ) + (block $compile_block.86 (result i32) + (block $compile_store.80 + (local.set $41 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $39) + (i32.const 1) + ) ) ) - (block $do_backpatches.71 + (block $do_backpatches.79 ) ) (if (result i32) (i32.shr_u - (local.get $38) + (local.get $41) (i32.const 31) ) - (block $compile_block.76 (result i32) + (block $compile_block.84 (result i32) (drop - (block $compile_set.73 (result i32) + (block $compile_set.81 (result i32) (local.set $11 (tuple.extract 0 (tuple.make @@ -598,7 +632,7 @@ pattern matching › tuple_match_deep3 ) ) (drop - (block $compile_set.74 (result i32) + (block $compile_set.82 (result i32) (local.set $12 (tuple.extract 0 (tuple.make @@ -620,7 +654,7 @@ pattern matching › tuple_match_deep3 ) ) (drop - (block $compile_set.75 (result i32) + (block $compile_set.83 (result i32) (local.set $13 (tuple.extract 0 (tuple.make @@ -643,13 +677,13 @@ pattern matching › tuple_match_deep3 ) (i32.const 2) ) - (block $compile_block.77 (result i32) + (block $compile_block.85 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.53 (result i32) + (block $cleanup.59 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -667,31 +701,29 @@ pattern matching › tuple_match_deep3 ) ) ) - (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) - ) + (block $compile_block.94 (result i32) + (block $compile_store.89 + (local.set $37 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $35) + (i32.const 1) + ) ) ) - (block $do_backpatches.80 + (block $do_backpatches.88 ) ) (if (result i32) (i32.shr_u - (local.get $35) + (local.get $37) (i32.const 31) ) - (block $compile_block.84 (result i32) + (block $compile_block.92 (result i32) (drop - (block $compile_set.82 (result i32) + (block $compile_set.90 (result i32) (local.set $9 (tuple.extract 0 (tuple.make @@ -713,7 +745,7 @@ pattern matching › tuple_match_deep3 ) ) (drop - (block $compile_set.83 (result i32) + (block $compile_set.91 (result i32) (local.set $10 (tuple.extract 0 (tuple.make @@ -736,13 +768,13 @@ pattern matching › tuple_match_deep3 ) (i32.const 1) ) - (block $compile_block.85 (result i32) + (block $compile_block.93 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.44 (result i32) + (block $cleanup.48 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -760,31 +792,29 @@ pattern matching › tuple_match_deep3 ) ) ) - (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) - ) + (block $compile_block.101 (result i32) + (block $compile_store.97 + (local.set $33 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $30) + (i32.const 1) + ) ) ) - (block $do_backpatches.88 + (block $do_backpatches.96 ) ) (if (result i32) (i32.shr_u - (local.get $32) + (local.get $33) (i32.const 31) ) - (block $compile_block.91 (result i32) + (block $compile_block.99 (result i32) (drop - (block $compile_set.90 (result i32) + (block $compile_set.98 (result i32) (local.set $8 (tuple.extract 0 (tuple.make @@ -807,17 +837,17 @@ pattern matching › tuple_match_deep3 ) (i32.const 0) ) - (block $compile_block.92 + (block $compile_block.100 (unreachable) ) ) ) ) ) - (block $do_backpatches.94 + (block $do_backpatches.102 ) ) - (block $cleanup.96 + (block $cleanup.104 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -833,48 +863,48 @@ pattern matching › tuple_match_deep3 ) (tuple.extract 0 (tuple.make - (block $switch.98_outer (result i32) - (block $switch.98_branch_0 (result i32) + (block $switch.106_outer (result i32) + (block $switch.106_branch_0 (result i32) (drop - (block $switch.98_branch_1 (result i32) + (block $switch.106_branch_1 (result i32) (drop - (block $switch.98_branch_2 (result i32) + (block $switch.106_branch_2 (result i32) (drop - (block $switch.98_branch_3 (result i32) + (block $switch.106_branch_3 (result i32) (drop - (block $switch.98_branch_4 (result i32) + (block $switch.106_branch_4 (result i32) (drop - (block $switch.98_branch_5 (result i32) + (block $switch.106_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 + (block $switch.106_default (result i32) + (br_table $switch.106_branch_1 $switch.106_branch_2 $switch.106_branch_3 $switch.106_branch_4 $switch.106_branch_5 $switch.106_default $switch.106_default (i32.const 0) - (local.get $31) + (local.get $32) ) ) ) - (br $switch.98_outer - (block $compile_block.113 (result i32) + (br $switch.106_outer + (block $compile_block.121 (result i32) (unreachable) ) ) ) ) - (br $switch.98_outer - (block $compile_block.112 (result i32) + (br $switch.106_outer + (block $compile_block.120 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.98_outer - (block $compile_block.111 - (block $compile_store.107 + (br $switch.106_outer + (block $compile_block.119 + (block $compile_store.115 (local.set $27 - (call $+_1151 + (call $+_1155 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) + (global.get $+_1155) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -886,15 +916,15 @@ pattern matching › tuple_match_deep3 ) ) ) - (block $do_backpatches.106 + (block $do_backpatches.114 ) ) - (block $compile_store.109 + (block $compile_store.117 (local.set $28 - (call $+_1151 + (call $+_1155 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) + (global.get $+_1155) ) (local.get $27) (call $incRef_0 @@ -903,10 +933,10 @@ pattern matching › tuple_match_deep3 ) ) ) - (block $do_backpatches.108 + (block $do_backpatches.116 ) ) - (block $cleanup.110 + (block $cleanup.118 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -962,10 +992,10 @@ pattern matching › tuple_match_deep3 ) ) ) - (return_call $+_1151 + (return_call $+_1155 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) + (global.get $+_1155) ) (local.get $28) (local.get $17) @@ -974,14 +1004,14 @@ pattern matching › tuple_match_deep3 ) ) ) - (br $switch.98_outer - (block $compile_block.105 - (block $compile_store.103 + (br $switch.106_outer + (block $compile_block.113 + (block $compile_store.111 (local.set $26 - (call $+_1151 + (call $+_1155 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) + (global.get $+_1155) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -993,10 +1023,10 @@ pattern matching › tuple_match_deep3 ) ) ) - (block $do_backpatches.102 + (block $do_backpatches.110 ) ) - (block $cleanup.104 + (block $cleanup.112 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1052,10 +1082,10 @@ pattern matching › tuple_match_deep3 ) ) ) - (return_call $+_1151 + (return_call $+_1155 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) + (global.get $+_1155) ) (local.get $26) (local.get $13) @@ -1064,9 +1094,9 @@ pattern matching › tuple_match_deep3 ) ) ) - (br $switch.98_outer - (block $compile_block.101 - (block $cleanup.100 + (br $switch.106_outer + (block $compile_block.109 + (block $cleanup.108 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1116,10 +1146,10 @@ pattern matching › tuple_match_deep3 ) ) ) - (return_call $+_1151 + (return_call $+_1155 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) + (global.get $+_1155) ) (local.get $9) (local.get $10) @@ -1128,8 +1158,8 @@ pattern matching › tuple_match_deep3 ) ) ) - (br $switch.98_outer - (block $compile_block.99 (result i32) + (br $switch.106_outer + (block $compile_block.107 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $8) @@ -1138,7 +1168,7 @@ pattern matching › tuple_match_deep3 ) ) ) - (block $cleanup.97 (result i32) + (block $cleanup.105 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot b/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot index 3c8ab6d54..4d718eab4 100644 --- a/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot @@ -13,11 +13,11 @@ pattern matching › adt_match_1 (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$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 $+_1143 (param i32 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)) @@ -58,7 +58,11 @@ pattern matching › adt_match_1 (local $29 i32) (local $30 i32) (local $31 i32) - (block $compile_block.89 (result i32) + (local $32 i32) + (local $33 i32) + (local $34 i32) + (local $35 i32) + (block $compile_block.97 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -146,29 +150,37 @@ pattern matching › adt_match_1 ) (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) + (i32.shr_s + (local.get $20) + (i32.const 1) ) ) (block $do_backpatches.18 ) ) - (block $compile_store.75 + (block $compile_store.21 (local.set $22 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $21) + (i32.const 0) + ) + ) + ) + (block $do_backpatches.20 + ) + ) + (block $compile_store.83 + (local.set $23 (if (result i32) (i32.shr_u - (local.get $21) + (local.get $22) (i32.const 31) ) - (block $compile_block.68 (result i32) - (block $compile_store.21 + (block $compile_block.76 (result i32) + (block $compile_store.23 (local.set $13 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -177,10 +189,10 @@ pattern matching › adt_match_1 ) ) ) - (block $do_backpatches.20 + (block $do_backpatches.22 ) ) - (block $compile_store.23 + (block $compile_store.25 (local.set $14 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -189,43 +201,51 @@ pattern matching › adt_match_1 ) ) ) - (block $do_backpatches.22 + (block $do_backpatches.24 ) ) - (block $compile_store.25 - (local.set $24 + (block $compile_store.27 + (local.set $25 (i32.load offset=12 (local.get $14) ) ) - (block $do_backpatches.24 + (block $do_backpatches.26 ) ) - (block $compile_store.27 - (local.set $25 - (i32.or - (i32.shl - (i32.eq - (local.get $24) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.29 + (local.set $26 + (i32.shr_s + (local.get $25) + (i32.const 1) + ) + ) + (block $do_backpatches.28 + ) + ) + (block $compile_store.31 + (local.set $27 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $26) + (i32.const 0) + ) ) ) - (block $do_backpatches.26 + (block $do_backpatches.30 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $25) + (local.get $27) (i32.const 31) ) - (block $compile_block.61 (result i32) - (block $compile_store.30 + (block $compile_block.69 (result i32) + (block $compile_store.34 (local.set $15 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -234,10 +254,10 @@ pattern matching › adt_match_1 ) ) ) - (block $do_backpatches.29 + (block $do_backpatches.33 ) ) - (block $compile_store.32 + (block $compile_store.36 (local.set $16 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -246,43 +266,51 @@ pattern matching › adt_match_1 ) ) ) - (block $do_backpatches.31 + (block $do_backpatches.35 ) ) - (block $compile_store.34 - (local.set $27 + (block $compile_store.38 + (local.set $29 (i32.load offset=12 (local.get $16) ) ) - (block $do_backpatches.33 + (block $do_backpatches.37 ) ) - (block $compile_store.36 - (local.set $28 - (i32.or - (i32.shl - (i32.eq - (local.get $27) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.40 + (local.set $30 + (i32.shr_s + (local.get $29) + (i32.const 1) + ) + ) + (block $do_backpatches.39 + ) + ) + (block $compile_store.42 + (local.set $31 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $30) + (i32.const 0) + ) ) ) - (block $do_backpatches.35 + (block $do_backpatches.41 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $28) + (local.get $31) (i32.const 31) ) - (block $compile_block.53 (result i32) - (block $compile_store.39 + (block $compile_block.61 (result i32) + (block $compile_store.45 (local.set $17 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -291,10 +319,10 @@ pattern matching › adt_match_1 ) ) ) - (block $do_backpatches.38 + (block $do_backpatches.44 ) ) - (block $compile_store.41 + (block $compile_store.47 (local.set $18 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -303,19 +331,19 @@ pattern matching › adt_match_1 ) ) ) - (block $do_backpatches.40 + (block $do_backpatches.46 ) ) - (block $compile_store.43 - (local.set $30 + (block $compile_store.49 + (local.set $33 (i32.load offset=12 (local.get $18) ) ) - (block $do_backpatches.42 + (block $do_backpatches.48 ) ) - (block $cleanup.44 + (block $cleanup.50 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -323,32 +351,40 @@ pattern matching › adt_match_1 ) ) ) - (block $compile_store.46 - (local.set $31 - (i32.or - (i32.shl - (i32.eq - (local.get $30) - (i32.const 3) - ) - (i32.const 31) - ) + (block $compile_store.52 + (local.set $34 + (i32.shr_s + (local.get $33) + (i32.const 1) + ) + ) + (block $do_backpatches.51 + ) + ) + (block $compile_store.54 + (local.set $35 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $34) + (i32.const 1) + ) ) ) - (block $do_backpatches.45 + (block $do_backpatches.53 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $31) + (local.get $35) (i32.const 31) ) - (block $compile_block.51 (result i32) + (block $compile_block.59 (result i32) (drop - (block $compile_set.48 (result i32) + (block $compile_set.56 (result i32) (local.set $10 (tuple.extract 0 (tuple.make @@ -370,7 +406,7 @@ pattern matching › adt_match_1 ) ) (drop - (block $compile_set.49 (result i32) + (block $compile_set.57 (result i32) (local.set $11 (tuple.extract 0 (tuple.make @@ -392,7 +428,7 @@ pattern matching › adt_match_1 ) ) (drop - (block $compile_set.50 (result i32) + (block $compile_set.58 (result i32) (local.set $12 (tuple.extract 0 (tuple.make @@ -415,11 +451,11 @@ pattern matching › adt_match_1 ) (i32.const 3) ) - (block $compile_block.52 (result i32) + (block $compile_block.60 (result i32) (i32.const 4) ) ) - (block $cleanup.47 (result i32) + (block $cleanup.55 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -431,31 +467,29 @@ pattern matching › adt_match_1 ) ) ) - (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) - ) + (block $compile_block.68 (result i32) + (block $compile_store.63 + (local.set $32 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $30) + (i32.const 1) + ) ) ) - (block $do_backpatches.54 + (block $do_backpatches.62 ) ) (if (result i32) (i32.shr_u - (local.get $29) + (local.get $32) (i32.const 31) ) - (block $compile_block.58 (result i32) + (block $compile_block.66 (result i32) (drop - (block $compile_set.56 (result i32) + (block $compile_set.64 (result i32) (local.set $8 (tuple.extract 0 (tuple.make @@ -477,7 +511,7 @@ pattern matching › adt_match_1 ) ) (drop - (block $compile_set.57 (result i32) + (block $compile_set.65 (result i32) (local.set $9 (tuple.extract 0 (tuple.make @@ -500,13 +534,13 @@ pattern matching › adt_match_1 ) (i32.const 2) ) - (block $compile_block.59 (result i32) + (block $compile_block.67 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.37 (result i32) + (block $cleanup.43 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -524,31 +558,29 @@ pattern matching › adt_match_1 ) ) ) - (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) - ) + (block $compile_block.75 (result i32) + (block $compile_store.71 + (local.set $28 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $26) + (i32.const 1) + ) ) ) - (block $do_backpatches.62 + (block $do_backpatches.70 ) ) (if (result i32) (i32.shr_u - (local.get $26) + (local.get $28) (i32.const 31) ) - (block $compile_block.65 (result i32) + (block $compile_block.73 (result i32) (drop - (block $compile_set.64 (result i32) + (block $compile_set.72 (result i32) (local.set $7 (tuple.extract 0 (tuple.make @@ -571,13 +603,13 @@ pattern matching › adt_match_1 ) (i32.const 1) ) - (block $compile_block.66 (result i32) + (block $compile_block.74 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.28 (result i32) + (block $cleanup.32 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -595,42 +627,40 @@ pattern matching › adt_match_1 ) ) ) - (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) - ) + (block $compile_block.81 (result i32) + (block $compile_store.78 + (local.set $24 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $21) + (i32.const 1) + ) ) ) - (block $do_backpatches.69 + (block $do_backpatches.77 ) ) (if (result i32) (i32.shr_u - (local.get $23) + (local.get $24) (i32.const 31) ) - (block $compile_block.71 (result i32) + (block $compile_block.79 (result i32) (i32.const 0) ) - (block $compile_block.72 + (block $compile_block.80 (unreachable) ) ) ) ) ) - (block $do_backpatches.74 + (block $do_backpatches.82 ) ) - (block $cleanup.76 + (block $cleanup.84 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -640,48 +670,48 @@ pattern matching › adt_match_1 ) (tuple.extract 0 (tuple.make - (block $switch.78_outer (result i32) - (block $switch.78_branch_0 (result i32) + (block $switch.86_outer (result i32) + (block $switch.86_branch_0 (result i32) (drop - (block $switch.78_branch_1 (result i32) + (block $switch.86_branch_1 (result i32) (drop - (block $switch.78_branch_2 (result i32) + (block $switch.86_branch_2 (result i32) (drop - (block $switch.78_branch_3 (result i32) + (block $switch.86_branch_3 (result i32) (drop - (block $switch.78_branch_4 (result i32) + (block $switch.86_branch_4 (result i32) (drop - (block $switch.78_branch_5 (result i32) + (block $switch.86_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 + (block $switch.86_default (result i32) + (br_table $switch.86_branch_1 $switch.86_branch_2 $switch.86_branch_3 $switch.86_branch_4 $switch.86_branch_5 $switch.86_default $switch.86_default (i32.const 0) - (local.get $22) + (local.get $23) ) ) ) - (br $switch.78_outer - (block $compile_block.88 (result i32) + (br $switch.86_outer + (block $compile_block.96 (result i32) (unreachable) ) ) ) ) - (br $switch.78_outer - (block $compile_block.87 (result i32) + (br $switch.86_outer + (block $compile_block.95 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.78_outer - (block $compile_block.86 - (block $compile_store.84 + (br $switch.86_outer + (block $compile_block.94 + (block $compile_store.92 (local.set $19 - (call $+_1143 + (call $+_1147 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1143) + (global.get $+_1147) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -693,10 +723,10 @@ pattern matching › adt_match_1 ) ) ) - (block $do_backpatches.83 + (block $do_backpatches.91 ) ) - (block $cleanup.85 + (block $cleanup.93 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -728,10 +758,10 @@ pattern matching › adt_match_1 ) ) ) - (return_call $+_1143 + (return_call $+_1147 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1143) + (global.get $+_1147) ) (local.get $19) (local.get $12) @@ -740,9 +770,9 @@ pattern matching › adt_match_1 ) ) ) - (br $switch.78_outer - (block $compile_block.82 - (block $cleanup.81 + (br $switch.86_outer + (block $compile_block.90 + (block $cleanup.89 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -768,10 +798,10 @@ pattern matching › adt_match_1 ) ) ) - (return_call $+_1143 + (return_call $+_1147 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1143) + (global.get $+_1147) ) (local.get $8) (local.get $9) @@ -780,8 +810,8 @@ pattern matching › adt_match_1 ) ) ) - (br $switch.78_outer - (block $compile_block.80 (result i32) + (br $switch.86_outer + (block $compile_block.88 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $7) @@ -790,14 +820,14 @@ pattern matching › adt_match_1 ) ) ) - (br $switch.78_outer - (block $compile_block.79 (result i32) + (br $switch.86_outer + (block $compile_block.87 (result i32) (i32.const 1) ) ) ) ) - (block $cleanup.77 (result i32) + (block $cleanup.85 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot b/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot index 78fe793c4..e3b4e1f27 100644 --- a/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot @@ -13,11 +13,11 @@ pattern matching › adt_match_2 (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$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 $+_1145 (param i32 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)) @@ -59,7 +59,11 @@ pattern matching › adt_match_2 (local $30 i32) (local $31 i32) (local $32 i32) - (block $compile_block.92 (result i32) + (local $33 i32) + (local $34 i32) + (local $35 i32) + (local $36 i32) + (block $compile_block.100 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -189,29 +193,37 @@ pattern matching › adt_match_2 ) (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) + (i32.shr_s + (local.get $21) + (i32.const 1) ) ) (block $do_backpatches.21 ) ) - (block $compile_store.78 + (block $compile_store.24 (local.set $23 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $22) + (i32.const 0) + ) + ) + ) + (block $do_backpatches.23 + ) + ) + (block $compile_store.86 + (local.set $24 (if (result i32) (i32.shr_u - (local.get $22) + (local.get $23) (i32.const 31) ) - (block $compile_block.71 (result i32) - (block $compile_store.24 + (block $compile_block.79 (result i32) + (block $compile_store.26 (local.set $14 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -220,10 +232,10 @@ pattern matching › adt_match_2 ) ) ) - (block $do_backpatches.23 + (block $do_backpatches.25 ) ) - (block $compile_store.26 + (block $compile_store.28 (local.set $15 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -232,43 +244,51 @@ pattern matching › adt_match_2 ) ) ) - (block $do_backpatches.25 + (block $do_backpatches.27 ) ) - (block $compile_store.28 - (local.set $25 + (block $compile_store.30 + (local.set $26 (i32.load offset=12 (local.get $15) ) ) - (block $do_backpatches.27 + (block $do_backpatches.29 ) ) - (block $compile_store.30 - (local.set $26 - (i32.or - (i32.shl - (i32.eq - (local.get $25) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.32 + (local.set $27 + (i32.shr_s + (local.get $26) + (i32.const 1) + ) + ) + (block $do_backpatches.31 + ) + ) + (block $compile_store.34 + (local.set $28 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $27) + (i32.const 0) + ) ) ) - (block $do_backpatches.29 + (block $do_backpatches.33 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $26) + (local.get $28) (i32.const 31) ) - (block $compile_block.64 (result i32) - (block $compile_store.33 + (block $compile_block.72 (result i32) + (block $compile_store.37 (local.set $16 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -277,10 +297,10 @@ pattern matching › adt_match_2 ) ) ) - (block $do_backpatches.32 + (block $do_backpatches.36 ) ) - (block $compile_store.35 + (block $compile_store.39 (local.set $17 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -289,43 +309,51 @@ pattern matching › adt_match_2 ) ) ) - (block $do_backpatches.34 + (block $do_backpatches.38 ) ) - (block $compile_store.37 - (local.set $28 + (block $compile_store.41 + (local.set $30 (i32.load offset=12 (local.get $17) ) ) - (block $do_backpatches.36 + (block $do_backpatches.40 ) ) - (block $compile_store.39 - (local.set $29 - (i32.or - (i32.shl - (i32.eq - (local.get $28) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.43 + (local.set $31 + (i32.shr_s + (local.get $30) + (i32.const 1) + ) + ) + (block $do_backpatches.42 + ) + ) + (block $compile_store.45 + (local.set $32 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $31) + (i32.const 0) + ) ) ) - (block $do_backpatches.38 + (block $do_backpatches.44 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $29) + (local.get $32) (i32.const 31) ) - (block $compile_block.56 (result i32) - (block $compile_store.42 + (block $compile_block.64 (result i32) + (block $compile_store.48 (local.set $18 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -334,10 +362,10 @@ pattern matching › adt_match_2 ) ) ) - (block $do_backpatches.41 + (block $do_backpatches.47 ) ) - (block $compile_store.44 + (block $compile_store.50 (local.set $19 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -346,19 +374,19 @@ pattern matching › adt_match_2 ) ) ) - (block $do_backpatches.43 + (block $do_backpatches.49 ) ) - (block $compile_store.46 - (local.set $31 + (block $compile_store.52 + (local.set $34 (i32.load offset=12 (local.get $19) ) ) - (block $do_backpatches.45 + (block $do_backpatches.51 ) ) - (block $cleanup.47 + (block $cleanup.53 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -366,32 +394,40 @@ pattern matching › adt_match_2 ) ) ) - (block $compile_store.49 - (local.set $32 - (i32.or - (i32.shl - (i32.eq - (local.get $31) - (i32.const 3) - ) - (i32.const 31) - ) + (block $compile_store.55 + (local.set $35 + (i32.shr_s + (local.get $34) + (i32.const 1) + ) + ) + (block $do_backpatches.54 + ) + ) + (block $compile_store.57 + (local.set $36 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $35) + (i32.const 1) + ) ) ) - (block $do_backpatches.48 + (block $do_backpatches.56 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $32) + (local.get $36) (i32.const 31) ) - (block $compile_block.54 (result i32) + (block $compile_block.62 (result i32) (drop - (block $compile_set.51 (result i32) + (block $compile_set.59 (result i32) (local.set $11 (tuple.extract 0 (tuple.make @@ -413,7 +449,7 @@ pattern matching › adt_match_2 ) ) (drop - (block $compile_set.52 (result i32) + (block $compile_set.60 (result i32) (local.set $12 (tuple.extract 0 (tuple.make @@ -435,7 +471,7 @@ pattern matching › adt_match_2 ) ) (drop - (block $compile_set.53 (result i32) + (block $compile_set.61 (result i32) (local.set $13 (tuple.extract 0 (tuple.make @@ -458,11 +494,11 @@ pattern matching › adt_match_2 ) (i32.const 3) ) - (block $compile_block.55 (result i32) + (block $compile_block.63 (result i32) (i32.const 4) ) ) - (block $cleanup.50 (result i32) + (block $cleanup.58 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -474,31 +510,29 @@ pattern matching › adt_match_2 ) ) ) - (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) - ) + (block $compile_block.71 (result i32) + (block $compile_store.66 + (local.set $33 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $31) + (i32.const 1) + ) ) ) - (block $do_backpatches.57 + (block $do_backpatches.65 ) ) (if (result i32) (i32.shr_u - (local.get $30) + (local.get $33) (i32.const 31) ) - (block $compile_block.61 (result i32) + (block $compile_block.69 (result i32) (drop - (block $compile_set.59 (result i32) + (block $compile_set.67 (result i32) (local.set $9 (tuple.extract 0 (tuple.make @@ -520,7 +554,7 @@ pattern matching › adt_match_2 ) ) (drop - (block $compile_set.60 (result i32) + (block $compile_set.68 (result i32) (local.set $10 (tuple.extract 0 (tuple.make @@ -543,13 +577,13 @@ pattern matching › adt_match_2 ) (i32.const 2) ) - (block $compile_block.62 (result i32) + (block $compile_block.70 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.40 (result i32) + (block $cleanup.46 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -567,31 +601,29 @@ pattern matching › adt_match_2 ) ) ) - (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) - ) + (block $compile_block.78 (result i32) + (block $compile_store.74 + (local.set $29 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $27) + (i32.const 1) + ) ) ) - (block $do_backpatches.65 + (block $do_backpatches.73 ) ) (if (result i32) (i32.shr_u - (local.get $27) + (local.get $29) (i32.const 31) ) - (block $compile_block.68 (result i32) + (block $compile_block.76 (result i32) (drop - (block $compile_set.67 (result i32) + (block $compile_set.75 (result i32) (local.set $8 (tuple.extract 0 (tuple.make @@ -614,13 +646,13 @@ pattern matching › adt_match_2 ) (i32.const 1) ) - (block $compile_block.69 (result i32) + (block $compile_block.77 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.31 (result i32) + (block $cleanup.35 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -638,42 +670,40 @@ pattern matching › adt_match_2 ) ) ) - (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) - ) + (block $compile_block.84 (result i32) + (block $compile_store.81 + (local.set $25 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $22) + (i32.const 1) + ) ) ) - (block $do_backpatches.72 + (block $do_backpatches.80 ) ) (if (result i32) (i32.shr_u - (local.get $24) + (local.get $25) (i32.const 31) ) - (block $compile_block.74 (result i32) + (block $compile_block.82 (result i32) (i32.const 0) ) - (block $compile_block.75 + (block $compile_block.83 (unreachable) ) ) ) ) ) - (block $do_backpatches.77 + (block $do_backpatches.85 ) ) - (block $cleanup.79 + (block $cleanup.87 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -683,48 +713,48 @@ pattern matching › adt_match_2 ) (tuple.extract 0 (tuple.make - (block $switch.81_outer (result i32) - (block $switch.81_branch_0 (result i32) + (block $switch.89_outer (result i32) + (block $switch.89_branch_0 (result i32) (drop - (block $switch.81_branch_1 (result i32) + (block $switch.89_branch_1 (result i32) (drop - (block $switch.81_branch_2 (result i32) + (block $switch.89_branch_2 (result i32) (drop - (block $switch.81_branch_3 (result i32) + (block $switch.89_branch_3 (result i32) (drop - (block $switch.81_branch_4 (result i32) + (block $switch.89_branch_4 (result i32) (drop - (block $switch.81_branch_5 (result i32) + (block $switch.89_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 + (block $switch.89_default (result i32) + (br_table $switch.89_branch_1 $switch.89_branch_2 $switch.89_branch_3 $switch.89_branch_4 $switch.89_branch_5 $switch.89_default $switch.89_default (i32.const 0) - (local.get $23) + (local.get $24) ) ) ) - (br $switch.81_outer - (block $compile_block.91 (result i32) + (br $switch.89_outer + (block $compile_block.99 (result i32) (unreachable) ) ) ) ) - (br $switch.81_outer - (block $compile_block.90 (result i32) + (br $switch.89_outer + (block $compile_block.98 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.81_outer - (block $compile_block.89 - (block $compile_store.87 + (br $switch.89_outer + (block $compile_block.97 + (block $compile_store.95 (local.set $20 - (call $+_1145 + (call $+_1149 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1145) + (global.get $+_1149) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -736,10 +766,10 @@ pattern matching › adt_match_2 ) ) ) - (block $do_backpatches.86 + (block $do_backpatches.94 ) ) - (block $cleanup.88 + (block $cleanup.96 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -771,10 +801,10 @@ pattern matching › adt_match_2 ) ) ) - (return_call $+_1145 + (return_call $+_1149 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1145) + (global.get $+_1149) ) (local.get $20) (local.get $13) @@ -783,9 +813,9 @@ pattern matching › adt_match_2 ) ) ) - (br $switch.81_outer - (block $compile_block.85 - (block $cleanup.84 + (br $switch.89_outer + (block $compile_block.93 + (block $cleanup.92 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -811,10 +841,10 @@ pattern matching › adt_match_2 ) ) ) - (return_call $+_1145 + (return_call $+_1149 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1145) + (global.get $+_1149) ) (local.get $9) (local.get $10) @@ -823,8 +853,8 @@ pattern matching › adt_match_2 ) ) ) - (br $switch.81_outer - (block $compile_block.83 (result i32) + (br $switch.89_outer + (block $compile_block.91 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $8) @@ -833,14 +863,14 @@ pattern matching › adt_match_2 ) ) ) - (br $switch.81_outer - (block $compile_block.82 (result i32) + (br $switch.89_outer + (block $compile_block.90 (result i32) (i32.const 1) ) ) ) ) - (block $cleanup.80 (result i32) + (block $cleanup.88 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot b/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot index 3ebf6dcb1..98d0e4f88 100644 --- a/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot @@ -13,11 +13,11 @@ pattern matching › adt_match_3 (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$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 $+_1147 (param i32 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)) @@ -60,7 +60,11 @@ pattern matching › adt_match_3 (local $31 i32) (local $32 i32) (local $33 i32) - (block $compile_block.95 (result i32) + (local $34 i32) + (local $35 i32) + (local $36 i32) + (local $37 i32) + (block $compile_block.103 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -232,29 +236,37 @@ pattern matching › adt_match_3 ) (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) + (i32.shr_s + (local.get $22) + (i32.const 1) ) ) (block $do_backpatches.24 ) ) - (block $compile_store.81 + (block $compile_store.27 (local.set $24 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $23) + (i32.const 0) + ) + ) + ) + (block $do_backpatches.26 + ) + ) + (block $compile_store.89 + (local.set $25 (if (result i32) (i32.shr_u - (local.get $23) + (local.get $24) (i32.const 31) ) - (block $compile_block.74 (result i32) - (block $compile_store.27 + (block $compile_block.82 (result i32) + (block $compile_store.29 (local.set $15 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -263,10 +275,10 @@ pattern matching › adt_match_3 ) ) ) - (block $do_backpatches.26 + (block $do_backpatches.28 ) ) - (block $compile_store.29 + (block $compile_store.31 (local.set $16 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -275,43 +287,51 @@ pattern matching › adt_match_3 ) ) ) - (block $do_backpatches.28 + (block $do_backpatches.30 ) ) - (block $compile_store.31 - (local.set $26 + (block $compile_store.33 + (local.set $27 (i32.load offset=12 (local.get $16) ) ) - (block $do_backpatches.30 + (block $do_backpatches.32 ) ) - (block $compile_store.33 - (local.set $27 - (i32.or - (i32.shl - (i32.eq - (local.get $26) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.35 + (local.set $28 + (i32.shr_s + (local.get $27) + (i32.const 1) + ) + ) + (block $do_backpatches.34 + ) + ) + (block $compile_store.37 + (local.set $29 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $28) + (i32.const 0) + ) ) ) - (block $do_backpatches.32 + (block $do_backpatches.36 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $27) + (local.get $29) (i32.const 31) ) - (block $compile_block.67 (result i32) - (block $compile_store.36 + (block $compile_block.75 (result i32) + (block $compile_store.40 (local.set $17 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -320,10 +340,10 @@ pattern matching › adt_match_3 ) ) ) - (block $do_backpatches.35 + (block $do_backpatches.39 ) ) - (block $compile_store.38 + (block $compile_store.42 (local.set $18 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -332,43 +352,51 @@ pattern matching › adt_match_3 ) ) ) - (block $do_backpatches.37 + (block $do_backpatches.41 ) ) - (block $compile_store.40 - (local.set $29 + (block $compile_store.44 + (local.set $31 (i32.load offset=12 (local.get $18) ) ) - (block $do_backpatches.39 + (block $do_backpatches.43 ) ) - (block $compile_store.42 - (local.set $30 - (i32.or - (i32.shl - (i32.eq - (local.get $29) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.46 + (local.set $32 + (i32.shr_s + (local.get $31) + (i32.const 1) + ) + ) + (block $do_backpatches.45 + ) + ) + (block $compile_store.48 + (local.set $33 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $32) + (i32.const 0) + ) ) ) - (block $do_backpatches.41 + (block $do_backpatches.47 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $30) + (local.get $33) (i32.const 31) ) - (block $compile_block.59 (result i32) - (block $compile_store.45 + (block $compile_block.67 (result i32) + (block $compile_store.51 (local.set $19 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -377,10 +405,10 @@ pattern matching › adt_match_3 ) ) ) - (block $do_backpatches.44 + (block $do_backpatches.50 ) ) - (block $compile_store.47 + (block $compile_store.53 (local.set $20 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -389,19 +417,19 @@ pattern matching › adt_match_3 ) ) ) - (block $do_backpatches.46 + (block $do_backpatches.52 ) ) - (block $compile_store.49 - (local.set $32 + (block $compile_store.55 + (local.set $35 (i32.load offset=12 (local.get $20) ) ) - (block $do_backpatches.48 + (block $do_backpatches.54 ) ) - (block $cleanup.50 + (block $cleanup.56 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -409,32 +437,40 @@ pattern matching › adt_match_3 ) ) ) - (block $compile_store.52 - (local.set $33 - (i32.or - (i32.shl - (i32.eq - (local.get $32) - (i32.const 3) - ) - (i32.const 31) - ) + (block $compile_store.58 + (local.set $36 + (i32.shr_s + (local.get $35) + (i32.const 1) + ) + ) + (block $do_backpatches.57 + ) + ) + (block $compile_store.60 + (local.set $37 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $36) + (i32.const 1) + ) ) ) - (block $do_backpatches.51 + (block $do_backpatches.59 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $33) + (local.get $37) (i32.const 31) ) - (block $compile_block.57 (result i32) + (block $compile_block.65 (result i32) (drop - (block $compile_set.54 (result i32) + (block $compile_set.62 (result i32) (local.set $12 (tuple.extract 0 (tuple.make @@ -456,7 +492,7 @@ pattern matching › adt_match_3 ) ) (drop - (block $compile_set.55 (result i32) + (block $compile_set.63 (result i32) (local.set $13 (tuple.extract 0 (tuple.make @@ -478,7 +514,7 @@ pattern matching › adt_match_3 ) ) (drop - (block $compile_set.56 (result i32) + (block $compile_set.64 (result i32) (local.set $14 (tuple.extract 0 (tuple.make @@ -501,11 +537,11 @@ pattern matching › adt_match_3 ) (i32.const 3) ) - (block $compile_block.58 (result i32) + (block $compile_block.66 (result i32) (i32.const 4) ) ) - (block $cleanup.53 (result i32) + (block $cleanup.61 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -517,31 +553,29 @@ pattern matching › adt_match_3 ) ) ) - (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) - ) + (block $compile_block.74 (result i32) + (block $compile_store.69 + (local.set $34 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $32) + (i32.const 1) + ) ) ) - (block $do_backpatches.60 + (block $do_backpatches.68 ) ) (if (result i32) (i32.shr_u - (local.get $31) + (local.get $34) (i32.const 31) ) - (block $compile_block.64 (result i32) + (block $compile_block.72 (result i32) (drop - (block $compile_set.62 (result i32) + (block $compile_set.70 (result i32) (local.set $10 (tuple.extract 0 (tuple.make @@ -563,7 +597,7 @@ pattern matching › adt_match_3 ) ) (drop - (block $compile_set.63 (result i32) + (block $compile_set.71 (result i32) (local.set $11 (tuple.extract 0 (tuple.make @@ -586,13 +620,13 @@ pattern matching › adt_match_3 ) (i32.const 2) ) - (block $compile_block.65 (result i32) + (block $compile_block.73 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.43 (result i32) + (block $cleanup.49 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -610,31 +644,29 @@ pattern matching › adt_match_3 ) ) ) - (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) - ) + (block $compile_block.81 (result i32) + (block $compile_store.77 + (local.set $30 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $28) + (i32.const 1) + ) ) ) - (block $do_backpatches.68 + (block $do_backpatches.76 ) ) (if (result i32) (i32.shr_u - (local.get $28) + (local.get $30) (i32.const 31) ) - (block $compile_block.71 (result i32) + (block $compile_block.79 (result i32) (drop - (block $compile_set.70 (result i32) + (block $compile_set.78 (result i32) (local.set $9 (tuple.extract 0 (tuple.make @@ -657,13 +689,13 @@ pattern matching › adt_match_3 ) (i32.const 1) ) - (block $compile_block.72 (result i32) + (block $compile_block.80 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.34 (result i32) + (block $cleanup.38 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -681,42 +713,40 @@ pattern matching › adt_match_3 ) ) ) - (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) - ) + (block $compile_block.87 (result i32) + (block $compile_store.84 + (local.set $26 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $23) + (i32.const 1) + ) ) ) - (block $do_backpatches.75 + (block $do_backpatches.83 ) ) (if (result i32) (i32.shr_u - (local.get $25) + (local.get $26) (i32.const 31) ) - (block $compile_block.77 (result i32) + (block $compile_block.85 (result i32) (i32.const 0) ) - (block $compile_block.78 + (block $compile_block.86 (unreachable) ) ) ) ) ) - (block $do_backpatches.80 + (block $do_backpatches.88 ) ) - (block $cleanup.82 + (block $cleanup.90 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -726,48 +756,48 @@ pattern matching › adt_match_3 ) (tuple.extract 0 (tuple.make - (block $switch.84_outer (result i32) - (block $switch.84_branch_0 (result i32) + (block $switch.92_outer (result i32) + (block $switch.92_branch_0 (result i32) (drop - (block $switch.84_branch_1 (result i32) + (block $switch.92_branch_1 (result i32) (drop - (block $switch.84_branch_2 (result i32) + (block $switch.92_branch_2 (result i32) (drop - (block $switch.84_branch_3 (result i32) + (block $switch.92_branch_3 (result i32) (drop - (block $switch.84_branch_4 (result i32) + (block $switch.92_branch_4 (result i32) (drop - (block $switch.84_branch_5 (result i32) + (block $switch.92_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 + (block $switch.92_default (result i32) + (br_table $switch.92_branch_1 $switch.92_branch_2 $switch.92_branch_3 $switch.92_branch_4 $switch.92_branch_5 $switch.92_default $switch.92_default (i32.const 0) - (local.get $24) + (local.get $25) ) ) ) - (br $switch.84_outer - (block $compile_block.94 (result i32) + (br $switch.92_outer + (block $compile_block.102 (result i32) (unreachable) ) ) ) ) - (br $switch.84_outer - (block $compile_block.93 (result i32) + (br $switch.92_outer + (block $compile_block.101 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.84_outer - (block $compile_block.92 - (block $compile_store.90 + (br $switch.92_outer + (block $compile_block.100 + (block $compile_store.98 (local.set $21 - (call $+_1147 + (call $+_1151 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1147) + (global.get $+_1151) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -779,10 +809,10 @@ pattern matching › adt_match_3 ) ) ) - (block $do_backpatches.89 + (block $do_backpatches.97 ) ) - (block $cleanup.91 + (block $cleanup.99 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -814,10 +844,10 @@ pattern matching › adt_match_3 ) ) ) - (return_call $+_1147 + (return_call $+_1151 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1147) + (global.get $+_1151) ) (local.get $21) (local.get $14) @@ -826,9 +856,9 @@ pattern matching › adt_match_3 ) ) ) - (br $switch.84_outer - (block $compile_block.88 - (block $cleanup.87 + (br $switch.92_outer + (block $compile_block.96 + (block $cleanup.95 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -854,10 +884,10 @@ pattern matching › adt_match_3 ) ) ) - (return_call $+_1147 + (return_call $+_1151 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1147) + (global.get $+_1151) ) (local.get $10) (local.get $11) @@ -866,8 +896,8 @@ pattern matching › adt_match_3 ) ) ) - (br $switch.84_outer - (block $compile_block.86 (result i32) + (br $switch.92_outer + (block $compile_block.94 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $9) @@ -876,14 +906,14 @@ pattern matching › adt_match_3 ) ) ) - (br $switch.84_outer - (block $compile_block.85 (result i32) + (br $switch.92_outer + (block $compile_block.93 (result i32) (i32.const 1) ) ) ) ) - (block $cleanup.83 (result i32) + (block $cleanup.91 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.c9582b6d.0.snapshot b/compiler/test/__snapshots__/pattern_matching.c9582b6d.0.snapshot index f1a8af1bb..1796327a6 100644 --- a/compiler/test/__snapshots__/pattern_matching.c9582b6d.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.c9582b6d.0.snapshot @@ -41,7 +41,8 @@ pattern matching › alias_match_4 (local $12 i32) (local $13 i32) (local $14 i32) - (block $compile_block.38 (result i32) + (local $15 i32) + (block $compile_block.40 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -98,54 +99,60 @@ pattern matching › alias_match_4 ) (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) + (i32.shr_s + (local.get $9) + (i32.const 1) ) ) (block $do_backpatches.8 ) ) - (block $compile_store.30 + (block $compile_store.11 (local.set $11 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $10) + (i32.const 1) + ) + ) + ) + (block $do_backpatches.10 + ) + ) + (block $compile_store.32 + (local.set $12 (if (result i32) (i32.shr_u - (local.get $10) + (local.get $11) (i32.const 31) ) - (block $compile_block.10 (result i32) + (block $compile_block.12 (result i32) (i32.const 1) ) - (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) - ) + (block $compile_block.30 (result i32) + (block $compile_store.14 + (local.set $13 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $10) + (i32.const 0) + ) ) ) - (block $do_backpatches.11 + (block $do_backpatches.13 ) ) (if (result i32) (i32.shr_u - (local.get $12) + (local.get $13) (i32.const 31) ) - (block $compile_block.26 (result i32) - (block $compile_store.14 + (block $compile_block.28 (result i32) + (block $compile_store.16 (local.set $8 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -154,11 +161,11 @@ pattern matching › alias_match_4 ) ) ) - (block $do_backpatches.13 + (block $do_backpatches.15 ) ) - (block $compile_store.16 - (local.set $13 + (block $compile_store.18 + (local.set $14 (call $equal_0 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -171,19 +178,19 @@ pattern matching › alias_match_4 (i32.const 7) ) ) - (block $do_backpatches.15 + (block $do_backpatches.17 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $13) + (local.get $14) (i32.const 31) ) - (block $compile_block.19 (result i32) + (block $compile_block.21 (result i32) (drop - (block $compile_set.18 (result i32) + (block $compile_set.20 (result i32) (local.set $7 (tuple.extract 0 (tuple.make @@ -206,9 +213,9 @@ pattern matching › alias_match_4 ) (i32.const 0) ) - (block $compile_block.25 (result i32) - (block $compile_store.21 - (local.set $14 + (block $compile_block.27 (result i32) + (block $compile_store.23 + (local.set $15 (call $equal_0 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -221,17 +228,17 @@ pattern matching › alias_match_4 (i32.const 9) ) ) - (block $do_backpatches.20 + (block $do_backpatches.22 ) ) (if (result i32) (i32.shr_u - (local.get $14) + (local.get $15) (i32.const 31) ) - (block $compile_block.23 (result i32) + (block $compile_block.25 (result i32) (drop - (block $compile_set.22 (result i32) + (block $compile_set.24 (result i32) (local.set $7 (tuple.extract 0 (tuple.make @@ -254,13 +261,13 @@ pattern matching › alias_match_4 ) (i32.const 0) ) - (block $compile_block.24 (result i32) + (block $compile_block.26 (result i32) (i32.const 1) ) ) ) ) - (block $cleanup.17 (result i32) + (block $cleanup.19 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -272,17 +279,17 @@ pattern matching › alias_match_4 ) ) ) - (block $compile_block.27 (result i32) + (block $compile_block.29 (result i32) (i32.const 2) ) ) ) ) ) - (block $do_backpatches.29 + (block $do_backpatches.31 ) ) - (block $cleanup.31 + (block $cleanup.33 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -292,45 +299,45 @@ pattern matching › alias_match_4 ) (tuple.extract 0 (tuple.make - (block $switch.33_outer (result i32) - (block $switch.33_branch_0 (result i32) + (block $switch.35_outer (result i32) + (block $switch.35_branch_0 (result i32) (drop - (block $switch.33_branch_1 (result i32) + (block $switch.35_branch_1 (result i32) (drop - (block $switch.33_branch_2 (result i32) + (block $switch.35_branch_2 (result i32) (drop - (block $switch.33_branch_3 (result i32) + (block $switch.35_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 + (block $switch.35_default (result i32) + (br_table $switch.35_branch_1 $switch.35_branch_2 $switch.35_branch_3 $switch.35_default $switch.35_default (i32.const 0) - (local.get $11) + (local.get $12) ) ) ) - (br $switch.33_outer - (block $compile_block.37 (result i32) + (br $switch.35_outer + (block $compile_block.39 (result i32) (unreachable) ) ) ) ) - (br $switch.33_outer - (block $compile_block.36 (result i32) + (br $switch.35_outer + (block $compile_block.38 (result i32) (i32.const 13) ) ) ) ) - (br $switch.33_outer - (block $compile_block.35 (result i32) + (br $switch.35_outer + (block $compile_block.37 (result i32) (i32.const 11) ) ) ) ) - (br $switch.33_outer - (block $compile_block.34 (result i32) + (br $switch.35_outer + (block $compile_block.36 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $7) @@ -339,7 +346,7 @@ pattern matching › alias_match_4 ) ) ) - (block $cleanup.32 (result i32) + (block $cleanup.34 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot b/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot index d2c4d5574..67263a2d7 100644 --- a/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot @@ -13,11 +13,11 @@ pattern matching › adt_match_5 (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$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 $+_1151 (param i32 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)) @@ -62,7 +62,11 @@ pattern matching › adt_match_5 (local $33 i32) (local $34 i32) (local $35 i32) - (block $compile_block.101 (result i32) + (local $36 i32) + (local $37 i32) + (local $38 i32) + (local $39 i32) + (block $compile_block.109 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -318,29 +322,37 @@ pattern matching › adt_match_5 ) (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) + (i32.shr_s + (local.get $24) + (i32.const 1) ) ) (block $do_backpatches.30 ) ) - (block $compile_store.87 + (block $compile_store.33 (local.set $26 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $25) + (i32.const 0) + ) + ) + ) + (block $do_backpatches.32 + ) + ) + (block $compile_store.95 + (local.set $27 (if (result i32) (i32.shr_u - (local.get $25) + (local.get $26) (i32.const 31) ) - (block $compile_block.80 (result i32) - (block $compile_store.33 + (block $compile_block.88 (result i32) + (block $compile_store.35 (local.set $17 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -349,10 +361,10 @@ pattern matching › adt_match_5 ) ) ) - (block $do_backpatches.32 + (block $do_backpatches.34 ) ) - (block $compile_store.35 + (block $compile_store.37 (local.set $18 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -361,43 +373,51 @@ pattern matching › adt_match_5 ) ) ) - (block $do_backpatches.34 + (block $do_backpatches.36 ) ) - (block $compile_store.37 - (local.set $28 + (block $compile_store.39 + (local.set $29 (i32.load offset=12 (local.get $18) ) ) - (block $do_backpatches.36 + (block $do_backpatches.38 ) ) - (block $compile_store.39 - (local.set $29 - (i32.or - (i32.shl - (i32.eq - (local.get $28) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.41 + (local.set $30 + (i32.shr_s + (local.get $29) + (i32.const 1) + ) + ) + (block $do_backpatches.40 + ) + ) + (block $compile_store.43 + (local.set $31 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $30) + (i32.const 0) + ) ) ) - (block $do_backpatches.38 + (block $do_backpatches.42 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $29) + (local.get $31) (i32.const 31) ) - (block $compile_block.73 (result i32) - (block $compile_store.42 + (block $compile_block.81 (result i32) + (block $compile_store.46 (local.set $19 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -406,10 +426,10 @@ pattern matching › adt_match_5 ) ) ) - (block $do_backpatches.41 + (block $do_backpatches.45 ) ) - (block $compile_store.44 + (block $compile_store.48 (local.set $20 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -418,43 +438,51 @@ pattern matching › adt_match_5 ) ) ) - (block $do_backpatches.43 + (block $do_backpatches.47 ) ) - (block $compile_store.46 - (local.set $31 + (block $compile_store.50 + (local.set $33 (i32.load offset=12 (local.get $20) ) ) - (block $do_backpatches.45 + (block $do_backpatches.49 ) ) - (block $compile_store.48 - (local.set $32 - (i32.or - (i32.shl - (i32.eq - (local.get $31) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.52 + (local.set $34 + (i32.shr_s + (local.get $33) + (i32.const 1) + ) + ) + (block $do_backpatches.51 + ) + ) + (block $compile_store.54 + (local.set $35 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $34) + (i32.const 0) + ) ) ) - (block $do_backpatches.47 + (block $do_backpatches.53 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $32) + (local.get $35) (i32.const 31) ) - (block $compile_block.65 (result i32) - (block $compile_store.51 + (block $compile_block.73 (result i32) + (block $compile_store.57 (local.set $21 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -463,10 +491,10 @@ pattern matching › adt_match_5 ) ) ) - (block $do_backpatches.50 + (block $do_backpatches.56 ) ) - (block $compile_store.53 + (block $compile_store.59 (local.set $22 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -475,19 +503,19 @@ pattern matching › adt_match_5 ) ) ) - (block $do_backpatches.52 + (block $do_backpatches.58 ) ) - (block $compile_store.55 - (local.set $34 + (block $compile_store.61 + (local.set $37 (i32.load offset=12 (local.get $22) ) ) - (block $do_backpatches.54 + (block $do_backpatches.60 ) ) - (block $cleanup.56 + (block $cleanup.62 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -495,32 +523,40 @@ pattern matching › adt_match_5 ) ) ) - (block $compile_store.58 - (local.set $35 - (i32.or - (i32.shl - (i32.eq - (local.get $34) - (i32.const 3) - ) - (i32.const 31) - ) + (block $compile_store.64 + (local.set $38 + (i32.shr_s + (local.get $37) + (i32.const 1) + ) + ) + (block $do_backpatches.63 + ) + ) + (block $compile_store.66 + (local.set $39 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $38) + (i32.const 1) + ) ) ) - (block $do_backpatches.57 + (block $do_backpatches.65 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $35) + (local.get $39) (i32.const 31) ) - (block $compile_block.63 (result i32) + (block $compile_block.71 (result i32) (drop - (block $compile_set.60 (result i32) + (block $compile_set.68 (result i32) (local.set $14 (tuple.extract 0 (tuple.make @@ -542,7 +578,7 @@ pattern matching › adt_match_5 ) ) (drop - (block $compile_set.61 (result i32) + (block $compile_set.69 (result i32) (local.set $15 (tuple.extract 0 (tuple.make @@ -564,7 +600,7 @@ pattern matching › adt_match_5 ) ) (drop - (block $compile_set.62 (result i32) + (block $compile_set.70 (result i32) (local.set $16 (tuple.extract 0 (tuple.make @@ -587,11 +623,11 @@ pattern matching › adt_match_5 ) (i32.const 3) ) - (block $compile_block.64 (result i32) + (block $compile_block.72 (result i32) (i32.const 4) ) ) - (block $cleanup.59 (result i32) + (block $cleanup.67 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -603,31 +639,29 @@ pattern matching › adt_match_5 ) ) ) - (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) - ) + (block $compile_block.80 (result i32) + (block $compile_store.75 + (local.set $36 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $34) + (i32.const 1) + ) ) ) - (block $do_backpatches.66 + (block $do_backpatches.74 ) ) (if (result i32) (i32.shr_u - (local.get $33) + (local.get $36) (i32.const 31) ) - (block $compile_block.70 (result i32) + (block $compile_block.78 (result i32) (drop - (block $compile_set.68 (result i32) + (block $compile_set.76 (result i32) (local.set $12 (tuple.extract 0 (tuple.make @@ -649,7 +683,7 @@ pattern matching › adt_match_5 ) ) (drop - (block $compile_set.69 (result i32) + (block $compile_set.77 (result i32) (local.set $13 (tuple.extract 0 (tuple.make @@ -672,13 +706,13 @@ pattern matching › adt_match_5 ) (i32.const 2) ) - (block $compile_block.71 (result i32) + (block $compile_block.79 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.49 (result i32) + (block $cleanup.55 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -696,31 +730,29 @@ pattern matching › adt_match_5 ) ) ) - (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) - ) + (block $compile_block.87 (result i32) + (block $compile_store.83 + (local.set $32 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $30) + (i32.const 1) + ) ) ) - (block $do_backpatches.74 + (block $do_backpatches.82 ) ) (if (result i32) (i32.shr_u - (local.get $30) + (local.get $32) (i32.const 31) ) - (block $compile_block.77 (result i32) + (block $compile_block.85 (result i32) (drop - (block $compile_set.76 (result i32) + (block $compile_set.84 (result i32) (local.set $11 (tuple.extract 0 (tuple.make @@ -743,13 +775,13 @@ pattern matching › adt_match_5 ) (i32.const 1) ) - (block $compile_block.78 (result i32) + (block $compile_block.86 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.40 (result i32) + (block $cleanup.44 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -767,42 +799,40 @@ pattern matching › adt_match_5 ) ) ) - (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) - ) + (block $compile_block.93 (result i32) + (block $compile_store.90 + (local.set $28 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $25) + (i32.const 1) + ) ) ) - (block $do_backpatches.81 + (block $do_backpatches.89 ) ) (if (result i32) (i32.shr_u - (local.get $27) + (local.get $28) (i32.const 31) ) - (block $compile_block.83 (result i32) + (block $compile_block.91 (result i32) (i32.const 0) ) - (block $compile_block.84 + (block $compile_block.92 (unreachable) ) ) ) ) ) - (block $do_backpatches.86 + (block $do_backpatches.94 ) ) - (block $cleanup.88 + (block $cleanup.96 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -812,48 +842,48 @@ pattern matching › adt_match_5 ) (tuple.extract 0 (tuple.make - (block $switch.90_outer (result i32) - (block $switch.90_branch_0 (result i32) + (block $switch.98_outer (result i32) + (block $switch.98_branch_0 (result i32) (drop - (block $switch.90_branch_1 (result i32) + (block $switch.98_branch_1 (result i32) (drop - (block $switch.90_branch_2 (result i32) + (block $switch.98_branch_2 (result i32) (drop - (block $switch.90_branch_3 (result i32) + (block $switch.98_branch_3 (result i32) (drop - (block $switch.90_branch_4 (result i32) + (block $switch.98_branch_4 (result i32) (drop - (block $switch.90_branch_5 (result i32) + (block $switch.98_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 + (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) - (local.get $26) + (local.get $27) ) ) ) - (br $switch.90_outer - (block $compile_block.100 (result i32) + (br $switch.98_outer + (block $compile_block.108 (result i32) (unreachable) ) ) ) ) - (br $switch.90_outer - (block $compile_block.99 (result i32) + (br $switch.98_outer + (block $compile_block.107 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.90_outer - (block $compile_block.98 - (block $compile_store.96 + (br $switch.98_outer + (block $compile_block.106 + (block $compile_store.104 (local.set $23 - (call $+_1151 + (call $+_1155 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) + (global.get $+_1155) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -865,10 +895,10 @@ pattern matching › adt_match_5 ) ) ) - (block $do_backpatches.95 + (block $do_backpatches.103 ) ) - (block $cleanup.97 + (block $cleanup.105 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -900,10 +930,10 @@ pattern matching › adt_match_5 ) ) ) - (return_call $+_1151 + (return_call $+_1155 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) + (global.get $+_1155) ) (local.get $23) (local.get $16) @@ -912,9 +942,9 @@ pattern matching › adt_match_5 ) ) ) - (br $switch.90_outer - (block $compile_block.94 - (block $cleanup.93 + (br $switch.98_outer + (block $compile_block.102 + (block $cleanup.101 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -940,10 +970,10 @@ pattern matching › adt_match_5 ) ) ) - (return_call $+_1151 + (return_call $+_1155 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) + (global.get $+_1155) ) (local.get $12) (local.get $13) @@ -952,8 +982,8 @@ pattern matching › adt_match_5 ) ) ) - (br $switch.90_outer - (block $compile_block.92 (result i32) + (br $switch.98_outer + (block $compile_block.100 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $11) @@ -962,14 +992,14 @@ pattern matching › adt_match_5 ) ) ) - (br $switch.90_outer - (block $compile_block.91 (result i32) + (br $switch.98_outer + (block $compile_block.99 (result i32) (i32.const 1) ) ) ) ) - (block $cleanup.89 (result i32) + (block $cleanup.97 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot index 047e61787..0487a1ada 100644 --- a/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot @@ -13,11 +13,11 @@ pattern matching › tuple_match_deep5 (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$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 $+_1155 (param i32 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)) @@ -69,7 +69,11 @@ pattern matching › tuple_match_deep5 (local $40 i32) (local $41 i32) (local $42 i32) - (block $compile_block.120 (result i32) + (local $43 i32) + (local $44 i32) + (local $45 i32) + (local $46 i32) + (block $compile_block.128 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -331,29 +335,37 @@ pattern matching › tuple_match_deep5 ) (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) + (i32.shr_s + (local.get $31) + (i32.const 1) ) ) (block $do_backpatches.40 ) ) - (block $compile_store.101 + (block $compile_store.43 (local.set $33 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $32) + (i32.const 0) + ) + ) + ) + (block $do_backpatches.42 + ) + ) + (block $compile_store.109 + (local.set $34 (if (result i32) (i32.shr_u - (local.get $32) + (local.get $33) (i32.const 31) ) - (block $compile_block.93 (result i32) - (block $compile_store.43 + (block $compile_block.101 (result i32) + (block $compile_store.45 (local.set $22 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -362,10 +374,10 @@ pattern matching › tuple_match_deep5 ) ) ) - (block $do_backpatches.42 + (block $do_backpatches.44 ) ) - (block $compile_store.45 + (block $compile_store.47 (local.set $23 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -374,43 +386,51 @@ pattern matching › tuple_match_deep5 ) ) ) - (block $do_backpatches.44 + (block $do_backpatches.46 ) ) - (block $compile_store.47 - (local.set $35 + (block $compile_store.49 + (local.set $36 (i32.load offset=12 (local.get $23) ) ) - (block $do_backpatches.46 + (block $do_backpatches.48 ) ) - (block $compile_store.49 - (local.set $36 - (i32.or - (i32.shl - (i32.eq - (local.get $35) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.51 + (local.set $37 + (i32.shr_s + (local.get $36) + (i32.const 1) + ) + ) + (block $do_backpatches.50 + ) + ) + (block $compile_store.53 + (local.set $38 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $37) + (i32.const 0) + ) ) ) - (block $do_backpatches.48 + (block $do_backpatches.52 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $36) + (local.get $38) (i32.const 31) ) - (block $compile_block.85 (result i32) - (block $compile_store.52 + (block $compile_block.93 (result i32) + (block $compile_store.56 (local.set $24 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -419,10 +439,10 @@ pattern matching › tuple_match_deep5 ) ) ) - (block $do_backpatches.51 + (block $do_backpatches.55 ) ) - (block $compile_store.54 + (block $compile_store.58 (local.set $25 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -431,43 +451,51 @@ pattern matching › tuple_match_deep5 ) ) ) - (block $do_backpatches.53 + (block $do_backpatches.57 ) ) - (block $compile_store.56 - (local.set $38 + (block $compile_store.60 + (local.set $40 (i32.load offset=12 (local.get $25) ) ) - (block $do_backpatches.55 + (block $do_backpatches.59 ) ) - (block $compile_store.58 - (local.set $39 - (i32.or - (i32.shl - (i32.eq - (local.get $38) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.62 + (local.set $41 + (i32.shr_s + (local.get $40) + (i32.const 1) + ) + ) + (block $do_backpatches.61 + ) + ) + (block $compile_store.64 + (local.set $42 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $41) + (i32.const 0) + ) ) ) - (block $do_backpatches.57 + (block $do_backpatches.63 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $39) + (local.get $42) (i32.const 31) ) - (block $compile_block.76 (result i32) - (block $compile_store.61 + (block $compile_block.84 (result i32) + (block $compile_store.67 (local.set $26 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -476,10 +504,10 @@ pattern matching › tuple_match_deep5 ) ) ) - (block $do_backpatches.60 + (block $do_backpatches.66 ) ) - (block $compile_store.63 + (block $compile_store.69 (local.set $27 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -488,19 +516,19 @@ pattern matching › tuple_match_deep5 ) ) ) - (block $do_backpatches.62 + (block $do_backpatches.68 ) ) - (block $compile_store.65 - (local.set $41 + (block $compile_store.71 + (local.set $44 (i32.load offset=12 (local.get $27) ) ) - (block $do_backpatches.64 + (block $do_backpatches.70 ) ) - (block $cleanup.66 + (block $cleanup.72 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -508,32 +536,40 @@ pattern matching › tuple_match_deep5 ) ) ) - (block $compile_store.68 - (local.set $42 - (i32.or - (i32.shl - (i32.eq - (local.get $41) - (i32.const 3) - ) - (i32.const 31) - ) + (block $compile_store.74 + (local.set $45 + (i32.shr_s + (local.get $44) + (i32.const 1) + ) + ) + (block $do_backpatches.73 + ) + ) + (block $compile_store.76 + (local.set $46 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $45) + (i32.const 1) + ) ) ) - (block $do_backpatches.67 + (block $do_backpatches.75 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $42) + (local.get $46) (i32.const 31) ) - (block $compile_block.74 (result i32) + (block $compile_block.82 (result i32) (drop - (block $compile_set.70 (result i32) + (block $compile_set.78 (result i32) (local.set $16 (tuple.extract 0 (tuple.make @@ -555,7 +591,7 @@ pattern matching › tuple_match_deep5 ) ) (drop - (block $compile_set.71 (result i32) + (block $compile_set.79 (result i32) (local.set $17 (tuple.extract 0 (tuple.make @@ -577,7 +613,7 @@ pattern matching › tuple_match_deep5 ) ) (drop - (block $compile_set.72 (result i32) + (block $compile_set.80 (result i32) (local.set $18 (tuple.extract 0 (tuple.make @@ -599,7 +635,7 @@ pattern matching › tuple_match_deep5 ) ) (drop - (block $compile_set.73 (result i32) + (block $compile_set.81 (result i32) (local.set $19 (tuple.extract 0 (tuple.make @@ -622,11 +658,11 @@ pattern matching › tuple_match_deep5 ) (i32.const 3) ) - (block $compile_block.75 (result i32) + (block $compile_block.83 (result i32) (i32.const 4) ) ) - (block $cleanup.69 (result i32) + (block $cleanup.77 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -638,31 +674,29 @@ pattern matching › tuple_match_deep5 ) ) ) - (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) - ) + (block $compile_block.92 (result i32) + (block $compile_store.86 + (local.set $43 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $41) + (i32.const 1) + ) ) ) - (block $do_backpatches.77 + (block $do_backpatches.85 ) ) (if (result i32) (i32.shr_u - (local.get $40) + (local.get $43) (i32.const 31) ) - (block $compile_block.82 (result i32) + (block $compile_block.90 (result i32) (drop - (block $compile_set.79 (result i32) + (block $compile_set.87 (result i32) (local.set $13 (tuple.extract 0 (tuple.make @@ -684,7 +718,7 @@ pattern matching › tuple_match_deep5 ) ) (drop - (block $compile_set.80 (result i32) + (block $compile_set.88 (result i32) (local.set $14 (tuple.extract 0 (tuple.make @@ -706,7 +740,7 @@ pattern matching › tuple_match_deep5 ) ) (drop - (block $compile_set.81 (result i32) + (block $compile_set.89 (result i32) (local.set $15 (tuple.extract 0 (tuple.make @@ -729,13 +763,13 @@ pattern matching › tuple_match_deep5 ) (i32.const 2) ) - (block $compile_block.83 (result i32) + (block $compile_block.91 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.59 (result i32) + (block $cleanup.65 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -753,31 +787,29 @@ pattern matching › tuple_match_deep5 ) ) ) - (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) - ) + (block $compile_block.100 (result i32) + (block $compile_store.95 + (local.set $39 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $37) + (i32.const 1) + ) ) ) - (block $do_backpatches.86 + (block $do_backpatches.94 ) ) (if (result i32) (i32.shr_u - (local.get $37) + (local.get $39) (i32.const 31) ) - (block $compile_block.90 (result i32) + (block $compile_block.98 (result i32) (drop - (block $compile_set.88 (result i32) + (block $compile_set.96 (result i32) (local.set $11 (tuple.extract 0 (tuple.make @@ -799,7 +831,7 @@ pattern matching › tuple_match_deep5 ) ) (drop - (block $compile_set.89 (result i32) + (block $compile_set.97 (result i32) (local.set $12 (tuple.extract 0 (tuple.make @@ -822,13 +854,13 @@ pattern matching › tuple_match_deep5 ) (i32.const 1) ) - (block $compile_block.91 (result i32) + (block $compile_block.99 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.50 (result i32) + (block $cleanup.54 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -846,31 +878,29 @@ pattern matching › tuple_match_deep5 ) ) ) - (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) - ) + (block $compile_block.107 (result i32) + (block $compile_store.103 + (local.set $35 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $32) + (i32.const 1) + ) ) ) - (block $do_backpatches.94 + (block $do_backpatches.102 ) ) (if (result i32) (i32.shr_u - (local.get $34) + (local.get $35) (i32.const 31) ) - (block $compile_block.97 (result i32) + (block $compile_block.105 (result i32) (drop - (block $compile_set.96 (result i32) + (block $compile_set.104 (result i32) (local.set $10 (tuple.extract 0 (tuple.make @@ -893,17 +923,17 @@ pattern matching › tuple_match_deep5 ) (i32.const 0) ) - (block $compile_block.98 + (block $compile_block.106 (unreachable) ) ) ) ) ) - (block $do_backpatches.100 + (block $do_backpatches.108 ) ) - (block $cleanup.102 + (block $cleanup.110 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -919,48 +949,48 @@ pattern matching › tuple_match_deep5 ) (tuple.extract 0 (tuple.make - (block $switch.104_outer (result i32) - (block $switch.104_branch_0 (result i32) + (block $switch.112_outer (result i32) + (block $switch.112_branch_0 (result i32) (drop - (block $switch.104_branch_1 (result i32) + (block $switch.112_branch_1 (result i32) (drop - (block $switch.104_branch_2 (result i32) + (block $switch.112_branch_2 (result i32) (drop - (block $switch.104_branch_3 (result i32) + (block $switch.112_branch_3 (result i32) (drop - (block $switch.104_branch_4 (result i32) + (block $switch.112_branch_4 (result i32) (drop - (block $switch.104_branch_5 (result i32) + (block $switch.112_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 + (block $switch.112_default (result i32) + (br_table $switch.112_branch_1 $switch.112_branch_2 $switch.112_branch_3 $switch.112_branch_4 $switch.112_branch_5 $switch.112_default $switch.112_default (i32.const 0) - (local.get $33) + (local.get $34) ) ) ) - (br $switch.104_outer - (block $compile_block.119 (result i32) + (br $switch.112_outer + (block $compile_block.127 (result i32) (unreachable) ) ) ) ) - (br $switch.104_outer - (block $compile_block.118 (result i32) + (br $switch.112_outer + (block $compile_block.126 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.104_outer - (block $compile_block.117 - (block $compile_store.113 + (br $switch.112_outer + (block $compile_block.125 + (block $compile_store.121 (local.set $29 - (call $+_1155 + (call $+_1159 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) + (global.get $+_1159) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -972,15 +1002,15 @@ pattern matching › tuple_match_deep5 ) ) ) - (block $do_backpatches.112 + (block $do_backpatches.120 ) ) - (block $compile_store.115 + (block $compile_store.123 (local.set $30 - (call $+_1155 + (call $+_1159 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) + (global.get $+_1159) ) (local.get $29) (call $incRef_0 @@ -989,10 +1019,10 @@ pattern matching › tuple_match_deep5 ) ) ) - (block $do_backpatches.114 + (block $do_backpatches.122 ) ) - (block $cleanup.116 + (block $cleanup.124 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1048,10 +1078,10 @@ pattern matching › tuple_match_deep5 ) ) ) - (return_call $+_1155 + (return_call $+_1159 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) + (global.get $+_1159) ) (local.get $30) (local.get $19) @@ -1060,14 +1090,14 @@ pattern matching › tuple_match_deep5 ) ) ) - (br $switch.104_outer - (block $compile_block.111 - (block $compile_store.109 + (br $switch.112_outer + (block $compile_block.119 + (block $compile_store.117 (local.set $28 - (call $+_1155 + (call $+_1159 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) + (global.get $+_1159) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -1079,10 +1109,10 @@ pattern matching › tuple_match_deep5 ) ) ) - (block $do_backpatches.108 + (block $do_backpatches.116 ) ) - (block $cleanup.110 + (block $cleanup.118 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1138,10 +1168,10 @@ pattern matching › tuple_match_deep5 ) ) ) - (return_call $+_1155 + (return_call $+_1159 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) + (global.get $+_1159) ) (local.get $28) (local.get $15) @@ -1150,9 +1180,9 @@ pattern matching › tuple_match_deep5 ) ) ) - (br $switch.104_outer - (block $compile_block.107 - (block $cleanup.106 + (br $switch.112_outer + (block $compile_block.115 + (block $cleanup.114 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1202,10 +1232,10 @@ pattern matching › tuple_match_deep5 ) ) ) - (return_call $+_1155 + (return_call $+_1159 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) + (global.get $+_1159) ) (local.get $11) (local.get $12) @@ -1214,8 +1244,8 @@ pattern matching › tuple_match_deep5 ) ) ) - (br $switch.104_outer - (block $compile_block.105 (result i32) + (br $switch.112_outer + (block $compile_block.113 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $10) @@ -1224,7 +1254,7 @@ pattern matching › tuple_match_deep5 ) ) ) - (block $cleanup.103 (result i32) + (block $cleanup.111 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot b/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot index 7219cae2d..89c208f4f 100644 --- a/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot @@ -13,11 +13,11 @@ pattern matching › tuple_match_deep7 (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$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1163 (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))) + (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1163 (param i32 i32 i32) (result i32))) (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) (memory $0 0) (elem $elem (global.get $relocBase_0)) @@ -71,7 +71,11 @@ pattern matching › tuple_match_deep7 (local $42 i32) (local $43 i32) (local $44 i32) - (block $compile_block.126 (result i32) + (local $45 i32) + (local $46 i32) + (local $47 i32) + (local $48 i32) + (block $compile_block.134 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -417,29 +421,37 @@ pattern matching › tuple_match_deep7 ) (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) + (i32.shr_s + (local.get $33) + (i32.const 1) ) ) (block $do_backpatches.46 ) ) - (block $compile_store.107 + (block $compile_store.49 (local.set $35 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $34) + (i32.const 0) + ) + ) + ) + (block $do_backpatches.48 + ) + ) + (block $compile_store.115 + (local.set $36 (if (result i32) (i32.shr_u - (local.get $34) + (local.get $35) (i32.const 31) ) - (block $compile_block.99 (result i32) - (block $compile_store.49 + (block $compile_block.107 (result i32) + (block $compile_store.51 (local.set $24 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -448,10 +460,10 @@ pattern matching › tuple_match_deep7 ) ) ) - (block $do_backpatches.48 + (block $do_backpatches.50 ) ) - (block $compile_store.51 + (block $compile_store.53 (local.set $25 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -460,43 +472,51 @@ pattern matching › tuple_match_deep7 ) ) ) - (block $do_backpatches.50 + (block $do_backpatches.52 ) ) - (block $compile_store.53 - (local.set $37 + (block $compile_store.55 + (local.set $38 (i32.load offset=12 (local.get $25) ) ) - (block $do_backpatches.52 + (block $do_backpatches.54 ) ) - (block $compile_store.55 - (local.set $38 - (i32.or - (i32.shl - (i32.eq - (local.get $37) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.57 + (local.set $39 + (i32.shr_s + (local.get $38) + (i32.const 1) + ) + ) + (block $do_backpatches.56 + ) + ) + (block $compile_store.59 + (local.set $40 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $39) + (i32.const 0) + ) ) ) - (block $do_backpatches.54 + (block $do_backpatches.58 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $38) + (local.get $40) (i32.const 31) ) - (block $compile_block.91 (result i32) - (block $compile_store.58 + (block $compile_block.99 (result i32) + (block $compile_store.62 (local.set $26 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -505,10 +525,10 @@ pattern matching › tuple_match_deep7 ) ) ) - (block $do_backpatches.57 + (block $do_backpatches.61 ) ) - (block $compile_store.60 + (block $compile_store.64 (local.set $27 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -517,43 +537,51 @@ pattern matching › tuple_match_deep7 ) ) ) - (block $do_backpatches.59 + (block $do_backpatches.63 ) ) - (block $compile_store.62 - (local.set $40 + (block $compile_store.66 + (local.set $42 (i32.load offset=12 (local.get $27) ) ) - (block $do_backpatches.61 + (block $do_backpatches.65 ) ) - (block $compile_store.64 - (local.set $41 - (i32.or - (i32.shl - (i32.eq - (local.get $40) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.68 + (local.set $43 + (i32.shr_s + (local.get $42) + (i32.const 1) + ) + ) + (block $do_backpatches.67 + ) + ) + (block $compile_store.70 + (local.set $44 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $43) + (i32.const 0) + ) ) ) - (block $do_backpatches.63 + (block $do_backpatches.69 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $41) + (local.get $44) (i32.const 31) ) - (block $compile_block.82 (result i32) - (block $compile_store.67 + (block $compile_block.90 (result i32) + (block $compile_store.73 (local.set $28 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -562,10 +590,10 @@ pattern matching › tuple_match_deep7 ) ) ) - (block $do_backpatches.66 + (block $do_backpatches.72 ) ) - (block $compile_store.69 + (block $compile_store.75 (local.set $29 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -574,19 +602,19 @@ pattern matching › tuple_match_deep7 ) ) ) - (block $do_backpatches.68 + (block $do_backpatches.74 ) ) - (block $compile_store.71 - (local.set $43 + (block $compile_store.77 + (local.set $46 (i32.load offset=12 (local.get $29) ) ) - (block $do_backpatches.70 + (block $do_backpatches.76 ) ) - (block $cleanup.72 + (block $cleanup.78 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -594,32 +622,40 @@ pattern matching › tuple_match_deep7 ) ) ) - (block $compile_store.74 - (local.set $44 - (i32.or - (i32.shl - (i32.eq - (local.get $43) - (i32.const 3) - ) - (i32.const 31) - ) + (block $compile_store.80 + (local.set $47 + (i32.shr_s + (local.get $46) + (i32.const 1) + ) + ) + (block $do_backpatches.79 + ) + ) + (block $compile_store.82 + (local.set $48 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $47) + (i32.const 1) + ) ) ) - (block $do_backpatches.73 + (block $do_backpatches.81 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $44) + (local.get $48) (i32.const 31) ) - (block $compile_block.80 (result i32) + (block $compile_block.88 (result i32) (drop - (block $compile_set.76 (result i32) + (block $compile_set.84 (result i32) (local.set $18 (tuple.extract 0 (tuple.make @@ -641,7 +677,7 @@ pattern matching › tuple_match_deep7 ) ) (drop - (block $compile_set.77 (result i32) + (block $compile_set.85 (result i32) (local.set $19 (tuple.extract 0 (tuple.make @@ -663,7 +699,7 @@ pattern matching › tuple_match_deep7 ) ) (drop - (block $compile_set.78 (result i32) + (block $compile_set.86 (result i32) (local.set $20 (tuple.extract 0 (tuple.make @@ -685,7 +721,7 @@ pattern matching › tuple_match_deep7 ) ) (drop - (block $compile_set.79 (result i32) + (block $compile_set.87 (result i32) (local.set $21 (tuple.extract 0 (tuple.make @@ -708,11 +744,11 @@ pattern matching › tuple_match_deep7 ) (i32.const 3) ) - (block $compile_block.81 (result i32) + (block $compile_block.89 (result i32) (i32.const 4) ) ) - (block $cleanup.75 (result i32) + (block $cleanup.83 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -724,31 +760,29 @@ pattern matching › tuple_match_deep7 ) ) ) - (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) - ) + (block $compile_block.98 (result i32) + (block $compile_store.92 + (local.set $45 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $43) + (i32.const 1) + ) ) ) - (block $do_backpatches.83 + (block $do_backpatches.91 ) ) (if (result i32) (i32.shr_u - (local.get $42) + (local.get $45) (i32.const 31) ) - (block $compile_block.88 (result i32) + (block $compile_block.96 (result i32) (drop - (block $compile_set.85 (result i32) + (block $compile_set.93 (result i32) (local.set $15 (tuple.extract 0 (tuple.make @@ -770,7 +804,7 @@ pattern matching › tuple_match_deep7 ) ) (drop - (block $compile_set.86 (result i32) + (block $compile_set.94 (result i32) (local.set $16 (tuple.extract 0 (tuple.make @@ -792,7 +826,7 @@ pattern matching › tuple_match_deep7 ) ) (drop - (block $compile_set.87 (result i32) + (block $compile_set.95 (result i32) (local.set $17 (tuple.extract 0 (tuple.make @@ -815,13 +849,13 @@ pattern matching › tuple_match_deep7 ) (i32.const 2) ) - (block $compile_block.89 (result i32) + (block $compile_block.97 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.65 (result i32) + (block $cleanup.71 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -839,31 +873,29 @@ pattern matching › tuple_match_deep7 ) ) ) - (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) - ) + (block $compile_block.106 (result i32) + (block $compile_store.101 + (local.set $41 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $39) + (i32.const 1) + ) ) ) - (block $do_backpatches.92 + (block $do_backpatches.100 ) ) (if (result i32) (i32.shr_u - (local.get $39) + (local.get $41) (i32.const 31) ) - (block $compile_block.96 (result i32) + (block $compile_block.104 (result i32) (drop - (block $compile_set.94 (result i32) + (block $compile_set.102 (result i32) (local.set $13 (tuple.extract 0 (tuple.make @@ -885,7 +917,7 @@ pattern matching › tuple_match_deep7 ) ) (drop - (block $compile_set.95 (result i32) + (block $compile_set.103 (result i32) (local.set $14 (tuple.extract 0 (tuple.make @@ -908,13 +940,13 @@ pattern matching › tuple_match_deep7 ) (i32.const 1) ) - (block $compile_block.97 (result i32) + (block $compile_block.105 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.56 (result i32) + (block $cleanup.60 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -932,31 +964,29 @@ pattern matching › tuple_match_deep7 ) ) ) - (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) - ) + (block $compile_block.113 (result i32) + (block $compile_store.109 + (local.set $37 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $34) + (i32.const 1) + ) ) ) - (block $do_backpatches.100 + (block $do_backpatches.108 ) ) (if (result i32) (i32.shr_u - (local.get $36) + (local.get $37) (i32.const 31) ) - (block $compile_block.103 (result i32) + (block $compile_block.111 (result i32) (drop - (block $compile_set.102 (result i32) + (block $compile_set.110 (result i32) (local.set $12 (tuple.extract 0 (tuple.make @@ -979,17 +1009,17 @@ pattern matching › tuple_match_deep7 ) (i32.const 0) ) - (block $compile_block.104 + (block $compile_block.112 (unreachable) ) ) ) ) ) - (block $do_backpatches.106 + (block $do_backpatches.114 ) ) - (block $cleanup.108 + (block $cleanup.116 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1005,48 +1035,48 @@ pattern matching › tuple_match_deep7 ) (tuple.extract 0 (tuple.make - (block $switch.110_outer (result i32) - (block $switch.110_branch_0 (result i32) + (block $switch.118_outer (result i32) + (block $switch.118_branch_0 (result i32) (drop - (block $switch.110_branch_1 (result i32) + (block $switch.118_branch_1 (result i32) (drop - (block $switch.110_branch_2 (result i32) + (block $switch.118_branch_2 (result i32) (drop - (block $switch.110_branch_3 (result i32) + (block $switch.118_branch_3 (result i32) (drop - (block $switch.110_branch_4 (result i32) + (block $switch.118_branch_4 (result i32) (drop - (block $switch.110_branch_5 (result i32) + (block $switch.118_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 + (block $switch.118_default (result i32) + (br_table $switch.118_branch_1 $switch.118_branch_2 $switch.118_branch_3 $switch.118_branch_4 $switch.118_branch_5 $switch.118_default $switch.118_default (i32.const 0) - (local.get $35) + (local.get $36) ) ) ) - (br $switch.110_outer - (block $compile_block.125 (result i32) + (br $switch.118_outer + (block $compile_block.133 (result i32) (unreachable) ) ) ) ) - (br $switch.110_outer - (block $compile_block.124 (result i32) + (br $switch.118_outer + (block $compile_block.132 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.110_outer - (block $compile_block.123 - (block $compile_store.119 + (br $switch.118_outer + (block $compile_block.131 + (block $compile_store.127 (local.set $31 - (call $+_1159 + (call $+_1163 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) + (global.get $+_1163) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -1058,15 +1088,15 @@ pattern matching › tuple_match_deep7 ) ) ) - (block $do_backpatches.118 + (block $do_backpatches.126 ) ) - (block $compile_store.121 + (block $compile_store.129 (local.set $32 - (call $+_1159 + (call $+_1163 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) + (global.get $+_1163) ) (local.get $31) (call $incRef_0 @@ -1075,10 +1105,10 @@ pattern matching › tuple_match_deep7 ) ) ) - (block $do_backpatches.120 + (block $do_backpatches.128 ) ) - (block $cleanup.122 + (block $cleanup.130 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1134,10 +1164,10 @@ pattern matching › tuple_match_deep7 ) ) ) - (return_call $+_1159 + (return_call $+_1163 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) + (global.get $+_1163) ) (local.get $32) (local.get $21) @@ -1146,14 +1176,14 @@ pattern matching › tuple_match_deep7 ) ) ) - (br $switch.110_outer - (block $compile_block.117 - (block $compile_store.115 + (br $switch.118_outer + (block $compile_block.125 + (block $compile_store.123 (local.set $30 - (call $+_1159 + (call $+_1163 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) + (global.get $+_1163) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -1165,10 +1195,10 @@ pattern matching › tuple_match_deep7 ) ) ) - (block $do_backpatches.114 + (block $do_backpatches.122 ) ) - (block $cleanup.116 + (block $cleanup.124 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1224,10 +1254,10 @@ pattern matching › tuple_match_deep7 ) ) ) - (return_call $+_1159 + (return_call $+_1163 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) + (global.get $+_1163) ) (local.get $30) (local.get $17) @@ -1236,9 +1266,9 @@ pattern matching › tuple_match_deep7 ) ) ) - (br $switch.110_outer - (block $compile_block.113 - (block $cleanup.112 + (br $switch.118_outer + (block $compile_block.121 + (block $cleanup.120 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1288,10 +1318,10 @@ pattern matching › tuple_match_deep7 ) ) ) - (return_call $+_1159 + (return_call $+_1163 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) + (global.get $+_1163) ) (local.get $13) (local.get $14) @@ -1300,8 +1330,8 @@ pattern matching › tuple_match_deep7 ) ) ) - (br $switch.110_outer - (block $compile_block.111 (result i32) + (br $switch.118_outer + (block $compile_block.119 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $12) @@ -1310,7 +1340,7 @@ pattern matching › tuple_match_deep7 ) ) ) - (block $cleanup.109 (result i32) + (block $cleanup.117 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.f25e0163.0.snapshot b/compiler/test/__snapshots__/pattern_matching.f25e0163.0.snapshot index db1a0163f..ee92bbd0e 100644 --- a/compiler/test/__snapshots__/pattern_matching.f25e0163.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.f25e0163.0.snapshot @@ -48,7 +48,11 @@ pattern matching › or_match_3 (local $22 i32) (local $23 i32) (local $24 i32) - (block $compile_block.65 (result i32) + (local $25 i32) + (local $26 i32) + (local $27 i32) + (local $28 i32) + (block $compile_block.73 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -143,29 +147,37 @@ pattern matching › or_match_3 ) (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) + (i32.shr_s + (local.get $14) + (i32.const 1) ) ) (block $do_backpatches.11 ) ) - (block $compile_store.58 + (block $compile_store.14 (local.set $16 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $15) + (i32.const 0) + ) + ) + ) + (block $do_backpatches.13 + ) + ) + (block $compile_store.66 + (local.set $17 (if (result i32) (i32.shr_u - (local.get $15) + (local.get $16) (i32.const 31) ) - (block $compile_block.55 (result i32) - (block $compile_store.14 + (block $compile_block.63 (result i32) + (block $compile_store.16 (local.set $9 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -174,10 +186,10 @@ pattern matching › or_match_3 ) ) ) - (block $do_backpatches.13 + (block $do_backpatches.15 ) ) - (block $compile_store.16 + (block $compile_store.18 (local.set $10 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -186,43 +198,51 @@ pattern matching › or_match_3 ) ) ) - (block $do_backpatches.15 + (block $do_backpatches.17 ) ) - (block $compile_store.18 - (local.set $17 + (block $compile_store.20 + (local.set $18 (i32.load offset=12 (local.get $10) ) ) - (block $do_backpatches.17 + (block $do_backpatches.19 ) ) - (block $compile_store.20 - (local.set $18 - (i32.or - (i32.shl - (i32.eq - (local.get $17) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.22 + (local.set $19 + (i32.shr_s + (local.get $18) + (i32.const 1) + ) + ) + (block $do_backpatches.21 + ) + ) + (block $compile_store.24 + (local.set $20 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $19) + (i32.const 0) + ) ) ) - (block $do_backpatches.19 + (block $do_backpatches.23 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $18) + (local.get $20) (i32.const 31) ) - (block $compile_block.48 (result i32) - (block $compile_store.23 + (block $compile_block.56 (result i32) + (block $compile_store.27 (local.set $11 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -231,10 +251,10 @@ pattern matching › or_match_3 ) ) ) - (block $do_backpatches.22 + (block $do_backpatches.26 ) ) - (block $compile_store.25 + (block $compile_store.29 (local.set $12 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -243,43 +263,51 @@ pattern matching › or_match_3 ) ) ) - (block $do_backpatches.24 + (block $do_backpatches.28 ) ) - (block $compile_store.27 - (local.set $20 + (block $compile_store.31 + (local.set $22 (i32.load offset=12 (local.get $12) ) ) - (block $do_backpatches.26 + (block $do_backpatches.30 ) ) - (block $compile_store.29 - (local.set $21 - (i32.or - (i32.shl - (i32.eq - (local.get $20) - (i32.const 1) - ) - (i32.const 31) - ) + (block $compile_store.33 + (local.set $23 + (i32.shr_s + (local.get $22) + (i32.const 1) + ) + ) + (block $do_backpatches.32 + ) + ) + (block $compile_store.35 + (local.set $24 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $23) + (i32.const 0) + ) ) ) - (block $do_backpatches.28 + (block $do_backpatches.34 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $21) + (local.get $24) (i32.const 31) ) - (block $compile_block.41 (result i32) - (block $compile_store.32 + (block $compile_block.49 (result i32) + (block $compile_store.38 (local.set $13 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -288,19 +316,19 @@ pattern matching › or_match_3 ) ) ) - (block $do_backpatches.31 + (block $do_backpatches.37 ) ) - (block $compile_store.34 - (local.set $23 + (block $compile_store.40 + (local.set $26 (i32.load offset=12 (local.get $13) ) ) - (block $do_backpatches.33 + (block $do_backpatches.39 ) ) - (block $cleanup.35 + (block $cleanup.41 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -308,30 +336,38 @@ pattern matching › or_match_3 ) ) ) - (block $compile_store.37 - (local.set $24 - (i32.or - (i32.shl - (i32.eq - (local.get $23) - (i32.const 3) - ) - (i32.const 31) - ) + (block $compile_store.43 + (local.set $27 + (i32.shr_s + (local.get $26) + (i32.const 1) + ) + ) + (block $do_backpatches.42 + ) + ) + (block $compile_store.45 + (local.set $28 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $27) + (i32.const 1) + ) ) ) - (block $do_backpatches.36 + (block $do_backpatches.44 ) ) (if (result i32) (i32.shr_u - (local.get $24) + (local.get $28) (i32.const 31) ) - (block $compile_block.39 (result i32) + (block $compile_block.47 (result i32) (drop - (block $compile_set.38 (result i32) + (block $compile_set.46 (result i32) (local.set $8 (tuple.extract 0 (tuple.make @@ -354,36 +390,34 @@ pattern matching › or_match_3 ) (i32.const 0) ) - (block $compile_block.40 (result i32) + (block $compile_block.48 (result i32) (i32.const 1) ) ) ) - (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) - ) + (block $compile_block.55 (result i32) + (block $compile_store.51 + (local.set $25 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $23) + (i32.const 1) + ) ) ) - (block $do_backpatches.42 + (block $do_backpatches.50 ) ) (if (result i32) (i32.shr_u - (local.get $22) + (local.get $25) (i32.const 31) ) - (block $compile_block.45 (result i32) + (block $compile_block.53 (result i32) (drop - (block $compile_set.44 (result i32) + (block $compile_set.52 (result i32) (local.set $8 (tuple.extract 0 (tuple.make @@ -406,13 +440,13 @@ pattern matching › or_match_3 ) (i32.const 0) ) - (block $compile_block.46 (result i32) + (block $compile_block.54 (result i32) (i32.const 1) ) ) ) ) - (block $cleanup.30 (result i32) + (block $cleanup.36 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -430,31 +464,29 @@ pattern matching › or_match_3 ) ) ) - (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) - ) + (block $compile_block.62 (result i32) + (block $compile_store.58 + (local.set $21 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $19) + (i32.const 1) + ) ) ) - (block $do_backpatches.49 + (block $do_backpatches.57 ) ) (if (result i32) (i32.shr_u - (local.get $19) + (local.get $21) (i32.const 31) ) - (block $compile_block.52 (result i32) + (block $compile_block.60 (result i32) (drop - (block $compile_set.51 (result i32) + (block $compile_set.59 (result i32) (local.set $8 (tuple.extract 0 (tuple.make @@ -477,13 +509,13 @@ pattern matching › or_match_3 ) (i32.const 0) ) - (block $compile_block.53 (result i32) + (block $compile_block.61 (result i32) (i32.const 1) ) ) ) ) - (block $cleanup.21 (result i32) + (block $cleanup.25 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -501,15 +533,15 @@ pattern matching › or_match_3 ) ) ) - (block $compile_block.56 (result i32) + (block $compile_block.64 (result i32) (i32.const 1) ) ) ) - (block $do_backpatches.57 + (block $do_backpatches.65 ) ) - (block $cleanup.59 + (block $cleanup.67 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -519,42 +551,42 @@ pattern matching › or_match_3 ) (tuple.extract 0 (tuple.make - (block $switch.61_outer (result i32) - (block $switch.61_branch_0 (result i32) + (block $switch.69_outer (result i32) + (block $switch.69_branch_0 (result i32) (drop - (block $switch.61_branch_1 (result i32) + (block $switch.69_branch_1 (result i32) (drop - (block $switch.61_branch_2 (result i32) + (block $switch.69_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 + (block $switch.69_default (result i32) + (br_table $switch.69_branch_1 $switch.69_branch_2 $switch.69_default $switch.69_default (i32.const 0) - (local.get $16) + (local.get $17) ) ) ) - (br $switch.61_outer - (block $compile_block.64 (result i32) + (br $switch.69_outer + (block $compile_block.72 (result i32) (unreachable) ) ) ) ) - (br $switch.61_outer - (block $compile_block.63 (result i32) + (br $switch.69_outer + (block $compile_block.71 (result i32) (i32.const 2147483646) ) ) ) ) - (br $switch.61_outer - (block $compile_block.62 (result i32) + (br $switch.69_outer + (block $compile_block.70 (result i32) (i32.const -2) ) ) ) ) - (block $cleanup.60 (result i32) + (block $cleanup.68 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.f6c9c89c.0.snapshot b/compiler/test/__snapshots__/pattern_matching.f6c9c89c.0.snapshot index 576982f48..d20125b83 100644 --- a/compiler/test/__snapshots__/pattern_matching.f6c9c89c.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.f6c9c89c.0.snapshot @@ -41,7 +41,8 @@ pattern matching › or_match_2 (local $12 i32) (local $13 i32) (local $14 i32) - (block $compile_block.37 (result i32) + (local $15 i32) + (block $compile_block.39 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -91,54 +92,60 @@ pattern matching › or_match_2 ) (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) + (i32.shr_s + (local.get $8) + (i32.const 1) ) ) (block $do_backpatches.6 ) ) - (block $compile_store.30 + (block $compile_store.9 (local.set $10 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $9) + (i32.const 1) + ) + ) + ) + (block $do_backpatches.8 + ) + ) + (block $compile_store.32 + (local.set $11 (if (result i32) (i32.shr_u - (local.get $9) + (local.get $10) (i32.const 31) ) - (block $compile_block.8 (result i32) + (block $compile_block.10 (result i32) (i32.const 1) ) - (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) - ) + (block $compile_block.30 (result i32) + (block $compile_store.12 + (local.set $12 + (select + (i32.const -2) (i32.const 2147483646) + (i32.eq + (local.get $9) + (i32.const 0) + ) ) ) - (block $do_backpatches.9 + (block $do_backpatches.11 ) ) (if (result i32) (i32.shr_u - (local.get $11) + (local.get $12) (i32.const 31) ) - (block $compile_block.26 (result i32) - (block $compile_store.12 + (block $compile_block.28 (result i32) + (block $compile_store.14 (local.set $7 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -147,11 +154,11 @@ pattern matching › or_match_2 ) ) ) - (block $do_backpatches.11 + (block $do_backpatches.13 ) ) - (block $compile_store.14 - (local.set $12 + (block $compile_store.16 + (local.set $13 (call $equal_0 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -164,22 +171,22 @@ pattern matching › or_match_2 (i32.const 7) ) ) - (block $do_backpatches.13 + (block $do_backpatches.15 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $12) + (local.get $13) (i32.const 31) ) - (block $compile_block.16 (result i32) + (block $compile_block.18 (result i32) (i32.const 0) ) - (block $compile_block.25 (result i32) - (block $compile_store.18 - (local.set $13 + (block $compile_block.27 (result i32) + (block $compile_store.20 + (local.set $14 (call $equal_0 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -192,20 +199,20 @@ pattern matching › or_match_2 (i32.const 9) ) ) - (block $do_backpatches.17 + (block $do_backpatches.19 ) ) (if (result i32) (i32.shr_u - (local.get $13) + (local.get $14) (i32.const 31) ) - (block $compile_block.19 (result i32) + (block $compile_block.21 (result i32) (i32.const 0) ) - (block $compile_block.24 (result i32) - (block $compile_store.21 - (local.set $14 + (block $compile_block.26 (result i32) + (block $compile_store.23 + (local.set $15 (call $equal_0 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -218,18 +225,18 @@ pattern matching › or_match_2 (i32.const 11) ) ) - (block $do_backpatches.20 + (block $do_backpatches.22 ) ) (if (result i32) (i32.shr_u - (local.get $14) + (local.get $15) (i32.const 31) ) - (block $compile_block.22 (result i32) + (block $compile_block.24 (result i32) (i32.const 1) ) - (block $compile_block.23 (result i32) + (block $compile_block.25 (result i32) (i32.const 2) ) ) @@ -237,7 +244,7 @@ pattern matching › or_match_2 ) ) ) - (block $cleanup.15 (result i32) + (block $cleanup.17 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -249,17 +256,17 @@ pattern matching › or_match_2 ) ) ) - (block $compile_block.27 (result i32) + (block $compile_block.29 (result i32) (i32.const 2) ) ) ) ) ) - (block $do_backpatches.29 + (block $do_backpatches.31 ) ) - (block $cleanup.31 + (block $cleanup.33 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -267,45 +274,45 @@ pattern matching › or_match_2 ) ) ) - (block $switch.32_outer (result i32) - (block $switch.32_branch_0 (result i32) + (block $switch.34_outer (result i32) + (block $switch.34_branch_0 (result i32) (drop - (block $switch.32_branch_1 (result i32) + (block $switch.34_branch_1 (result i32) (drop - (block $switch.32_branch_2 (result i32) + (block $switch.34_branch_2 (result i32) (drop - (block $switch.32_branch_3 (result i32) + (block $switch.34_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 + (block $switch.34_default (result i32) + (br_table $switch.34_branch_1 $switch.34_branch_2 $switch.34_branch_3 $switch.34_default $switch.34_default (i32.const 0) - (local.get $10) + (local.get $11) ) ) ) - (br $switch.32_outer - (block $compile_block.36 (result i32) + (br $switch.34_outer + (block $compile_block.38 (result i32) (unreachable) ) ) ) ) - (br $switch.32_outer - (block $compile_block.35 (result i32) + (br $switch.34_outer + (block $compile_block.37 (result i32) (i32.const 2147483646) ) ) ) ) - (br $switch.32_outer - (block $compile_block.34 (result i32) + (br $switch.34_outer + (block $compile_block.36 (result i32) (i32.const -2) ) ) ) ) - (br $switch.32_outer - (block $compile_block.33 (result i32) + (br $switch.34_outer + (block $compile_block.35 (result i32) (i32.const 2147483646) ) ) diff --git a/compiler/test/suites/basic_functionality.re b/compiler/test/suites/basic_functionality.re index 58d190f72..7c8afe088 100644 --- a/compiler/test/suites/basic_functionality.re +++ b/compiler/test/suites/basic_functionality.re @@ -377,6 +377,6 @@ describe("basic functionality", ({test, testSkip}) => { ~config_fn=smallestFileConfig, "smallest_grain_program", "", - 4741, + 4730, ); }); From 22841e8a88c7ac274fd5f1d0e7961aacc298a159 Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Fri, 11 Oct 2024 21:26:33 -0400 Subject: [PATCH 07/10] feat: Use jump table in specific cases --- compiler/src/middle_end/matchcomp.re | 195 ++++++++++++++++++++------- 1 file changed, 145 insertions(+), 50 deletions(-) diff --git a/compiler/src/middle_end/matchcomp.re b/compiler/src/middle_end/matchcomp.re index b36b4d2fe..ccab8426e 100644 --- a/compiler/src/middle_end/matchcomp.re +++ b/compiler/src/middle_end/matchcomp.re @@ -1204,19 +1204,6 @@ module MatchTreeCompiler = { | [hd, ...tl] => (hd, tl) }; - /* Runs when no cases match */ - let base_tree = Option.value(~default=Fail, default_tree); - let base = - compile_tree_help( - ~loc, - ~env, - ~mut_boxing, - base_tree, - values, - expr, - helpI, - helpConst, - ); // Get Value Constructor let comp_cond_i32 = v => Imm.const(~loc=Location.dummy_loc, Const_wasmi32(Int32.of_int(v))); @@ -1340,46 +1327,154 @@ module MatchTreeCompiler = { ret_type: Grain_bool, }) }; - /* Fold left should be safe here, since there should be at most one branch - per value */ - let (switch_body_ans, switch_body_setup) = + // Setup Our Switch + let (min, max) = List.fold_left( - ((body_ans, body_setup), (tag, tree)) => { - let cmp_id_name = Ident.create("match_cmp_values"); - let cmp_id = Imm.id(~loc=Location.dummy_loc, cmp_id_name); - let branch_condition = - Comp.prim2( - ~loc=Location.dummy_loc, - ~allocation_type=Unmanaged(WasmI32), - equality_op, - cond_id, - compile_cond(tag), - ); - let setup = [BLet(cmp_id_name, branch_condition, Nonglobal)]; - let (tree_ans, tree_setup) = - compile_tree_help( - ~loc, - ~env, - ~mut_boxing, - tree, - values, - expr, - helpI, - helpConst, - ); - let ans = - Comp.if_( - ~loc=Location.dummy_loc, - ~allocation_type=tree_ans.comp_allocation_type, - cmp_id, - fold_tree(tree_setup, tree_ans), - fold_tree(body_setup, body_ans), - ); - (ans, setup); - }, - base, + ((min, max), (t, _)) => (Int.min(min, t), Int.max(max, t)), + (Int.max_int, Int.min_int), cases, ); + let branch_count = List.length(cases); + let branch_range = Int.abs(max - min + 1); + // Printf.printf( + // "%d branches in a range of %d, min: %d, max: %d, default: %s \n", + // branch_count, + // branch_range, + // min, + // max, + // default_tree != None ? "true" : "false", + // ); + // TODO: We do not care about the min == 0 in the future + let optimize = + branch_count == branch_range && default_tree == None && min == 0; + // let optimize = false; + let (switch_body_ans, switch_body_setup) = + if (optimize) { + // Printf.printf("Performing Jump Table Optimiztion\n"); + // let sub_op = + // switch (value_typ) { + // | WasmI32 => + // WasmBinaryI32({ + // wasm_op: Op_add_int32, + // arg_types: (Wasm_int32, Wasm_int32), + // ret_type: Grain_bool, + // }) + // | WasmI64 => + // WasmBinaryI64({ + // wasm_op: Op_add_int64, + // arg_types: (Wasm_int64, Wasm_int64), + // ret_type: Grain_bool, + // }) + // | WasmF32 => + // WasmBinaryF32({ + // wasm_op: Op_add_float32, + // arg_types: (Wasm_float32, Wasm_float32), + // ret_type: Grain_bool, + // }) + // | WasmF64 => + // WasmBinaryF64({ + // wasm_op: Op_add_float64, + // arg_types: (Wasm_float64, Wasm_float64), + // ret_type: Grain_bool, + // }) + // }; + // TODO: Avoid the math if min is 0 + // let match_jmp_name = Ident.create("match_jmp_id"); + // let match_jmp_id = Imm.id(~loc=Location.dummy_loc, match_jmp_name); + // let match_mapped_cond = + // Comp.prim2( + // ~loc=Location.dummy_loc, + // ~allocation_type=Unmanaged(value_typ), + // sub_op, + // cond_id, + // compile_cond(0), + // ); + let cases = + List.map( + ((tag, tree)) => { + let (tree_ans, tree_setup) = + compile_tree_help( + ~loc, + ~env, + ~mut_boxing, + tree, + values, + expr, + helpI, + helpConst, + ); + // Printf.printf("Unmapped: %d -> %d\n", tag, tag - min); + (tag - min, fold_tree(tree_setup, tree_ans)); + }, + cases, + ); + let switch_body = + Comp.switch_( + ~loc=Location.dummy_loc, + // TODO: We should probably grab this from ~allocation_type=tree_ans.comp_allocation_type, + ~allocation_type=Unmanaged(WasmI32), + cond_id, + cases, + Total, + ); + ( + switch_body, + [], + // [BLet(match_jmp_name, match_mapped_cond, Nonglobal)], + ); + } else { + // Printf.printf("Not Performing Jump Table Operation\n"); + /* Runs when no cases match */ + let base_tree = Option.value(~default=Fail, default_tree); + let base = + compile_tree_help( + ~loc, + ~env, + ~mut_boxing, + base_tree, + values, + expr, + helpI, + helpConst, + ); + List.fold_left( + ((body_ans, body_setup), (tag, tree)) => { + let cmp_id_name = Ident.create("match_cmp_values"); + let cmp_id = Imm.id(~loc=Location.dummy_loc, cmp_id_name); + let branch_condition = + Comp.prim2( + ~loc=Location.dummy_loc, + ~allocation_type=Unmanaged(WasmI32), + equality_op, + cond_id, + compile_cond(tag), + ); + let setup = [BLet(cmp_id_name, branch_condition, Nonglobal)]; + let (tree_ans, tree_setup) = + compile_tree_help( + ~loc, + ~env, + ~mut_boxing, + tree, + values, + expr, + helpI, + helpConst, + ); + let ans = + Comp.if_( + ~loc=Location.dummy_loc, + ~allocation_type=tree_ans.comp_allocation_type, + cmp_id, + fold_tree(tree_setup, tree_ans), + fold_tree(body_setup, body_ans), + ); + (ans, setup); + }, + base, + cases, + ); + }; let switch_setup = cond_binds @ [BLet(cond_name, cond, Nonglobal), ...switch_body_setup]; let switch_body_setup = From 22d2808450a79a326408f0f3671435af1b991865 Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Fri, 11 Oct 2024 21:26:41 -0400 Subject: [PATCH 08/10] chore: Update snapshots --- .../pattern_matching.05b60a1e.0.snapshot | 194 ++--- .../pattern_matching.0ad4ac05.0.snapshot | 802 +++++++++--------- .../pattern_matching.0bb6923e.0.snapshot | 694 ++++++++------- .../pattern_matching.702ed9b0.0.snapshot | 802 +++++++++--------- .../pattern_matching.79346fef.0.snapshot | 802 +++++++++--------- .../pattern_matching.8c0dc67a.0.snapshot | 694 ++++++++------- .../pattern_matching.b1b060ad.0.snapshot | 694 ++++++++------- .../pattern_matching.c91eac29.0.snapshot | 694 ++++++++------- .../pattern_matching.d048ece0.0.snapshot | 694 ++++++++------- .../pattern_matching.e41ad64e.0.snapshot | 802 +++++++++--------- .../pattern_matching.f0c08ea4.0.snapshot | 802 +++++++++--------- 11 files changed, 3738 insertions(+), 3936 deletions(-) diff --git a/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot index b478fbde3..6fefad3c6 100644 --- a/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot @@ -38,9 +38,7 @@ pattern matching › adt_match_deep (local $12 i32) (local $13 i32) (local $14 i32) - (local $15 i32) - (local $16 i32) - (block $compile_block.38 (result i32) + (block $compile_block.34 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_record.1 (result i32) @@ -177,115 +175,99 @@ pattern matching › adt_match_deep (block $do_backpatches.14 ) ) - (block $compile_store.17 + (block $compile_store.27 (local.set $14 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $13) - (i32.const 0) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.31 - (local.set $15 - (if (result i32) - (i32.shr_u - (local.get $14) - (i32.const 31) - ) - (block $compile_block.24 (result i32) - (block $compile_store.19 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $8) - ) - ) - ) - (block $do_backpatches.18 - ) - ) - (block $compile_store.21 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $10) - ) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $cleanup.22 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) + (block $switch.16_outer (result i32) + (block $switch.16_branch_0 (result i32) (drop - (block $compile_set.23 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) + (block $switch.16_branch_1 (result i32) + (drop + (block $switch.16_branch_2 (result i32) + (drop + (block $switch.16_default (result i32) + (br_table $switch.16_branch_2 $switch.16_branch_1 $switch.16_default $switch.16_default + (i32.const 0) + (local.get $13) + ) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) + ) + (br $switch.16_outer + (block $compile_block.25 (result i32) + (unreachable) ) ) ) ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.29 (result i32) - (block $compile_store.26 - (local.set $16 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $13) + (br $switch.16_outer + (block $compile_block.24 (result i32) + (block $compile_store.19 + (local.set $10 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=20 + (local.get $8) + ) + ) + ) + (block $do_backpatches.18 + ) + ) + (block $compile_store.21 + (local.set $11 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=16 + (local.get $10) + ) + ) + ) + (block $do_backpatches.20 + ) + ) + (block $cleanup.22 + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $10) + ) + ) + ) + (drop + (block $compile_set.23 (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 1) ) ) ) - (block $do_backpatches.25 - ) ) - (if (result i32) - (i32.shr_u - (local.get $16) - (i32.const 31) - ) - (block $compile_block.27 (result i32) + (br $switch.16_outer + (block $compile_block.17 (result i32) (i32.const 0) ) - (block $compile_block.28 - (unreachable) - ) ) ) ) ) - (block $do_backpatches.30 + (block $do_backpatches.26 ) ) - (block $cleanup.32 + (block $cleanup.28 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -295,29 +277,29 @@ pattern matching › adt_match_deep ) (tuple.extract 0 (tuple.make - (block $switch.34_outer (result i32) - (block $switch.34_branch_0 (result i32) + (block $switch.30_outer (result i32) + (block $switch.30_branch_0 (result i32) (drop - (block $switch.34_branch_1 (result i32) + (block $switch.30_branch_1 (result i32) (drop - (block $switch.34_branch_2 (result i32) + (block $switch.30_branch_2 (result i32) (drop - (block $switch.34_default (result i32) - (br_table $switch.34_branch_1 $switch.34_branch_2 $switch.34_default $switch.34_default + (block $switch.30_default (result i32) + (br_table $switch.30_branch_1 $switch.30_branch_2 $switch.30_default $switch.30_default (i32.const 0) - (local.get $15) + (local.get $14) ) ) ) - (br $switch.34_outer - (block $compile_block.37 (result i32) + (br $switch.30_outer + (block $compile_block.33 (result i32) (unreachable) ) ) ) ) - (br $switch.34_outer - (block $compile_block.36 (result i32) + (br $switch.30_outer + (block $compile_block.32 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $9) @@ -326,14 +308,14 @@ pattern matching › adt_match_deep ) ) ) - (br $switch.34_outer - (block $compile_block.35 (result i32) + (br $switch.30_outer + (block $compile_block.31 (result i32) (i32.const 1999) ) ) ) ) - (block $cleanup.33 (result i32) + (block $cleanup.29 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot index 56ba5ace1..2d646f1fd 100644 --- a/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot @@ -13,11 +13,11 @@ pattern matching › tuple_match_deep4 (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$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 $+_1157 (param i32 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)) @@ -70,9 +70,7 @@ pattern matching › tuple_match_deep4 (local $41 i32) (local $42 i32) (local $43 i32) - (local $44 i32) - (local $45 i32) - (block $compile_block.125 (result i32) + (block $compile_block.121 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -300,330 +298,446 @@ pattern matching › tuple_match_deep4 (block $do_backpatches.37 ) ) - (block $compile_store.40 + (block $compile_store.102 (local.set $32 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $31) - (i32.const 0) - ) - ) - ) - (block $do_backpatches.39 - ) - ) - (block $compile_store.106 - (local.set $33 - (if (result i32) - (i32.shr_u - (local.get $32) - (i32.const 31) - ) - (block $compile_block.98 (result i32) - (block $compile_store.42 - (local.set $21 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $20) - ) - ) - ) - (block $do_backpatches.41 - ) - ) - (block $compile_store.44 - (local.set $22 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $20) - ) - ) - ) - (block $do_backpatches.43 - ) - ) - (block $compile_store.46 - (local.set $35 - (i32.load offset=12 - (local.get $22) - ) - ) - (block $do_backpatches.45 - ) - ) - (block $compile_store.48 - (local.set $36 - (i32.shr_s - (local.get $35) - (i32.const 1) - ) - ) - (block $do_backpatches.47 - ) - ) - (block $compile_store.50 - (local.set $37 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $36) - (i32.const 0) + (block $switch.39_outer (result i32) + (block $switch.39_branch_0 (result i32) + (drop + (block $switch.39_branch_1 (result i32) + (drop + (block $switch.39_branch_2 (result i32) + (drop + (block $switch.39_default (result i32) + (br_table $switch.39_branch_2 $switch.39_branch_1 $switch.39_default $switch.39_default + (i32.const 0) + (local.get $31) + ) + ) + ) + (br $switch.39_outer + (block $compile_block.100 (result i32) + (unreachable) + ) + ) ) ) - ) - (block $do_backpatches.49 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $37) - (i32.const 31) - ) - (block $compile_block.90 (result i32) - (block $compile_store.53 - (local.set $23 + (br $switch.39_outer + (block $compile_block.99 (result i32) + (block $compile_store.43 + (local.set $21 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $22) + (local.get $20) ) ) ) - (block $do_backpatches.52 + (block $do_backpatches.42 ) ) - (block $compile_store.55 - (local.set $24 + (block $compile_store.45 + (local.set $22 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $22) + (local.get $20) ) ) ) - (block $do_backpatches.54 + (block $do_backpatches.44 ) ) - (block $compile_store.57 - (local.set $39 + (block $compile_store.47 + (local.set $33 (i32.load offset=12 - (local.get $24) + (local.get $22) ) ) - (block $do_backpatches.56 + (block $do_backpatches.46 ) ) - (block $compile_store.59 - (local.set $40 + (block $compile_store.49 + (local.set $34 (i32.shr_s - (local.get $39) + (local.get $33) (i32.const 1) ) ) - (block $do_backpatches.58 + (block $do_backpatches.48 ) ) - (block $compile_store.61 - (local.set $41 + (block $compile_store.51 + (local.set $35 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $40) + (local.get $34) (i32.const 0) ) ) ) - (block $do_backpatches.60 + (block $do_backpatches.50 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $41) + (local.get $35) (i32.const 31) ) - (block $compile_block.81 (result i32) - (block $compile_store.64 - (local.set $25 + (block $compile_block.91 (result i32) + (block $compile_store.54 + (local.set $23 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $24) + (local.get $22) ) ) ) - (block $do_backpatches.63 + (block $do_backpatches.53 ) ) - (block $compile_store.66 - (local.set $26 + (block $compile_store.56 + (local.set $24 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $24) + (local.get $22) ) ) ) - (block $do_backpatches.65 + (block $do_backpatches.55 ) ) - (block $compile_store.68 - (local.set $43 + (block $compile_store.58 + (local.set $37 (i32.load offset=12 - (local.get $26) + (local.get $24) ) ) - (block $do_backpatches.67 - ) - ) - (block $cleanup.69 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $26) - ) + (block $do_backpatches.57 ) ) - (block $compile_store.71 - (local.set $44 + (block $compile_store.60 + (local.set $38 (i32.shr_s - (local.get $43) + (local.get $37) (i32.const 1) ) ) - (block $do_backpatches.70 + (block $do_backpatches.59 ) ) - (block $compile_store.73 - (local.set $45 + (block $compile_store.62 + (local.set $39 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $44) - (i32.const 1) + (local.get $38) + (i32.const 0) ) ) ) - (block $do_backpatches.72 + (block $do_backpatches.61 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $45) + (local.get $39) (i32.const 31) ) - (block $compile_block.79 (result i32) - (drop - (block $compile_set.75 (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) - ) - ) + (block $compile_block.82 (result i32) + (block $compile_store.65 + (local.set $25 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=20 + (local.get $24) + ) + ) + ) + (block $do_backpatches.64 + ) + ) + (block $compile_store.67 + (local.set $26 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=24 + (local.get $24) + ) + ) + ) + (block $do_backpatches.66 + ) + ) + (block $compile_store.69 + (local.set $41 + (i32.load offset=12 + (local.get $26) + ) + ) + (block $do_backpatches.68 + ) + ) + (block $cleanup.70 + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $26) + ) + ) + ) + (block $compile_store.72 + (local.set $42 + (i32.shr_s + (local.get $41) + (i32.const 1) + ) + ) + (block $do_backpatches.71 + ) + ) + (block $compile_store.74 + (local.set $43 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $42) + (i32.const 1) ) ) - (i32.const 1879048190) + ) + (block $do_backpatches.73 ) ) - (drop - (block $compile_set.76 (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) + (tuple.extract 0 + (tuple.make + (if (result i32) + (i32.shr_u + (local.get $43) + (i32.const 31) + ) + (block $compile_block.80 (result i32) + (drop + (block $compile_set.76 (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.77 (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.78 (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) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) + ) + (drop + (block $compile_set.79 (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 3) + ) + (block $compile_block.81 (result i32) + (i32.const 4) ) ) - (i32.const 1879048190) + (block $cleanup.75 (result i32) + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $25) + ) + ) + (i32.const 1879048190) + ) ) ) - (drop - (block $compile_set.77 (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) + ) + (block $compile_block.90 (result i32) + (block $compile_store.84 + (local.set $40 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $38) + (i32.const 1) + ) + ) + ) + (block $do_backpatches.83 + ) + ) + (if (result i32) + (i32.shr_u + (local.get $40) + (i32.const 31) + ) + (block $compile_block.88 (result i32) + (drop + (block $compile_set.85 (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) + ) ) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) ) + (i32.const 1879048190) ) ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.78 (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) + (drop + (block $compile_set.86 (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) + ) ) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) + ) + (i32.const 1879048190) + ) + ) + (drop + (block $compile_set.87 (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 1879048190) + (i32.const 2) + ) + (block $compile_block.89 (result i32) + (i32.const 4) ) ) - (i32.const 3) - ) - (block $compile_block.80 (result i32) - (i32.const 4) ) ) - (block $cleanup.74 (result i32) + (block $cleanup.63 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $25) + (local.get $23) + ) + ) + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $24) ) ) (i32.const 1879048190) @@ -631,30 +745,30 @@ pattern matching › tuple_match_deep4 ) ) ) - (block $compile_block.89 (result i32) - (block $compile_store.83 - (local.set $42 + (block $compile_block.98 (result i32) + (block $compile_store.93 + (local.set $36 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $40) + (local.get $34) (i32.const 1) ) ) ) - (block $do_backpatches.82 + (block $do_backpatches.92 ) ) (if (result i32) (i32.shr_u - (local.get $42) + (local.get $36) (i32.const 31) ) - (block $compile_block.87 (result i32) + (block $compile_block.96 (result i32) (drop - (block $compile_set.84 (result i32) - (local.set $12 + (block $compile_set.94 (result i32) + (local.set $10 (tuple.extract 0 (tuple.make (call $incRef_0 @@ -666,7 +780,7 @@ pattern matching › tuple_match_deep4 ) (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) + (local.get $10) ) ) ) @@ -675,8 +789,8 @@ pattern matching › tuple_match_deep4 ) ) (drop - (block $compile_set.85 (result i32) - (local.set $13 + (block $compile_set.95 (result i32) + (local.set $11 (tuple.extract 0 (tuple.make (call $incRef_0 @@ -688,29 +802,7 @@ pattern matching › tuple_match_deep4 ) (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.86 (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) + (local.get $11) ) ) ) @@ -718,25 +810,25 @@ pattern matching › tuple_match_deep4 (i32.const 1879048190) ) ) - (i32.const 2) + (i32.const 1) ) - (block $compile_block.88 (result i32) + (block $compile_block.97 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.62 (result i32) + (block $cleanup.52 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $23) + (local.get $21) ) ) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $24) + (local.get $22) ) ) (i32.const 1879048190) @@ -744,120 +836,13 @@ pattern matching › tuple_match_deep4 ) ) ) - (block $compile_block.97 (result i32) - (block $compile_store.92 - (local.set $38 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $36) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.91 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $38) - (i32.const 31) - ) - (block $compile_block.95 (result i32) - (drop - (block $compile_set.93 (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.94 (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.96 (result i32) - (i32.const 4) - ) - ) - ) ) - (block $cleanup.51 (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.104 (result i32) - (block $compile_store.100 - (local.set $34 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $31) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.99 ) ) - (if (result i32) - (i32.shr_u - (local.get $34) - (i32.const 31) - ) - (block $compile_block.102 (result i32) + (br $switch.39_outer + (block $compile_block.41 (result i32) (drop - (block $compile_set.101 (result i32) + (block $compile_set.40 (result i32) (local.set $9 (tuple.extract 0 (tuple.make @@ -880,17 +865,14 @@ pattern matching › tuple_match_deep4 ) (i32.const 0) ) - (block $compile_block.103 - (unreachable) - ) ) ) ) ) - (block $do_backpatches.105 + (block $do_backpatches.101 ) ) - (block $cleanup.107 + (block $cleanup.103 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -906,48 +888,48 @@ pattern matching › tuple_match_deep4 ) (tuple.extract 0 (tuple.make - (block $switch.109_outer (result i32) - (block $switch.109_branch_0 (result i32) + (block $switch.105_outer (result i32) + (block $switch.105_branch_0 (result i32) (drop - (block $switch.109_branch_1 (result i32) + (block $switch.105_branch_1 (result i32) (drop - (block $switch.109_branch_2 (result i32) + (block $switch.105_branch_2 (result i32) (drop - (block $switch.109_branch_3 (result i32) + (block $switch.105_branch_3 (result i32) (drop - (block $switch.109_branch_4 (result i32) + (block $switch.105_branch_4 (result i32) (drop - (block $switch.109_branch_5 (result i32) + (block $switch.105_branch_5 (result i32) (drop - (block $switch.109_default (result i32) - (br_table $switch.109_branch_1 $switch.109_branch_2 $switch.109_branch_3 $switch.109_branch_4 $switch.109_branch_5 $switch.109_default $switch.109_default + (block $switch.105_default (result i32) + (br_table $switch.105_branch_1 $switch.105_branch_2 $switch.105_branch_3 $switch.105_branch_4 $switch.105_branch_5 $switch.105_default $switch.105_default (i32.const 0) - (local.get $33) + (local.get $32) ) ) ) - (br $switch.109_outer - (block $compile_block.124 (result i32) + (br $switch.105_outer + (block $compile_block.120 (result i32) (unreachable) ) ) ) ) - (br $switch.109_outer - (block $compile_block.123 (result i32) + (br $switch.105_outer + (block $compile_block.119 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.109_outer - (block $compile_block.122 - (block $compile_store.118 + (br $switch.105_outer + (block $compile_block.118 + (block $compile_store.114 (local.set $28 - (call $+_1157 + (call $+_1155 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) + (global.get $+_1155) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -959,15 +941,15 @@ pattern matching › tuple_match_deep4 ) ) ) - (block $do_backpatches.117 + (block $do_backpatches.113 ) ) - (block $compile_store.120 + (block $compile_store.116 (local.set $29 - (call $+_1157 + (call $+_1155 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) + (global.get $+_1155) ) (local.get $28) (call $incRef_0 @@ -976,10 +958,10 @@ pattern matching › tuple_match_deep4 ) ) ) - (block $do_backpatches.119 + (block $do_backpatches.115 ) ) - (block $cleanup.121 + (block $cleanup.117 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1035,10 +1017,10 @@ pattern matching › tuple_match_deep4 ) ) ) - (return_call $+_1157 + (return_call $+_1155 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) + (global.get $+_1155) ) (local.get $29) (local.get $18) @@ -1047,14 +1029,14 @@ pattern matching › tuple_match_deep4 ) ) ) - (br $switch.109_outer - (block $compile_block.116 - (block $compile_store.114 + (br $switch.105_outer + (block $compile_block.112 + (block $compile_store.110 (local.set $27 - (call $+_1157 + (call $+_1155 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) + (global.get $+_1155) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -1066,10 +1048,10 @@ pattern matching › tuple_match_deep4 ) ) ) - (block $do_backpatches.113 + (block $do_backpatches.109 ) ) - (block $cleanup.115 + (block $cleanup.111 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1125,10 +1107,10 @@ pattern matching › tuple_match_deep4 ) ) ) - (return_call $+_1157 + (return_call $+_1155 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) + (global.get $+_1155) ) (local.get $27) (local.get $14) @@ -1137,9 +1119,9 @@ pattern matching › tuple_match_deep4 ) ) ) - (br $switch.109_outer - (block $compile_block.112 - (block $cleanup.111 + (br $switch.105_outer + (block $compile_block.108 + (block $cleanup.107 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1189,10 +1171,10 @@ pattern matching › tuple_match_deep4 ) ) ) - (return_call $+_1157 + (return_call $+_1155 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) + (global.get $+_1155) ) (local.get $10) (local.get $11) @@ -1201,8 +1183,8 @@ pattern matching › tuple_match_deep4 ) ) ) - (br $switch.109_outer - (block $compile_block.110 (result i32) + (br $switch.105_outer + (block $compile_block.106 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $9) @@ -1211,7 +1193,7 @@ pattern matching › tuple_match_deep4 ) ) ) - (block $cleanup.108 (result i32) + (block $cleanup.104 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot index 80dd3ad19..5c2ab1895 100644 --- a/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot @@ -13,11 +13,11 @@ pattern matching › adt_match_4 (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$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 $+_1153 (param i32 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)) @@ -63,9 +63,7 @@ pattern matching › adt_match_4 (local $34 i32) (local $35 i32) (local $36 i32) - (local $37 i32) - (local $38 i32) - (block $compile_block.106 (result i32) + (block $compile_block.102 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -287,308 +285,402 @@ pattern matching › adt_match_4 (block $do_backpatches.27 ) ) - (block $compile_store.30 + (block $compile_store.88 (local.set $25 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $24) - (i32.const 0) - ) - ) - ) - (block $do_backpatches.29 - ) - ) - (block $compile_store.92 - (local.set $26 - (if (result i32) - (i32.shr_u - (local.get $25) - (i32.const 31) - ) - (block $compile_block.85 (result i32) - (block $compile_store.32 - (local.set $16 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $9) - ) - ) - ) - (block $do_backpatches.31 - ) - ) - (block $compile_store.34 - (local.set $17 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $9) - ) - ) - ) - (block $do_backpatches.33 - ) - ) - (block $compile_store.36 - (local.set $28 - (i32.load offset=12 - (local.get $17) - ) - ) - (block $do_backpatches.35 - ) - ) - (block $compile_store.38 - (local.set $29 - (i32.shr_s - (local.get $28) - (i32.const 1) - ) - ) - (block $do_backpatches.37 - ) - ) - (block $compile_store.40 - (local.set $30 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $29) - (i32.const 0) + (block $switch.29_outer (result i32) + (block $switch.29_branch_0 (result i32) + (drop + (block $switch.29_branch_1 (result i32) + (drop + (block $switch.29_branch_2 (result i32) + (drop + (block $switch.29_default (result i32) + (br_table $switch.29_branch_2 $switch.29_branch_1 $switch.29_default $switch.29_default + (i32.const 0) + (local.get $24) + ) + ) + ) + (br $switch.29_outer + (block $compile_block.86 (result i32) + (unreachable) + ) + ) ) ) - ) - (block $do_backpatches.39 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $30) - (i32.const 31) - ) - (block $compile_block.78 (result i32) - (block $compile_store.43 - (local.set $18 + (br $switch.29_outer + (block $compile_block.85 (result i32) + (block $compile_store.32 + (local.set $16 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $17) + (local.get $9) ) ) ) - (block $do_backpatches.42 + (block $do_backpatches.31 ) ) - (block $compile_store.45 - (local.set $19 + (block $compile_store.34 + (local.set $17 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $17) + (local.get $9) ) ) ) - (block $do_backpatches.44 + (block $do_backpatches.33 ) ) - (block $compile_store.47 - (local.set $32 + (block $compile_store.36 + (local.set $26 (i32.load offset=12 - (local.get $19) + (local.get $17) ) ) - (block $do_backpatches.46 + (block $do_backpatches.35 ) ) - (block $compile_store.49 - (local.set $33 + (block $compile_store.38 + (local.set $27 (i32.shr_s - (local.get $32) + (local.get $26) (i32.const 1) ) ) - (block $do_backpatches.48 + (block $do_backpatches.37 ) ) - (block $compile_store.51 - (local.set $34 + (block $compile_store.40 + (local.set $28 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $33) + (local.get $27) (i32.const 0) ) ) ) - (block $do_backpatches.50 + (block $do_backpatches.39 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $34) + (local.get $28) (i32.const 31) ) - (block $compile_block.70 (result i32) - (block $compile_store.54 - (local.set $20 + (block $compile_block.78 (result i32) + (block $compile_store.43 + (local.set $18 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $19) + (local.get $17) ) ) ) - (block $do_backpatches.53 + (block $do_backpatches.42 ) ) - (block $compile_store.56 - (local.set $21 + (block $compile_store.45 + (local.set $19 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $19) + (local.get $17) ) ) ) - (block $do_backpatches.55 + (block $do_backpatches.44 ) ) - (block $compile_store.58 - (local.set $36 + (block $compile_store.47 + (local.set $30 (i32.load offset=12 - (local.get $21) + (local.get $19) ) ) - (block $do_backpatches.57 + (block $do_backpatches.46 ) ) - (block $cleanup.59 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - ) - (block $compile_store.61 - (local.set $37 + (block $compile_store.49 + (local.set $31 (i32.shr_s - (local.get $36) + (local.get $30) (i32.const 1) ) ) - (block $do_backpatches.60 + (block $do_backpatches.48 ) ) - (block $compile_store.63 - (local.set $38 + (block $compile_store.51 + (local.set $32 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $37) - (i32.const 1) + (local.get $31) + (i32.const 0) ) ) ) - (block $do_backpatches.62 + (block $do_backpatches.50 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $38) + (local.get $32) (i32.const 31) ) - (block $compile_block.68 (result i32) - (drop - (block $compile_set.65 (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) - ) - ) + (block $compile_block.70 (result i32) + (block $compile_store.54 + (local.set $20 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=20 + (local.get $19) + ) + ) + ) + (block $do_backpatches.53 + ) + ) + (block $compile_store.56 + (local.set $21 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=24 + (local.get $19) + ) + ) + ) + (block $do_backpatches.55 + ) + ) + (block $compile_store.58 + (local.set $34 + (i32.load offset=12 + (local.get $21) + ) + ) + (block $do_backpatches.57 + ) + ) + (block $cleanup.59 + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $21) + ) + ) + ) + (block $compile_store.61 + (local.set $35 + (i32.shr_s + (local.get $34) + (i32.const 1) + ) + ) + (block $do_backpatches.60 + ) + ) + (block $compile_store.63 + (local.set $36 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $35) + (i32.const 1) ) ) - (i32.const 1879048190) + ) + (block $do_backpatches.62 ) ) - (drop - (block $compile_set.66 (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) + (tuple.extract 0 + (tuple.make + (if (result i32) + (i32.shr_u + (local.get $36) + (i32.const 31) + ) + (block $compile_block.68 (result i32) + (drop + (block $compile_set.65 (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) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) + ) + (drop + (block $compile_set.66 (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.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 $20) + ) + ) + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $15) + ) + ) + ) + ) + (i32.const 1879048190) + ) + ) + (i32.const 3) + ) + (block $compile_block.69 (result i32) + (i32.const 4) ) ) - (i32.const 1879048190) + (block $cleanup.64 (result i32) + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $20) + ) + ) + (i32.const 1879048190) + ) + ) + ) + ) + (block $compile_block.77 (result i32) + (block $compile_store.72 + (local.set $33 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $31) + (i32.const 1) + ) + ) + ) + (block $do_backpatches.71 ) ) - (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 $20) + (if (result i32) + (i32.shr_u + (local.get $33) + (i32.const 31) + ) + (block $compile_block.75 (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 $16) + ) + ) + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $11) + ) ) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) + ) + (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 $18) + ) + ) + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $12) + ) + ) ) ) + (i32.const 1879048190) ) ) - (i32.const 1879048190) + (i32.const 2) + ) + (block $compile_block.76 (result i32) + (i32.const 4) ) ) - (i32.const 3) - ) - (block $compile_block.69 (result i32) - (i32.const 4) ) ) - (block $cleanup.64 (result i32) + (block $cleanup.52 (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 $20) + (local.get $19) ) ) (i32.const 1879048190) @@ -596,30 +688,30 @@ pattern matching › adt_match_4 ) ) ) - (block $compile_block.77 (result i32) - (block $compile_store.72 - (local.set $35 + (block $compile_block.84 (result i32) + (block $compile_store.80 + (local.set $29 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $33) + (local.get $27) (i32.const 1) ) ) ) - (block $do_backpatches.71 + (block $do_backpatches.79 ) ) (if (result i32) (i32.shr_u - (local.get $35) + (local.get $29) (i32.const 31) ) - (block $compile_block.75 (result i32) + (block $compile_block.82 (result i32) (drop - (block $compile_set.73 (result i32) - (local.set $11 + (block $compile_set.81 (result i32) + (local.set $10 (tuple.extract 0 (tuple.make (call $incRef_0 @@ -631,29 +723,7 @@ pattern matching › adt_match_4 ) (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 $18) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) + (local.get $10) ) ) ) @@ -661,25 +731,25 @@ pattern matching › adt_match_4 (i32.const 1879048190) ) ) - (i32.const 2) + (i32.const 1) ) - (block $compile_block.76 (result i32) + (block $compile_block.83 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.52 (result i32) + (block $cleanup.41 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) + (local.get $16) ) ) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) + (local.get $17) ) ) (i32.const 1879048190) @@ -687,109 +757,21 @@ pattern matching › adt_match_4 ) ) ) - (block $compile_block.84 (result i32) - (block $compile_store.80 - (local.set $31 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $29) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.79 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $31) - (i32.const 31) - ) - (block $compile_block.82 (result i32) - (drop - (block $compile_set.81 (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 1) - ) - (block $compile_block.83 (result i32) - (i32.const 4) - ) - ) - ) - ) - (block $cleanup.41 (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.90 (result i32) - (block $compile_store.87 - (local.set $27 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $24) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.86 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $27) - (i32.const 31) - ) - (block $compile_block.88 (result i32) + (br $switch.29_outer + (block $compile_block.30 (result i32) (i32.const 0) ) - (block $compile_block.89 - (unreachable) - ) ) ) ) ) - (block $do_backpatches.91 + (block $do_backpatches.87 ) ) - (block $cleanup.93 + (block $cleanup.89 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -799,48 +781,48 @@ pattern matching › adt_match_4 ) (tuple.extract 0 (tuple.make - (block $switch.95_outer (result i32) - (block $switch.95_branch_0 (result i32) + (block $switch.91_outer (result i32) + (block $switch.91_branch_0 (result i32) (drop - (block $switch.95_branch_1 (result i32) + (block $switch.91_branch_1 (result i32) (drop - (block $switch.95_branch_2 (result i32) + (block $switch.91_branch_2 (result i32) (drop - (block $switch.95_branch_3 (result i32) + (block $switch.91_branch_3 (result i32) (drop - (block $switch.95_branch_4 (result i32) + (block $switch.91_branch_4 (result i32) (drop - (block $switch.95_branch_5 (result i32) + (block $switch.91_branch_5 (result i32) (drop - (block $switch.95_default (result i32) - (br_table $switch.95_branch_1 $switch.95_branch_2 $switch.95_branch_3 $switch.95_branch_4 $switch.95_branch_5 $switch.95_default $switch.95_default + (block $switch.91_default (result i32) + (br_table $switch.91_branch_1 $switch.91_branch_2 $switch.91_branch_3 $switch.91_branch_4 $switch.91_branch_5 $switch.91_default $switch.91_default (i32.const 0) - (local.get $26) + (local.get $25) ) ) ) - (br $switch.95_outer - (block $compile_block.105 (result i32) + (br $switch.91_outer + (block $compile_block.101 (result i32) (unreachable) ) ) ) ) - (br $switch.95_outer - (block $compile_block.104 (result i32) + (br $switch.91_outer + (block $compile_block.100 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.95_outer - (block $compile_block.103 - (block $compile_store.101 + (br $switch.91_outer + (block $compile_block.99 + (block $compile_store.97 (local.set $22 - (call $+_1153 + (call $+_1151 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) + (global.get $+_1151) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -852,10 +834,10 @@ pattern matching › adt_match_4 ) ) ) - (block $do_backpatches.100 + (block $do_backpatches.96 ) ) - (block $cleanup.102 + (block $cleanup.98 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -887,10 +869,10 @@ pattern matching › adt_match_4 ) ) ) - (return_call $+_1153 + (return_call $+_1151 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) + (global.get $+_1151) ) (local.get $22) (local.get $15) @@ -899,9 +881,9 @@ pattern matching › adt_match_4 ) ) ) - (br $switch.95_outer - (block $compile_block.99 - (block $cleanup.98 + (br $switch.91_outer + (block $compile_block.95 + (block $cleanup.94 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -927,10 +909,10 @@ pattern matching › adt_match_4 ) ) ) - (return_call $+_1153 + (return_call $+_1151 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) + (global.get $+_1151) ) (local.get $11) (local.get $12) @@ -939,8 +921,8 @@ pattern matching › adt_match_4 ) ) ) - (br $switch.95_outer - (block $compile_block.97 (result i32) + (br $switch.91_outer + (block $compile_block.93 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $10) @@ -949,14 +931,14 @@ pattern matching › adt_match_4 ) ) ) - (br $switch.95_outer - (block $compile_block.96 (result i32) + (br $switch.91_outer + (block $compile_block.92 (result i32) (i32.const 1) ) ) ) ) - (block $cleanup.94 (result i32) + (block $cleanup.90 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot b/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot index 5d1393bbe..b61fbc5fb 100644 --- a/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot @@ -13,11 +13,11 @@ pattern matching › tuple_match_deep6 (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 $+_1161 (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 $+_1161 (param i32 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)) @@ -72,9 +72,7 @@ pattern matching › tuple_match_deep6 (local $43 i32) (local $44 i32) (local $45 i32) - (local $46 i32) - (local $47 i32) - (block $compile_block.131 (result i32) + (block $compile_block.127 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -386,330 +384,446 @@ pattern matching › tuple_match_deep6 (block $do_backpatches.43 ) ) - (block $compile_store.46 + (block $compile_store.108 (local.set $34 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $33) - (i32.const 0) - ) - ) - ) - (block $do_backpatches.45 - ) - ) - (block $compile_store.112 - (local.set $35 - (if (result i32) - (i32.shr_u - (local.get $34) - (i32.const 31) - ) - (block $compile_block.104 (result i32) - (block $compile_store.48 - (local.set $23 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $22) - ) - ) - ) - (block $do_backpatches.47 - ) - ) - (block $compile_store.50 - (local.set $24 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $22) - ) - ) - ) - (block $do_backpatches.49 - ) - ) - (block $compile_store.52 - (local.set $37 - (i32.load offset=12 - (local.get $24) - ) - ) - (block $do_backpatches.51 - ) - ) - (block $compile_store.54 - (local.set $38 - (i32.shr_s - (local.get $37) - (i32.const 1) - ) - ) - (block $do_backpatches.53 - ) - ) - (block $compile_store.56 - (local.set $39 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $38) - (i32.const 0) + (block $switch.45_outer (result i32) + (block $switch.45_branch_0 (result i32) + (drop + (block $switch.45_branch_1 (result i32) + (drop + (block $switch.45_branch_2 (result i32) + (drop + (block $switch.45_default (result i32) + (br_table $switch.45_branch_2 $switch.45_branch_1 $switch.45_default $switch.45_default + (i32.const 0) + (local.get $33) + ) + ) + ) + (br $switch.45_outer + (block $compile_block.106 (result i32) + (unreachable) + ) + ) ) ) - ) - (block $do_backpatches.55 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $39) - (i32.const 31) - ) - (block $compile_block.96 (result i32) - (block $compile_store.59 - (local.set $25 + (br $switch.45_outer + (block $compile_block.105 (result i32) + (block $compile_store.49 + (local.set $23 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $24) + (local.get $22) ) ) ) - (block $do_backpatches.58 + (block $do_backpatches.48 ) ) - (block $compile_store.61 - (local.set $26 + (block $compile_store.51 + (local.set $24 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $24) + (local.get $22) ) ) ) - (block $do_backpatches.60 + (block $do_backpatches.50 ) ) - (block $compile_store.63 - (local.set $41 + (block $compile_store.53 + (local.set $35 (i32.load offset=12 - (local.get $26) + (local.get $24) ) ) - (block $do_backpatches.62 + (block $do_backpatches.52 ) ) - (block $compile_store.65 - (local.set $42 + (block $compile_store.55 + (local.set $36 (i32.shr_s - (local.get $41) + (local.get $35) (i32.const 1) ) ) - (block $do_backpatches.64 + (block $do_backpatches.54 ) ) - (block $compile_store.67 - (local.set $43 + (block $compile_store.57 + (local.set $37 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $42) + (local.get $36) (i32.const 0) ) ) ) - (block $do_backpatches.66 + (block $do_backpatches.56 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $43) + (local.get $37) (i32.const 31) ) - (block $compile_block.87 (result i32) - (block $compile_store.70 - (local.set $27 + (block $compile_block.97 (result i32) + (block $compile_store.60 + (local.set $25 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $26) + (local.get $24) ) ) ) - (block $do_backpatches.69 + (block $do_backpatches.59 ) ) - (block $compile_store.72 - (local.set $28 + (block $compile_store.62 + (local.set $26 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $26) + (local.get $24) ) ) ) - (block $do_backpatches.71 + (block $do_backpatches.61 ) ) - (block $compile_store.74 - (local.set $45 + (block $compile_store.64 + (local.set $39 (i32.load offset=12 - (local.get $28) + (local.get $26) ) ) - (block $do_backpatches.73 - ) - ) - (block $cleanup.75 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $28) - ) + (block $do_backpatches.63 ) ) - (block $compile_store.77 - (local.set $46 + (block $compile_store.66 + (local.set $40 (i32.shr_s - (local.get $45) + (local.get $39) (i32.const 1) ) ) - (block $do_backpatches.76 + (block $do_backpatches.65 ) ) - (block $compile_store.79 - (local.set $47 + (block $compile_store.68 + (local.set $41 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $46) - (i32.const 1) + (local.get $40) + (i32.const 0) ) ) ) - (block $do_backpatches.78 + (block $do_backpatches.67 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $47) + (local.get $41) (i32.const 31) ) - (block $compile_block.85 (result i32) - (drop - (block $compile_set.81 (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) - ) - ) + (block $compile_block.88 (result i32) + (block $compile_store.71 + (local.set $27 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=20 + (local.get $26) + ) + ) + ) + (block $do_backpatches.70 + ) + ) + (block $compile_store.73 + (local.set $28 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=24 + (local.get $26) + ) + ) + ) + (block $do_backpatches.72 + ) + ) + (block $compile_store.75 + (local.set $43 + (i32.load offset=12 + (local.get $28) + ) + ) + (block $do_backpatches.74 + ) + ) + (block $cleanup.76 + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $28) + ) + ) + ) + (block $compile_store.78 + (local.set $44 + (i32.shr_s + (local.get $43) + (i32.const 1) + ) + ) + (block $do_backpatches.77 + ) + ) + (block $compile_store.80 + (local.set $45 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $44) + (i32.const 1) ) ) - (i32.const 1879048190) + ) + (block $do_backpatches.79 ) ) - (drop - (block $compile_set.82 (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) + (tuple.extract 0 + (tuple.make + (if (result i32) + (i32.shr_u + (local.get $45) + (i32.const 31) + ) + (block $compile_block.86 (result i32) + (drop + (block $compile_set.82 (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.83 (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.84 (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) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) + ) + (drop + (block $compile_set.85 (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 3) + ) + (block $compile_block.87 (result i32) + (i32.const 4) ) ) - (i32.const 1879048190) + (block $cleanup.81 (result i32) + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $27) + ) + ) + (i32.const 1879048190) + ) ) ) - (drop - (block $compile_set.83 (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) + ) + (block $compile_block.96 (result i32) + (block $compile_store.90 + (local.set $42 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $40) + (i32.const 1) + ) + ) + ) + (block $do_backpatches.89 + ) + ) + (if (result i32) + (i32.shr_u + (local.get $42) + (i32.const 31) + ) + (block $compile_block.94 (result i32) + (drop + (block $compile_set.91 (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) + ) ) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) ) + (i32.const 1879048190) ) ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.84 (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) + (drop + (block $compile_set.92 (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) + ) ) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) + ) + (i32.const 1879048190) + ) + ) + (drop + (block $compile_set.93 (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 1879048190) + (i32.const 2) + ) + (block $compile_block.95 (result i32) + (i32.const 4) ) ) - (i32.const 3) - ) - (block $compile_block.86 (result i32) - (i32.const 4) ) ) - (block $cleanup.80 (result i32) + (block $cleanup.69 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $27) + (local.get $25) + ) + ) + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $26) ) ) (i32.const 1879048190) @@ -717,30 +831,30 @@ pattern matching › tuple_match_deep6 ) ) ) - (block $compile_block.95 (result i32) - (block $compile_store.89 - (local.set $44 + (block $compile_block.104 (result i32) + (block $compile_store.99 + (local.set $38 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $42) + (local.get $36) (i32.const 1) ) ) ) - (block $do_backpatches.88 + (block $do_backpatches.98 ) ) (if (result i32) (i32.shr_u - (local.get $44) + (local.get $38) (i32.const 31) ) - (block $compile_block.93 (result i32) + (block $compile_block.102 (result i32) (drop - (block $compile_set.90 (result i32) - (local.set $14 + (block $compile_set.100 (result i32) + (local.set $12 (tuple.extract 0 (tuple.make (call $incRef_0 @@ -752,7 +866,7 @@ pattern matching › tuple_match_deep6 ) (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) + (local.get $12) ) ) ) @@ -761,8 +875,8 @@ pattern matching › tuple_match_deep6 ) ) (drop - (block $compile_set.91 (result i32) - (local.set $15 + (block $compile_set.101 (result i32) + (local.set $13 (tuple.extract 0 (tuple.make (call $incRef_0 @@ -774,29 +888,7 @@ pattern matching › tuple_match_deep6 ) (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.92 (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) + (local.get $13) ) ) ) @@ -804,25 +896,25 @@ pattern matching › tuple_match_deep6 (i32.const 1879048190) ) ) - (i32.const 2) + (i32.const 1) ) - (block $compile_block.94 (result i32) + (block $compile_block.103 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.68 (result i32) + (block $cleanup.58 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $25) + (local.get $23) ) ) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $26) + (local.get $24) ) ) (i32.const 1879048190) @@ -830,120 +922,13 @@ pattern matching › tuple_match_deep6 ) ) ) - (block $compile_block.103 (result i32) - (block $compile_store.98 - (local.set $40 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $38) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.97 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $40) - (i32.const 31) - ) - (block $compile_block.101 (result i32) - (drop - (block $compile_set.99 (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.100 (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 1) - ) - (block $compile_block.102 (result i32) - (i32.const 4) - ) - ) - ) ) - (block $cleanup.57 (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.110 (result i32) - (block $compile_store.106 - (local.set $36 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $33) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.105 ) ) - (if (result i32) - (i32.shr_u - (local.get $36) - (i32.const 31) - ) - (block $compile_block.108 (result i32) + (br $switch.45_outer + (block $compile_block.47 (result i32) (drop - (block $compile_set.107 (result i32) + (block $compile_set.46 (result i32) (local.set $11 (tuple.extract 0 (tuple.make @@ -966,17 +951,14 @@ pattern matching › tuple_match_deep6 ) (i32.const 0) ) - (block $compile_block.109 - (unreachable) - ) ) ) ) ) - (block $do_backpatches.111 + (block $do_backpatches.107 ) ) - (block $cleanup.113 + (block $cleanup.109 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -992,48 +974,48 @@ pattern matching › tuple_match_deep6 ) (tuple.extract 0 (tuple.make - (block $switch.115_outer (result i32) - (block $switch.115_branch_0 (result i32) + (block $switch.111_outer (result i32) + (block $switch.111_branch_0 (result i32) (drop - (block $switch.115_branch_1 (result i32) + (block $switch.111_branch_1 (result i32) (drop - (block $switch.115_branch_2 (result i32) + (block $switch.111_branch_2 (result i32) (drop - (block $switch.115_branch_3 (result i32) + (block $switch.111_branch_3 (result i32) (drop - (block $switch.115_branch_4 (result i32) + (block $switch.111_branch_4 (result i32) (drop - (block $switch.115_branch_5 (result i32) + (block $switch.111_branch_5 (result i32) (drop - (block $switch.115_default (result i32) - (br_table $switch.115_branch_1 $switch.115_branch_2 $switch.115_branch_3 $switch.115_branch_4 $switch.115_branch_5 $switch.115_default $switch.115_default + (block $switch.111_default (result i32) + (br_table $switch.111_branch_1 $switch.111_branch_2 $switch.111_branch_3 $switch.111_branch_4 $switch.111_branch_5 $switch.111_default $switch.111_default (i32.const 0) - (local.get $35) + (local.get $34) ) ) ) - (br $switch.115_outer - (block $compile_block.130 (result i32) + (br $switch.111_outer + (block $compile_block.126 (result i32) (unreachable) ) ) ) ) - (br $switch.115_outer - (block $compile_block.129 (result i32) + (br $switch.111_outer + (block $compile_block.125 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.115_outer - (block $compile_block.128 - (block $compile_store.124 + (br $switch.111_outer + (block $compile_block.124 + (block $compile_store.120 (local.set $30 - (call $+_1161 + (call $+_1159 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1161) + (global.get $+_1159) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -1045,15 +1027,15 @@ pattern matching › tuple_match_deep6 ) ) ) - (block $do_backpatches.123 + (block $do_backpatches.119 ) ) - (block $compile_store.126 + (block $compile_store.122 (local.set $31 - (call $+_1161 + (call $+_1159 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1161) + (global.get $+_1159) ) (local.get $30) (call $incRef_0 @@ -1062,10 +1044,10 @@ pattern matching › tuple_match_deep6 ) ) ) - (block $do_backpatches.125 + (block $do_backpatches.121 ) ) - (block $cleanup.127 + (block $cleanup.123 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1121,10 +1103,10 @@ pattern matching › tuple_match_deep6 ) ) ) - (return_call $+_1161 + (return_call $+_1159 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1161) + (global.get $+_1159) ) (local.get $31) (local.get $20) @@ -1133,14 +1115,14 @@ pattern matching › tuple_match_deep6 ) ) ) - (br $switch.115_outer - (block $compile_block.122 - (block $compile_store.120 + (br $switch.111_outer + (block $compile_block.118 + (block $compile_store.116 (local.set $29 - (call $+_1161 + (call $+_1159 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1161) + (global.get $+_1159) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -1152,10 +1134,10 @@ pattern matching › tuple_match_deep6 ) ) ) - (block $do_backpatches.119 + (block $do_backpatches.115 ) ) - (block $cleanup.121 + (block $cleanup.117 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1211,10 +1193,10 @@ pattern matching › tuple_match_deep6 ) ) ) - (return_call $+_1161 + (return_call $+_1159 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1161) + (global.get $+_1159) ) (local.get $29) (local.get $16) @@ -1223,9 +1205,9 @@ pattern matching › tuple_match_deep6 ) ) ) - (br $switch.115_outer - (block $compile_block.118 - (block $cleanup.117 + (br $switch.111_outer + (block $compile_block.114 + (block $cleanup.113 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1275,10 +1257,10 @@ pattern matching › tuple_match_deep6 ) ) ) - (return_call $+_1161 + (return_call $+_1159 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1161) + (global.get $+_1159) ) (local.get $12) (local.get $13) @@ -1287,8 +1269,8 @@ pattern matching › tuple_match_deep6 ) ) ) - (br $switch.115_outer - (block $compile_block.116 (result i32) + (br $switch.111_outer + (block $compile_block.112 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $11) @@ -1297,7 +1279,7 @@ pattern matching › tuple_match_deep6 ) ) ) - (block $cleanup.114 (result i32) + (block $cleanup.110 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot b/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot index c18cdaf5b..1af8bcf1c 100644 --- a/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot @@ -13,11 +13,11 @@ pattern matching › tuple_match_deep3 (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$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 $+_1155 (param i32 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)) @@ -69,9 +69,7 @@ pattern matching › tuple_match_deep3 (local $40 i32) (local $41 i32) (local $42 i32) - (local $43 i32) - (local $44 i32) - (block $compile_block.122 (result i32) + (block $compile_block.118 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -257,330 +255,446 @@ pattern matching › tuple_match_deep3 (block $do_backpatches.34 ) ) - (block $compile_store.37 + (block $compile_store.99 (local.set $31 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $30) - (i32.const 0) - ) - ) - ) - (block $do_backpatches.36 - ) - ) - (block $compile_store.103 - (local.set $32 - (if (result i32) - (i32.shr_u - (local.get $31) - (i32.const 31) - ) - (block $compile_block.95 (result i32) - (block $compile_store.39 - (local.set $20 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $19) - ) - ) - ) - (block $do_backpatches.38 - ) - ) - (block $compile_store.41 - (local.set $21 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $19) - ) - ) - ) - (block $do_backpatches.40 - ) - ) - (block $compile_store.43 - (local.set $34 - (i32.load offset=12 - (local.get $21) - ) - ) - (block $do_backpatches.42 - ) - ) - (block $compile_store.45 - (local.set $35 - (i32.shr_s - (local.get $34) - (i32.const 1) - ) - ) - (block $do_backpatches.44 - ) - ) - (block $compile_store.47 - (local.set $36 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $35) - (i32.const 0) + (block $switch.36_outer (result i32) + (block $switch.36_branch_0 (result i32) + (drop + (block $switch.36_branch_1 (result i32) + (drop + (block $switch.36_branch_2 (result i32) + (drop + (block $switch.36_default (result i32) + (br_table $switch.36_branch_2 $switch.36_branch_1 $switch.36_default $switch.36_default + (i32.const 0) + (local.get $30) + ) + ) + ) + (br $switch.36_outer + (block $compile_block.97 (result i32) + (unreachable) + ) + ) ) ) - ) - (block $do_backpatches.46 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $36) - (i32.const 31) - ) - (block $compile_block.87 (result i32) - (block $compile_store.50 - (local.set $22 + (br $switch.36_outer + (block $compile_block.96 (result i32) + (block $compile_store.40 + (local.set $20 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $21) + (local.get $19) ) ) ) - (block $do_backpatches.49 + (block $do_backpatches.39 ) ) - (block $compile_store.52 - (local.set $23 + (block $compile_store.42 + (local.set $21 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $21) + (local.get $19) ) ) ) - (block $do_backpatches.51 + (block $do_backpatches.41 ) ) - (block $compile_store.54 - (local.set $38 + (block $compile_store.44 + (local.set $32 (i32.load offset=12 - (local.get $23) + (local.get $21) ) ) - (block $do_backpatches.53 + (block $do_backpatches.43 ) ) - (block $compile_store.56 - (local.set $39 + (block $compile_store.46 + (local.set $33 (i32.shr_s - (local.get $38) + (local.get $32) (i32.const 1) ) ) - (block $do_backpatches.55 + (block $do_backpatches.45 ) ) - (block $compile_store.58 - (local.set $40 + (block $compile_store.48 + (local.set $34 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $39) + (local.get $33) (i32.const 0) ) ) ) - (block $do_backpatches.57 + (block $do_backpatches.47 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $40) + (local.get $34) (i32.const 31) ) - (block $compile_block.78 (result i32) - (block $compile_store.61 - (local.set $24 + (block $compile_block.88 (result i32) + (block $compile_store.51 + (local.set $22 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $23) + (local.get $21) ) ) ) - (block $do_backpatches.60 + (block $do_backpatches.50 ) ) - (block $compile_store.63 - (local.set $25 + (block $compile_store.53 + (local.set $23 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $23) + (local.get $21) ) ) ) - (block $do_backpatches.62 + (block $do_backpatches.52 ) ) - (block $compile_store.65 - (local.set $42 + (block $compile_store.55 + (local.set $36 (i32.load offset=12 - (local.get $25) + (local.get $23) ) ) - (block $do_backpatches.64 - ) - ) - (block $cleanup.66 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $25) - ) + (block $do_backpatches.54 ) ) - (block $compile_store.68 - (local.set $43 + (block $compile_store.57 + (local.set $37 (i32.shr_s - (local.get $42) + (local.get $36) (i32.const 1) ) ) - (block $do_backpatches.67 + (block $do_backpatches.56 ) ) - (block $compile_store.70 - (local.set $44 + (block $compile_store.59 + (local.set $38 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $43) - (i32.const 1) + (local.get $37) + (i32.const 0) ) ) ) - (block $do_backpatches.69 + (block $do_backpatches.58 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $44) + (local.get $38) (i32.const 31) ) - (block $compile_block.76 (result i32) - (drop - (block $compile_set.72 (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) - ) - ) + (block $compile_block.79 (result i32) + (block $compile_store.62 + (local.set $24 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=20 + (local.get $23) + ) + ) + ) + (block $do_backpatches.61 + ) + ) + (block $compile_store.64 + (local.set $25 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=24 + (local.get $23) + ) + ) + ) + (block $do_backpatches.63 + ) + ) + (block $compile_store.66 + (local.set $40 + (i32.load offset=12 + (local.get $25) + ) + ) + (block $do_backpatches.65 + ) + ) + (block $cleanup.67 + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $25) + ) + ) + ) + (block $compile_store.69 + (local.set $41 + (i32.shr_s + (local.get $40) + (i32.const 1) + ) + ) + (block $do_backpatches.68 + ) + ) + (block $compile_store.71 + (local.set $42 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $41) + (i32.const 1) ) ) - (i32.const 1879048190) + ) + (block $do_backpatches.70 ) ) - (drop - (block $compile_set.73 (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) + (tuple.extract 0 + (tuple.make + (if (result i32) + (i32.shr_u + (local.get $42) + (i32.const 31) + ) + (block $compile_block.77 (result i32) + (drop + (block $compile_set.73 (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.74 (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.75 (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) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) + ) + (drop + (block $compile_set.76 (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 3) + ) + (block $compile_block.78 (result i32) + (i32.const 4) ) ) - (i32.const 1879048190) + (block $cleanup.72 (result i32) + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $24) + ) + ) + (i32.const 1879048190) + ) ) ) - (drop - (block $compile_set.74 (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) + ) + (block $compile_block.87 (result i32) + (block $compile_store.81 + (local.set $39 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $37) + (i32.const 1) + ) + ) + ) + (block $do_backpatches.80 + ) + ) + (if (result i32) + (i32.shr_u + (local.get $39) + (i32.const 31) + ) + (block $compile_block.85 (result i32) + (drop + (block $compile_set.82 (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) + ) ) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) ) + (i32.const 1879048190) ) ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.75 (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) + (drop + (block $compile_set.83 (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) + ) ) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) + ) + (i32.const 1879048190) + ) + ) + (drop + (block $compile_set.84 (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 1879048190) + (i32.const 2) + ) + (block $compile_block.86 (result i32) + (i32.const 4) ) ) - (i32.const 3) - ) - (block $compile_block.77 (result i32) - (i32.const 4) ) ) - (block $cleanup.71 (result i32) + (block $cleanup.60 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $24) + (local.get $22) + ) + ) + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $23) ) ) (i32.const 1879048190) @@ -588,30 +702,30 @@ pattern matching › tuple_match_deep3 ) ) ) - (block $compile_block.86 (result i32) - (block $compile_store.80 - (local.set $41 + (block $compile_block.95 (result i32) + (block $compile_store.90 + (local.set $35 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $39) + (local.get $33) (i32.const 1) ) ) ) - (block $do_backpatches.79 + (block $do_backpatches.89 ) ) (if (result i32) (i32.shr_u - (local.get $41) + (local.get $35) (i32.const 31) ) - (block $compile_block.84 (result i32) + (block $compile_block.93 (result i32) (drop - (block $compile_set.81 (result i32) - (local.set $11 + (block $compile_set.91 (result i32) + (local.set $9 (tuple.extract 0 (tuple.make (call $incRef_0 @@ -623,7 +737,7 @@ pattern matching › tuple_match_deep3 ) (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) + (local.get $9) ) ) ) @@ -632,8 +746,8 @@ pattern matching › tuple_match_deep3 ) ) (drop - (block $compile_set.82 (result i32) - (local.set $12 + (block $compile_set.92 (result i32) + (local.set $10 (tuple.extract 0 (tuple.make (call $incRef_0 @@ -645,29 +759,7 @@ pattern matching › tuple_match_deep3 ) (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.83 (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) + (local.get $10) ) ) ) @@ -675,25 +767,25 @@ pattern matching › tuple_match_deep3 (i32.const 1879048190) ) ) - (i32.const 2) + (i32.const 1) ) - (block $compile_block.85 (result i32) + (block $compile_block.94 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.59 (result i32) + (block $cleanup.49 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $22) + (local.get $20) ) ) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $23) + (local.get $21) ) ) (i32.const 1879048190) @@ -701,120 +793,13 @@ pattern matching › tuple_match_deep3 ) ) ) - (block $compile_block.94 (result i32) - (block $compile_store.89 - (local.set $37 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $35) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.88 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $37) - (i32.const 31) - ) - (block $compile_block.92 (result i32) - (drop - (block $compile_set.90 (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.91 (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.93 (result i32) - (i32.const 4) - ) - ) - ) ) - (block $cleanup.48 (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.101 (result i32) - (block $compile_store.97 - (local.set $33 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $30) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.96 ) ) - (if (result i32) - (i32.shr_u - (local.get $33) - (i32.const 31) - ) - (block $compile_block.99 (result i32) + (br $switch.36_outer + (block $compile_block.38 (result i32) (drop - (block $compile_set.98 (result i32) + (block $compile_set.37 (result i32) (local.set $8 (tuple.extract 0 (tuple.make @@ -837,17 +822,14 @@ pattern matching › tuple_match_deep3 ) (i32.const 0) ) - (block $compile_block.100 - (unreachable) - ) ) ) ) ) - (block $do_backpatches.102 + (block $do_backpatches.98 ) ) - (block $cleanup.104 + (block $cleanup.100 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -863,48 +845,48 @@ pattern matching › tuple_match_deep3 ) (tuple.extract 0 (tuple.make - (block $switch.106_outer (result i32) - (block $switch.106_branch_0 (result i32) + (block $switch.102_outer (result i32) + (block $switch.102_branch_0 (result i32) (drop - (block $switch.106_branch_1 (result i32) + (block $switch.102_branch_1 (result i32) (drop - (block $switch.106_branch_2 (result i32) + (block $switch.102_branch_2 (result i32) (drop - (block $switch.106_branch_3 (result i32) + (block $switch.102_branch_3 (result i32) (drop - (block $switch.106_branch_4 (result i32) + (block $switch.102_branch_4 (result i32) (drop - (block $switch.106_branch_5 (result i32) + (block $switch.102_branch_5 (result i32) (drop - (block $switch.106_default (result i32) - (br_table $switch.106_branch_1 $switch.106_branch_2 $switch.106_branch_3 $switch.106_branch_4 $switch.106_branch_5 $switch.106_default $switch.106_default + (block $switch.102_default (result i32) + (br_table $switch.102_branch_1 $switch.102_branch_2 $switch.102_branch_3 $switch.102_branch_4 $switch.102_branch_5 $switch.102_default $switch.102_default (i32.const 0) - (local.get $32) + (local.get $31) ) ) ) - (br $switch.106_outer - (block $compile_block.121 (result i32) + (br $switch.102_outer + (block $compile_block.117 (result i32) (unreachable) ) ) ) ) - (br $switch.106_outer - (block $compile_block.120 (result i32) + (br $switch.102_outer + (block $compile_block.116 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.106_outer - (block $compile_block.119 - (block $compile_store.115 + (br $switch.102_outer + (block $compile_block.115 + (block $compile_store.111 (local.set $27 - (call $+_1155 + (call $+_1153 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) + (global.get $+_1153) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -916,15 +898,15 @@ pattern matching › tuple_match_deep3 ) ) ) - (block $do_backpatches.114 + (block $do_backpatches.110 ) ) - (block $compile_store.117 + (block $compile_store.113 (local.set $28 - (call $+_1155 + (call $+_1153 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) + (global.get $+_1153) ) (local.get $27) (call $incRef_0 @@ -933,10 +915,10 @@ pattern matching › tuple_match_deep3 ) ) ) - (block $do_backpatches.116 + (block $do_backpatches.112 ) ) - (block $cleanup.118 + (block $cleanup.114 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -992,10 +974,10 @@ pattern matching › tuple_match_deep3 ) ) ) - (return_call $+_1155 + (return_call $+_1153 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) + (global.get $+_1153) ) (local.get $28) (local.get $17) @@ -1004,14 +986,14 @@ pattern matching › tuple_match_deep3 ) ) ) - (br $switch.106_outer - (block $compile_block.113 - (block $compile_store.111 + (br $switch.102_outer + (block $compile_block.109 + (block $compile_store.107 (local.set $26 - (call $+_1155 + (call $+_1153 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) + (global.get $+_1153) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -1023,10 +1005,10 @@ pattern matching › tuple_match_deep3 ) ) ) - (block $do_backpatches.110 + (block $do_backpatches.106 ) ) - (block $cleanup.112 + (block $cleanup.108 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1082,10 +1064,10 @@ pattern matching › tuple_match_deep3 ) ) ) - (return_call $+_1155 + (return_call $+_1153 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) + (global.get $+_1153) ) (local.get $26) (local.get $13) @@ -1094,9 +1076,9 @@ pattern matching › tuple_match_deep3 ) ) ) - (br $switch.106_outer - (block $compile_block.109 - (block $cleanup.108 + (br $switch.102_outer + (block $compile_block.105 + (block $cleanup.104 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1146,10 +1128,10 @@ pattern matching › tuple_match_deep3 ) ) ) - (return_call $+_1155 + (return_call $+_1153 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) + (global.get $+_1153) ) (local.get $9) (local.get $10) @@ -1158,8 +1140,8 @@ pattern matching › tuple_match_deep3 ) ) ) - (br $switch.106_outer - (block $compile_block.107 (result i32) + (br $switch.102_outer + (block $compile_block.103 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $8) @@ -1168,7 +1150,7 @@ pattern matching › tuple_match_deep3 ) ) ) - (block $cleanup.105 (result i32) + (block $cleanup.101 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot b/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot index 4d718eab4..1d729666e 100644 --- a/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot @@ -13,11 +13,11 @@ pattern matching › adt_match_1 (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$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 $+_1147 (param i32 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)) @@ -60,9 +60,7 @@ pattern matching › adt_match_1 (local $31 i32) (local $32 i32) (local $33 i32) - (local $34 i32) - (local $35 i32) - (block $compile_block.97 (result i32) + (block $compile_block.93 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -158,308 +156,402 @@ pattern matching › adt_match_1 (block $do_backpatches.18 ) ) - (block $compile_store.21 + (block $compile_store.79 (local.set $22 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $21) - (i32.const 0) - ) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.83 - (local.set $23 - (if (result i32) - (i32.shr_u - (local.get $22) - (i32.const 31) - ) - (block $compile_block.76 (result i32) - (block $compile_store.23 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.22 - ) - ) - (block $compile_store.25 - (local.set $14 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $6) - ) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $25 - (i32.load offset=12 - (local.get $14) - ) - ) - (block $do_backpatches.26 - ) - ) - (block $compile_store.29 - (local.set $26 - (i32.shr_s - (local.get $25) - (i32.const 1) - ) - ) - (block $do_backpatches.28 - ) - ) - (block $compile_store.31 - (local.set $27 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $26) - (i32.const 0) + (block $switch.20_outer (result i32) + (block $switch.20_branch_0 (result i32) + (drop + (block $switch.20_branch_1 (result i32) + (drop + (block $switch.20_branch_2 (result i32) + (drop + (block $switch.20_default (result i32) + (br_table $switch.20_branch_2 $switch.20_branch_1 $switch.20_default $switch.20_default + (i32.const 0) + (local.get $21) + ) + ) + ) + (br $switch.20_outer + (block $compile_block.77 (result i32) + (unreachable) + ) + ) ) ) - ) - (block $do_backpatches.30 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $27) - (i32.const 31) - ) - (block $compile_block.69 (result i32) - (block $compile_store.34 - (local.set $15 + (br $switch.20_outer + (block $compile_block.76 (result i32) + (block $compile_store.23 + (local.set $13 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $14) + (local.get $6) ) ) ) - (block $do_backpatches.33 + (block $do_backpatches.22 ) ) - (block $compile_store.36 - (local.set $16 + (block $compile_store.25 + (local.set $14 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $14) + (local.get $6) ) ) ) - (block $do_backpatches.35 + (block $do_backpatches.24 ) ) - (block $compile_store.38 - (local.set $29 + (block $compile_store.27 + (local.set $23 (i32.load offset=12 - (local.get $16) + (local.get $14) ) ) - (block $do_backpatches.37 + (block $do_backpatches.26 ) ) - (block $compile_store.40 - (local.set $30 + (block $compile_store.29 + (local.set $24 (i32.shr_s - (local.get $29) + (local.get $23) (i32.const 1) ) ) - (block $do_backpatches.39 + (block $do_backpatches.28 ) ) - (block $compile_store.42 - (local.set $31 + (block $compile_store.31 + (local.set $25 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $30) + (local.get $24) (i32.const 0) ) ) ) - (block $do_backpatches.41 + (block $do_backpatches.30 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $31) + (local.get $25) (i32.const 31) ) - (block $compile_block.61 (result i32) - (block $compile_store.45 - (local.set $17 + (block $compile_block.69 (result i32) + (block $compile_store.34 + (local.set $15 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $16) + (local.get $14) ) ) ) - (block $do_backpatches.44 + (block $do_backpatches.33 ) ) - (block $compile_store.47 - (local.set $18 + (block $compile_store.36 + (local.set $16 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $16) + (local.get $14) ) ) ) - (block $do_backpatches.46 + (block $do_backpatches.35 ) ) - (block $compile_store.49 - (local.set $33 + (block $compile_store.38 + (local.set $27 (i32.load offset=12 - (local.get $18) + (local.get $16) ) ) - (block $do_backpatches.48 + (block $do_backpatches.37 ) ) - (block $cleanup.50 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - ) - (block $compile_store.52 - (local.set $34 + (block $compile_store.40 + (local.set $28 (i32.shr_s - (local.get $33) + (local.get $27) (i32.const 1) ) ) - (block $do_backpatches.51 + (block $do_backpatches.39 ) ) - (block $compile_store.54 - (local.set $35 + (block $compile_store.42 + (local.set $29 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $34) - (i32.const 1) + (local.get $28) + (i32.const 0) ) ) ) - (block $do_backpatches.53 + (block $do_backpatches.41 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $35) + (local.get $29) (i32.const 31) ) - (block $compile_block.59 (result i32) - (drop - (block $compile_set.56 (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) - ) - ) + (block $compile_block.61 (result i32) + (block $compile_store.45 + (local.set $17 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=20 + (local.get $16) + ) + ) + ) + (block $do_backpatches.44 + ) + ) + (block $compile_store.47 + (local.set $18 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=24 + (local.get $16) + ) + ) + ) + (block $do_backpatches.46 + ) + ) + (block $compile_store.49 + (local.set $31 + (i32.load offset=12 + (local.get $18) + ) + ) + (block $do_backpatches.48 + ) + ) + (block $cleanup.50 + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $18) + ) + ) + ) + (block $compile_store.52 + (local.set $32 + (i32.shr_s + (local.get $31) + (i32.const 1) + ) + ) + (block $do_backpatches.51 + ) + ) + (block $compile_store.54 + (local.set $33 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $32) + (i32.const 1) ) ) - (i32.const 1879048190) + ) + (block $do_backpatches.53 ) ) - (drop - (block $compile_set.57 (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) + (tuple.extract 0 + (tuple.make + (if (result i32) + (i32.shr_u + (local.get $33) + (i32.const 31) + ) + (block $compile_block.59 (result i32) + (drop + (block $compile_set.56 (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) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) + ) + (drop + (block $compile_set.57 (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.58 (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 3) + ) + (block $compile_block.60 (result i32) + (i32.const 4) + ) + ) + (block $cleanup.55 (result i32) + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $17) + ) + ) + (i32.const 1879048190) + ) + ) + ) + ) + (block $compile_block.68 (result i32) + (block $compile_store.63 + (local.set $30 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $28) + (i32.const 1) ) ) - (i32.const 1879048190) + ) + (block $do_backpatches.62 ) ) - (drop - (block $compile_set.58 (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) + (if (result i32) + (i32.shr_u + (local.get $30) + (i32.const 31) + ) + (block $compile_block.66 (result i32) + (drop + (block $compile_set.64 (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) + ) ) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) + ) + (i32.const 1879048190) + ) + ) + (drop + (block $compile_set.65 (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 1879048190) + (i32.const 2) + ) + (block $compile_block.67 (result i32) + (i32.const 4) ) ) - (i32.const 3) - ) - (block $compile_block.60 (result i32) - (i32.const 4) ) ) - (block $cleanup.55 (result i32) + (block $cleanup.43 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) + (local.get $15) + ) + ) + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $16) ) ) (i32.const 1879048190) @@ -467,30 +559,30 @@ pattern matching › adt_match_1 ) ) ) - (block $compile_block.68 (result i32) - (block $compile_store.63 - (local.set $32 + (block $compile_block.75 (result i32) + (block $compile_store.71 + (local.set $26 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $30) + (local.get $24) (i32.const 1) ) ) ) - (block $do_backpatches.62 + (block $do_backpatches.70 ) ) (if (result i32) (i32.shr_u - (local.get $32) + (local.get $26) (i32.const 31) ) - (block $compile_block.66 (result i32) + (block $compile_block.73 (result i32) (drop - (block $compile_set.64 (result i32) - (local.set $8 + (block $compile_set.72 (result i32) + (local.set $7 (tuple.extract 0 (tuple.make (call $incRef_0 @@ -502,29 +594,7 @@ pattern matching › adt_match_1 ) (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.65 (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) + (local.get $7) ) ) ) @@ -532,25 +602,25 @@ pattern matching › adt_match_1 (i32.const 1879048190) ) ) - (i32.const 2) + (i32.const 1) ) - (block $compile_block.67 (result i32) + (block $compile_block.74 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.43 (result i32) + (block $cleanup.32 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) + (local.get $13) ) ) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) + (local.get $14) ) ) (i32.const 1879048190) @@ -558,109 +628,21 @@ pattern matching › adt_match_1 ) ) ) - (block $compile_block.75 (result i32) - (block $compile_store.71 - (local.set $28 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $26) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.70 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $28) - (i32.const 31) - ) - (block $compile_block.73 (result i32) - (drop - (block $compile_set.72 (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 1) - ) - (block $compile_block.74 (result i32) - (i32.const 4) - ) - ) - ) - ) - (block $cleanup.32 (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.81 (result i32) - (block $compile_store.78 - (local.set $24 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $21) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.77 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $24) - (i32.const 31) - ) - (block $compile_block.79 (result i32) + (br $switch.20_outer + (block $compile_block.21 (result i32) (i32.const 0) ) - (block $compile_block.80 - (unreachable) - ) ) ) ) ) - (block $do_backpatches.82 + (block $do_backpatches.78 ) ) - (block $cleanup.84 + (block $cleanup.80 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -670,48 +652,48 @@ pattern matching › adt_match_1 ) (tuple.extract 0 (tuple.make - (block $switch.86_outer (result i32) - (block $switch.86_branch_0 (result i32) + (block $switch.82_outer (result i32) + (block $switch.82_branch_0 (result i32) (drop - (block $switch.86_branch_1 (result i32) + (block $switch.82_branch_1 (result i32) (drop - (block $switch.86_branch_2 (result i32) + (block $switch.82_branch_2 (result i32) (drop - (block $switch.86_branch_3 (result i32) + (block $switch.82_branch_3 (result i32) (drop - (block $switch.86_branch_4 (result i32) + (block $switch.82_branch_4 (result i32) (drop - (block $switch.86_branch_5 (result i32) + (block $switch.82_branch_5 (result i32) (drop - (block $switch.86_default (result i32) - (br_table $switch.86_branch_1 $switch.86_branch_2 $switch.86_branch_3 $switch.86_branch_4 $switch.86_branch_5 $switch.86_default $switch.86_default + (block $switch.82_default (result i32) + (br_table $switch.82_branch_1 $switch.82_branch_2 $switch.82_branch_3 $switch.82_branch_4 $switch.82_branch_5 $switch.82_default $switch.82_default (i32.const 0) - (local.get $23) + (local.get $22) ) ) ) - (br $switch.86_outer - (block $compile_block.96 (result i32) + (br $switch.82_outer + (block $compile_block.92 (result i32) (unreachable) ) ) ) ) - (br $switch.86_outer - (block $compile_block.95 (result i32) + (br $switch.82_outer + (block $compile_block.91 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.86_outer - (block $compile_block.94 - (block $compile_store.92 + (br $switch.82_outer + (block $compile_block.90 + (block $compile_store.88 (local.set $19 - (call $+_1147 + (call $+_1145 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1147) + (global.get $+_1145) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -723,10 +705,10 @@ pattern matching › adt_match_1 ) ) ) - (block $do_backpatches.91 + (block $do_backpatches.87 ) ) - (block $cleanup.93 + (block $cleanup.89 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -758,10 +740,10 @@ pattern matching › adt_match_1 ) ) ) - (return_call $+_1147 + (return_call $+_1145 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1147) + (global.get $+_1145) ) (local.get $19) (local.get $12) @@ -770,9 +752,9 @@ pattern matching › adt_match_1 ) ) ) - (br $switch.86_outer - (block $compile_block.90 - (block $cleanup.89 + (br $switch.82_outer + (block $compile_block.86 + (block $cleanup.85 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -798,10 +780,10 @@ pattern matching › adt_match_1 ) ) ) - (return_call $+_1147 + (return_call $+_1145 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1147) + (global.get $+_1145) ) (local.get $8) (local.get $9) @@ -810,8 +792,8 @@ pattern matching › adt_match_1 ) ) ) - (br $switch.86_outer - (block $compile_block.88 (result i32) + (br $switch.82_outer + (block $compile_block.84 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $7) @@ -820,14 +802,14 @@ pattern matching › adt_match_1 ) ) ) - (br $switch.86_outer - (block $compile_block.87 (result i32) + (br $switch.82_outer + (block $compile_block.83 (result i32) (i32.const 1) ) ) ) ) - (block $cleanup.85 (result i32) + (block $cleanup.81 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot b/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot index e3b4e1f27..9c0f3165f 100644 --- a/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot @@ -13,11 +13,11 @@ pattern matching › adt_match_2 (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$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 $+_1149 (param i32 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)) @@ -61,9 +61,7 @@ pattern matching › adt_match_2 (local $32 i32) (local $33 i32) (local $34 i32) - (local $35 i32) - (local $36 i32) - (block $compile_block.100 (result i32) + (block $compile_block.96 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -201,308 +199,402 @@ pattern matching › adt_match_2 (block $do_backpatches.21 ) ) - (block $compile_store.24 + (block $compile_store.82 (local.set $23 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $22) - (i32.const 0) - ) - ) - ) - (block $do_backpatches.23 - ) - ) - (block $compile_store.86 - (local.set $24 - (if (result i32) - (i32.shr_u - (local.get $23) - (i32.const 31) - ) - (block $compile_block.79 (result i32) - (block $compile_store.26 - (local.set $14 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $7) - ) - ) - ) - (block $do_backpatches.25 - ) - ) - (block $compile_store.28 - (local.set $15 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $7) - ) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $compile_store.30 - (local.set $26 - (i32.load offset=12 - (local.get $15) - ) - ) - (block $do_backpatches.29 - ) - ) - (block $compile_store.32 - (local.set $27 - (i32.shr_s - (local.get $26) - (i32.const 1) - ) - ) - (block $do_backpatches.31 - ) - ) - (block $compile_store.34 - (local.set $28 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $27) - (i32.const 0) + (block $switch.23_outer (result i32) + (block $switch.23_branch_0 (result i32) + (drop + (block $switch.23_branch_1 (result i32) + (drop + (block $switch.23_branch_2 (result i32) + (drop + (block $switch.23_default (result i32) + (br_table $switch.23_branch_2 $switch.23_branch_1 $switch.23_default $switch.23_default + (i32.const 0) + (local.get $22) + ) + ) + ) + (br $switch.23_outer + (block $compile_block.80 (result i32) + (unreachable) + ) + ) ) ) - ) - (block $do_backpatches.33 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $28) - (i32.const 31) - ) - (block $compile_block.72 (result i32) - (block $compile_store.37 - (local.set $16 + (br $switch.23_outer + (block $compile_block.79 (result i32) + (block $compile_store.26 + (local.set $14 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $15) + (local.get $7) ) ) ) - (block $do_backpatches.36 + (block $do_backpatches.25 ) ) - (block $compile_store.39 - (local.set $17 + (block $compile_store.28 + (local.set $15 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $15) + (local.get $7) ) ) ) - (block $do_backpatches.38 + (block $do_backpatches.27 ) ) - (block $compile_store.41 - (local.set $30 + (block $compile_store.30 + (local.set $24 (i32.load offset=12 - (local.get $17) + (local.get $15) ) ) - (block $do_backpatches.40 + (block $do_backpatches.29 ) ) - (block $compile_store.43 - (local.set $31 + (block $compile_store.32 + (local.set $25 (i32.shr_s - (local.get $30) + (local.get $24) (i32.const 1) ) ) - (block $do_backpatches.42 + (block $do_backpatches.31 ) ) - (block $compile_store.45 - (local.set $32 + (block $compile_store.34 + (local.set $26 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $31) + (local.get $25) (i32.const 0) ) ) ) - (block $do_backpatches.44 + (block $do_backpatches.33 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $32) + (local.get $26) (i32.const 31) ) - (block $compile_block.64 (result i32) - (block $compile_store.48 - (local.set $18 + (block $compile_block.72 (result i32) + (block $compile_store.37 + (local.set $16 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $17) + (local.get $15) ) ) ) - (block $do_backpatches.47 + (block $do_backpatches.36 ) ) - (block $compile_store.50 - (local.set $19 + (block $compile_store.39 + (local.set $17 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $17) + (local.get $15) ) ) ) - (block $do_backpatches.49 + (block $do_backpatches.38 ) ) - (block $compile_store.52 - (local.set $34 + (block $compile_store.41 + (local.set $28 (i32.load offset=12 - (local.get $19) + (local.get $17) ) ) - (block $do_backpatches.51 + (block $do_backpatches.40 ) ) - (block $cleanup.53 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - ) - (block $compile_store.55 - (local.set $35 + (block $compile_store.43 + (local.set $29 (i32.shr_s - (local.get $34) + (local.get $28) (i32.const 1) ) ) - (block $do_backpatches.54 + (block $do_backpatches.42 ) ) - (block $compile_store.57 - (local.set $36 + (block $compile_store.45 + (local.set $30 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $35) - (i32.const 1) + (local.get $29) + (i32.const 0) ) ) ) - (block $do_backpatches.56 + (block $do_backpatches.44 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $36) + (local.get $30) (i32.const 31) ) - (block $compile_block.62 (result i32) - (drop - (block $compile_set.59 (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) - ) - ) + (block $compile_block.64 (result i32) + (block $compile_store.48 + (local.set $18 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=20 + (local.get $17) + ) + ) + ) + (block $do_backpatches.47 + ) + ) + (block $compile_store.50 + (local.set $19 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=24 + (local.get $17) + ) + ) + ) + (block $do_backpatches.49 + ) + ) + (block $compile_store.52 + (local.set $32 + (i32.load offset=12 + (local.get $19) + ) + ) + (block $do_backpatches.51 + ) + ) + (block $cleanup.53 + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $19) + ) + ) + ) + (block $compile_store.55 + (local.set $33 + (i32.shr_s + (local.get $32) + (i32.const 1) + ) + ) + (block $do_backpatches.54 + ) + ) + (block $compile_store.57 + (local.set $34 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $33) + (i32.const 1) ) ) - (i32.const 1879048190) + ) + (block $do_backpatches.56 ) ) - (drop - (block $compile_set.60 (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) + (tuple.extract 0 + (tuple.make + (if (result i32) + (i32.shr_u + (local.get $34) + (i32.const 31) + ) + (block $compile_block.62 (result i32) + (drop + (block $compile_set.59 (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) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) + ) + (drop + (block $compile_set.60 (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.61 (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 3) + ) + (block $compile_block.63 (result i32) + (i32.const 4) + ) + ) + (block $cleanup.58 (result i32) + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $18) + ) + ) + (i32.const 1879048190) + ) + ) + ) + ) + (block $compile_block.71 (result i32) + (block $compile_store.66 + (local.set $31 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $29) + (i32.const 1) ) ) - (i32.const 1879048190) + ) + (block $do_backpatches.65 ) ) - (drop - (block $compile_set.61 (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) + (if (result i32) + (i32.shr_u + (local.get $31) + (i32.const 31) + ) + (block $compile_block.69 (result i32) + (drop + (block $compile_set.67 (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) + ) ) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) + ) + (i32.const 1879048190) + ) + ) + (drop + (block $compile_set.68 (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 1879048190) + (i32.const 2) + ) + (block $compile_block.70 (result i32) + (i32.const 4) ) ) - (i32.const 3) - ) - (block $compile_block.63 (result i32) - (i32.const 4) ) ) - (block $cleanup.58 (result i32) + (block $cleanup.46 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) + (local.get $16) + ) + ) + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $17) ) ) (i32.const 1879048190) @@ -510,30 +602,30 @@ pattern matching › adt_match_2 ) ) ) - (block $compile_block.71 (result i32) - (block $compile_store.66 - (local.set $33 + (block $compile_block.78 (result i32) + (block $compile_store.74 + (local.set $27 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $31) + (local.get $25) (i32.const 1) ) ) ) - (block $do_backpatches.65 + (block $do_backpatches.73 ) ) (if (result i32) (i32.shr_u - (local.get $33) + (local.get $27) (i32.const 31) ) - (block $compile_block.69 (result i32) + (block $compile_block.76 (result i32) (drop - (block $compile_set.67 (result i32) - (local.set $9 + (block $compile_set.75 (result i32) + (local.set $8 (tuple.extract 0 (tuple.make (call $incRef_0 @@ -545,29 +637,7 @@ pattern matching › adt_match_2 ) (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.68 (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) + (local.get $8) ) ) ) @@ -575,25 +645,25 @@ pattern matching › adt_match_2 (i32.const 1879048190) ) ) - (i32.const 2) + (i32.const 1) ) - (block $compile_block.70 (result i32) + (block $compile_block.77 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.46 (result i32) + (block $cleanup.35 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) + (local.get $14) ) ) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) + (local.get $15) ) ) (i32.const 1879048190) @@ -601,109 +671,21 @@ pattern matching › adt_match_2 ) ) ) - (block $compile_block.78 (result i32) - (block $compile_store.74 - (local.set $29 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $27) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.73 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $29) - (i32.const 31) - ) - (block $compile_block.76 (result i32) - (drop - (block $compile_set.75 (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 1) - ) - (block $compile_block.77 (result i32) - (i32.const 4) - ) - ) - ) - ) - (block $cleanup.35 (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.84 (result i32) - (block $compile_store.81 - (local.set $25 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $22) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.80 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $25) - (i32.const 31) - ) - (block $compile_block.82 (result i32) + (br $switch.23_outer + (block $compile_block.24 (result i32) (i32.const 0) ) - (block $compile_block.83 - (unreachable) - ) ) ) ) ) - (block $do_backpatches.85 + (block $do_backpatches.81 ) ) - (block $cleanup.87 + (block $cleanup.83 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -713,48 +695,48 @@ pattern matching › adt_match_2 ) (tuple.extract 0 (tuple.make - (block $switch.89_outer (result i32) - (block $switch.89_branch_0 (result i32) + (block $switch.85_outer (result i32) + (block $switch.85_branch_0 (result i32) (drop - (block $switch.89_branch_1 (result i32) + (block $switch.85_branch_1 (result i32) (drop - (block $switch.89_branch_2 (result i32) + (block $switch.85_branch_2 (result i32) (drop - (block $switch.89_branch_3 (result i32) + (block $switch.85_branch_3 (result i32) (drop - (block $switch.89_branch_4 (result i32) + (block $switch.85_branch_4 (result i32) (drop - (block $switch.89_branch_5 (result i32) + (block $switch.85_branch_5 (result i32) (drop - (block $switch.89_default (result i32) - (br_table $switch.89_branch_1 $switch.89_branch_2 $switch.89_branch_3 $switch.89_branch_4 $switch.89_branch_5 $switch.89_default $switch.89_default + (block $switch.85_default (result i32) + (br_table $switch.85_branch_1 $switch.85_branch_2 $switch.85_branch_3 $switch.85_branch_4 $switch.85_branch_5 $switch.85_default $switch.85_default (i32.const 0) - (local.get $24) + (local.get $23) ) ) ) - (br $switch.89_outer - (block $compile_block.99 (result i32) + (br $switch.85_outer + (block $compile_block.95 (result i32) (unreachable) ) ) ) ) - (br $switch.89_outer - (block $compile_block.98 (result i32) + (br $switch.85_outer + (block $compile_block.94 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.89_outer - (block $compile_block.97 - (block $compile_store.95 + (br $switch.85_outer + (block $compile_block.93 + (block $compile_store.91 (local.set $20 - (call $+_1149 + (call $+_1147 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) + (global.get $+_1147) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -766,10 +748,10 @@ pattern matching › adt_match_2 ) ) ) - (block $do_backpatches.94 + (block $do_backpatches.90 ) ) - (block $cleanup.96 + (block $cleanup.92 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -801,10 +783,10 @@ pattern matching › adt_match_2 ) ) ) - (return_call $+_1149 + (return_call $+_1147 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) + (global.get $+_1147) ) (local.get $20) (local.get $13) @@ -813,9 +795,9 @@ pattern matching › adt_match_2 ) ) ) - (br $switch.89_outer - (block $compile_block.93 - (block $cleanup.92 + (br $switch.85_outer + (block $compile_block.89 + (block $cleanup.88 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -841,10 +823,10 @@ pattern matching › adt_match_2 ) ) ) - (return_call $+_1149 + (return_call $+_1147 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) + (global.get $+_1147) ) (local.get $9) (local.get $10) @@ -853,8 +835,8 @@ pattern matching › adt_match_2 ) ) ) - (br $switch.89_outer - (block $compile_block.91 (result i32) + (br $switch.85_outer + (block $compile_block.87 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $8) @@ -863,14 +845,14 @@ pattern matching › adt_match_2 ) ) ) - (br $switch.89_outer - (block $compile_block.90 (result i32) + (br $switch.85_outer + (block $compile_block.86 (result i32) (i32.const 1) ) ) ) ) - (block $cleanup.88 (result i32) + (block $cleanup.84 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot b/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot index 98d0e4f88..84e9b91c0 100644 --- a/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot @@ -13,11 +13,11 @@ pattern matching › adt_match_3 (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$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 $+_1151 (param i32 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)) @@ -62,9 +62,7 @@ pattern matching › adt_match_3 (local $33 i32) (local $34 i32) (local $35 i32) - (local $36 i32) - (local $37 i32) - (block $compile_block.103 (result i32) + (block $compile_block.99 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -244,308 +242,402 @@ pattern matching › adt_match_3 (block $do_backpatches.24 ) ) - (block $compile_store.27 + (block $compile_store.85 (local.set $24 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $23) - (i32.const 0) - ) - ) - ) - (block $do_backpatches.26 - ) - ) - (block $compile_store.89 - (local.set $25 - (if (result i32) - (i32.shr_u - (local.get $24) - (i32.const 31) - ) - (block $compile_block.82 (result i32) - (block $compile_store.29 - (local.set $15 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $8) - ) - ) - ) - (block $do_backpatches.28 - ) - ) - (block $compile_store.31 - (local.set $16 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $8) - ) - ) - ) - (block $do_backpatches.30 - ) - ) - (block $compile_store.33 - (local.set $27 - (i32.load offset=12 - (local.get $16) - ) - ) - (block $do_backpatches.32 - ) - ) - (block $compile_store.35 - (local.set $28 - (i32.shr_s - (local.get $27) - (i32.const 1) - ) - ) - (block $do_backpatches.34 - ) - ) - (block $compile_store.37 - (local.set $29 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $28) - (i32.const 0) + (block $switch.26_outer (result i32) + (block $switch.26_branch_0 (result i32) + (drop + (block $switch.26_branch_1 (result i32) + (drop + (block $switch.26_branch_2 (result i32) + (drop + (block $switch.26_default (result i32) + (br_table $switch.26_branch_2 $switch.26_branch_1 $switch.26_default $switch.26_default + (i32.const 0) + (local.get $23) + ) + ) + ) + (br $switch.26_outer + (block $compile_block.83 (result i32) + (unreachable) + ) + ) ) ) - ) - (block $do_backpatches.36 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $29) - (i32.const 31) - ) - (block $compile_block.75 (result i32) - (block $compile_store.40 - (local.set $17 + (br $switch.26_outer + (block $compile_block.82 (result i32) + (block $compile_store.29 + (local.set $15 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $16) + (local.get $8) ) ) ) - (block $do_backpatches.39 + (block $do_backpatches.28 ) ) - (block $compile_store.42 - (local.set $18 + (block $compile_store.31 + (local.set $16 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $16) + (local.get $8) ) ) ) - (block $do_backpatches.41 + (block $do_backpatches.30 ) ) - (block $compile_store.44 - (local.set $31 + (block $compile_store.33 + (local.set $25 (i32.load offset=12 - (local.get $18) + (local.get $16) ) ) - (block $do_backpatches.43 + (block $do_backpatches.32 ) ) - (block $compile_store.46 - (local.set $32 + (block $compile_store.35 + (local.set $26 (i32.shr_s - (local.get $31) + (local.get $25) (i32.const 1) ) ) - (block $do_backpatches.45 + (block $do_backpatches.34 ) ) - (block $compile_store.48 - (local.set $33 + (block $compile_store.37 + (local.set $27 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $32) + (local.get $26) (i32.const 0) ) ) ) - (block $do_backpatches.47 + (block $do_backpatches.36 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $33) + (local.get $27) (i32.const 31) ) - (block $compile_block.67 (result i32) - (block $compile_store.51 - (local.set $19 + (block $compile_block.75 (result i32) + (block $compile_store.40 + (local.set $17 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $18) + (local.get $16) ) ) ) - (block $do_backpatches.50 + (block $do_backpatches.39 ) ) - (block $compile_store.53 - (local.set $20 + (block $compile_store.42 + (local.set $18 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $18) + (local.get $16) ) ) ) - (block $do_backpatches.52 + (block $do_backpatches.41 ) ) - (block $compile_store.55 - (local.set $35 + (block $compile_store.44 + (local.set $29 (i32.load offset=12 - (local.get $20) + (local.get $18) ) ) - (block $do_backpatches.54 + (block $do_backpatches.43 ) ) - (block $cleanup.56 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - ) - (block $compile_store.58 - (local.set $36 + (block $compile_store.46 + (local.set $30 (i32.shr_s - (local.get $35) + (local.get $29) (i32.const 1) ) ) - (block $do_backpatches.57 + (block $do_backpatches.45 ) ) - (block $compile_store.60 - (local.set $37 + (block $compile_store.48 + (local.set $31 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $36) - (i32.const 1) + (local.get $30) + (i32.const 0) ) ) ) - (block $do_backpatches.59 + (block $do_backpatches.47 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $37) + (local.get $31) (i32.const 31) ) - (block $compile_block.65 (result i32) - (drop - (block $compile_set.62 (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) - ) - ) + (block $compile_block.67 (result i32) + (block $compile_store.51 + (local.set $19 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=20 + (local.get $18) + ) + ) + ) + (block $do_backpatches.50 + ) + ) + (block $compile_store.53 + (local.set $20 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=24 + (local.get $18) + ) + ) + ) + (block $do_backpatches.52 + ) + ) + (block $compile_store.55 + (local.set $33 + (i32.load offset=12 + (local.get $20) + ) + ) + (block $do_backpatches.54 + ) + ) + (block $cleanup.56 + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $20) + ) + ) + ) + (block $compile_store.58 + (local.set $34 + (i32.shr_s + (local.get $33) + (i32.const 1) + ) + ) + (block $do_backpatches.57 + ) + ) + (block $compile_store.60 + (local.set $35 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $34) + (i32.const 1) ) ) - (i32.const 1879048190) + ) + (block $do_backpatches.59 ) ) - (drop - (block $compile_set.63 (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) + (tuple.extract 0 + (tuple.make + (if (result i32) + (i32.shr_u + (local.get $35) + (i32.const 31) + ) + (block $compile_block.65 (result i32) + (drop + (block $compile_set.62 (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) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) + ) + (drop + (block $compile_set.63 (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.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 $19) + ) + ) + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $14) + ) + ) + ) + ) + (i32.const 1879048190) + ) + ) + (i32.const 3) + ) + (block $compile_block.66 (result i32) + (i32.const 4) + ) + ) + (block $cleanup.61 (result i32) + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $19) + ) + ) + (i32.const 1879048190) + ) + ) + ) + ) + (block $compile_block.74 (result i32) + (block $compile_store.69 + (local.set $32 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $30) + (i32.const 1) ) ) - (i32.const 1879048190) + ) + (block $do_backpatches.68 ) ) - (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 $19) + (if (result i32) + (i32.shr_u + (local.get $32) + (i32.const 31) + ) + (block $compile_block.72 (result i32) + (drop + (block $compile_set.70 (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) + ) ) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) + ) + (i32.const 1879048190) + ) + ) + (drop + (block $compile_set.71 (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 1879048190) + (i32.const 2) + ) + (block $compile_block.73 (result i32) + (i32.const 4) ) ) - (i32.const 3) - ) - (block $compile_block.66 (result i32) - (i32.const 4) ) ) - (block $cleanup.61 (result i32) + (block $cleanup.49 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) + (local.get $17) + ) + ) + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $18) ) ) (i32.const 1879048190) @@ -553,30 +645,30 @@ pattern matching › adt_match_3 ) ) ) - (block $compile_block.74 (result i32) - (block $compile_store.69 - (local.set $34 + (block $compile_block.81 (result i32) + (block $compile_store.77 + (local.set $28 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $32) + (local.get $26) (i32.const 1) ) ) ) - (block $do_backpatches.68 + (block $do_backpatches.76 ) ) (if (result i32) (i32.shr_u - (local.get $34) + (local.get $28) (i32.const 31) ) - (block $compile_block.72 (result i32) + (block $compile_block.79 (result i32) (drop - (block $compile_set.70 (result i32) - (local.set $10 + (block $compile_set.78 (result i32) + (local.set $9 (tuple.extract 0 (tuple.make (call $incRef_0 @@ -588,29 +680,7 @@ pattern matching › adt_match_3 ) (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.71 (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) + (local.get $9) ) ) ) @@ -618,25 +688,25 @@ pattern matching › adt_match_3 (i32.const 1879048190) ) ) - (i32.const 2) + (i32.const 1) ) - (block $compile_block.73 (result i32) + (block $compile_block.80 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.49 (result i32) + (block $cleanup.38 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) + (local.get $15) ) ) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) + (local.get $16) ) ) (i32.const 1879048190) @@ -644,109 +714,21 @@ pattern matching › adt_match_3 ) ) ) - (block $compile_block.81 (result i32) - (block $compile_store.77 - (local.set $30 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $28) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.76 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $30) - (i32.const 31) - ) - (block $compile_block.79 (result i32) - (drop - (block $compile_set.78 (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 1) - ) - (block $compile_block.80 (result i32) - (i32.const 4) - ) - ) - ) - ) - (block $cleanup.38 (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.87 (result i32) - (block $compile_store.84 - (local.set $26 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $23) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.83 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $26) - (i32.const 31) - ) - (block $compile_block.85 (result i32) + (br $switch.26_outer + (block $compile_block.27 (result i32) (i32.const 0) ) - (block $compile_block.86 - (unreachable) - ) ) ) ) ) - (block $do_backpatches.88 + (block $do_backpatches.84 ) ) - (block $cleanup.90 + (block $cleanup.86 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -756,48 +738,48 @@ pattern matching › adt_match_3 ) (tuple.extract 0 (tuple.make - (block $switch.92_outer (result i32) - (block $switch.92_branch_0 (result i32) + (block $switch.88_outer (result i32) + (block $switch.88_branch_0 (result i32) (drop - (block $switch.92_branch_1 (result i32) + (block $switch.88_branch_1 (result i32) (drop - (block $switch.92_branch_2 (result i32) + (block $switch.88_branch_2 (result i32) (drop - (block $switch.92_branch_3 (result i32) + (block $switch.88_branch_3 (result i32) (drop - (block $switch.92_branch_4 (result i32) + (block $switch.88_branch_4 (result i32) (drop - (block $switch.92_branch_5 (result i32) + (block $switch.88_branch_5 (result i32) (drop - (block $switch.92_default (result i32) - (br_table $switch.92_branch_1 $switch.92_branch_2 $switch.92_branch_3 $switch.92_branch_4 $switch.92_branch_5 $switch.92_default $switch.92_default + (block $switch.88_default (result i32) + (br_table $switch.88_branch_1 $switch.88_branch_2 $switch.88_branch_3 $switch.88_branch_4 $switch.88_branch_5 $switch.88_default $switch.88_default (i32.const 0) - (local.get $25) + (local.get $24) ) ) ) - (br $switch.92_outer - (block $compile_block.102 (result i32) + (br $switch.88_outer + (block $compile_block.98 (result i32) (unreachable) ) ) ) ) - (br $switch.92_outer - (block $compile_block.101 (result i32) + (br $switch.88_outer + (block $compile_block.97 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.92_outer - (block $compile_block.100 - (block $compile_store.98 + (br $switch.88_outer + (block $compile_block.96 + (block $compile_store.94 (local.set $21 - (call $+_1151 + (call $+_1149 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) + (global.get $+_1149) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -809,10 +791,10 @@ pattern matching › adt_match_3 ) ) ) - (block $do_backpatches.97 + (block $do_backpatches.93 ) ) - (block $cleanup.99 + (block $cleanup.95 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -844,10 +826,10 @@ pattern matching › adt_match_3 ) ) ) - (return_call $+_1151 + (return_call $+_1149 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) + (global.get $+_1149) ) (local.get $21) (local.get $14) @@ -856,9 +838,9 @@ pattern matching › adt_match_3 ) ) ) - (br $switch.92_outer - (block $compile_block.96 - (block $cleanup.95 + (br $switch.88_outer + (block $compile_block.92 + (block $cleanup.91 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -884,10 +866,10 @@ pattern matching › adt_match_3 ) ) ) - (return_call $+_1151 + (return_call $+_1149 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) + (global.get $+_1149) ) (local.get $10) (local.get $11) @@ -896,8 +878,8 @@ pattern matching › adt_match_3 ) ) ) - (br $switch.92_outer - (block $compile_block.94 (result i32) + (br $switch.88_outer + (block $compile_block.90 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $9) @@ -906,14 +888,14 @@ pattern matching › adt_match_3 ) ) ) - (br $switch.92_outer - (block $compile_block.93 (result i32) + (br $switch.88_outer + (block $compile_block.89 (result i32) (i32.const 1) ) ) ) ) - (block $cleanup.91 (result i32) + (block $cleanup.87 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot b/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot index 67263a2d7..bcd08f607 100644 --- a/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot @@ -13,11 +13,11 @@ pattern matching › adt_match_5 (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$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 $+_1155 (param i32 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)) @@ -64,9 +64,7 @@ pattern matching › adt_match_5 (local $35 i32) (local $36 i32) (local $37 i32) - (local $38 i32) - (local $39 i32) - (block $compile_block.109 (result i32) + (block $compile_block.105 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -330,308 +328,402 @@ pattern matching › adt_match_5 (block $do_backpatches.30 ) ) - (block $compile_store.33 + (block $compile_store.91 (local.set $26 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $25) - (i32.const 0) - ) - ) - ) - (block $do_backpatches.32 - ) - ) - (block $compile_store.95 - (local.set $27 - (if (result i32) - (i32.shr_u - (local.get $26) - (i32.const 31) - ) - (block $compile_block.88 (result i32) - (block $compile_store.35 - (local.set $17 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $10) - ) - ) - ) - (block $do_backpatches.34 - ) - ) - (block $compile_store.37 - (local.set $18 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $10) - ) - ) - ) - (block $do_backpatches.36 - ) - ) - (block $compile_store.39 - (local.set $29 - (i32.load offset=12 - (local.get $18) - ) - ) - (block $do_backpatches.38 - ) - ) - (block $compile_store.41 - (local.set $30 - (i32.shr_s - (local.get $29) - (i32.const 1) - ) - ) - (block $do_backpatches.40 - ) - ) - (block $compile_store.43 - (local.set $31 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $30) - (i32.const 0) + (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_2 $switch.32_branch_1 $switch.32_default $switch.32_default + (i32.const 0) + (local.get $25) + ) + ) + ) + (br $switch.32_outer + (block $compile_block.89 (result i32) + (unreachable) + ) + ) ) ) - ) - (block $do_backpatches.42 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $31) - (i32.const 31) - ) - (block $compile_block.81 (result i32) - (block $compile_store.46 - (local.set $19 + (br $switch.32_outer + (block $compile_block.88 (result i32) + (block $compile_store.35 + (local.set $17 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $18) + (local.get $10) ) ) ) - (block $do_backpatches.45 + (block $do_backpatches.34 ) ) - (block $compile_store.48 - (local.set $20 + (block $compile_store.37 + (local.set $18 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $18) + (local.get $10) ) ) ) - (block $do_backpatches.47 + (block $do_backpatches.36 ) ) - (block $compile_store.50 - (local.set $33 + (block $compile_store.39 + (local.set $27 (i32.load offset=12 - (local.get $20) + (local.get $18) ) ) - (block $do_backpatches.49 + (block $do_backpatches.38 ) ) - (block $compile_store.52 - (local.set $34 + (block $compile_store.41 + (local.set $28 (i32.shr_s - (local.get $33) + (local.get $27) (i32.const 1) ) ) - (block $do_backpatches.51 + (block $do_backpatches.40 ) ) - (block $compile_store.54 - (local.set $35 + (block $compile_store.43 + (local.set $29 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $34) + (local.get $28) (i32.const 0) ) ) ) - (block $do_backpatches.53 + (block $do_backpatches.42 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $35) + (local.get $29) (i32.const 31) ) - (block $compile_block.73 (result i32) - (block $compile_store.57 - (local.set $21 + (block $compile_block.81 (result i32) + (block $compile_store.46 + (local.set $19 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $20) + (local.get $18) ) ) ) - (block $do_backpatches.56 + (block $do_backpatches.45 ) ) - (block $compile_store.59 - (local.set $22 + (block $compile_store.48 + (local.set $20 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $20) + (local.get $18) ) ) ) - (block $do_backpatches.58 + (block $do_backpatches.47 ) ) - (block $compile_store.61 - (local.set $37 + (block $compile_store.50 + (local.set $31 (i32.load offset=12 - (local.get $22) + (local.get $20) ) ) - (block $do_backpatches.60 + (block $do_backpatches.49 ) ) - (block $cleanup.62 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $22) - ) - ) - ) - (block $compile_store.64 - (local.set $38 + (block $compile_store.52 + (local.set $32 (i32.shr_s - (local.get $37) + (local.get $31) (i32.const 1) ) ) - (block $do_backpatches.63 + (block $do_backpatches.51 ) ) - (block $compile_store.66 - (local.set $39 + (block $compile_store.54 + (local.set $33 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $38) - (i32.const 1) + (local.get $32) + (i32.const 0) ) ) ) - (block $do_backpatches.65 + (block $do_backpatches.53 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $39) + (local.get $33) (i32.const 31) ) - (block $compile_block.71 (result i32) - (drop - (block $compile_set.68 (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) - ) - ) + (block $compile_block.73 (result i32) + (block $compile_store.57 + (local.set $21 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=20 + (local.get $20) + ) + ) + ) + (block $do_backpatches.56 + ) + ) + (block $compile_store.59 + (local.set $22 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=24 + (local.get $20) + ) + ) + ) + (block $do_backpatches.58 + ) + ) + (block $compile_store.61 + (local.set $35 + (i32.load offset=12 + (local.get $22) + ) + ) + (block $do_backpatches.60 + ) + ) + (block $cleanup.62 + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $22) + ) + ) + ) + (block $compile_store.64 + (local.set $36 + (i32.shr_s + (local.get $35) + (i32.const 1) + ) + ) + (block $do_backpatches.63 + ) + ) + (block $compile_store.66 + (local.set $37 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $36) + (i32.const 1) ) ) - (i32.const 1879048190) + ) + (block $do_backpatches.65 ) ) - (drop - (block $compile_set.69 (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) + (tuple.extract 0 + (tuple.make + (if (result i32) + (i32.shr_u + (local.get $37) + (i32.const 31) + ) + (block $compile_block.71 (result i32) + (drop + (block $compile_set.68 (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) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) + ) + (drop + (block $compile_set.69 (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.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 $21) + ) + ) + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $16) + ) + ) + ) + ) + (i32.const 1879048190) + ) + ) + (i32.const 3) + ) + (block $compile_block.72 (result i32) + (i32.const 4) + ) + ) + (block $cleanup.67 (result i32) + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $21) + ) + ) + (i32.const 1879048190) + ) + ) + ) + ) + (block $compile_block.80 (result i32) + (block $compile_store.75 + (local.set $34 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $32) + (i32.const 1) ) ) - (i32.const 1879048190) + ) + (block $do_backpatches.74 ) ) - (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 $21) + (if (result i32) + (i32.shr_u + (local.get $34) + (i32.const 31) + ) + (block $compile_block.78 (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 $17) + ) + ) + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $12) + ) ) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) + ) + (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 $19) + ) + ) + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $13) + ) + ) ) ) + (i32.const 1879048190) ) ) - (i32.const 1879048190) + (i32.const 2) + ) + (block $compile_block.79 (result i32) + (i32.const 4) ) ) - (i32.const 3) - ) - (block $compile_block.72 (result i32) - (i32.const 4) ) ) - (block $cleanup.67 (result i32) + (block $cleanup.55 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) + (local.get $19) + ) + ) + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $20) ) ) (i32.const 1879048190) @@ -639,30 +731,30 @@ pattern matching › adt_match_5 ) ) ) - (block $compile_block.80 (result i32) - (block $compile_store.75 - (local.set $36 + (block $compile_block.87 (result i32) + (block $compile_store.83 + (local.set $30 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $34) + (local.get $28) (i32.const 1) ) ) ) - (block $do_backpatches.74 + (block $do_backpatches.82 ) ) (if (result i32) (i32.shr_u - (local.get $36) + (local.get $30) (i32.const 31) ) - (block $compile_block.78 (result i32) + (block $compile_block.85 (result i32) (drop - (block $compile_set.76 (result i32) - (local.set $12 + (block $compile_set.84 (result i32) + (local.set $11 (tuple.extract 0 (tuple.make (call $incRef_0 @@ -674,29 +766,7 @@ pattern matching › adt_match_5 ) (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 $19) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) + (local.get $11) ) ) ) @@ -704,25 +774,25 @@ pattern matching › adt_match_5 (i32.const 1879048190) ) ) - (i32.const 2) + (i32.const 1) ) - (block $compile_block.79 (result i32) + (block $compile_block.86 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.55 (result i32) + (block $cleanup.44 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) + (local.get $17) ) ) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) + (local.get $18) ) ) (i32.const 1879048190) @@ -730,109 +800,21 @@ pattern matching › adt_match_5 ) ) ) - (block $compile_block.87 (result i32) - (block $compile_store.83 - (local.set $32 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $30) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.82 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $32) - (i32.const 31) - ) - (block $compile_block.85 (result i32) - (drop - (block $compile_set.84 (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 1) - ) - (block $compile_block.86 (result i32) - (i32.const 4) - ) - ) - ) - ) - (block $cleanup.44 (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.93 (result i32) - (block $compile_store.90 - (local.set $28 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $25) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.89 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $28) - (i32.const 31) - ) - (block $compile_block.91 (result i32) + (br $switch.32_outer + (block $compile_block.33 (result i32) (i32.const 0) ) - (block $compile_block.92 - (unreachable) - ) ) ) ) ) - (block $do_backpatches.94 + (block $do_backpatches.90 ) ) - (block $cleanup.96 + (block $cleanup.92 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -842,48 +824,48 @@ pattern matching › adt_match_5 ) (tuple.extract 0 (tuple.make - (block $switch.98_outer (result i32) - (block $switch.98_branch_0 (result i32) + (block $switch.94_outer (result i32) + (block $switch.94_branch_0 (result i32) (drop - (block $switch.98_branch_1 (result i32) + (block $switch.94_branch_1 (result i32) (drop - (block $switch.98_branch_2 (result i32) + (block $switch.94_branch_2 (result i32) (drop - (block $switch.98_branch_3 (result i32) + (block $switch.94_branch_3 (result i32) (drop - (block $switch.98_branch_4 (result i32) + (block $switch.94_branch_4 (result i32) (drop - (block $switch.98_branch_5 (result i32) + (block $switch.94_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 + (block $switch.94_default (result i32) + (br_table $switch.94_branch_1 $switch.94_branch_2 $switch.94_branch_3 $switch.94_branch_4 $switch.94_branch_5 $switch.94_default $switch.94_default (i32.const 0) - (local.get $27) + (local.get $26) ) ) ) - (br $switch.98_outer - (block $compile_block.108 (result i32) + (br $switch.94_outer + (block $compile_block.104 (result i32) (unreachable) ) ) ) ) - (br $switch.98_outer - (block $compile_block.107 (result i32) + (br $switch.94_outer + (block $compile_block.103 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.98_outer - (block $compile_block.106 - (block $compile_store.104 + (br $switch.94_outer + (block $compile_block.102 + (block $compile_store.100 (local.set $23 - (call $+_1155 + (call $+_1153 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) + (global.get $+_1153) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -895,10 +877,10 @@ pattern matching › adt_match_5 ) ) ) - (block $do_backpatches.103 + (block $do_backpatches.99 ) ) - (block $cleanup.105 + (block $cleanup.101 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -930,10 +912,10 @@ pattern matching › adt_match_5 ) ) ) - (return_call $+_1155 + (return_call $+_1153 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) + (global.get $+_1153) ) (local.get $23) (local.get $16) @@ -942,9 +924,9 @@ pattern matching › adt_match_5 ) ) ) - (br $switch.98_outer - (block $compile_block.102 - (block $cleanup.101 + (br $switch.94_outer + (block $compile_block.98 + (block $cleanup.97 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -970,10 +952,10 @@ pattern matching › adt_match_5 ) ) ) - (return_call $+_1155 + (return_call $+_1153 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) + (global.get $+_1153) ) (local.get $12) (local.get $13) @@ -982,8 +964,8 @@ pattern matching › adt_match_5 ) ) ) - (br $switch.98_outer - (block $compile_block.100 (result i32) + (br $switch.94_outer + (block $compile_block.96 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $11) @@ -992,14 +974,14 @@ pattern matching › adt_match_5 ) ) ) - (br $switch.98_outer - (block $compile_block.99 (result i32) + (br $switch.94_outer + (block $compile_block.95 (result i32) (i32.const 1) ) ) ) ) - (block $cleanup.97 (result i32) + (block $cleanup.93 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot index 0487a1ada..4fa21b364 100644 --- a/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot @@ -13,11 +13,11 @@ pattern matching › tuple_match_deep5 (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$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 $+_1159 (param i32 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)) @@ -71,9 +71,7 @@ pattern matching › tuple_match_deep5 (local $42 i32) (local $43 i32) (local $44 i32) - (local $45 i32) - (local $46 i32) - (block $compile_block.128 (result i32) + (block $compile_block.124 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -343,330 +341,446 @@ pattern matching › tuple_match_deep5 (block $do_backpatches.40 ) ) - (block $compile_store.43 + (block $compile_store.105 (local.set $33 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $32) - (i32.const 0) - ) - ) - ) - (block $do_backpatches.42 - ) - ) - (block $compile_store.109 - (local.set $34 - (if (result i32) - (i32.shr_u - (local.get $33) - (i32.const 31) - ) - (block $compile_block.101 (result i32) - (block $compile_store.45 - (local.set $22 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $21) - ) - ) - ) - (block $do_backpatches.44 - ) - ) - (block $compile_store.47 - (local.set $23 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $21) - ) - ) - ) - (block $do_backpatches.46 - ) - ) - (block $compile_store.49 - (local.set $36 - (i32.load offset=12 - (local.get $23) - ) - ) - (block $do_backpatches.48 - ) - ) - (block $compile_store.51 - (local.set $37 - (i32.shr_s - (local.get $36) - (i32.const 1) - ) - ) - (block $do_backpatches.50 - ) - ) - (block $compile_store.53 - (local.set $38 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $37) - (i32.const 0) + (block $switch.42_outer (result i32) + (block $switch.42_branch_0 (result i32) + (drop + (block $switch.42_branch_1 (result i32) + (drop + (block $switch.42_branch_2 (result i32) + (drop + (block $switch.42_default (result i32) + (br_table $switch.42_branch_2 $switch.42_branch_1 $switch.42_default $switch.42_default + (i32.const 0) + (local.get $32) + ) + ) + ) + (br $switch.42_outer + (block $compile_block.103 (result i32) + (unreachable) + ) + ) ) ) - ) - (block $do_backpatches.52 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $38) - (i32.const 31) - ) - (block $compile_block.93 (result i32) - (block $compile_store.56 - (local.set $24 + (br $switch.42_outer + (block $compile_block.102 (result i32) + (block $compile_store.46 + (local.set $22 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $23) + (local.get $21) ) ) ) - (block $do_backpatches.55 + (block $do_backpatches.45 ) ) - (block $compile_store.58 - (local.set $25 + (block $compile_store.48 + (local.set $23 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $23) + (local.get $21) ) ) ) - (block $do_backpatches.57 + (block $do_backpatches.47 ) ) - (block $compile_store.60 - (local.set $40 + (block $compile_store.50 + (local.set $34 (i32.load offset=12 - (local.get $25) + (local.get $23) ) ) - (block $do_backpatches.59 + (block $do_backpatches.49 ) ) - (block $compile_store.62 - (local.set $41 + (block $compile_store.52 + (local.set $35 (i32.shr_s - (local.get $40) + (local.get $34) (i32.const 1) ) ) - (block $do_backpatches.61 + (block $do_backpatches.51 ) ) - (block $compile_store.64 - (local.set $42 + (block $compile_store.54 + (local.set $36 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $41) + (local.get $35) (i32.const 0) ) ) ) - (block $do_backpatches.63 + (block $do_backpatches.53 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $42) + (local.get $36) (i32.const 31) ) - (block $compile_block.84 (result i32) - (block $compile_store.67 - (local.set $26 + (block $compile_block.94 (result i32) + (block $compile_store.57 + (local.set $24 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $25) + (local.get $23) ) ) ) - (block $do_backpatches.66 + (block $do_backpatches.56 ) ) - (block $compile_store.69 - (local.set $27 + (block $compile_store.59 + (local.set $25 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $25) + (local.get $23) ) ) ) - (block $do_backpatches.68 + (block $do_backpatches.58 ) ) - (block $compile_store.71 - (local.set $44 + (block $compile_store.61 + (local.set $38 (i32.load offset=12 - (local.get $27) + (local.get $25) ) ) - (block $do_backpatches.70 - ) - ) - (block $cleanup.72 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $27) - ) + (block $do_backpatches.60 ) ) - (block $compile_store.74 - (local.set $45 + (block $compile_store.63 + (local.set $39 (i32.shr_s - (local.get $44) + (local.get $38) (i32.const 1) ) ) - (block $do_backpatches.73 + (block $do_backpatches.62 ) ) - (block $compile_store.76 - (local.set $46 + (block $compile_store.65 + (local.set $40 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $45) - (i32.const 1) + (local.get $39) + (i32.const 0) ) ) ) - (block $do_backpatches.75 + (block $do_backpatches.64 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $46) + (local.get $40) (i32.const 31) ) - (block $compile_block.82 (result i32) - (drop - (block $compile_set.78 (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) - ) - ) + (block $compile_block.85 (result i32) + (block $compile_store.68 + (local.set $26 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=20 + (local.get $25) + ) + ) + ) + (block $do_backpatches.67 + ) + ) + (block $compile_store.70 + (local.set $27 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=24 + (local.get $25) + ) + ) + ) + (block $do_backpatches.69 + ) + ) + (block $compile_store.72 + (local.set $42 + (i32.load offset=12 + (local.get $27) + ) + ) + (block $do_backpatches.71 + ) + ) + (block $cleanup.73 + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $27) + ) + ) + ) + (block $compile_store.75 + (local.set $43 + (i32.shr_s + (local.get $42) + (i32.const 1) + ) + ) + (block $do_backpatches.74 + ) + ) + (block $compile_store.77 + (local.set $44 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $43) + (i32.const 1) ) ) - (i32.const 1879048190) + ) + (block $do_backpatches.76 ) ) - (drop - (block $compile_set.79 (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) + (tuple.extract 0 + (tuple.make + (if (result i32) + (i32.shr_u + (local.get $44) + (i32.const 31) + ) + (block $compile_block.83 (result i32) + (drop + (block $compile_set.79 (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.80 (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.81 (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) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) + ) + (drop + (block $compile_set.82 (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 3) + ) + (block $compile_block.84 (result i32) + (i32.const 4) ) ) - (i32.const 1879048190) + (block $cleanup.78 (result i32) + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $26) + ) + ) + (i32.const 1879048190) + ) ) ) - (drop - (block $compile_set.80 (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) + ) + (block $compile_block.93 (result i32) + (block $compile_store.87 + (local.set $41 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $39) + (i32.const 1) + ) + ) + ) + (block $do_backpatches.86 + ) + ) + (if (result i32) + (i32.shr_u + (local.get $41) + (i32.const 31) + ) + (block $compile_block.91 (result i32) + (drop + (block $compile_set.88 (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) + ) ) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) ) + (i32.const 1879048190) ) ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.81 (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) + (drop + (block $compile_set.89 (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) + ) ) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) + ) + (i32.const 1879048190) + ) + ) + (drop + (block $compile_set.90 (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 1879048190) + (i32.const 2) + ) + (block $compile_block.92 (result i32) + (i32.const 4) ) ) - (i32.const 3) - ) - (block $compile_block.83 (result i32) - (i32.const 4) ) ) - (block $cleanup.77 (result i32) + (block $cleanup.66 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $26) + (local.get $24) + ) + ) + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $25) ) ) (i32.const 1879048190) @@ -674,30 +788,30 @@ pattern matching › tuple_match_deep5 ) ) ) - (block $compile_block.92 (result i32) - (block $compile_store.86 - (local.set $43 + (block $compile_block.101 (result i32) + (block $compile_store.96 + (local.set $37 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $41) + (local.get $35) (i32.const 1) ) ) ) - (block $do_backpatches.85 + (block $do_backpatches.95 ) ) (if (result i32) (i32.shr_u - (local.get $43) + (local.get $37) (i32.const 31) ) - (block $compile_block.90 (result i32) + (block $compile_block.99 (result i32) (drop - (block $compile_set.87 (result i32) - (local.set $13 + (block $compile_set.97 (result i32) + (local.set $11 (tuple.extract 0 (tuple.make (call $incRef_0 @@ -709,7 +823,7 @@ pattern matching › tuple_match_deep5 ) (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) + (local.get $11) ) ) ) @@ -718,8 +832,8 @@ pattern matching › tuple_match_deep5 ) ) (drop - (block $compile_set.88 (result i32) - (local.set $14 + (block $compile_set.98 (result i32) + (local.set $12 (tuple.extract 0 (tuple.make (call $incRef_0 @@ -731,29 +845,7 @@ pattern matching › tuple_match_deep5 ) (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.89 (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) + (local.get $12) ) ) ) @@ -761,25 +853,25 @@ pattern matching › tuple_match_deep5 (i32.const 1879048190) ) ) - (i32.const 2) + (i32.const 1) ) - (block $compile_block.91 (result i32) + (block $compile_block.100 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.65 (result i32) + (block $cleanup.55 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $24) + (local.get $22) ) ) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $25) + (local.get $23) ) ) (i32.const 1879048190) @@ -787,120 +879,13 @@ pattern matching › tuple_match_deep5 ) ) ) - (block $compile_block.100 (result i32) - (block $compile_store.95 - (local.set $39 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $37) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.94 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $39) - (i32.const 31) - ) - (block $compile_block.98 (result i32) - (drop - (block $compile_set.96 (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.97 (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.99 (result i32) - (i32.const 4) - ) - ) - ) ) - (block $cleanup.54 (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.107 (result i32) - (block $compile_store.103 - (local.set $35 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $32) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.102 ) ) - (if (result i32) - (i32.shr_u - (local.get $35) - (i32.const 31) - ) - (block $compile_block.105 (result i32) + (br $switch.42_outer + (block $compile_block.44 (result i32) (drop - (block $compile_set.104 (result i32) + (block $compile_set.43 (result i32) (local.set $10 (tuple.extract 0 (tuple.make @@ -923,17 +908,14 @@ pattern matching › tuple_match_deep5 ) (i32.const 0) ) - (block $compile_block.106 - (unreachable) - ) ) ) ) ) - (block $do_backpatches.108 + (block $do_backpatches.104 ) ) - (block $cleanup.110 + (block $cleanup.106 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -949,48 +931,48 @@ pattern matching › tuple_match_deep5 ) (tuple.extract 0 (tuple.make - (block $switch.112_outer (result i32) - (block $switch.112_branch_0 (result i32) + (block $switch.108_outer (result i32) + (block $switch.108_branch_0 (result i32) (drop - (block $switch.112_branch_1 (result i32) + (block $switch.108_branch_1 (result i32) (drop - (block $switch.112_branch_2 (result i32) + (block $switch.108_branch_2 (result i32) (drop - (block $switch.112_branch_3 (result i32) + (block $switch.108_branch_3 (result i32) (drop - (block $switch.112_branch_4 (result i32) + (block $switch.108_branch_4 (result i32) (drop - (block $switch.112_branch_5 (result i32) + (block $switch.108_branch_5 (result i32) (drop - (block $switch.112_default (result i32) - (br_table $switch.112_branch_1 $switch.112_branch_2 $switch.112_branch_3 $switch.112_branch_4 $switch.112_branch_5 $switch.112_default $switch.112_default + (block $switch.108_default (result i32) + (br_table $switch.108_branch_1 $switch.108_branch_2 $switch.108_branch_3 $switch.108_branch_4 $switch.108_branch_5 $switch.108_default $switch.108_default (i32.const 0) - (local.get $34) + (local.get $33) ) ) ) - (br $switch.112_outer - (block $compile_block.127 (result i32) + (br $switch.108_outer + (block $compile_block.123 (result i32) (unreachable) ) ) ) ) - (br $switch.112_outer - (block $compile_block.126 (result i32) + (br $switch.108_outer + (block $compile_block.122 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.112_outer - (block $compile_block.125 - (block $compile_store.121 + (br $switch.108_outer + (block $compile_block.121 + (block $compile_store.117 (local.set $29 - (call $+_1159 + (call $+_1157 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) + (global.get $+_1157) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -1002,15 +984,15 @@ pattern matching › tuple_match_deep5 ) ) ) - (block $do_backpatches.120 + (block $do_backpatches.116 ) ) - (block $compile_store.123 + (block $compile_store.119 (local.set $30 - (call $+_1159 + (call $+_1157 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) + (global.get $+_1157) ) (local.get $29) (call $incRef_0 @@ -1019,10 +1001,10 @@ pattern matching › tuple_match_deep5 ) ) ) - (block $do_backpatches.122 + (block $do_backpatches.118 ) ) - (block $cleanup.124 + (block $cleanup.120 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1078,10 +1060,10 @@ pattern matching › tuple_match_deep5 ) ) ) - (return_call $+_1159 + (return_call $+_1157 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) + (global.get $+_1157) ) (local.get $30) (local.get $19) @@ -1090,14 +1072,14 @@ pattern matching › tuple_match_deep5 ) ) ) - (br $switch.112_outer - (block $compile_block.119 - (block $compile_store.117 + (br $switch.108_outer + (block $compile_block.115 + (block $compile_store.113 (local.set $28 - (call $+_1159 + (call $+_1157 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) + (global.get $+_1157) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -1109,10 +1091,10 @@ pattern matching › tuple_match_deep5 ) ) ) - (block $do_backpatches.116 + (block $do_backpatches.112 ) ) - (block $cleanup.118 + (block $cleanup.114 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1168,10 +1150,10 @@ pattern matching › tuple_match_deep5 ) ) ) - (return_call $+_1159 + (return_call $+_1157 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) + (global.get $+_1157) ) (local.get $28) (local.get $15) @@ -1180,9 +1162,9 @@ pattern matching › tuple_match_deep5 ) ) ) - (br $switch.112_outer - (block $compile_block.115 - (block $cleanup.114 + (br $switch.108_outer + (block $compile_block.111 + (block $cleanup.110 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1232,10 +1214,10 @@ pattern matching › tuple_match_deep5 ) ) ) - (return_call $+_1159 + (return_call $+_1157 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) + (global.get $+_1157) ) (local.get $11) (local.get $12) @@ -1244,8 +1226,8 @@ pattern matching › tuple_match_deep5 ) ) ) - (br $switch.112_outer - (block $compile_block.113 (result i32) + (br $switch.108_outer + (block $compile_block.109 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $10) @@ -1254,7 +1236,7 @@ pattern matching › tuple_match_deep5 ) ) ) - (block $cleanup.111 (result i32) + (block $cleanup.107 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) diff --git a/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot b/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot index 89c208f4f..b44d779f9 100644 --- a/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot @@ -13,11 +13,11 @@ pattern matching › tuple_match_deep7 (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 $+_1163 (mut i32))) + (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1161 (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 $+_1163 (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1161 (param i32 i32 i32) (result i32))) (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) (memory $0 0) (elem $elem (global.get $relocBase_0)) @@ -73,9 +73,7 @@ pattern matching › tuple_match_deep7 (local $44 i32) (local $45 i32) (local $46 i32) - (local $47 i32) - (local $48 i32) - (block $compile_block.134 (result i32) + (block $compile_block.130 (result i32) (block $compile_store.3 (local.set $6 (block $allocate_adt.1 (result i32) @@ -429,330 +427,446 @@ pattern matching › tuple_match_deep7 (block $do_backpatches.46 ) ) - (block $compile_store.49 + (block $compile_store.111 (local.set $35 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $34) - (i32.const 0) - ) - ) - ) - (block $do_backpatches.48 - ) - ) - (block $compile_store.115 - (local.set $36 - (if (result i32) - (i32.shr_u - (local.get $35) - (i32.const 31) - ) - (block $compile_block.107 (result i32) - (block $compile_store.51 - (local.set $24 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $23) - ) - ) - ) - (block $do_backpatches.50 - ) - ) - (block $compile_store.53 - (local.set $25 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $23) - ) - ) - ) - (block $do_backpatches.52 - ) - ) - (block $compile_store.55 - (local.set $38 - (i32.load offset=12 - (local.get $25) - ) - ) - (block $do_backpatches.54 - ) - ) - (block $compile_store.57 - (local.set $39 - (i32.shr_s - (local.get $38) - (i32.const 1) - ) - ) - (block $do_backpatches.56 - ) - ) - (block $compile_store.59 - (local.set $40 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $39) - (i32.const 0) + (block $switch.48_outer (result i32) + (block $switch.48_branch_0 (result i32) + (drop + (block $switch.48_branch_1 (result i32) + (drop + (block $switch.48_branch_2 (result i32) + (drop + (block $switch.48_default (result i32) + (br_table $switch.48_branch_2 $switch.48_branch_1 $switch.48_default $switch.48_default + (i32.const 0) + (local.get $34) + ) + ) + ) + (br $switch.48_outer + (block $compile_block.109 (result i32) + (unreachable) + ) + ) ) ) - ) - (block $do_backpatches.58 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $40) - (i32.const 31) - ) - (block $compile_block.99 (result i32) - (block $compile_store.62 - (local.set $26 + (br $switch.48_outer + (block $compile_block.108 (result i32) + (block $compile_store.52 + (local.set $24 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $25) + (local.get $23) ) ) ) - (block $do_backpatches.61 + (block $do_backpatches.51 ) ) - (block $compile_store.64 - (local.set $27 + (block $compile_store.54 + (local.set $25 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $25) + (local.get $23) ) ) ) - (block $do_backpatches.63 + (block $do_backpatches.53 ) ) - (block $compile_store.66 - (local.set $42 + (block $compile_store.56 + (local.set $36 (i32.load offset=12 - (local.get $27) + (local.get $25) ) ) - (block $do_backpatches.65 + (block $do_backpatches.55 ) ) - (block $compile_store.68 - (local.set $43 + (block $compile_store.58 + (local.set $37 (i32.shr_s - (local.get $42) + (local.get $36) (i32.const 1) ) ) - (block $do_backpatches.67 + (block $do_backpatches.57 ) ) - (block $compile_store.70 - (local.set $44 + (block $compile_store.60 + (local.set $38 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $43) + (local.get $37) (i32.const 0) ) ) ) - (block $do_backpatches.69 + (block $do_backpatches.59 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $44) + (local.get $38) (i32.const 31) ) - (block $compile_block.90 (result i32) - (block $compile_store.73 - (local.set $28 + (block $compile_block.100 (result i32) + (block $compile_store.63 + (local.set $26 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=20 - (local.get $27) + (local.get $25) ) ) ) - (block $do_backpatches.72 + (block $do_backpatches.62 ) ) - (block $compile_store.75 - (local.set $29 + (block $compile_store.65 + (local.set $27 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (i32.load offset=24 - (local.get $27) + (local.get $25) ) ) ) - (block $do_backpatches.74 + (block $do_backpatches.64 ) ) - (block $compile_store.77 - (local.set $46 + (block $compile_store.67 + (local.set $40 (i32.load offset=12 - (local.get $29) + (local.get $27) ) ) - (block $do_backpatches.76 - ) - ) - (block $cleanup.78 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $29) - ) + (block $do_backpatches.66 ) ) - (block $compile_store.80 - (local.set $47 + (block $compile_store.69 + (local.set $41 (i32.shr_s - (local.get $46) + (local.get $40) (i32.const 1) ) ) - (block $do_backpatches.79 + (block $do_backpatches.68 ) ) - (block $compile_store.82 - (local.set $48 + (block $compile_store.71 + (local.set $42 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $47) - (i32.const 1) + (local.get $41) + (i32.const 0) ) ) ) - (block $do_backpatches.81 + (block $do_backpatches.70 ) ) (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (local.get $48) + (local.get $42) (i32.const 31) ) - (block $compile_block.88 (result i32) - (drop - (block $compile_set.84 (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) - ) - ) + (block $compile_block.91 (result i32) + (block $compile_store.74 + (local.set $28 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=20 + (local.get $27) + ) + ) + ) + (block $do_backpatches.73 + ) + ) + (block $compile_store.76 + (local.set $29 + (call $incRef_0 + (global.get $GRAIN$EXPORT$incRef_0) + (i32.load offset=24 + (local.get $27) + ) + ) + ) + (block $do_backpatches.75 + ) + ) + (block $compile_store.78 + (local.set $44 + (i32.load offset=12 + (local.get $29) + ) + ) + (block $do_backpatches.77 + ) + ) + (block $cleanup.79 + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $29) + ) + ) + ) + (block $compile_store.81 + (local.set $45 + (i32.shr_s + (local.get $44) + (i32.const 1) + ) + ) + (block $do_backpatches.80 + ) + ) + (block $compile_store.83 + (local.set $46 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $45) + (i32.const 1) ) ) - (i32.const 1879048190) + ) + (block $do_backpatches.82 ) ) - (drop - (block $compile_set.85 (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) + (tuple.extract 0 + (tuple.make + (if (result i32) + (i32.shr_u + (local.get $46) + (i32.const 31) + ) + (block $compile_block.89 (result i32) + (drop + (block $compile_set.85 (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.86 (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.87 (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) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) + ) + (drop + (block $compile_set.88 (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 3) + ) + (block $compile_block.90 (result i32) + (i32.const 4) ) ) - (i32.const 1879048190) + (block $cleanup.84 (result i32) + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $28) + ) + ) + (i32.const 1879048190) + ) ) ) - (drop - (block $compile_set.86 (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) + ) + (block $compile_block.99 (result i32) + (block $compile_store.93 + (local.set $43 + (select + (i32.const -2) + (i32.const 2147483646) + (i32.eq + (local.get $41) + (i32.const 1) + ) + ) + ) + (block $do_backpatches.92 + ) + ) + (if (result i32) + (i32.shr_u + (local.get $43) + (i32.const 31) + ) + (block $compile_block.97 (result i32) + (drop + (block $compile_set.94 (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) + ) ) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) ) + (i32.const 1879048190) ) ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.87 (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) + (drop + (block $compile_set.95 (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) + ) ) ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) + ) + (i32.const 1879048190) + ) + ) + (drop + (block $compile_set.96 (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 1879048190) + (i32.const 2) + ) + (block $compile_block.98 (result i32) + (i32.const 4) ) ) - (i32.const 3) - ) - (block $compile_block.89 (result i32) - (i32.const 4) ) ) - (block $cleanup.83 (result i32) + (block $cleanup.72 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $28) + (local.get $26) + ) + ) + (drop + (call $decRef_0 + (global.get $GRAIN$EXPORT$decRef_0) + (local.get $27) ) ) (i32.const 1879048190) @@ -760,30 +874,30 @@ pattern matching › tuple_match_deep7 ) ) ) - (block $compile_block.98 (result i32) - (block $compile_store.92 - (local.set $45 + (block $compile_block.107 (result i32) + (block $compile_store.102 + (local.set $39 (select (i32.const -2) (i32.const 2147483646) (i32.eq - (local.get $43) + (local.get $37) (i32.const 1) ) ) ) - (block $do_backpatches.91 + (block $do_backpatches.101 ) ) (if (result i32) (i32.shr_u - (local.get $45) + (local.get $39) (i32.const 31) ) - (block $compile_block.96 (result i32) + (block $compile_block.105 (result i32) (drop - (block $compile_set.93 (result i32) - (local.set $15 + (block $compile_set.103 (result i32) + (local.set $13 (tuple.extract 0 (tuple.make (call $incRef_0 @@ -795,7 +909,7 @@ pattern matching › tuple_match_deep7 ) (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) + (local.get $13) ) ) ) @@ -804,8 +918,8 @@ pattern matching › tuple_match_deep7 ) ) (drop - (block $compile_set.94 (result i32) - (local.set $16 + (block $compile_set.104 (result i32) + (local.set $14 (tuple.extract 0 (tuple.make (call $incRef_0 @@ -817,29 +931,7 @@ pattern matching › tuple_match_deep7 ) (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.95 (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) + (local.get $14) ) ) ) @@ -847,25 +939,25 @@ pattern matching › tuple_match_deep7 (i32.const 1879048190) ) ) - (i32.const 2) + (i32.const 1) ) - (block $compile_block.97 (result i32) + (block $compile_block.106 (result i32) (i32.const 4) ) ) ) ) - (block $cleanup.71 (result i32) + (block $cleanup.61 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $26) + (local.get $24) ) ) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) - (local.get $27) + (local.get $25) ) ) (i32.const 1879048190) @@ -873,120 +965,13 @@ pattern matching › tuple_match_deep7 ) ) ) - (block $compile_block.106 (result i32) - (block $compile_store.101 - (local.set $41 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $39) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.100 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $41) - (i32.const 31) - ) - (block $compile_block.104 (result i32) - (drop - (block $compile_set.102 (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.103 (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 1) - ) - (block $compile_block.105 (result i32) - (i32.const 4) - ) - ) - ) ) - (block $cleanup.60 (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.113 (result i32) - (block $compile_store.109 - (local.set $37 - (select - (i32.const -2) - (i32.const 2147483646) - (i32.eq - (local.get $34) - (i32.const 1) - ) - ) - ) - (block $do_backpatches.108 ) ) - (if (result i32) - (i32.shr_u - (local.get $37) - (i32.const 31) - ) - (block $compile_block.111 (result i32) + (br $switch.48_outer + (block $compile_block.50 (result i32) (drop - (block $compile_set.110 (result i32) + (block $compile_set.49 (result i32) (local.set $12 (tuple.extract 0 (tuple.make @@ -1009,17 +994,14 @@ pattern matching › tuple_match_deep7 ) (i32.const 0) ) - (block $compile_block.112 - (unreachable) - ) ) ) ) ) - (block $do_backpatches.114 + (block $do_backpatches.110 ) ) - (block $cleanup.116 + (block $cleanup.112 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1035,48 +1017,48 @@ pattern matching › tuple_match_deep7 ) (tuple.extract 0 (tuple.make - (block $switch.118_outer (result i32) - (block $switch.118_branch_0 (result i32) + (block $switch.114_outer (result i32) + (block $switch.114_branch_0 (result i32) (drop - (block $switch.118_branch_1 (result i32) + (block $switch.114_branch_1 (result i32) (drop - (block $switch.118_branch_2 (result i32) + (block $switch.114_branch_2 (result i32) (drop - (block $switch.118_branch_3 (result i32) + (block $switch.114_branch_3 (result i32) (drop - (block $switch.118_branch_4 (result i32) + (block $switch.114_branch_4 (result i32) (drop - (block $switch.118_branch_5 (result i32) + (block $switch.114_branch_5 (result i32) (drop - (block $switch.118_default (result i32) - (br_table $switch.118_branch_1 $switch.118_branch_2 $switch.118_branch_3 $switch.118_branch_4 $switch.118_branch_5 $switch.118_default $switch.118_default + (block $switch.114_default (result i32) + (br_table $switch.114_branch_1 $switch.114_branch_2 $switch.114_branch_3 $switch.114_branch_4 $switch.114_branch_5 $switch.114_default $switch.114_default (i32.const 0) - (local.get $36) + (local.get $35) ) ) ) - (br $switch.118_outer - (block $compile_block.133 (result i32) + (br $switch.114_outer + (block $compile_block.129 (result i32) (unreachable) ) ) ) ) - (br $switch.118_outer - (block $compile_block.132 (result i32) + (br $switch.114_outer + (block $compile_block.128 (result i32) (i32.const 1999) ) ) ) ) - (br $switch.118_outer - (block $compile_block.131 - (block $compile_store.127 + (br $switch.114_outer + (block $compile_block.127 + (block $compile_store.123 (local.set $31 - (call $+_1163 + (call $+_1161 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1163) + (global.get $+_1161) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -1088,15 +1070,15 @@ pattern matching › tuple_match_deep7 ) ) ) - (block $do_backpatches.126 + (block $do_backpatches.122 ) ) - (block $compile_store.129 + (block $compile_store.125 (local.set $32 - (call $+_1163 + (call $+_1161 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1163) + (global.get $+_1161) ) (local.get $31) (call $incRef_0 @@ -1105,10 +1087,10 @@ pattern matching › tuple_match_deep7 ) ) ) - (block $do_backpatches.128 + (block $do_backpatches.124 ) ) - (block $cleanup.130 + (block $cleanup.126 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1164,10 +1146,10 @@ pattern matching › tuple_match_deep7 ) ) ) - (return_call $+_1163 + (return_call $+_1161 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1163) + (global.get $+_1161) ) (local.get $32) (local.get $21) @@ -1176,14 +1158,14 @@ pattern matching › tuple_match_deep7 ) ) ) - (br $switch.118_outer - (block $compile_block.125 - (block $compile_store.123 + (br $switch.114_outer + (block $compile_block.121 + (block $compile_store.119 (local.set $30 - (call $+_1163 + (call $+_1161 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1163) + (global.get $+_1161) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) @@ -1195,10 +1177,10 @@ pattern matching › tuple_match_deep7 ) ) ) - (block $do_backpatches.122 + (block $do_backpatches.118 ) ) - (block $cleanup.124 + (block $cleanup.120 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1254,10 +1236,10 @@ pattern matching › tuple_match_deep7 ) ) ) - (return_call $+_1163 + (return_call $+_1161 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1163) + (global.get $+_1161) ) (local.get $30) (local.get $17) @@ -1266,9 +1248,9 @@ pattern matching › tuple_match_deep7 ) ) ) - (br $switch.118_outer - (block $compile_block.121 - (block $cleanup.120 + (br $switch.114_outer + (block $compile_block.117 + (block $cleanup.116 (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) @@ -1318,10 +1300,10 @@ pattern matching › tuple_match_deep7 ) ) ) - (return_call $+_1163 + (return_call $+_1161 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1163) + (global.get $+_1161) ) (local.get $13) (local.get $14) @@ -1330,8 +1312,8 @@ pattern matching › tuple_match_deep7 ) ) ) - (br $switch.118_outer - (block $compile_block.119 (result i32) + (br $switch.114_outer + (block $compile_block.115 (result i32) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) (local.get $12) @@ -1340,7 +1322,7 @@ pattern matching › tuple_match_deep7 ) ) ) - (block $cleanup.117 (result i32) + (block $cleanup.113 (result i32) (drop (call $decRef_0 (global.get $GRAIN$EXPORT$decRef_0) From c92cd204bd66ea6d75cd303aaf3757820ee7cd1d Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Fri, 11 Oct 2024 21:52:21 -0400 Subject: [PATCH 09/10] chore: cleanup --- compiler/src/middle_end/matchcomp.re | 170 ++++++++++++--------------- 1 file changed, 77 insertions(+), 93 deletions(-) diff --git a/compiler/src/middle_end/matchcomp.re b/compiler/src/middle_end/matchcomp.re index ccab8426e..b3041a967 100644 --- a/compiler/src/middle_end/matchcomp.re +++ b/compiler/src/middle_end/matchcomp.re @@ -688,13 +688,6 @@ let rec compile_matrix = mtx => let constants = matrix_head_constants(mtx); let constant_type = List.hd(constants); - // TODO(#1185): Optimize physical equality checks into a switch. - // We can also do partial switches on Numbers if some of the - // patterns are stack-allocated numbers. Addtionally, since we - // know the types of the non-Number number types, we can make - // compilation smarter and also switch on those values after - // loaded from the heap. - let default = default_matrix(alias, mtx); let default_tree = if (List.length(default) != 0) { @@ -1300,33 +1293,6 @@ module MatchTreeCompiler = { [], ) }; - let equality_op = - switch (value_typ) { - | WasmI32 => - WasmBinaryI32({ - wasm_op: Op_eq_int32, - arg_types: (Wasm_int32, Wasm_int32), - ret_type: Grain_bool, - }) - | WasmI64 => - WasmBinaryI64({ - wasm_op: Op_eq_int64, - arg_types: (Wasm_int64, Wasm_int64), - ret_type: Grain_bool, - }) - | WasmF32 => - WasmBinaryF32({ - wasm_op: Op_eq_float32, - arg_types: (Wasm_float32, Wasm_float32), - ret_type: Grain_bool, - }) - | WasmF64 => - WasmBinaryF64({ - wasm_op: Op_eq_float64, - arg_types: (Wasm_float64, Wasm_float64), - ret_type: Grain_bool, - }) - }; // Setup Our Switch let (min, max) = List.fold_left( @@ -1336,59 +1302,56 @@ module MatchTreeCompiler = { ); let branch_count = List.length(cases); let branch_range = Int.abs(max - min + 1); - // Printf.printf( - // "%d branches in a range of %d, min: %d, max: %d, default: %s \n", - // branch_count, - // branch_range, - // min, - // max, - // default_tree != None ? "true" : "false", - // ); - // TODO: We do not care about the min == 0 in the future - let optimize = - branch_count == branch_range && default_tree == None && min == 0; - // let optimize = false; + let optimize = branch_count == branch_range && default_tree == None; let (switch_body_ans, switch_body_setup) = if (optimize) { - // Printf.printf("Performing Jump Table Optimiztion\n"); - // let sub_op = - // switch (value_typ) { - // | WasmI32 => - // WasmBinaryI32({ - // wasm_op: Op_add_int32, - // arg_types: (Wasm_int32, Wasm_int32), - // ret_type: Grain_bool, - // }) - // | WasmI64 => - // WasmBinaryI64({ - // wasm_op: Op_add_int64, - // arg_types: (Wasm_int64, Wasm_int64), - // ret_type: Grain_bool, - // }) - // | WasmF32 => - // WasmBinaryF32({ - // wasm_op: Op_add_float32, - // arg_types: (Wasm_float32, Wasm_float32), - // ret_type: Grain_bool, - // }) - // | WasmF64 => - // WasmBinaryF64({ - // wasm_op: Op_add_float64, - // arg_types: (Wasm_float64, Wasm_float64), - // ret_type: Grain_bool, - // }) - // }; - // TODO: Avoid the math if min is 0 - // let match_jmp_name = Ident.create("match_jmp_id"); - // let match_jmp_id = Imm.id(~loc=Location.dummy_loc, match_jmp_name); - // let match_mapped_cond = - // Comp.prim2( - // ~loc=Location.dummy_loc, - // ~allocation_type=Unmanaged(value_typ), - // sub_op, - // cond_id, - // compile_cond(0), - // ); + let sub_op = + switch (value_typ) { + | WasmI32 => + WasmBinaryI32({ + wasm_op: Op_sub_int32, + arg_types: (Wasm_int32, Wasm_int32), + ret_type: Wasm_int32, + }) + | WasmI64 => + WasmBinaryI64({ + wasm_op: Op_sub_int64, + arg_types: (Wasm_int64, Wasm_int64), + ret_type: Wasm_int32, + }) + | WasmF32 => + WasmBinaryF32({ + wasm_op: Op_sub_float32, + arg_types: (Wasm_float32, Wasm_float32), + ret_type: Wasm_int32, + }) + | WasmF64 => + WasmBinaryF64({ + wasm_op: Op_sub_float64, + arg_types: (Wasm_float64, Wasm_float64), + ret_type: Wasm_int32, + }) + }; + let (match_cond_id, match_cond_binds) = + if (min == 0) { + (cond_id, []); + } else { + let match_jmp_name = Ident.create("match_jmp_id"); + let match_jmp_id = + Imm.id(~loc=Location.dummy_loc, match_jmp_name); + let match_mapped_cond = + Comp.prim2( + ~loc=Location.dummy_loc, + ~allocation_type=Unmanaged(value_typ), + sub_op, + cond_id, + compile_cond(min), + ); + ( + match_jmp_id, + [BLet(match_jmp_name, match_mapped_cond, Nonglobal)], + ); + }; let cases = List.map( ((tag, tree)) => { @@ -1403,7 +1366,6 @@ module MatchTreeCompiler = { helpI, helpConst, ); - // Printf.printf("Unmapped: %d -> %d\n", tag, tag - min); (tag - min, fold_tree(tree_setup, tree_ans)); }, cases, @@ -1413,17 +1375,12 @@ module MatchTreeCompiler = { ~loc=Location.dummy_loc, // TODO: We should probably grab this from ~allocation_type=tree_ans.comp_allocation_type, ~allocation_type=Unmanaged(WasmI32), - cond_id, + match_cond_id, cases, Total, ); - ( - switch_body, - [], - // [BLet(match_jmp_name, match_mapped_cond, Nonglobal)], - ); + (switch_body, match_cond_binds); } else { - // Printf.printf("Not Performing Jump Table Operation\n"); /* Runs when no cases match */ let base_tree = Option.value(~default=Fail, default_tree); let base = @@ -1437,6 +1394,33 @@ module MatchTreeCompiler = { helpI, helpConst, ); + let equality_op = + switch (value_typ) { + | WasmI32 => + WasmBinaryI32({ + wasm_op: Op_eq_int32, + arg_types: (Wasm_int32, Wasm_int32), + ret_type: Grain_bool, + }) + | WasmI64 => + WasmBinaryI64({ + wasm_op: Op_eq_int64, + arg_types: (Wasm_int64, Wasm_int64), + ret_type: Grain_bool, + }) + | WasmF32 => + WasmBinaryF32({ + wasm_op: Op_eq_float32, + arg_types: (Wasm_float32, Wasm_float32), + ret_type: Grain_bool, + }) + | WasmF64 => + WasmBinaryF64({ + wasm_op: Op_eq_float64, + arg_types: (Wasm_float64, Wasm_float64), + ret_type: Grain_bool, + }) + }; List.fold_left( ((body_ans, body_setup), (tag, tree)) => { let cmp_id_name = Ident.create("match_cmp_values"); From 12aba1b4d21c1541886ddf18e4f412127e593392 Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Fri, 11 Oct 2024 22:20:05 -0400 Subject: [PATCH 10/10] feat: do not hardcode allocation type --- compiler/src/middle_end/matchcomp.re | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/src/middle_end/matchcomp.re b/compiler/src/middle_end/matchcomp.re index b3041a967..58f8d3bb2 100644 --- a/compiler/src/middle_end/matchcomp.re +++ b/compiler/src/middle_end/matchcomp.re @@ -1352,6 +1352,7 @@ module MatchTreeCompiler = { [BLet(match_jmp_name, match_mapped_cond, Nonglobal)], ); }; + let allocation_type = ref(Unmanaged(WasmI32)); let cases = List.map( ((tag, tree)) => { @@ -1366,15 +1367,16 @@ module MatchTreeCompiler = { helpI, helpConst, ); + allocation_type := tree_ans.comp_allocation_type; (tag - min, fold_tree(tree_setup, tree_ans)); }, cases, ); + assert(List.length(cases) != 0); let switch_body = Comp.switch_( ~loc=Location.dummy_loc, - // TODO: We should probably grab this from ~allocation_type=tree_ans.comp_allocation_type, - ~allocation_type=Unmanaged(WasmI32), + ~allocation_type=allocation_type^, match_cond_id, cases, Total,