Model var as a pattern operator (#4720)

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
Geoff Romer
2025-01-17 17:51:34 +00:00
committed by GitHub
co-authored by Richard Smith
parent 6572da7314
commit 13434f0e8a
510 changed files with 11819 additions and 3352 deletions
+13 -3
View File
@@ -90,8 +90,11 @@ fn F(b: bool, n: i32, m: i32) -> i32 {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F(%b.param_patt: bool, %n.param_patt: %i32, %m.param_patt: %i32) -> %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %x.patt: %array_type = binding_pattern x
// CHECK:STDOUT: %.loc12_3.1: %array_type = var_pattern %x.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %x.var: ref %array_type = var x
// CHECK:STDOUT: %x: ref %array_type = bind_name x, %x.var
// CHECK:STDOUT: %int_0.loc12_22: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6]
// CHECK:STDOUT: %.loc12_24.1: %tuple.type = tuple_literal (%int_0.loc12_22)
// CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
@@ -103,8 +106,15 @@ fn F(b: bool, n: i32, m: i32) -> i32 {
// CHECK:STDOUT: %.loc12_24.3: ref %i32 = array_index %x.var, %int_0.loc12_24
// CHECK:STDOUT: %.loc12_24.4: init %i32 = initialize_from %.loc12_24.2 to %.loc12_24.3 [template = constants.%int_0.6a9]
// CHECK:STDOUT: %.loc12_24.5: init %array_type = array_init (%.loc12_24.4) to %x.var [template = constants.%array]
// CHECK:STDOUT: %.loc12_25: init %array_type = converted %.loc12_24.1, %.loc12_24.5 [template = constants.%array]
// CHECK:STDOUT: assign %x.var, %.loc12_25
// CHECK:STDOUT: %.loc12_3.2: init %array_type = converted %.loc12_24.1, %.loc12_24.5 [template = constants.%array]
// CHECK:STDOUT: assign %x.var, %.loc12_3.2
// CHECK:STDOUT: %.loc12_17: type = splice_block %array_type [template = constants.%array_type] {
// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1]
// CHECK:STDOUT: %array_type: type = array_type %int_1, %i32 [template = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %x: ref %array_type = bind_name x, %x.var
// CHECK:STDOUT: %b.ref: bool = name_ref b, %b
// CHECK:STDOUT: if %b.ref br !if.expr.then else br !if.expr.else
// CHECK:STDOUT: