diff --git a/toolchain/check/context.cpp b/toolchain/check/context.cpp index 92d6c73adb33..07c01466d6fe 100644 --- a/toolchain/check/context.cpp +++ b/toolchain/check/context.cpp @@ -64,6 +64,13 @@ auto Context::AddInst(SemIR::Inst inst) -> SemIR::InstId { return inst_id; } +auto Context::AddConstantInst(SemIR::Inst inst) -> SemIR::InstId { + auto inst_id = insts().AddInNoBlock(inst); + constants().Add(inst_id); + CARBON_VLOG() << "AddConstantInst: " << inst << "\n"; + return inst_id; +} + auto Context::AddInstAndPush(Parse::Node parse_node, SemIR::Inst inst) -> void { auto inst_id = AddInst(inst); node_stack_.Push(parse_node, inst_id); @@ -594,7 +601,7 @@ class TypeCompleter { if (field_value_rep.type_id != field.field_type_id) { same_as_object_rep = false; field.field_type_id = field_value_rep.type_id; - field_id = context_.AddInst(field); + field_id = context_.AddConstantInst(field); } value_rep_fields.push_back(field_id); } @@ -882,7 +889,7 @@ auto Context::CanonicalizeTypeAndAddInstIfNew(SemIR::Inst inst) auto profile_node = [&](llvm::FoldingSetNodeID& canonical_id) { ProfileType(*this, inst, canonical_id); }; - auto make_inst = [&] { return AddInst(inst); }; + auto make_inst = [&] { return AddConstantInst(inst); }; return CanonicalizeTypeImpl(inst.kind(), profile_node, make_inst); } @@ -917,8 +924,8 @@ auto Context::CanonicalizeTupleType(Parse::Node parse_node, ProfileTupleType(type_ids, canonical_id); }; auto make_tuple_inst = [&] { - return AddInst(SemIR::TupleType{parse_node, SemIR::TypeId::TypeType, - type_blocks().Add(type_ids)}); + return AddConstantInst(SemIR::TupleType{parse_node, SemIR::TypeId::TypeType, + type_blocks().Add(type_ids)}); }; return CanonicalizeTypeImpl(SemIR::TupleType::Kind, profile_tuple, make_tuple_inst); diff --git a/toolchain/check/context.h b/toolchain/check/context.h index 301fa139baee..f35eba2042d7 100644 --- a/toolchain/check/context.h +++ b/toolchain/check/context.h @@ -44,6 +44,9 @@ class Context { // Adds an instruction to the current block, returning the produced ID. auto AddInst(SemIR::Inst inst) -> SemIR::InstId; + // Adds an instruction to the constants block, returning the produced ID. + auto AddConstantInst(SemIR::Inst inst) -> SemIR::InstId; + // Pushes a parse tree node onto the stack, storing the SemIR::Inst as the // result. auto AddInstAndPush(Parse::Node parse_node, SemIR::Inst inst) -> void; @@ -275,6 +278,7 @@ class Context { auto inst_blocks() -> SemIR::InstBlockStore& { return sem_ir().inst_blocks(); } + auto constants() -> SemIR::ConstantStore& { return sem_ir().constants(); } private: // A FoldingSet node for a type. diff --git a/toolchain/check/testdata/array/array_in_place.carbon b/toolchain/check/testdata/array/array_in_place.carbon index 023a991e1d73..63e976d84ee3 100644 --- a/toolchain/check/testdata/array/array_in_place.carbon +++ b/toolchain/check/testdata/array/array_in_place.carbon @@ -10,8 +10,15 @@ fn G() { var v: [(i32, i32, i32); 2] = (F(), F()); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7_25.1: type = tuple_type (type, type, type) +// CHECK:STDOUT: %.loc7_25.2: type = tuple_type (i32, i32, i32) +// CHECK:STDOUT: %.loc7_25.3: type = ptr_type (i32, i32, i32) +// CHECK:STDOUT: %.loc10_29: type = ptr_type [(i32, i32, i32); 2] +// CHECK:STDOUT: %.loc10_42: type = tuple_type ((i32, i32, i32), (i32, i32, i32)) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "array_in_place.carbon" { -// CHECK:STDOUT: %.loc7: type = ptr_type (i32, i32, i32) // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: %G: = fn_decl @G // CHECK:STDOUT: } @@ -22,8 +29,7 @@ fn G() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc10_25: (type, type, type) = tuple_literal (i32, i32, i32) // CHECK:STDOUT: %.loc10_28: i32 = int_literal 2 -// CHECK:STDOUT: %.loc10_29.1: type = array_type %.loc10_28, (i32, i32, i32) -// CHECK:STDOUT: %.loc10_29.2: type = ptr_type [(i32, i32, i32); 2] +// CHECK:STDOUT: %.loc10_29: type = array_type %.loc10_28, (i32, i32, i32) // CHECK:STDOUT: %v.var: ref [(i32, i32, i32); 2] = var "v" // CHECK:STDOUT: %v: ref [(i32, i32, i32); 2] = bind_name "v", %v.var // CHECK:STDOUT: %F.ref.loc10_34: = name_reference "F", file.%F @@ -38,9 +44,8 @@ fn G() { // CHECK:STDOUT: %.loc10_42.5: ref (i32, i32, i32) = array_index %v.var, %.loc10_42.4 // CHECK:STDOUT: } // CHECK:STDOUT: %.loc10_40: init (i32, i32, i32) = call %F.ref.loc10_39() to %.loc10_42.6 -// CHECK:STDOUT: %.loc10_42.7: type = tuple_type ((i32, i32, i32), (i32, i32, i32)) -// CHECK:STDOUT: %.loc10_42.8: ((i32, i32, i32), (i32, i32, i32)) = tuple_literal (%.loc10_35, %.loc10_40) -// CHECK:STDOUT: %.loc10_42.9: init [(i32, i32, i32); 2] = array_init %.loc10_42.8, (%.loc10_35, %.loc10_40) to %v.var -// CHECK:STDOUT: assign %v.var, %.loc10_42.9 +// CHECK:STDOUT: %.loc10_42.7: ((i32, i32, i32), (i32, i32, i32)) = tuple_literal (%.loc10_35, %.loc10_40) +// CHECK:STDOUT: %.loc10_42.8: init [(i32, i32, i32); 2] = array_init %.loc10_42.7, (%.loc10_35, %.loc10_40) to %v.var +// CHECK:STDOUT: assign %v.var, %.loc10_42.8 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/array/assign_return_value.carbon b/toolchain/check/testdata/array/assign_return_value.carbon index 59e12a0f1422..0aaf0b0a63bc 100644 --- a/toolchain/check/testdata/array/assign_return_value.carbon +++ b/toolchain/check/testdata/array/assign_return_value.carbon @@ -10,6 +10,12 @@ fn Run() { var t: [i32; 1] = F(); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7_16.1: type = tuple_type (type) +// CHECK:STDOUT: %.loc7_16.2: type = tuple_type (i32) +// CHECK:STDOUT: %.loc10: type = ptr_type [i32; 1] +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "assign_return_value.carbon" { // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: %Run: = fn_decl @Run @@ -26,8 +32,7 @@ fn Run() { // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc10_16: i32 = int_literal 1 -// CHECK:STDOUT: %.loc10_17.1: type = array_type %.loc10_16, i32 -// CHECK:STDOUT: %.loc10_17.2: type = ptr_type [i32; 1] +// CHECK:STDOUT: %.loc10_17: type = array_type %.loc10_16, i32 // CHECK:STDOUT: %t.var: ref [i32; 1] = var "t" // CHECK:STDOUT: %t: ref [i32; 1] = bind_name "t", %t.var // CHECK:STDOUT: %F.ref: = name_reference "F", file.%F diff --git a/toolchain/check/testdata/array/assign_var.carbon b/toolchain/check/testdata/array/assign_var.carbon index be370a0338f7..b1caf214de7a 100644 --- a/toolchain/check/testdata/array/assign_var.carbon +++ b/toolchain/check/testdata/array/assign_var.carbon @@ -7,11 +7,15 @@ var a: (i32, i32, i32) = (1, 2, 3); var b: [i32; 3] = a; -// CHECK:STDOUT: file "assign_var.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc7_22.1: type = tuple_type (type, type, type) -// CHECK:STDOUT: %.loc7_22.2: (type, type, type) = tuple_literal (i32, i32, i32) -// CHECK:STDOUT: %.loc7_22.3: type = tuple_type (i32, i32, i32) -// CHECK:STDOUT: %.loc7_22.4: type = ptr_type (i32, i32, i32) +// CHECK:STDOUT: %.loc7_22.2: type = tuple_type (i32, i32, i32) +// CHECK:STDOUT: %.loc7_22.3: type = ptr_type (i32, i32, i32) +// CHECK:STDOUT: %.loc8: type = ptr_type [i32; 3] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "assign_var.carbon" { +// CHECK:STDOUT: %.loc7_22: (type, type, type) = tuple_literal (i32, i32, i32) // CHECK:STDOUT: %a.var: ref (i32, i32, i32) = var "a" // CHECK:STDOUT: %a: ref (i32, i32, i32) = bind_name "a", %a.var // CHECK:STDOUT: %.loc7_27: i32 = int_literal 1 @@ -27,8 +31,7 @@ var b: [i32; 3] = a; // CHECK:STDOUT: %.loc7_34.8: init (i32, i32, i32) = tuple_init %.loc7_34.1, (%.loc7_34.3, %.loc7_34.5, %.loc7_34.7) // CHECK:STDOUT: assign %a.var, %.loc7_34.8 // CHECK:STDOUT: %.loc8_14: i32 = int_literal 3 -// CHECK:STDOUT: %.loc8_15.1: type = array_type %.loc8_14, i32 -// CHECK:STDOUT: %.loc8_15.2: type = ptr_type [i32; 3] +// CHECK:STDOUT: %.loc8_15: type = array_type %.loc8_14, i32 // CHECK:STDOUT: %b.var: ref [i32; 3] = var "b" // CHECK:STDOUT: %b: ref [i32; 3] = bind_name "b", %b.var // CHECK:STDOUT: %a.ref: ref (i32, i32, i32) = name_reference "a", %a diff --git a/toolchain/check/testdata/array/base.carbon b/toolchain/check/testdata/array/base.carbon index fee3cf4605eb..89a25de6f3f6 100644 --- a/toolchain/check/testdata/array/base.carbon +++ b/toolchain/check/testdata/array/base.carbon @@ -8,42 +8,46 @@ var a: [i32; 1] = (1,); var b: [f64; 2] = (11.1, 2.2,); var c: [(); 5] = ((), (), (), (), (),); +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7_15: type = ptr_type [i32; 1] +// CHECK:STDOUT: %.loc7_22: type = tuple_type (i32) +// CHECK:STDOUT: %.loc8_15: type = ptr_type [f64; 2] +// CHECK:STDOUT: %.loc8_30: type = tuple_type (f64, f64) +// CHECK:STDOUT: %.loc9_10: type = tuple_type () +// CHECK:STDOUT: %.loc9_14: type = ptr_type [(); 5] +// CHECK:STDOUT: %.loc9_38: type = tuple_type ((), (), (), (), ()) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "base.carbon" { // CHECK:STDOUT: %.loc7_14: i32 = int_literal 1 -// CHECK:STDOUT: %.loc7_15.1: type = array_type %.loc7_14, i32 -// CHECK:STDOUT: %.loc7_15.2: type = ptr_type [i32; 1] +// CHECK:STDOUT: %.loc7_15: type = array_type %.loc7_14, i32 // CHECK:STDOUT: %a.var: ref [i32; 1] = var "a" // CHECK:STDOUT: %a: ref [i32; 1] = bind_name "a", %a.var // CHECK:STDOUT: %.loc7_20: i32 = int_literal 1 -// CHECK:STDOUT: %.loc7_22.1: type = tuple_type (i32) -// CHECK:STDOUT: %.loc7_22.2: (i32,) = tuple_literal (%.loc7_20) -// CHECK:STDOUT: %.loc7_22.3: i32 = int_literal 0 -// CHECK:STDOUT: %.loc7_22.4: ref i32 = array_index %a.var, %.loc7_22.3 -// CHECK:STDOUT: %.loc7_22.5: init i32 = initialize_from %.loc7_20 to %.loc7_22.4 -// CHECK:STDOUT: %.loc7_22.6: init [i32; 1] = array_init %.loc7_22.2, (%.loc7_22.5) to %a.var -// CHECK:STDOUT: assign %a.var, %.loc7_22.6 +// CHECK:STDOUT: %.loc7_22.1: (i32,) = tuple_literal (%.loc7_20) +// CHECK:STDOUT: %.loc7_22.2: i32 = int_literal 0 +// CHECK:STDOUT: %.loc7_22.3: ref i32 = array_index %a.var, %.loc7_22.2 +// CHECK:STDOUT: %.loc7_22.4: init i32 = initialize_from %.loc7_20 to %.loc7_22.3 +// CHECK:STDOUT: %.loc7_22.5: init [i32; 1] = array_init %.loc7_22.1, (%.loc7_22.4) to %a.var +// CHECK:STDOUT: assign %a.var, %.loc7_22.5 // CHECK:STDOUT: %.loc8_14: i32 = int_literal 2 -// CHECK:STDOUT: %.loc8_15.1: type = array_type %.loc8_14, f64 -// CHECK:STDOUT: %.loc8_15.2: type = ptr_type [f64; 2] +// CHECK:STDOUT: %.loc8_15: type = array_type %.loc8_14, f64 // CHECK:STDOUT: %b.var: ref [f64; 2] = var "b" // CHECK:STDOUT: %b: ref [f64; 2] = bind_name "b", %b.var // CHECK:STDOUT: %.loc8_20: f64 = real_literal 111e-1 // CHECK:STDOUT: %.loc8_26: f64 = real_literal 22e-1 -// CHECK:STDOUT: %.loc8_30.1: type = tuple_type (f64, f64) -// CHECK:STDOUT: %.loc8_30.2: (f64, f64) = tuple_literal (%.loc8_20, %.loc8_26) -// CHECK:STDOUT: %.loc8_30.3: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_30.4: ref f64 = array_index %b.var, %.loc8_30.3 -// CHECK:STDOUT: %.loc8_30.5: init f64 = initialize_from %.loc8_20 to %.loc8_30.4 -// CHECK:STDOUT: %.loc8_30.6: i32 = int_literal 1 -// CHECK:STDOUT: %.loc8_30.7: ref f64 = array_index %b.var, %.loc8_30.6 -// CHECK:STDOUT: %.loc8_30.8: init f64 = initialize_from %.loc8_26 to %.loc8_30.7 -// CHECK:STDOUT: %.loc8_30.9: init [f64; 2] = array_init %.loc8_30.2, (%.loc8_30.5, %.loc8_30.8) to %b.var -// CHECK:STDOUT: assign %b.var, %.loc8_30.9 -// CHECK:STDOUT: %.loc9_10.1: type = tuple_type () -// CHECK:STDOUT: %.loc9_10.2: () = tuple_literal () +// CHECK:STDOUT: %.loc8_30.1: (f64, f64) = tuple_literal (%.loc8_20, %.loc8_26) +// CHECK:STDOUT: %.loc8_30.2: i32 = int_literal 0 +// CHECK:STDOUT: %.loc8_30.3: ref f64 = array_index %b.var, %.loc8_30.2 +// CHECK:STDOUT: %.loc8_30.4: init f64 = initialize_from %.loc8_20 to %.loc8_30.3 +// CHECK:STDOUT: %.loc8_30.5: i32 = int_literal 1 +// CHECK:STDOUT: %.loc8_30.6: ref f64 = array_index %b.var, %.loc8_30.5 +// CHECK:STDOUT: %.loc8_30.7: init f64 = initialize_from %.loc8_26 to %.loc8_30.6 +// CHECK:STDOUT: %.loc8_30.8: init [f64; 2] = array_init %.loc8_30.1, (%.loc8_30.4, %.loc8_30.7) to %b.var +// CHECK:STDOUT: assign %b.var, %.loc8_30.8 +// CHECK:STDOUT: %.loc9_10: () = tuple_literal () // CHECK:STDOUT: %.loc9_13: i32 = int_literal 5 -// CHECK:STDOUT: %.loc9_14.1: type = array_type %.loc9_13, () -// CHECK:STDOUT: %.loc9_14.2: type = ptr_type [(); 5] +// CHECK:STDOUT: %.loc9_14: type = array_type %.loc9_13, () // CHECK:STDOUT: %c.var: ref [(); 5] = var "c" // CHECK:STDOUT: %c: ref [(); 5] = bind_name "c", %c.var // CHECK:STDOUT: %.loc9_20.1: () = tuple_literal () @@ -51,13 +55,12 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: %.loc9_28.1: () = tuple_literal () // CHECK:STDOUT: %.loc9_32.1: () = tuple_literal () // CHECK:STDOUT: %.loc9_36.1: () = tuple_literal () -// CHECK:STDOUT: %.loc9_38.1: type = tuple_type ((), (), (), (), ()) -// CHECK:STDOUT: %.loc9_38.2: ((), (), (), (), ()) = tuple_literal (%.loc9_20.1, %.loc9_24.1, %.loc9_28.1, %.loc9_32.1, %.loc9_36.1) +// CHECK:STDOUT: %.loc9_38.1: ((), (), (), (), ()) = tuple_literal (%.loc9_20.1, %.loc9_24.1, %.loc9_28.1, %.loc9_32.1, %.loc9_36.1) // CHECK:STDOUT: %.loc9_20.2: init () = tuple_init %.loc9_20.1, () // CHECK:STDOUT: %.loc9_24.2: init () = tuple_init %.loc9_24.1, () // CHECK:STDOUT: %.loc9_28.2: init () = tuple_init %.loc9_28.1, () // CHECK:STDOUT: %.loc9_32.2: init () = tuple_init %.loc9_32.1, () // CHECK:STDOUT: %.loc9_36.2: init () = tuple_init %.loc9_36.1, () -// CHECK:STDOUT: %.loc9_38.3: init [(); 5] = array_init %.loc9_38.2, (%.loc9_20.2, %.loc9_24.2, %.loc9_28.2, %.loc9_32.2, %.loc9_36.2) to %c.var -// CHECK:STDOUT: assign %c.var, %.loc9_38.3 +// CHECK:STDOUT: %.loc9_38.2: init [(); 5] = array_init %.loc9_38.1, (%.loc9_20.2, %.loc9_24.2, %.loc9_28.2, %.loc9_32.2, %.loc9_36.2) to %c.var +// CHECK:STDOUT: assign %c.var, %.loc9_38.2 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/array/fail_incomplete_element.carbon b/toolchain/check/testdata/array/fail_incomplete_element.carbon index 7da1ad462aa5..be2a3e062432 100644 --- a/toolchain/check/testdata/array/fail_incomplete_element.carbon +++ b/toolchain/check/testdata/array/fail_incomplete_element.carbon @@ -19,6 +19,10 @@ var a: [Incomplete; 1]; // CHECK:STDERR: ^ var p: Incomplete* = &a[0]; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc20: type = ptr_type +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_incomplete_element.carbon" { // CHECK:STDOUT: class_declaration @Incomplete, () // CHECK:STDOUT: %Incomplete: type = class_type @Incomplete @@ -33,8 +37,7 @@ var p: Incomplete* = &a[0]; // CHECK:STDOUT: %p: ref Incomplete* = bind_name "p", %p.var // CHECK:STDOUT: %a.ref: ref = name_reference "a", %a // CHECK:STDOUT: %.loc20_25: i32 = int_literal 0 -// CHECK:STDOUT: %.loc20_22.1: type = ptr_type -// CHECK:STDOUT: %.loc20_22.2: * = address_of +// CHECK:STDOUT: %.loc20_22: * = address_of // CHECK:STDOUT: assign %p.var, // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/array/fail_invalid_type.carbon b/toolchain/check/testdata/array/fail_invalid_type.carbon index cdef3091c66e..1d43cef44f26 100644 --- a/toolchain/check/testdata/array/fail_invalid_type.carbon +++ b/toolchain/check/testdata/array/fail_invalid_type.carbon @@ -9,11 +9,14 @@ // CHECK:STDERR: ^ var a: [1; 1]; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10: type = ptr_type [; 1] +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_invalid_type.carbon" { // CHECK:STDOUT: %.loc10_9: i32 = int_literal 1 // CHECK:STDOUT: %.loc10_12: i32 = int_literal 1 -// CHECK:STDOUT: %.loc10_13.1: type = array_type %.loc10_12, -// CHECK:STDOUT: %.loc10_13.2: type = ptr_type [; 1] +// CHECK:STDOUT: %.loc10_13: type = array_type %.loc10_12, // CHECK:STDOUT: %a.var: ref [; 1] = var "a" // CHECK:STDOUT: %a: ref [; 1] = bind_name "a", %a.var // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/array/fail_out_of_bound.carbon b/toolchain/check/testdata/array/fail_out_of_bound.carbon index 285a187be0d9..1fefe46f735c 100644 --- a/toolchain/check/testdata/array/fail_out_of_bound.carbon +++ b/toolchain/check/testdata/array/fail_out_of_bound.carbon @@ -9,16 +9,19 @@ // CHECK:STDERR: ^ var a: [i32; 1] = (1, 2, 3); +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10_15: type = ptr_type [i32; 1] +// CHECK:STDOUT: %.loc10_27: type = tuple_type (i32, i32, i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_out_of_bound.carbon" { // CHECK:STDOUT: %.loc10_14: i32 = int_literal 1 -// CHECK:STDOUT: %.loc10_15.1: type = array_type %.loc10_14, i32 -// CHECK:STDOUT: %.loc10_15.2: type = ptr_type [i32; 1] +// CHECK:STDOUT: %.loc10_15: type = array_type %.loc10_14, i32 // CHECK:STDOUT: %a.var: ref [i32; 1] = var "a" // CHECK:STDOUT: %a: ref [i32; 1] = bind_name "a", %a.var // CHECK:STDOUT: %.loc10_20: i32 = int_literal 1 // CHECK:STDOUT: %.loc10_23: i32 = int_literal 2 // CHECK:STDOUT: %.loc10_26: i32 = int_literal 3 -// CHECK:STDOUT: %.loc10_27.1: type = tuple_type (i32, i32, i32) -// CHECK:STDOUT: %.loc10_27.2: (i32, i32, i32) = tuple_literal (%.loc10_20, %.loc10_23, %.loc10_26) +// CHECK:STDOUT: %.loc10_27: (i32, i32, i32) = tuple_literal (%.loc10_20, %.loc10_23, %.loc10_26) // CHECK:STDOUT: assign %a.var, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/array/fail_type_mismatch.carbon b/toolchain/check/testdata/array/fail_type_mismatch.carbon index c9472115927b..e98c37a17f6c 100644 --- a/toolchain/check/testdata/array/fail_type_mismatch.carbon +++ b/toolchain/check/testdata/array/fail_type_mismatch.carbon @@ -26,26 +26,32 @@ var t2: (i32, i32); // CHECK:STDERR: ^ var d: [i32; 3] = t2; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10_15: type = ptr_type [i32; 3] +// CHECK:STDOUT: %.1: type = ptr_type String +// CHECK:STDOUT: %.loc10_39.1: type = tuple_type (i32, String, String) +// CHECK:STDOUT: %.loc12: type = tuple_type (type, type, type) +// CHECK:STDOUT: %.loc10_39.2: type = tuple_type (i32, String*, String*) +// CHECK:STDOUT: %.loc10_39.3: type = ptr_type (i32, String*, String*) +// CHECK:STDOUT: %.loc21_24.1: type = tuple_type (i32, i32) +// CHECK:STDOUT: %.loc23: type = tuple_type (type, type) +// CHECK:STDOUT: %.loc21_24.2: type = ptr_type (i32, i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_type_mismatch.carbon" { // CHECK:STDOUT: %.loc10_14: i32 = int_literal 3 -// CHECK:STDOUT: %.loc10_15.1: type = array_type %.loc10_14, i32 -// CHECK:STDOUT: %.loc10_15.2: type = ptr_type [i32; 3] +// CHECK:STDOUT: %.loc10_15: type = array_type %.loc10_14, i32 // CHECK:STDOUT: %a.var: ref [i32; 3] = var "a" // CHECK:STDOUT: %a: ref [i32; 3] = bind_name "a", %a.var // CHECK:STDOUT: %.loc10_20: i32 = int_literal 1 -// CHECK:STDOUT: %.1: type = ptr_type String // CHECK:STDOUT: %.loc10_23: String = string_literal "Hello" // CHECK:STDOUT: %.loc10_32: String = string_literal "World" -// CHECK:STDOUT: %.loc10_39.1: type = tuple_type (i32, String, String) -// CHECK:STDOUT: %.loc10_39.2: (i32, String, String) = tuple_literal (%.loc10_20, %.loc10_23, %.loc10_32) -// CHECK:STDOUT: %.loc10_39.3: i32 = int_literal 0 -// CHECK:STDOUT: %.loc10_39.4: ref i32 = array_index %a.var, %.loc10_39.3 -// CHECK:STDOUT: %.loc10_39.5: init i32 = initialize_from %.loc10_20 to %.loc10_39.4 +// CHECK:STDOUT: %.loc10_39.1: (i32, String, String) = tuple_literal (%.loc10_20, %.loc10_23, %.loc10_32) +// CHECK:STDOUT: %.loc10_39.2: i32 = int_literal 0 +// CHECK:STDOUT: %.loc10_39.3: ref i32 = array_index %a.var, %.loc10_39.2 +// CHECK:STDOUT: %.loc10_39.4: init i32 = initialize_from %.loc10_20 to %.loc10_39.3 // CHECK:STDOUT: assign %a.var, -// CHECK:STDOUT: %.loc12_29.1: type = tuple_type (type, type, type) -// CHECK:STDOUT: %.loc12_29.2: (type, type, type) = tuple_literal (i32, String, String) -// CHECK:STDOUT: %.loc10_39.6: type = tuple_type (i32, String*, String*) -// CHECK:STDOUT: %.loc10_39.7: type = ptr_type (i32, String*, String*) +// CHECK:STDOUT: %.loc12: (type, type, type) = tuple_literal (i32, String, String) // CHECK:STDOUT: %t1.var: ref (i32, String, String) = var "t1" // CHECK:STDOUT: %t1: ref (i32, String, String) = bind_name "t1", %t1.var // CHECK:STDOUT: %.loc16_14: i32 = int_literal 3 @@ -66,12 +72,9 @@ var d: [i32; 3] = t2; // CHECK:STDOUT: %c: ref [i32; 3] = bind_name "c", %c.var // CHECK:STDOUT: %.loc21_20: i32 = int_literal 1 // CHECK:STDOUT: %.loc21_23: i32 = int_literal 2 -// CHECK:STDOUT: %.loc21_24.1: type = tuple_type (i32, i32) -// CHECK:STDOUT: %.loc21_24.2: (i32, i32) = tuple_literal (%.loc21_20, %.loc21_23) +// CHECK:STDOUT: %.loc21_24: (i32, i32) = tuple_literal (%.loc21_20, %.loc21_23) // CHECK:STDOUT: assign %c.var, -// CHECK:STDOUT: %.loc23_18.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc23_18.2: (type, type) = tuple_literal (i32, i32) -// CHECK:STDOUT: %.loc21_24.3: type = ptr_type (i32, i32) +// CHECK:STDOUT: %.loc23: (type, type) = tuple_literal (i32, i32) // CHECK:STDOUT: %t2.var: ref (i32, i32) = var "t2" // CHECK:STDOUT: %t2: ref (i32, i32) = bind_name "t2", %t2.var // CHECK:STDOUT: %.loc27_14: i32 = int_literal 3 diff --git a/toolchain/check/testdata/array/function_param.carbon b/toolchain/check/testdata/array/function_param.carbon index 538654ec0d6d..83e7736c522b 100644 --- a/toolchain/check/testdata/array/function_param.carbon +++ b/toolchain/check/testdata/array/function_param.carbon @@ -12,6 +12,11 @@ fn G() -> i32 { return F((1, 2, 3), 1); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7: type = ptr_type [i32; 3] +// CHECK:STDOUT: %.loc12: type = tuple_type (i32, i32, i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "function_param.carbon" { // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: %G: = fn_decl @G @@ -19,7 +24,6 @@ fn G() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%arr: [i32; 3], %i: i32) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: type = ptr_type [i32; 3] // CHECK:STDOUT: %arr.ref: [i32; 3] = name_reference "arr", %arr // CHECK:STDOUT: %i.ref: i32 = name_reference "i", %i // CHECK:STDOUT: %.loc8_15.1: ref [i32; 3] = value_as_reference %arr.ref @@ -34,23 +38,22 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc12_13: i32 = int_literal 1 // CHECK:STDOUT: %.loc12_16: i32 = int_literal 2 // CHECK:STDOUT: %.loc12_19: i32 = int_literal 3 -// CHECK:STDOUT: %.loc12_20.1: type = tuple_type (i32, i32, i32) -// CHECK:STDOUT: %.loc12_20.2: (i32, i32, i32) = tuple_literal (%.loc12_13, %.loc12_16, %.loc12_19) +// CHECK:STDOUT: %.loc12_20.1: (i32, i32, i32) = tuple_literal (%.loc12_13, %.loc12_16, %.loc12_19) // CHECK:STDOUT: %.loc12_23: i32 = int_literal 1 -// CHECK:STDOUT: %.loc12_20.3: ref [i32; 3] = temporary_storage -// CHECK:STDOUT: %.loc12_20.4: i32 = int_literal 0 -// CHECK:STDOUT: %.loc12_20.5: ref i32 = array_index %.loc12_20.3, %.loc12_20.4 -// CHECK:STDOUT: %.loc12_20.6: init i32 = initialize_from %.loc12_13 to %.loc12_20.5 -// CHECK:STDOUT: %.loc12_20.7: i32 = int_literal 1 -// CHECK:STDOUT: %.loc12_20.8: ref i32 = array_index %.loc12_20.3, %.loc12_20.7 -// CHECK:STDOUT: %.loc12_20.9: init i32 = initialize_from %.loc12_16 to %.loc12_20.8 -// CHECK:STDOUT: %.loc12_20.10: i32 = int_literal 2 -// CHECK:STDOUT: %.loc12_20.11: ref i32 = array_index %.loc12_20.3, %.loc12_20.10 -// CHECK:STDOUT: %.loc12_20.12: init i32 = initialize_from %.loc12_19 to %.loc12_20.11 -// CHECK:STDOUT: %.loc12_20.13: init [i32; 3] = array_init %.loc12_20.2, (%.loc12_20.6, %.loc12_20.9, %.loc12_20.12) to %.loc12_20.3 -// CHECK:STDOUT: %.loc12_20.14: ref [i32; 3] = temporary %.loc12_20.3, %.loc12_20.13 -// CHECK:STDOUT: %.loc12_20.15: [i32; 3] = bind_value %.loc12_20.14 -// CHECK:STDOUT: %.loc12_11: init i32 = call %F.ref(%.loc12_20.15, %.loc12_23) +// CHECK:STDOUT: %.loc12_20.2: ref [i32; 3] = temporary_storage +// CHECK:STDOUT: %.loc12_20.3: i32 = int_literal 0 +// CHECK:STDOUT: %.loc12_20.4: ref i32 = array_index %.loc12_20.2, %.loc12_20.3 +// CHECK:STDOUT: %.loc12_20.5: init i32 = initialize_from %.loc12_13 to %.loc12_20.4 +// CHECK:STDOUT: %.loc12_20.6: i32 = int_literal 1 +// CHECK:STDOUT: %.loc12_20.7: ref i32 = array_index %.loc12_20.2, %.loc12_20.6 +// CHECK:STDOUT: %.loc12_20.8: init i32 = initialize_from %.loc12_16 to %.loc12_20.7 +// CHECK:STDOUT: %.loc12_20.9: i32 = int_literal 2 +// CHECK:STDOUT: %.loc12_20.10: ref i32 = array_index %.loc12_20.2, %.loc12_20.9 +// CHECK:STDOUT: %.loc12_20.11: init i32 = initialize_from %.loc12_19 to %.loc12_20.10 +// CHECK:STDOUT: %.loc12_20.12: init [i32; 3] = array_init %.loc12_20.1, (%.loc12_20.5, %.loc12_20.8, %.loc12_20.11) to %.loc12_20.2 +// CHECK:STDOUT: %.loc12_20.13: ref [i32; 3] = temporary %.loc12_20.2, %.loc12_20.12 +// CHECK:STDOUT: %.loc12_20.14: [i32; 3] = bind_value %.loc12_20.13 +// CHECK:STDOUT: %.loc12_11: init i32 = call %F.ref(%.loc12_20.14, %.loc12_23) // CHECK:STDOUT: %.loc12_25: i32 = value_of_initializer %.loc12_11 // CHECK:STDOUT: return %.loc12_25 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/array/nine_elements.carbon b/toolchain/check/testdata/array/nine_elements.carbon index 821873425673..80f32ccc3acc 100644 --- a/toolchain/check/testdata/array/nine_elements.carbon +++ b/toolchain/check/testdata/array/nine_elements.carbon @@ -6,10 +6,14 @@ var a: [i32; 9] = (1, 2, 3, 4, 5, 6, 7, 8, 9); +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7_15: type = ptr_type [i32; 9] +// CHECK:STDOUT: %.loc7_45: type = tuple_type (i32, i32, i32, i32, i32, i32, i32, i32, i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "nine_elements.carbon" { // CHECK:STDOUT: %.loc7_14: i32 = int_literal 9 -// CHECK:STDOUT: %.loc7_15.1: type = array_type %.loc7_14, i32 -// CHECK:STDOUT: %.loc7_15.2: type = ptr_type [i32; 9] +// CHECK:STDOUT: %.loc7_15: type = array_type %.loc7_14, i32 // CHECK:STDOUT: %a.var: ref [i32; 9] = var "a" // CHECK:STDOUT: %a: ref [i32; 9] = bind_name "a", %a.var // CHECK:STDOUT: %.loc7_20: i32 = int_literal 1 @@ -21,35 +25,34 @@ var a: [i32; 9] = (1, 2, 3, 4, 5, 6, 7, 8, 9); // CHECK:STDOUT: %.loc7_38: i32 = int_literal 7 // CHECK:STDOUT: %.loc7_41: i32 = int_literal 8 // CHECK:STDOUT: %.loc7_44: i32 = int_literal 9 -// CHECK:STDOUT: %.loc7_45.1: type = tuple_type (i32, i32, i32, i32, i32, i32, i32, i32, i32) -// CHECK:STDOUT: %.loc7_45.2: (i32, i32, i32, i32, i32, i32, i32, i32, i32) = tuple_literal (%.loc7_20, %.loc7_23, %.loc7_26, %.loc7_29, %.loc7_32, %.loc7_35, %.loc7_38, %.loc7_41, %.loc7_44) -// CHECK:STDOUT: %.loc7_45.3: i32 = int_literal 0 -// CHECK:STDOUT: %.loc7_45.4: ref i32 = array_index %a.var, %.loc7_45.3 -// CHECK:STDOUT: %.loc7_45.5: init i32 = initialize_from %.loc7_20 to %.loc7_45.4 -// CHECK:STDOUT: %.loc7_45.6: i32 = int_literal 1 -// CHECK:STDOUT: %.loc7_45.7: ref i32 = array_index %a.var, %.loc7_45.6 -// CHECK:STDOUT: %.loc7_45.8: init i32 = initialize_from %.loc7_23 to %.loc7_45.7 -// CHECK:STDOUT: %.loc7_45.9: i32 = int_literal 2 -// CHECK:STDOUT: %.loc7_45.10: ref i32 = array_index %a.var, %.loc7_45.9 -// CHECK:STDOUT: %.loc7_45.11: init i32 = initialize_from %.loc7_26 to %.loc7_45.10 -// CHECK:STDOUT: %.loc7_45.12: i32 = int_literal 3 -// CHECK:STDOUT: %.loc7_45.13: ref i32 = array_index %a.var, %.loc7_45.12 -// CHECK:STDOUT: %.loc7_45.14: init i32 = initialize_from %.loc7_29 to %.loc7_45.13 -// CHECK:STDOUT: %.loc7_45.15: i32 = int_literal 4 -// CHECK:STDOUT: %.loc7_45.16: ref i32 = array_index %a.var, %.loc7_45.15 -// CHECK:STDOUT: %.loc7_45.17: init i32 = initialize_from %.loc7_32 to %.loc7_45.16 -// CHECK:STDOUT: %.loc7_45.18: i32 = int_literal 5 -// CHECK:STDOUT: %.loc7_45.19: ref i32 = array_index %a.var, %.loc7_45.18 -// CHECK:STDOUT: %.loc7_45.20: init i32 = initialize_from %.loc7_35 to %.loc7_45.19 -// CHECK:STDOUT: %.loc7_45.21: i32 = int_literal 6 -// CHECK:STDOUT: %.loc7_45.22: ref i32 = array_index %a.var, %.loc7_45.21 -// CHECK:STDOUT: %.loc7_45.23: init i32 = initialize_from %.loc7_38 to %.loc7_45.22 -// CHECK:STDOUT: %.loc7_45.24: i32 = int_literal 7 -// CHECK:STDOUT: %.loc7_45.25: ref i32 = array_index %a.var, %.loc7_45.24 -// CHECK:STDOUT: %.loc7_45.26: init i32 = initialize_from %.loc7_41 to %.loc7_45.25 -// CHECK:STDOUT: %.loc7_45.27: i32 = int_literal 8 -// CHECK:STDOUT: %.loc7_45.28: ref i32 = array_index %a.var, %.loc7_45.27 -// CHECK:STDOUT: %.loc7_45.29: init i32 = initialize_from %.loc7_44 to %.loc7_45.28 -// CHECK:STDOUT: %.loc7_45.30: init [i32; 9] = array_init %.loc7_45.2, (%.loc7_45.5, %.loc7_45.8, %.loc7_45.11, %.loc7_45.14, %.loc7_45.17, %.loc7_45.20, %.loc7_45.23, %.loc7_45.26, %.loc7_45.29) to %a.var -// CHECK:STDOUT: assign %a.var, %.loc7_45.30 +// CHECK:STDOUT: %.loc7_45.1: (i32, i32, i32, i32, i32, i32, i32, i32, i32) = tuple_literal (%.loc7_20, %.loc7_23, %.loc7_26, %.loc7_29, %.loc7_32, %.loc7_35, %.loc7_38, %.loc7_41, %.loc7_44) +// CHECK:STDOUT: %.loc7_45.2: i32 = int_literal 0 +// CHECK:STDOUT: %.loc7_45.3: ref i32 = array_index %a.var, %.loc7_45.2 +// CHECK:STDOUT: %.loc7_45.4: init i32 = initialize_from %.loc7_20 to %.loc7_45.3 +// CHECK:STDOUT: %.loc7_45.5: i32 = int_literal 1 +// CHECK:STDOUT: %.loc7_45.6: ref i32 = array_index %a.var, %.loc7_45.5 +// CHECK:STDOUT: %.loc7_45.7: init i32 = initialize_from %.loc7_23 to %.loc7_45.6 +// CHECK:STDOUT: %.loc7_45.8: i32 = int_literal 2 +// CHECK:STDOUT: %.loc7_45.9: ref i32 = array_index %a.var, %.loc7_45.8 +// CHECK:STDOUT: %.loc7_45.10: init i32 = initialize_from %.loc7_26 to %.loc7_45.9 +// CHECK:STDOUT: %.loc7_45.11: i32 = int_literal 3 +// CHECK:STDOUT: %.loc7_45.12: ref i32 = array_index %a.var, %.loc7_45.11 +// CHECK:STDOUT: %.loc7_45.13: init i32 = initialize_from %.loc7_29 to %.loc7_45.12 +// CHECK:STDOUT: %.loc7_45.14: i32 = int_literal 4 +// CHECK:STDOUT: %.loc7_45.15: ref i32 = array_index %a.var, %.loc7_45.14 +// CHECK:STDOUT: %.loc7_45.16: init i32 = initialize_from %.loc7_32 to %.loc7_45.15 +// CHECK:STDOUT: %.loc7_45.17: i32 = int_literal 5 +// CHECK:STDOUT: %.loc7_45.18: ref i32 = array_index %a.var, %.loc7_45.17 +// CHECK:STDOUT: %.loc7_45.19: init i32 = initialize_from %.loc7_35 to %.loc7_45.18 +// CHECK:STDOUT: %.loc7_45.20: i32 = int_literal 6 +// CHECK:STDOUT: %.loc7_45.21: ref i32 = array_index %a.var, %.loc7_45.20 +// CHECK:STDOUT: %.loc7_45.22: init i32 = initialize_from %.loc7_38 to %.loc7_45.21 +// CHECK:STDOUT: %.loc7_45.23: i32 = int_literal 7 +// CHECK:STDOUT: %.loc7_45.24: ref i32 = array_index %a.var, %.loc7_45.23 +// CHECK:STDOUT: %.loc7_45.25: init i32 = initialize_from %.loc7_41 to %.loc7_45.24 +// CHECK:STDOUT: %.loc7_45.26: i32 = int_literal 8 +// CHECK:STDOUT: %.loc7_45.27: ref i32 = array_index %a.var, %.loc7_45.26 +// CHECK:STDOUT: %.loc7_45.28: init i32 = initialize_from %.loc7_44 to %.loc7_45.27 +// CHECK:STDOUT: %.loc7_45.29: init [i32; 9] = array_init %.loc7_45.1, (%.loc7_45.4, %.loc7_45.7, %.loc7_45.10, %.loc7_45.13, %.loc7_45.16, %.loc7_45.19, %.loc7_45.22, %.loc7_45.25, %.loc7_45.28) to %a.var +// CHECK:STDOUT: assign %a.var, %.loc7_45.29 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/as/as_type.carbon b/toolchain/check/testdata/as/as_type.carbon index 32f4fec888e6..b4d237f42b22 100644 --- a/toolchain/check/testdata/as/as_type.carbon +++ b/toolchain/check/testdata/as/as_type.carbon @@ -6,9 +6,12 @@ let t: type = (i32, i32) as type; -// CHECK:STDOUT: file "as_type.carbon" { -// CHECK:STDOUT: %.loc7_24.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc7_24.2: (type, type) = tuple_literal (i32, i32) +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7_24: type = tuple_type (type, type) // CHECK:STDOUT: %.loc7_26: type = tuple_type (i32, i32) -// CHECK:STDOUT: %t: type = bind_name "t", %.loc7_26 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "as_type.carbon" { +// CHECK:STDOUT: %.loc7: (type, type) = tuple_literal (i32, i32) +// CHECK:STDOUT: %t: type = bind_name "t", constants.%.loc7_26 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/as/fail_no_conversion.carbon b/toolchain/check/testdata/as/fail_no_conversion.carbon index e2eea2053968..e0741410a7f3 100644 --- a/toolchain/check/testdata/as/fail_no_conversion.carbon +++ b/toolchain/check/testdata/as/fail_no_conversion.carbon @@ -9,11 +9,14 @@ // CHECK:STDERR: ^ let n: (i32, i32) = 1 as (i32, i32); -// CHECK:STDOUT: file "fail_no_conversion.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc10_17.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc10_17.2: (type, type) = tuple_literal (i32, i32) -// CHECK:STDOUT: %.loc10_17.3: type = tuple_type (i32, i32) -// CHECK:STDOUT: %.loc10_17.4: type = ptr_type (i32, i32) +// CHECK:STDOUT: %.loc10_17.2: type = tuple_type (i32, i32) +// CHECK:STDOUT: %.loc10_17.3: type = ptr_type (i32, i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "fail_no_conversion.carbon" { +// CHECK:STDOUT: %.loc10_17: (type, type) = tuple_literal (i32, i32) // CHECK:STDOUT: %.loc10_21: i32 = int_literal 1 // CHECK:STDOUT: %.loc10_35: (type, type) = tuple_literal (i32, i32) // CHECK:STDOUT: %n: (i32, i32) = bind_name "n", diff --git a/toolchain/check/testdata/as/identity.carbon b/toolchain/check/testdata/as/identity.carbon index 8f7e17bca3df..cb42a79e2da7 100644 --- a/toolchain/check/testdata/as/identity.carbon +++ b/toolchain/check/testdata/as/identity.carbon @@ -24,10 +24,15 @@ fn Initializing() { var x: X = (Make() as X); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc11_1.1: type = struct_type {} +// CHECK:STDOUT: %.loc11_1.2: type = tuple_type () +// CHECK:STDOUT: %.loc9: type = ptr_type {} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "identity.carbon" { // CHECK:STDOUT: class_declaration @X, () // CHECK:STDOUT: %X: type = class_type @X -// CHECK:STDOUT: %.loc11: type = struct_type {} // CHECK:STDOUT: %Value: = fn_decl @Value // CHECK:STDOUT: %Reference: = fn_decl @Reference // CHECK:STDOUT: %Make: = fn_decl @Make @@ -41,8 +46,6 @@ fn Initializing() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Value(%n: X) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11: type = tuple_type () -// CHECK:STDOUT: %.loc9: type = ptr_type {} // CHECK:STDOUT: %X.ref.loc14_10: type = name_reference "X", file.%X // CHECK:STDOUT: %n.ref: X = name_reference "n", %n // CHECK:STDOUT: %X.ref.loc14_19: type = name_reference "X", file.%X diff --git a/toolchain/check/testdata/as/tuple.carbon b/toolchain/check/testdata/as/tuple.carbon index b48a3e5fcacb..a871bc29efde 100644 --- a/toolchain/check/testdata/as/tuple.carbon +++ b/toolchain/check/testdata/as/tuple.carbon @@ -20,12 +20,19 @@ fn Var() { var b: (X, X) = (Make(), Make()) as (X, X); } -// CHECK:STDOUT: file "tuple.carbon" { -// CHECK:STDOUT: class_declaration @X, () -// CHECK:STDOUT: %X: type = class_type @X +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc9_1.1: type = struct_type {} // CHECK:STDOUT: %.loc9_1.2: type = tuple_type () // CHECK:STDOUT: %.loc7: type = ptr_type {} +// CHECK:STDOUT: %.loc15_15.1: type = tuple_type (type, type) +// CHECK:STDOUT: %.loc15_15.2: type = tuple_type (X, X) +// CHECK:STDOUT: %.loc15_15.3: type = tuple_type ({}*, {}*) +// CHECK:STDOUT: %.loc15_15.4: type = ptr_type ({}*, {}*) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "tuple.carbon" { +// CHECK:STDOUT: class_declaration @X, () +// CHECK:STDOUT: %X: type = class_type @X // CHECK:STDOUT: %Make: = fn_decl @Make // CHECK:STDOUT: %Let: = fn_decl @Let // CHECK:STDOUT: %Var: = fn_decl @Var @@ -42,11 +49,7 @@ fn Var() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %X.ref.loc15_11: type = name_reference "X", file.%X // CHECK:STDOUT: %X.ref.loc15_14: type = name_reference "X", file.%X -// CHECK:STDOUT: %.loc15_15.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc15_15.2: (type, type) = tuple_literal (%X.ref.loc15_11, %X.ref.loc15_14) -// CHECK:STDOUT: %.loc15_15.3: type = tuple_type (X, X) -// CHECK:STDOUT: %.loc15_15.4: type = tuple_type ({}*, {}*) -// CHECK:STDOUT: %.loc15_15.5: type = ptr_type ({}*, {}*) +// CHECK:STDOUT: %.loc15_15: (type, type) = tuple_literal (%X.ref.loc15_11, %X.ref.loc15_14) // CHECK:STDOUT: %Make.ref.loc15_20: = name_reference "Make", file.%Make // CHECK:STDOUT: %.loc15_24.1: ref X = temporary_storage // CHECK:STDOUT: %.loc15_24.2: init X = call %Make.ref.loc15_20() to %.loc15_24.1 diff --git a/toolchain/check/testdata/basics/builtin_types.carbon b/toolchain/check/testdata/basics/builtin_types.carbon index 9cd4fbbd8f9d..4b7731dd4b52 100644 --- a/toolchain/check/testdata/basics/builtin_types.carbon +++ b/toolchain/check/testdata/basics/builtin_types.carbon @@ -9,6 +9,10 @@ var test_f64: f64 = 0.1; let test_str: String = "Test"; var test_type: type = i32; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = ptr_type String +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "builtin_types.carbon" { // CHECK:STDOUT: %test_i32.var: ref i32 = var "test_i32" // CHECK:STDOUT: %test_i32: ref i32 = bind_name "test_i32", %test_i32.var @@ -18,7 +22,6 @@ var test_type: type = i32; // CHECK:STDOUT: %test_f64: ref f64 = bind_name "test_f64", %test_f64.var // CHECK:STDOUT: %.loc8: f64 = real_literal 1e-1 // CHECK:STDOUT: assign %test_f64.var, %.loc8 -// CHECK:STDOUT: %.1: type = ptr_type String // CHECK:STDOUT: %.loc9: String = string_literal "Test" // CHECK:STDOUT: %test_str: String = bind_name "test_str", %.loc9 // CHECK:STDOUT: %test_type.var: ref type = var "test_type" diff --git a/toolchain/check/testdata/basics/fail_bad_run.carbon b/toolchain/check/testdata/basics/fail_bad_run.carbon index 5b9364d88174..be38d442f2b2 100644 --- a/toolchain/check/testdata/basics/fail_bad_run.carbon +++ b/toolchain/check/testdata/basics/fail_bad_run.carbon @@ -12,12 +12,15 @@ // CHECK:STDERR: ^ fn Run() -> String {} -// CHECK:STDOUT: file "fail_bad_run.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.1: type = ptr_type String -// CHECK:STDOUT: %Run: = fn_decl @Run // CHECK:STDOUT: %.loc13: type = tuple_type () // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: file "fail_bad_run.carbon" { +// CHECK:STDOUT: %Run: = fn_decl @Run +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: fn @Run() -> %return: String { // CHECK:STDOUT: !entry: // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/basics/numeric_literals.carbon b/toolchain/check/testdata/basics/numeric_literals.carbon index 23434a6468f6..1af6d5b033e2 100644 --- a/toolchain/check/testdata/basics/numeric_literals.carbon +++ b/toolchain/check/testdata/basics/numeric_literals.carbon @@ -25,6 +25,13 @@ fn F() { ); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10: type = ptr_type [i32; 5] +// CHECK:STDOUT: %.loc16: type = tuple_type (i32, i32, i32, i32, i32) +// CHECK:STDOUT: %.loc17: type = ptr_type [f64; 7] +// CHECK:STDOUT: %.loc25: type = tuple_type (f64, f64, f64, f64, f64, f64, f64) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "numeric_literals.carbon" { // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: } @@ -32,8 +39,7 @@ fn F() { // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc10_19: i32 = int_literal 5 -// CHECK:STDOUT: %.loc10_20.1: type = array_type %.loc10_19, i32 -// CHECK:STDOUT: %.loc10_20.2: type = ptr_type [i32; 5] +// CHECK:STDOUT: %.loc10_20: type = array_type %.loc10_19, i32 // CHECK:STDOUT: %ints.var: ref [i32; 5] = var "ints" // CHECK:STDOUT: %ints: ref [i32; 5] = bind_name "ints", %ints.var // CHECK:STDOUT: %.loc11: i32 = int_literal 8 @@ -41,28 +47,26 @@ fn F() { // CHECK:STDOUT: %.loc13: i32 = int_literal 8 // CHECK:STDOUT: %.loc14: i32 = int_literal 8 // CHECK:STDOUT: %.loc15: i32 = int_literal 39999999999999999993 -// CHECK:STDOUT: %.loc16_3.1: type = tuple_type (i32, i32, i32, i32, i32) -// CHECK:STDOUT: %.loc16_3.2: (i32, i32, i32, i32, i32) = tuple_literal (%.loc11, %.loc12, %.loc13, %.loc14, %.loc15) -// CHECK:STDOUT: %.loc16_3.3: i32 = int_literal 0 -// CHECK:STDOUT: %.loc16_3.4: ref i32 = array_index %ints.var, %.loc16_3.3 -// CHECK:STDOUT: %.loc16_3.5: init i32 = initialize_from %.loc11 to %.loc16_3.4 -// CHECK:STDOUT: %.loc16_3.6: i32 = int_literal 1 -// CHECK:STDOUT: %.loc16_3.7: ref i32 = array_index %ints.var, %.loc16_3.6 -// CHECK:STDOUT: %.loc16_3.8: init i32 = initialize_from %.loc12 to %.loc16_3.7 -// CHECK:STDOUT: %.loc16_3.9: i32 = int_literal 2 -// CHECK:STDOUT: %.loc16_3.10: ref i32 = array_index %ints.var, %.loc16_3.9 -// CHECK:STDOUT: %.loc16_3.11: init i32 = initialize_from %.loc13 to %.loc16_3.10 -// CHECK:STDOUT: %.loc16_3.12: i32 = int_literal 3 -// CHECK:STDOUT: %.loc16_3.13: ref i32 = array_index %ints.var, %.loc16_3.12 -// CHECK:STDOUT: %.loc16_3.14: init i32 = initialize_from %.loc14 to %.loc16_3.13 -// CHECK:STDOUT: %.loc16_3.15: i32 = int_literal 4 -// CHECK:STDOUT: %.loc16_3.16: ref i32 = array_index %ints.var, %.loc16_3.15 -// CHECK:STDOUT: %.loc16_3.17: init i32 = initialize_from %.loc15 to %.loc16_3.16 -// CHECK:STDOUT: %.loc16_3.18: init [i32; 5] = array_init %.loc16_3.2, (%.loc16_3.5, %.loc16_3.8, %.loc16_3.11, %.loc16_3.14, %.loc16_3.17) to %ints.var -// CHECK:STDOUT: assign %ints.var, %.loc16_3.18 +// CHECK:STDOUT: %.loc16_3.1: (i32, i32, i32, i32, i32) = tuple_literal (%.loc11, %.loc12, %.loc13, %.loc14, %.loc15) +// CHECK:STDOUT: %.loc16_3.2: i32 = int_literal 0 +// CHECK:STDOUT: %.loc16_3.3: ref i32 = array_index %ints.var, %.loc16_3.2 +// CHECK:STDOUT: %.loc16_3.4: init i32 = initialize_from %.loc11 to %.loc16_3.3 +// CHECK:STDOUT: %.loc16_3.5: i32 = int_literal 1 +// CHECK:STDOUT: %.loc16_3.6: ref i32 = array_index %ints.var, %.loc16_3.5 +// CHECK:STDOUT: %.loc16_3.7: init i32 = initialize_from %.loc12 to %.loc16_3.6 +// CHECK:STDOUT: %.loc16_3.8: i32 = int_literal 2 +// CHECK:STDOUT: %.loc16_3.9: ref i32 = array_index %ints.var, %.loc16_3.8 +// CHECK:STDOUT: %.loc16_3.10: init i32 = initialize_from %.loc13 to %.loc16_3.9 +// CHECK:STDOUT: %.loc16_3.11: i32 = int_literal 3 +// CHECK:STDOUT: %.loc16_3.12: ref i32 = array_index %ints.var, %.loc16_3.11 +// CHECK:STDOUT: %.loc16_3.13: init i32 = initialize_from %.loc14 to %.loc16_3.12 +// CHECK:STDOUT: %.loc16_3.14: i32 = int_literal 4 +// CHECK:STDOUT: %.loc16_3.15: ref i32 = array_index %ints.var, %.loc16_3.14 +// CHECK:STDOUT: %.loc16_3.16: init i32 = initialize_from %.loc15 to %.loc16_3.15 +// CHECK:STDOUT: %.loc16_3.17: init [i32; 5] = array_init %.loc16_3.1, (%.loc16_3.4, %.loc16_3.7, %.loc16_3.10, %.loc16_3.13, %.loc16_3.16) to %ints.var +// CHECK:STDOUT: assign %ints.var, %.loc16_3.17 // CHECK:STDOUT: %.loc17_21: i32 = int_literal 7 -// CHECK:STDOUT: %.loc17_22.1: type = array_type %.loc17_21, f64 -// CHECK:STDOUT: %.loc17_22.2: type = ptr_type [f64; 7] +// CHECK:STDOUT: %.loc17_22: type = array_type %.loc17_21, f64 // CHECK:STDOUT: %floats.var: ref [f64; 7] = var "floats" // CHECK:STDOUT: %floats: ref [f64; 7] = bind_name "floats", %floats.var // CHECK:STDOUT: %.loc18: f64 = real_literal 9e-1 @@ -72,30 +76,29 @@ fn F() { // CHECK:STDOUT: %.loc22: f64 = real_literal 10e7 // CHECK:STDOUT: %.loc23: f64 = real_literal 10e-9 // CHECK:STDOUT: %.loc24: f64 = real_literal 399999999999999999930e39999999999999999992 -// CHECK:STDOUT: %.loc25_3.1: type = tuple_type (f64, f64, f64, f64, f64, f64, f64) -// CHECK:STDOUT: %.loc25_3.2: (f64, f64, f64, f64, f64, f64, f64) = tuple_literal (%.loc18, %.loc19, %.loc20, %.loc21, %.loc22, %.loc23, %.loc24) -// CHECK:STDOUT: %.loc25_3.3: i32 = int_literal 0 -// CHECK:STDOUT: %.loc25_3.4: ref f64 = array_index %floats.var, %.loc25_3.3 -// CHECK:STDOUT: %.loc25_3.5: init f64 = initialize_from %.loc18 to %.loc25_3.4 -// CHECK:STDOUT: %.loc25_3.6: i32 = int_literal 1 -// CHECK:STDOUT: %.loc25_3.7: ref f64 = array_index %floats.var, %.loc25_3.6 -// CHECK:STDOUT: %.loc25_3.8: init f64 = initialize_from %.loc19 to %.loc25_3.7 -// CHECK:STDOUT: %.loc25_3.9: i32 = int_literal 2 -// CHECK:STDOUT: %.loc25_3.10: ref f64 = array_index %floats.var, %.loc25_3.9 -// CHECK:STDOUT: %.loc25_3.11: init f64 = initialize_from %.loc20 to %.loc25_3.10 -// CHECK:STDOUT: %.loc25_3.12: i32 = int_literal 3 -// CHECK:STDOUT: %.loc25_3.13: ref f64 = array_index %floats.var, %.loc25_3.12 -// CHECK:STDOUT: %.loc25_3.14: init f64 = initialize_from %.loc21 to %.loc25_3.13 -// CHECK:STDOUT: %.loc25_3.15: i32 = int_literal 4 -// CHECK:STDOUT: %.loc25_3.16: ref f64 = array_index %floats.var, %.loc25_3.15 -// CHECK:STDOUT: %.loc25_3.17: init f64 = initialize_from %.loc22 to %.loc25_3.16 -// CHECK:STDOUT: %.loc25_3.18: i32 = int_literal 5 -// CHECK:STDOUT: %.loc25_3.19: ref f64 = array_index %floats.var, %.loc25_3.18 -// CHECK:STDOUT: %.loc25_3.20: init f64 = initialize_from %.loc23 to %.loc25_3.19 -// CHECK:STDOUT: %.loc25_3.21: i32 = int_literal 6 -// CHECK:STDOUT: %.loc25_3.22: ref f64 = array_index %floats.var, %.loc25_3.21 -// CHECK:STDOUT: %.loc25_3.23: init f64 = initialize_from %.loc24 to %.loc25_3.22 -// CHECK:STDOUT: %.loc25_3.24: init [f64; 7] = array_init %.loc25_3.2, (%.loc25_3.5, %.loc25_3.8, %.loc25_3.11, %.loc25_3.14, %.loc25_3.17, %.loc25_3.20, %.loc25_3.23) to %floats.var -// CHECK:STDOUT: assign %floats.var, %.loc25_3.24 +// CHECK:STDOUT: %.loc25_3.1: (f64, f64, f64, f64, f64, f64, f64) = tuple_literal (%.loc18, %.loc19, %.loc20, %.loc21, %.loc22, %.loc23, %.loc24) +// CHECK:STDOUT: %.loc25_3.2: i32 = int_literal 0 +// CHECK:STDOUT: %.loc25_3.3: ref f64 = array_index %floats.var, %.loc25_3.2 +// CHECK:STDOUT: %.loc25_3.4: init f64 = initialize_from %.loc18 to %.loc25_3.3 +// CHECK:STDOUT: %.loc25_3.5: i32 = int_literal 1 +// CHECK:STDOUT: %.loc25_3.6: ref f64 = array_index %floats.var, %.loc25_3.5 +// CHECK:STDOUT: %.loc25_3.7: init f64 = initialize_from %.loc19 to %.loc25_3.6 +// CHECK:STDOUT: %.loc25_3.8: i32 = int_literal 2 +// CHECK:STDOUT: %.loc25_3.9: ref f64 = array_index %floats.var, %.loc25_3.8 +// CHECK:STDOUT: %.loc25_3.10: init f64 = initialize_from %.loc20 to %.loc25_3.9 +// CHECK:STDOUT: %.loc25_3.11: i32 = int_literal 3 +// CHECK:STDOUT: %.loc25_3.12: ref f64 = array_index %floats.var, %.loc25_3.11 +// CHECK:STDOUT: %.loc25_3.13: init f64 = initialize_from %.loc21 to %.loc25_3.12 +// CHECK:STDOUT: %.loc25_3.14: i32 = int_literal 4 +// CHECK:STDOUT: %.loc25_3.15: ref f64 = array_index %floats.var, %.loc25_3.14 +// CHECK:STDOUT: %.loc25_3.16: init f64 = initialize_from %.loc22 to %.loc25_3.15 +// CHECK:STDOUT: %.loc25_3.17: i32 = int_literal 5 +// CHECK:STDOUT: %.loc25_3.18: ref f64 = array_index %floats.var, %.loc25_3.17 +// CHECK:STDOUT: %.loc25_3.19: init f64 = initialize_from %.loc23 to %.loc25_3.18 +// CHECK:STDOUT: %.loc25_3.20: i32 = int_literal 6 +// CHECK:STDOUT: %.loc25_3.21: ref f64 = array_index %floats.var, %.loc25_3.20 +// CHECK:STDOUT: %.loc25_3.22: init f64 = initialize_from %.loc24 to %.loc25_3.21 +// CHECK:STDOUT: %.loc25_3.23: init [f64; 7] = array_init %.loc25_3.1, (%.loc25_3.4, %.loc25_3.7, %.loc25_3.10, %.loc25_3.13, %.loc25_3.16, %.loc25_3.19, %.loc25_3.22) to %floats.var +// CHECK:STDOUT: assign %floats.var, %.loc25_3.23 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/basics/raw_and_textual_ir.carbon b/toolchain/check/testdata/basics/raw_and_textual_ir.carbon index d704890f076a..a608e43caa85 100644 --- a/toolchain/check/testdata/basics/raw_and_textual_ir.carbon +++ b/toolchain/check/testdata/basics/raw_and_textual_ir.carbon @@ -61,10 +61,8 @@ fn Foo(n: i32) -> (i32, f64) { // CHECK:STDOUT: 1: instFloatingPointType // CHECK:STDOUT: block3: // CHECK:STDOUT: 0: inst+0 -// CHECK:STDOUT: 1: inst+1 -// CHECK:STDOUT: 2: inst+2 -// CHECK:STDOUT: 3: inst+3 -// CHECK:STDOUT: 4: inst+4 +// CHECK:STDOUT: 1: inst+2 +// CHECK:STDOUT: 2: inst+4 // CHECK:STDOUT: block4: // CHECK:STDOUT: 0: inst+7 // CHECK:STDOUT: 1: inst+8 @@ -84,12 +82,16 @@ fn Foo(n: i32) -> (i32, f64) { // CHECK:STDOUT: 0: inst+13 // CHECK:STDOUT: 1: inst+15 // CHECK:STDOUT: block7: -// CHECK:STDOUT: 0: inst+5 -// CHECK:STDOUT: 1: inst+6 +// CHECK:STDOUT: 0: inst+6 // CHECK:STDOUT: ... // CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc11_28.1: type = tuple_type (type, type) +// CHECK:STDOUT: %.loc11_28.2: type = tuple_type (i32, f64) +// CHECK:STDOUT: %.loc11_28.3: type = ptr_type (i32, f64) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "raw_and_textual_ir.carbon" { -// CHECK:STDOUT: %.loc11: type = ptr_type (i32, f64) // CHECK:STDOUT: %Foo: = fn_decl @Foo // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/basics/raw_ir.carbon b/toolchain/check/testdata/basics/raw_ir.carbon index 3d6b779bd930..f13ece07ad87 100644 --- a/toolchain/check/testdata/basics/raw_ir.carbon +++ b/toolchain/check/testdata/basics/raw_ir.carbon @@ -61,10 +61,8 @@ fn Foo(n: i32) -> (i32, f64) { // CHECK:STDOUT: 1: instFloatingPointType // CHECK:STDOUT: block3: // CHECK:STDOUT: 0: inst+0 -// CHECK:STDOUT: 1: inst+1 -// CHECK:STDOUT: 2: inst+2 -// CHECK:STDOUT: 3: inst+3 -// CHECK:STDOUT: 4: inst+4 +// CHECK:STDOUT: 1: inst+2 +// CHECK:STDOUT: 2: inst+4 // CHECK:STDOUT: block4: // CHECK:STDOUT: 0: inst+7 // CHECK:STDOUT: 1: inst+8 @@ -84,6 +82,5 @@ fn Foo(n: i32) -> (i32, f64) { // CHECK:STDOUT: 0: inst+13 // CHECK:STDOUT: 1: inst+15 // CHECK:STDOUT: block7: -// CHECK:STDOUT: 0: inst+5 -// CHECK:STDOUT: 1: inst+6 +// CHECK:STDOUT: 0: inst+6 // CHECK:STDOUT: ... diff --git a/toolchain/check/testdata/basics/textual_ir.carbon b/toolchain/check/testdata/basics/textual_ir.carbon index a48c46909c3d..282896e408d9 100644 --- a/toolchain/check/testdata/basics/textual_ir.carbon +++ b/toolchain/check/testdata/basics/textual_ir.carbon @@ -12,8 +12,13 @@ fn Foo(n: i32) -> (i32, f64) { return (n + 2, 3.4); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc11_28.1: type = tuple_type (type, type) +// CHECK:STDOUT: %.loc11_28.2: type = tuple_type (i32, f64) +// CHECK:STDOUT: %.loc11_28.3: type = ptr_type (i32, f64) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "textual_ir.carbon" { -// CHECK:STDOUT: %.loc11: type = ptr_type (i32, f64) // CHECK:STDOUT: %Foo: = fn_decl @Foo // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/basic.carbon b/toolchain/check/testdata/class/basic.carbon index e1dba8ca17c3..9d6361b62204 100644 --- a/toolchain/check/testdata/class/basic.carbon +++ b/toolchain/check/testdata/class/basic.carbon @@ -22,10 +22,13 @@ fn Run() -> i32 { return Class.F(4); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc15: type = struct_type {.k: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "basic.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc15: type = struct_type {.k: i32} // CHECK:STDOUT: %G: = fn_decl @G // CHECK:STDOUT: %Run: = fn_decl @Run // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/fail_addr_not_self.carbon b/toolchain/check/testdata/class/fail_addr_not_self.carbon index 410bd5fe868f..8794417fdfcb 100644 --- a/toolchain/check/testdata/class/fail_addr_not_self.carbon +++ b/toolchain/check/testdata/class/fail_addr_not_self.carbon @@ -16,10 +16,13 @@ class Class { fn G(addr b: Class*); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc17: type = struct_type {} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_addr_not_self.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc17: type = struct_type {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Class { diff --git a/toolchain/check/testdata/class/fail_addr_self.carbon b/toolchain/check/testdata/class/fail_addr_self.carbon index 0936d3093c58..888cd7389178 100644 --- a/toolchain/check/testdata/class/fail_addr_self.carbon +++ b/toolchain/check/testdata/class/fail_addr_self.carbon @@ -38,10 +38,15 @@ fn F(c: Class, p: Class*) { (*p).G(); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10_1.1: type = struct_type {} +// CHECK:STDOUT: %.loc10_1.2: type = tuple_type () +// CHECK:STDOUT: %.loc7: type = ptr_type {} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_addr_self.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc10: type = struct_type {} // CHECK:STDOUT: %F: = fn_decl @F.2 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -60,8 +65,6 @@ fn F(c: Class, p: Class*) { // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2(%c: Class, %p: Class*) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc10: type = tuple_type () -// CHECK:STDOUT: %.loc7: type = ptr_type {} // CHECK:STDOUT: %c.ref.loc19: Class = name_reference "c", %c // CHECK:STDOUT: %.loc19_4: = bound_method %c.ref.loc19, @Class.%F // CHECK:STDOUT: %.loc19_6: init () = call %.loc19_4() diff --git a/toolchain/check/testdata/class/fail_incomplete.carbon b/toolchain/check/testdata/class/fail_incomplete.carbon index ced265c8841e..c2317188e722 100644 --- a/toolchain/check/testdata/class/fail_incomplete.carbon +++ b/toolchain/check/testdata/class/fail_incomplete.carbon @@ -115,6 +115,11 @@ fn CallReturnIncomplete() { ReturnIncomplete(); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc41: type = struct_type {} +// CHECK:STDOUT: %.loc100: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_incomplete.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class @@ -149,8 +154,7 @@ fn CallReturnIncomplete() { // CHECK:STDOUT: // CHECK:STDOUT: fn @ConvertFromStruct() -> { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc41_43.1: type = struct_type {} -// CHECK:STDOUT: %.loc41_43.2: {} = struct_literal () +// CHECK:STDOUT: %.loc41: {} = struct_literal () // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -186,8 +190,7 @@ fn CallReturnIncomplete() { // CHECK:STDOUT: %TakeIncomplete.ref.loc100: = name_reference "TakeIncomplete", file.%TakeIncomplete // CHECK:STDOUT: %p.ref: Class* = name_reference "p", %p // CHECK:STDOUT: %.loc100_18: ref Class = dereference %p.ref -// CHECK:STDOUT: %.loc100_17.1: type = tuple_type () -// CHECK:STDOUT: %.loc100_17.2: init () = call %TakeIncomplete.ref.loc100() +// CHECK:STDOUT: %.loc100_17: init () = call %TakeIncomplete.ref.loc100() // CHECK:STDOUT: %TakeIncomplete.ref.loc111: = name_reference "TakeIncomplete", file.%TakeIncomplete // CHECK:STDOUT: %.loc111_19: {} = struct_literal () // CHECK:STDOUT: %.loc111_17: init () = call %TakeIncomplete.ref.loc111() diff --git a/toolchain/check/testdata/class/fail_init.carbon b/toolchain/check/testdata/class/fail_init.carbon index 5bfddb9d96a6..33680e459978 100644 --- a/toolchain/check/testdata/class/fail_init.carbon +++ b/toolchain/check/testdata/class/fail_init.carbon @@ -24,10 +24,17 @@ fn F() { {.a = 1, .b = 2, .c = 3} as Class; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10_1.1: type = struct_type {.a: i32, .b: i32} +// CHECK:STDOUT: %.loc16: type = struct_type {.a: i32} +// CHECK:STDOUT: %.loc10_1.2: type = ptr_type {.a: i32, .b: i32} +// CHECK:STDOUT: %.loc20: type = struct_type {.a: i32, .c: i32} +// CHECK:STDOUT: %.loc24: type = struct_type {.a: i32, .b: i32, .c: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_init.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc10: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: @@ -47,28 +54,24 @@ fn F() { // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc16_9: i32 = int_literal 1 -// CHECK:STDOUT: %.loc16_10.1: type = struct_type {.a: i32} -// CHECK:STDOUT: %.loc16_10.2: {.a: i32} = struct_literal (%.loc16_9) +// CHECK:STDOUT: %.loc16_10.1: {.a: i32} = struct_literal (%.loc16_9) // CHECK:STDOUT: %Class.ref.loc16: type = name_reference "Class", file.%Class -// CHECK:STDOUT: %.loc10: type = ptr_type {.a: i32, .b: i32} -// CHECK:STDOUT: %.loc16_10.3: ref Class = temporary_storage -// CHECK:STDOUT: %.loc16_10.4: ref Class = temporary %.loc16_10.3, +// CHECK:STDOUT: %.loc16_10.2: ref Class = temporary_storage +// CHECK:STDOUT: %.loc16_10.3: ref Class = temporary %.loc16_10.2, // CHECK:STDOUT: %.loc20_9: i32 = int_literal 1 // CHECK:STDOUT: %.loc20_17: i32 = int_literal 2 -// CHECK:STDOUT: %.loc20_18.1: type = struct_type {.a: i32, .c: i32} -// CHECK:STDOUT: %.loc20_18.2: {.a: i32, .c: i32} = struct_literal (%.loc20_9, %.loc20_17) +// CHECK:STDOUT: %.loc20_18.1: {.a: i32, .c: i32} = struct_literal (%.loc20_9, %.loc20_17) // CHECK:STDOUT: %Class.ref.loc20: type = name_reference "Class", file.%Class -// CHECK:STDOUT: %.loc20_18.3: ref Class = temporary_storage -// CHECK:STDOUT: %.loc20_18.4: ref i32 = class_field_access %.loc20_18.3, member0 -// CHECK:STDOUT: %.loc20_18.5: init i32 = initialize_from %.loc20_9 to %.loc20_18.4 -// CHECK:STDOUT: %.loc20_18.6: ref Class = temporary %.loc20_18.3, +// CHECK:STDOUT: %.loc20_18.2: ref Class = temporary_storage +// CHECK:STDOUT: %.loc20_18.3: ref i32 = class_field_access %.loc20_18.2, member0 +// CHECK:STDOUT: %.loc20_18.4: init i32 = initialize_from %.loc20_9 to %.loc20_18.3 +// CHECK:STDOUT: %.loc20_18.5: ref Class = temporary %.loc20_18.2, // CHECK:STDOUT: %.loc24_9: i32 = int_literal 1 // CHECK:STDOUT: %.loc24_17: i32 = int_literal 2 // CHECK:STDOUT: %.loc24_25: i32 = int_literal 3 -// CHECK:STDOUT: %.loc24_26.1: type = struct_type {.a: i32, .b: i32, .c: i32} -// CHECK:STDOUT: %.loc24_26.2: {.a: i32, .b: i32, .c: i32} = struct_literal (%.loc24_9, %.loc24_17, %.loc24_25) +// CHECK:STDOUT: %.loc24_26.1: {.a: i32, .b: i32, .c: i32} = struct_literal (%.loc24_9, %.loc24_17, %.loc24_25) // CHECK:STDOUT: %Class.ref.loc24: type = name_reference "Class", file.%Class -// CHECK:STDOUT: %.loc24_26.3: ref Class = temporary_storage -// CHECK:STDOUT: %.loc24_26.4: ref Class = temporary %.loc24_26.3, +// CHECK:STDOUT: %.loc24_26.2: ref Class = temporary_storage +// CHECK:STDOUT: %.loc24_26.3: ref Class = temporary %.loc24_26.2, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/fail_init_as_inplace.carbon b/toolchain/check/testdata/class/fail_init_as_inplace.carbon index a024a357b76d..c481a51c3bbc 100644 --- a/toolchain/check/testdata/class/fail_init_as_inplace.carbon +++ b/toolchain/check/testdata/class/fail_init_as_inplace.carbon @@ -22,10 +22,15 @@ fn F() { G(&c); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10_1.1: type = struct_type {.a: i32, .b: i32} +// CHECK:STDOUT: %.loc10_1.2: type = ptr_type {.a: i32, .b: i32} +// CHECK:STDOUT: %.loc22: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_init_as_inplace.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc10: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %G: = fn_decl @G // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: } @@ -48,7 +53,6 @@ fn F() { // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Class.ref.loc21_10: type = name_reference "Class", file.%Class -// CHECK:STDOUT: %.loc10: type = ptr_type {.a: i32, .b: i32} // CHECK:STDOUT: %c.var: ref Class = var "c" // CHECK:STDOUT: %c: ref Class = bind_name "c", %c.var // CHECK:STDOUT: %.loc21_24: i32 = int_literal 1 @@ -67,7 +71,6 @@ fn F() { // CHECK:STDOUT: %G.ref: = name_reference "G", file.%G // CHECK:STDOUT: %c.ref: ref Class = name_reference "c", %c // CHECK:STDOUT: %.loc22_5: Class* = address_of %c.ref -// CHECK:STDOUT: %.loc22_4.1: type = tuple_type () -// CHECK:STDOUT: %.loc22_4.2: init () = call %G.ref(%.loc22_5) +// CHECK:STDOUT: %.loc22_4: init () = call %G.ref(%.loc22_5) // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/fail_memaccess_category.carbon b/toolchain/check/testdata/class/fail_memaccess_category.carbon index e17899540755..463ccbb38e3c 100644 --- a/toolchain/check/testdata/class/fail_memaccess_category.carbon +++ b/toolchain/check/testdata/class/fail_memaccess_category.carbon @@ -33,13 +33,20 @@ fn F(s: {.a: A}, b: B) { b.a.F(); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc9_1.1: type = struct_type {} +// CHECK:STDOUT: %.loc9_1.2: type = tuple_type () +// CHECK:STDOUT: %.loc7: type = ptr_type {} +// CHECK:STDOUT: %.loc13_1.1: type = struct_type {.a: A} +// CHECK:STDOUT: %.loc13_1.2: type = struct_type {.a: {}*} +// CHECK:STDOUT: %.loc11: type = ptr_type {.a: A} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_memaccess_category.carbon" { // CHECK:STDOUT: class_declaration @A, () // CHECK:STDOUT: %A: type = class_type @A -// CHECK:STDOUT: %.loc9: type = struct_type {} // CHECK:STDOUT: class_declaration @B, () // CHECK:STDOUT: %B: type = class_type @B -// CHECK:STDOUT: %.loc13: type = struct_type {.a: A} // CHECK:STDOUT: %F: = fn_decl @F.2 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -52,8 +59,6 @@ fn F(s: {.a: A}, b: B) { // CHECK:STDOUT: // CHECK:STDOUT: class @B { // CHECK:STDOUT: %A.ref: type = name_reference "A", file.%A -// CHECK:STDOUT: %.loc9: type = tuple_type () -// CHECK:STDOUT: %.loc7: type = ptr_type {} // CHECK:STDOUT: %.loc12_8.1: type = unbound_field_type B, A // CHECK:STDOUT: %.loc12_8.2: = field "a", member0 // CHECK:STDOUT: %a: = bind_name "a", %.loc12_8.2 @@ -66,8 +71,6 @@ fn F(s: {.a: A}, b: B) { // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2(%s: {.a: A}, %b: B) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc13: type = struct_type {.a: {}*} -// CHECK:STDOUT: %.loc11: type = ptr_type {.a: A} // CHECK:STDOUT: %s.ref: {.a: A} = name_reference "s", %s // CHECK:STDOUT: %.loc23_4: A = struct_access %s.ref, member0 // CHECK:STDOUT: %.loc23_6: = bound_method %.loc23_4, @A.%F diff --git a/toolchain/check/testdata/class/fail_member_of_let.carbon b/toolchain/check/testdata/class/fail_member_of_let.carbon index f3079881d19d..0c3d370aabd7 100644 --- a/toolchain/check/testdata/class/fail_member_of_let.carbon +++ b/toolchain/check/testdata/class/fail_member_of_let.carbon @@ -21,10 +21,13 @@ let T: type = Class; // CHECK:STDERR: ^ fn T.F() {} +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc9: type = struct_type {} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_member_of_let.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc9: type = struct_type {} // CHECK:STDOUT: %Class.ref: type = name_reference "Class", %Class // CHECK:STDOUT: %T: type = bind_name "T", %Class.ref // CHECK:STDOUT: %.loc22: = fn_decl @.1 diff --git a/toolchain/check/testdata/class/fail_method.carbon b/toolchain/check/testdata/class/fail_method.carbon index 45ac6da65cd0..740157b89a14 100644 --- a/toolchain/check/testdata/class/fail_method.carbon +++ b/toolchain/check/testdata/class/fail_method.carbon @@ -30,10 +30,15 @@ fn F(c: Class) { Class.WithSelf(c); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10_1.1: type = struct_type {} +// CHECK:STDOUT: %.loc10_1.2: type = tuple_type () +// CHECK:STDOUT: %.loc7: type = ptr_type {} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_method.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc10: type = struct_type {} // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: @@ -52,8 +57,6 @@ fn F(c: Class) { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%c: Class) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc10: type = tuple_type () -// CHECK:STDOUT: %.loc7: type = ptr_type {} // CHECK:STDOUT: %c.ref.loc13: Class = name_reference "c", %c // CHECK:STDOUT: %NoSelf.ref.loc13: = name_reference "NoSelf", @Class.%NoSelf // CHECK:STDOUT: %.loc13: init () = call %NoSelf.ref.loc13() diff --git a/toolchain/check/testdata/class/fail_redefinition.carbon b/toolchain/check/testdata/class/fail_redefinition.carbon index 887cf7c3fe4e..3c812c5f7286 100644 --- a/toolchain/check/testdata/class/fail_redefinition.carbon +++ b/toolchain/check/testdata/class/fail_redefinition.carbon @@ -24,10 +24,13 @@ fn Class.F() {} fn Class.G() {} fn Class.H() {} +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10: type = struct_type {} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_redefinition.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc10: type = struct_type {} // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: %G: = fn_decl @G diff --git a/toolchain/check/testdata/class/fail_reorder.carbon b/toolchain/check/testdata/class/fail_reorder.carbon index 8a716601b8b9..6c5f96b568dc 100644 --- a/toolchain/check/testdata/class/fail_reorder.carbon +++ b/toolchain/check/testdata/class/fail_reorder.carbon @@ -25,10 +25,13 @@ class Class { } } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc26: type = struct_type {} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_reorder.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc26: type = struct_type {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Class { diff --git a/toolchain/check/testdata/class/fail_scope.carbon b/toolchain/check/testdata/class/fail_scope.carbon index 1b8a50ef3e6a..9756a0eb03a0 100644 --- a/toolchain/check/testdata/class/fail_scope.carbon +++ b/toolchain/check/testdata/class/fail_scope.carbon @@ -18,10 +18,13 @@ class Class { } } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc19: type = struct_type {} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_scope.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc19: type = struct_type {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Class { diff --git a/toolchain/check/testdata/class/fail_self.carbon b/toolchain/check/testdata/class/fail_self.carbon index 231049b1b5e2..9711c0e8951f 100644 --- a/toolchain/check/testdata/class/fail_self.carbon +++ b/toolchain/check/testdata/class/fail_self.carbon @@ -50,10 +50,15 @@ fn CallWrongSelf(ws: WrongSelf) { ws.F(); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc20_1.1: type = struct_type {} +// CHECK:STDOUT: %.loc20_1.2: type = tuple_type () +// CHECK:STDOUT: %.loc7: type = ptr_type {} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_self.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc20: type = struct_type {} // CHECK:STDOUT: %F: = fn_decl @F.1 // CHECK:STDOUT: %G: = fn_decl @G // CHECK:STDOUT: class_declaration @WrongSelf, () @@ -79,8 +84,6 @@ fn CallWrongSelf(ws: WrongSelf) { // CHECK:STDOUT: // CHECK:STDOUT: fn @F.1(%self: Class) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc20: type = tuple_type () -// CHECK:STDOUT: %.loc7: type = ptr_type {} // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/fail_unbound_field.carbon b/toolchain/check/testdata/class/fail_unbound_field.carbon index 47a6d0e27035..5e4d9d49e577 100644 --- a/toolchain/check/testdata/class/fail_unbound_field.carbon +++ b/toolchain/check/testdata/class/fail_unbound_field.carbon @@ -22,10 +22,13 @@ fn G() -> i32 { return Class.field; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc16: type = struct_type {.field: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_unbound_field.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc16: type = struct_type {.field: i32} // CHECK:STDOUT: %G: = fn_decl @G // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/fail_unknown_member.carbon b/toolchain/check/testdata/class/fail_unknown_member.carbon index 57aa92cea987..2ad0dd53040d 100644 --- a/toolchain/check/testdata/class/fail_unknown_member.carbon +++ b/toolchain/check/testdata/class/fail_unknown_member.carbon @@ -16,10 +16,14 @@ fn G(c: Class) -> i32 { return c.something; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc9: type = struct_type {.n: i32} +// CHECK:STDOUT: %.loc7: type = ptr_type {.n: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_unknown_member.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc9: type = struct_type {.n: i32} // CHECK:STDOUT: %G: = fn_decl @G // CHECK:STDOUT: } // CHECK:STDOUT: @@ -34,7 +38,6 @@ fn G(c: Class) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @G(%c: Class) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: type = ptr_type {.n: i32} // CHECK:STDOUT: %c.ref: Class = name_reference "c", %c // CHECK:STDOUT: %something.ref: = name_reference "something", // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/class/field_access.carbon b/toolchain/check/testdata/class/field_access.carbon index df8fd6746e9e..8ccae3abea01 100644 --- a/toolchain/check/testdata/class/field_access.carbon +++ b/toolchain/check/testdata/class/field_access.carbon @@ -16,10 +16,14 @@ fn Run() -> i32 { return c.j + c.k; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10_1.1: type = struct_type {.j: i32, .k: i32} +// CHECK:STDOUT: %.loc10_1.2: type = ptr_type {.j: i32, .k: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "field_access.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc10: type = struct_type {.j: i32, .k: i32} // CHECK:STDOUT: %Run: = fn_decl @Run // CHECK:STDOUT: } // CHECK:STDOUT: @@ -39,7 +43,6 @@ fn Run() -> i32 { // CHECK:STDOUT: fn @Run() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Class.ref: type = name_reference "Class", file.%Class -// CHECK:STDOUT: %.loc10: type = ptr_type {.j: i32, .k: i32} // CHECK:STDOUT: %c.var: ref Class = var "c" // CHECK:STDOUT: %c: ref Class = bind_name "c", %c.var // CHECK:STDOUT: %c.ref.loc14: ref Class = name_reference "c", %c diff --git a/toolchain/check/testdata/class/field_access_in_value.carbon b/toolchain/check/testdata/class/field_access_in_value.carbon index 28c83cb30442..5d230e0ce6ac 100644 --- a/toolchain/check/testdata/class/field_access_in_value.carbon +++ b/toolchain/check/testdata/class/field_access_in_value.carbon @@ -17,10 +17,14 @@ fn Run() -> i32 { return c.j + c.k; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10_1.1: type = struct_type {.j: i32, .k: i32} +// CHECK:STDOUT: %.loc10_1.2: type = ptr_type {.j: i32, .k: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "field_access_in_value.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc10: type = struct_type {.j: i32, .k: i32} // CHECK:STDOUT: %Run: = fn_decl @Run // CHECK:STDOUT: } // CHECK:STDOUT: @@ -40,7 +44,6 @@ fn Run() -> i32 { // CHECK:STDOUT: fn @Run() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Class.ref.loc13: type = name_reference "Class", file.%Class -// CHECK:STDOUT: %.loc10: type = ptr_type {.j: i32, .k: i32} // CHECK:STDOUT: %cv.var: ref Class = var "cv" // CHECK:STDOUT: %cv: ref Class = bind_name "cv", %cv.var // CHECK:STDOUT: %cv.ref.loc14: ref Class = name_reference "cv", %cv diff --git a/toolchain/check/testdata/class/init.carbon b/toolchain/check/testdata/class/init.carbon index c45341dc1e1a..024b3533a94c 100644 --- a/toolchain/check/testdata/class/init.carbon +++ b/toolchain/check/testdata/class/init.carbon @@ -17,11 +17,15 @@ fn MakeReorder(n: i32, next: Class*) -> Class { return {.next = next, .n = n}; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10_1.1: type = struct_type {.n: i32, .next: Class*} +// CHECK:STDOUT: %.loc10_1.2: type = ptr_type {.n: i32, .next: Class*} +// CHECK:STDOUT: %.loc17: type = struct_type {.next: Class*, .n: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "init.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc10_1.1: type = struct_type {.n: i32, .next: Class*} -// CHECK:STDOUT: %.loc10_1.2: type = ptr_type {.n: i32, .next: Class*} // CHECK:STDOUT: %Make: = fn_decl @Make // CHECK:STDOUT: %MakeReorder: = fn_decl @MakeReorder // CHECK:STDOUT: } @@ -58,12 +62,11 @@ fn MakeReorder(n: i32, next: Class*) -> Class { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %next.ref: Class* = name_reference "next", %next // CHECK:STDOUT: %n.ref: i32 = name_reference "n", %n -// CHECK:STDOUT: %.loc17_31.1: type = struct_type {.next: Class*, .n: i32} -// CHECK:STDOUT: %.loc17_31.2: {.next: Class*, .n: i32} = struct_literal (%next.ref, %n.ref) -// CHECK:STDOUT: %.loc17_31.3: ref i32 = class_field_access %return, member1 -// CHECK:STDOUT: %.loc17_31.4: init i32 = initialize_from %n.ref to %.loc17_31.3 -// CHECK:STDOUT: %.loc17_31.5: ref Class* = class_field_access %return, member0 -// CHECK:STDOUT: %.loc17_31.6: init Class* = initialize_from %next.ref to %.loc17_31.5 -// CHECK:STDOUT: %.loc17_31.7: init Class = class_init %.loc17_31.2, (%.loc17_31.4, %.loc17_31.6) -// CHECK:STDOUT: return %.loc17_31.7 +// CHECK:STDOUT: %.loc17_31.1: {.next: Class*, .n: i32} = struct_literal (%next.ref, %n.ref) +// CHECK:STDOUT: %.loc17_31.2: ref i32 = class_field_access %return, member1 +// CHECK:STDOUT: %.loc17_31.3: init i32 = initialize_from %n.ref to %.loc17_31.2 +// CHECK:STDOUT: %.loc17_31.4: ref Class* = class_field_access %return, member0 +// CHECK:STDOUT: %.loc17_31.5: init Class* = initialize_from %next.ref to %.loc17_31.4 +// CHECK:STDOUT: %.loc17_31.6: init Class = class_init %.loc17_31.1, (%.loc17_31.3, %.loc17_31.5) +// CHECK:STDOUT: return %.loc17_31.6 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/init_as.carbon b/toolchain/check/testdata/class/init_as.carbon index dea0bac7f87a..97306e3f418e 100644 --- a/toolchain/check/testdata/class/init_as.carbon +++ b/toolchain/check/testdata/class/init_as.carbon @@ -13,10 +13,14 @@ fn F() -> i32 { return ({.a = 1, .b = 2} as Class).a; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10_1.1: type = struct_type {.a: i32, .b: i32} +// CHECK:STDOUT: %.loc10_1.2: type = ptr_type {.a: i32, .b: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "init_as.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc10: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: @@ -39,7 +43,6 @@ fn F() -> i32 { // CHECK:STDOUT: %.loc13_25: i32 = int_literal 2 // CHECK:STDOUT: %.loc13_26.1: {.a: i32, .b: i32} = struct_literal (%.loc13_17, %.loc13_25) // CHECK:STDOUT: %Class.ref: type = name_reference "Class", file.%Class -// CHECK:STDOUT: %.loc10: type = ptr_type {.a: i32, .b: i32} // CHECK:STDOUT: %.loc13_26.2: ref Class = temporary_storage // CHECK:STDOUT: %.loc13_26.3: ref i32 = class_field_access %.loc13_26.2, member0 // CHECK:STDOUT: %.loc13_26.4: init i32 = initialize_from %.loc13_17 to %.loc13_26.3 diff --git a/toolchain/check/testdata/class/init_nested.carbon b/toolchain/check/testdata/class/init_nested.carbon index 839c9ebe35c3..46ab3916001d 100644 --- a/toolchain/check/testdata/class/init_nested.carbon +++ b/toolchain/check/testdata/class/init_nested.carbon @@ -20,18 +20,21 @@ fn MakeOuter() -> Outer { return {.c = MakeInner(), .d = MakeInner()}; } -// CHECK:STDOUT: file "init_nested.carbon" { -// CHECK:STDOUT: class_declaration @Inner, () -// CHECK:STDOUT: %Inner: type = class_type @Inner +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc10_1.1: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %.loc10_1.2: type = ptr_type {.a: i32, .b: i32} -// CHECK:STDOUT: %MakeInner: = fn_decl @MakeInner -// CHECK:STDOUT: class_declaration @Outer, () -// CHECK:STDOUT: %Outer: type = class_type @Outer // CHECK:STDOUT: %.loc17_1.1: type = struct_type {.c: Inner, .d: Inner} // CHECK:STDOUT: %.loc17_1.2: type = struct_type {.c: {.a: i32, .b: i32}*, .d: {.a: i32, .b: i32}*} // CHECK:STDOUT: %.loc17_1.3: type = ptr_type {.c: {.a: i32, .b: i32}*, .d: {.a: i32, .b: i32}*} // CHECK:STDOUT: %.loc14: type = ptr_type {.c: Inner, .d: Inner} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "init_nested.carbon" { +// CHECK:STDOUT: class_declaration @Inner, () +// CHECK:STDOUT: %Inner: type = class_type @Inner +// CHECK:STDOUT: %MakeInner: = fn_decl @MakeInner +// CHECK:STDOUT: class_declaration @Outer, () +// CHECK:STDOUT: %Outer: type = class_type @Outer // CHECK:STDOUT: %MakeOuter: = fn_decl @MakeOuter // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/method.carbon b/toolchain/check/testdata/class/method.carbon index caa171b832ae..8c3a69bf6514 100644 --- a/toolchain/check/testdata/class/method.carbon +++ b/toolchain/check/testdata/class/method.carbon @@ -44,10 +44,14 @@ fn CallGOnInitializingExpression() -> i32 { return Make().G(); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc12: type = struct_type {.k: i32} +// CHECK:STDOUT: %.loc7: type = ptr_type {.k: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "method.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc12: type = struct_type {.k: i32} // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: %Call: = fn_decl @Call // CHECK:STDOUT: %CallWithAddr: = fn_decl @CallWithAddr @@ -73,7 +77,6 @@ fn CallGOnInitializingExpression() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F[%self: Class]() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: type = ptr_type {.k: i32} // CHECK:STDOUT: %self.ref: Class = name_reference "self", %self // CHECK:STDOUT: %.loc15_14.1: ref i32 = class_field_access %self.ref, member0 // CHECK:STDOUT: %.loc15_14.2: i32 = bind_value %.loc15_14.1 diff --git a/toolchain/check/testdata/class/nested_name.carbon b/toolchain/check/testdata/class/nested_name.carbon index 9e9c206c57ed..601fea8d95d9 100644 --- a/toolchain/check/testdata/class/nested_name.carbon +++ b/toolchain/check/testdata/class/nested_name.carbon @@ -18,10 +18,17 @@ fn G(o: Outer) { var i: o.Inner; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10: type = struct_type {.n: i32} +// CHECK:STDOUT: %.loc11_1.1: type = struct_type {} +// CHECK:STDOUT: %.loc8: type = ptr_type {.n: i32} +// CHECK:STDOUT: %.loc11_1.2: type = tuple_type () +// CHECK:STDOUT: %.loc7: type = ptr_type {} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "nested_name.carbon" { // CHECK:STDOUT: class_declaration @Outer, () // CHECK:STDOUT: %Outer: type = class_type @Outer -// CHECK:STDOUT: %.loc11: type = struct_type {} // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: %G: = fn_decl @G // CHECK:STDOUT: } @@ -29,7 +36,6 @@ fn G(o: Outer) { // CHECK:STDOUT: class @Outer { // CHECK:STDOUT: class_declaration @Inner, () // CHECK:STDOUT: %Inner: type = class_type @Inner -// CHECK:STDOUT: %.loc10: type = struct_type {.n: i32} // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Inner = @@ -46,7 +52,6 @@ fn G(o: Outer) { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%oi: Inner) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8: type = ptr_type {.n: i32} // CHECK:STDOUT: %oi.ref: Inner = name_reference "oi", %oi // CHECK:STDOUT: %.loc14_12.1: ref i32 = class_field_access %oi.ref, member0 // CHECK:STDOUT: %.loc14_12.2: i32 = bind_value %.loc14_12.1 @@ -55,8 +60,6 @@ fn G(o: Outer) { // CHECK:STDOUT: // CHECK:STDOUT: fn @G(%o: Outer) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11: type = tuple_type () -// CHECK:STDOUT: %.loc7: type = ptr_type {} // CHECK:STDOUT: %o.ref: Outer = name_reference "o", %o // CHECK:STDOUT: %Inner.ref: type = name_reference "Inner", @Outer.%Inner // CHECK:STDOUT: %i.var: ref Inner = var "i" diff --git a/toolchain/check/testdata/class/redeclaration.carbon b/toolchain/check/testdata/class/redeclaration.carbon index 4245092e8e41..5485b6386e94 100644 --- a/toolchain/check/testdata/class/redeclaration.carbon +++ b/toolchain/check/testdata/class/redeclaration.carbon @@ -12,11 +12,14 @@ class Class { fn Class.F() {} +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc11: type = struct_type {} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "redeclaration.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class // CHECK:STDOUT: class_declaration @Class, () -// CHECK:STDOUT: %.loc11: type = struct_type {} // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/scope.carbon b/toolchain/check/testdata/class/scope.carbon index 70296e7efc7e..86cf142ce9b1 100644 --- a/toolchain/check/testdata/class/scope.carbon +++ b/toolchain/check/testdata/class/scope.carbon @@ -18,10 +18,13 @@ fn Run() -> i32 { return F() + Class.F(); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc11: type = struct_type {} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "scope.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc11: type = struct_type {} // CHECK:STDOUT: %F: = fn_decl @F.2 // CHECK:STDOUT: %Run: = fn_decl @Run // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/self.carbon b/toolchain/check/testdata/class/self.carbon index a2a43b40e45e..79d8356f45d7 100644 --- a/toolchain/check/testdata/class/self.carbon +++ b/toolchain/check/testdata/class/self.carbon @@ -19,10 +19,14 @@ fn Class.G[addr self: Class*]() -> i32 { return (*self).n; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc12: type = struct_type {.n: i32} +// CHECK:STDOUT: %.loc7: type = ptr_type {.n: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "self.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc12: type = struct_type {.n: i32} // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: %G: = fn_decl @G // CHECK:STDOUT: } @@ -42,7 +46,6 @@ fn Class.G[addr self: Class*]() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F[%self: Class]() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: type = ptr_type {.n: i32} // CHECK:STDOUT: %self.ref: Class = name_reference "self", %self // CHECK:STDOUT: %.loc15_14.1: ref i32 = class_field_access %self.ref, member0 // CHECK:STDOUT: %.loc15_14.2: i32 = bind_value %.loc15_14.1 diff --git a/toolchain/check/testdata/class/self_type.carbon b/toolchain/check/testdata/class/self_type.carbon index 789071a30efc..0984f506cb96 100644 --- a/toolchain/check/testdata/class/self_type.carbon +++ b/toolchain/check/testdata/class/self_type.carbon @@ -16,10 +16,14 @@ fn Class.F[self: Class]() -> i32 { return (*self.p).F(); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10: type = struct_type {.p: Class*} +// CHECK:STDOUT: %.loc7: type = ptr_type {.p: Class*} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "self_type.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc10: type = struct_type {.p: Class*} // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: @@ -38,7 +42,6 @@ fn Class.F[self: Class]() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F[%self: Class]() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: type = ptr_type {.p: Class*} // CHECK:STDOUT: %self.ref: Class = name_reference "self", %self // CHECK:STDOUT: %.loc16_16.1: ref Class* = class_field_access %self.ref, member0 // CHECK:STDOUT: %.loc16_16.2: Class* = bind_value %.loc16_16.1 diff --git a/toolchain/check/testdata/class/static_method.carbon b/toolchain/check/testdata/class/static_method.carbon index cc0c65e7ced1..f70c81ddec39 100644 --- a/toolchain/check/testdata/class/static_method.carbon +++ b/toolchain/check/testdata/class/static_method.carbon @@ -13,10 +13,15 @@ fn Run() -> i32 { return c.F(); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc9_1.1: type = struct_type {} +// CHECK:STDOUT: %.loc9_1.2: type = tuple_type () +// CHECK:STDOUT: %.loc7: type = ptr_type {} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "static_method.carbon" { // CHECK:STDOUT: class_declaration @Class, () // CHECK:STDOUT: %Class: type = class_type @Class -// CHECK:STDOUT: %.loc9: type = struct_type {} // CHECK:STDOUT: %Run: = fn_decl @Run // CHECK:STDOUT: } // CHECK:STDOUT: @@ -32,8 +37,6 @@ fn Run() -> i32 { // CHECK:STDOUT: fn @Run() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Class.ref: type = name_reference "Class", file.%Class -// CHECK:STDOUT: %.loc9: type = tuple_type () -// CHECK:STDOUT: %.loc7: type = ptr_type {} // CHECK:STDOUT: %c.var: ref Class = var "c" // CHECK:STDOUT: %c: ref Class = bind_name "c", %c.var // CHECK:STDOUT: %c.ref: ref Class = name_reference "c", %c diff --git a/toolchain/check/testdata/expression_category/in_place_tuple_initialization.carbon b/toolchain/check/testdata/expression_category/in_place_tuple_initialization.carbon index 32e5cced4c4d..aeb0ee156e1d 100644 --- a/toolchain/check/testdata/expression_category/in_place_tuple_initialization.carbon +++ b/toolchain/check/testdata/expression_category/in_place_tuple_initialization.carbon @@ -16,8 +16,13 @@ fn H() -> i32 { return G()[0]; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7_20.1: type = tuple_type (type, type) +// CHECK:STDOUT: %.loc7_20.2: type = tuple_type (i32, i32) +// CHECK:STDOUT: %.loc7_20.3: type = ptr_type (i32, i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "in_place_tuple_initialization.carbon" { -// CHECK:STDOUT: %.loc7: type = ptr_type (i32, i32) // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: %G: = fn_decl @G // CHECK:STDOUT: %H: = fn_decl @H diff --git a/toolchain/check/testdata/function/call/empty_struct.carbon b/toolchain/check/testdata/function/call/empty_struct.carbon index 9f26c8cc09c0..8078006e9c64 100644 --- a/toolchain/check/testdata/function/call/empty_struct.carbon +++ b/toolchain/check/testdata/function/call/empty_struct.carbon @@ -12,8 +12,12 @@ fn Main() { Echo({}); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7_13.1: type = struct_type {} +// CHECK:STDOUT: %.loc7_13.2: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "empty_struct.carbon" { -// CHECK:STDOUT: %.loc7: type = tuple_type () // CHECK:STDOUT: %Echo: = fn_decl @Echo // CHECK:STDOUT: %Main: = fn_decl @Main // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/call/empty_tuple.carbon b/toolchain/check/testdata/function/call/empty_tuple.carbon index e62ee4675c1e..38316e00d369 100644 --- a/toolchain/check/testdata/function/call/empty_tuple.carbon +++ b/toolchain/check/testdata/function/call/empty_tuple.carbon @@ -12,6 +12,10 @@ fn Main() { Echo(()); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "empty_tuple.carbon" { // CHECK:STDOUT: %Echo: = fn_decl @Echo // CHECK:STDOUT: %Main: = fn_decl @Main diff --git a/toolchain/check/testdata/function/call/fail_not_callable.carbon b/toolchain/check/testdata/function/call/fail_not_callable.carbon index aff4100328fe..ceaaabaefe75 100644 --- a/toolchain/check/testdata/function/call/fail_not_callable.carbon +++ b/toolchain/check/testdata/function/call/fail_not_callable.carbon @@ -11,6 +11,10 @@ fn Run() { var x: i32 = "hello"(); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = ptr_type String +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_not_callable.carbon" { // CHECK:STDOUT: %Run: = fn_decl @Run // CHECK:STDOUT: } @@ -19,7 +23,6 @@ fn Run() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x.var: ref i32 = var "x" // CHECK:STDOUT: %x: ref i32 = bind_name "x", %x.var -// CHECK:STDOUT: %.1: type = ptr_type String // CHECK:STDOUT: %.loc11: String = string_literal "hello" // CHECK:STDOUT: assign %x.var, // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/function/call/fail_param_count.carbon b/toolchain/check/testdata/function/call/fail_param_count.carbon index 7f532a08b6b2..72b5fee4d2ef 100644 --- a/toolchain/check/testdata/function/call/fail_param_count.carbon +++ b/toolchain/check/testdata/function/call/fail_param_count.carbon @@ -55,6 +55,10 @@ fn Main() { Run2(0); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc18: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_param_count.carbon" { // CHECK:STDOUT: %Run0: = fn_decl @Run0 // CHECK:STDOUT: %Run1: = fn_decl @Run1 @@ -81,8 +85,7 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Run0.ref.loc18: = name_reference "Run0", file.%Run0 // CHECK:STDOUT: %.loc18_8: i32 = int_literal 1 -// CHECK:STDOUT: %.loc18_7.1: type = tuple_type () -// CHECK:STDOUT: %.loc18_7.2: init () = call %Run0.ref.loc18() +// CHECK:STDOUT: %.loc18_7: init () = call %Run0.ref.loc18() // CHECK:STDOUT: %Run0.ref.loc25: = name_reference "Run0", file.%Run0 // CHECK:STDOUT: %.loc25_8: i32 = int_literal 0 // CHECK:STDOUT: %.loc25_11: i32 = int_literal 1 diff --git a/toolchain/check/testdata/function/call/fail_param_type.carbon b/toolchain/check/testdata/function/call/fail_param_type.carbon index be0c4d87b6ac..c3dafeae54db 100644 --- a/toolchain/check/testdata/function/call/fail_param_type.carbon +++ b/toolchain/check/testdata/function/call/fail_param_type.carbon @@ -16,6 +16,10 @@ fn F() { G(1.0); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc16: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_param_type.carbon" { // CHECK:STDOUT: %G: = fn_decl @G // CHECK:STDOUT: %F: = fn_decl @F @@ -30,7 +34,6 @@ fn F() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %G.ref: = name_reference "G", file.%G // CHECK:STDOUT: %.loc16_5: f64 = real_literal 10e-1 -// CHECK:STDOUT: %.loc16_4.1: type = tuple_type () -// CHECK:STDOUT: %.loc16_4.2: init () = call %G.ref() +// CHECK:STDOUT: %.loc16_4: init () = call %G.ref() // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/call/more_param_ir.carbon b/toolchain/check/testdata/function/call/more_param_ir.carbon index f414a9fb9b9c..7d1f5cc47468 100644 --- a/toolchain/check/testdata/function/call/more_param_ir.carbon +++ b/toolchain/check/testdata/function/call/more_param_ir.carbon @@ -11,6 +11,10 @@ fn Main() { Foo(1 + 2 + 3, 4 + 5, 6); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc11: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "more_param_ir.carbon" { // CHECK:STDOUT: %Foo: = fn_decl @Foo // CHECK:STDOUT: %Main: = fn_decl @Main @@ -33,7 +37,6 @@ fn Main() { // CHECK:STDOUT: %.loc11_22: i32 = int_literal 5 // CHECK:STDOUT: %.loc11_20: i32 = add %.loc11_18, %.loc11_22 // CHECK:STDOUT: %.loc11_25: i32 = int_literal 6 -// CHECK:STDOUT: %.loc11_6.1: type = tuple_type () -// CHECK:STDOUT: %.loc11_6.2: init () = call %Foo.ref(%.loc11_13, %.loc11_20, %.loc11_25) +// CHECK:STDOUT: %.loc11_6: init () = call %Foo.ref(%.loc11_13, %.loc11_20, %.loc11_25) // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/call/params_one.carbon b/toolchain/check/testdata/function/call/params_one.carbon index cab4ce6185c5..72d3e25c9a02 100644 --- a/toolchain/check/testdata/function/call/params_one.carbon +++ b/toolchain/check/testdata/function/call/params_one.carbon @@ -10,6 +10,10 @@ fn Main() { Foo(1); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "params_one.carbon" { // CHECK:STDOUT: %Foo: = fn_decl @Foo // CHECK:STDOUT: %Main: = fn_decl @Main @@ -24,7 +28,6 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Foo.ref: = name_reference "Foo", file.%Foo // CHECK:STDOUT: %.loc10_7: i32 = int_literal 1 -// CHECK:STDOUT: %.loc10_6.1: type = tuple_type () -// CHECK:STDOUT: %.loc10_6.2: init () = call %Foo.ref(%.loc10_7) +// CHECK:STDOUT: %.loc10_6: init () = call %Foo.ref(%.loc10_7) // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/call/params_one_comma.carbon b/toolchain/check/testdata/function/call/params_one_comma.carbon index 627a511dddb1..72b14e8fad25 100644 --- a/toolchain/check/testdata/function/call/params_one_comma.carbon +++ b/toolchain/check/testdata/function/call/params_one_comma.carbon @@ -11,6 +11,10 @@ fn Main() { Foo(1,); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "params_one_comma.carbon" { // CHECK:STDOUT: %Foo: = fn_decl @Foo // CHECK:STDOUT: %Main: = fn_decl @Main @@ -25,8 +29,7 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Foo.ref.loc10: = name_reference "Foo", file.%Foo // CHECK:STDOUT: %.loc10_7: i32 = int_literal 1 -// CHECK:STDOUT: %.loc10_6.1: type = tuple_type () -// CHECK:STDOUT: %.loc10_6.2: init () = call %Foo.ref.loc10(%.loc10_7) +// CHECK:STDOUT: %.loc10_6: init () = call %Foo.ref.loc10(%.loc10_7) // CHECK:STDOUT: %Foo.ref.loc11: = name_reference "Foo", file.%Foo // CHECK:STDOUT: %.loc11_7: i32 = int_literal 1 // CHECK:STDOUT: %.loc11_6: init () = call %Foo.ref.loc11(%.loc11_7) diff --git a/toolchain/check/testdata/function/call/params_two.carbon b/toolchain/check/testdata/function/call/params_two.carbon index 2c9917d9fe46..9c6fcee8b8b1 100644 --- a/toolchain/check/testdata/function/call/params_two.carbon +++ b/toolchain/check/testdata/function/call/params_two.carbon @@ -10,6 +10,10 @@ fn Main() { Foo(1, 2); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "params_two.carbon" { // CHECK:STDOUT: %Foo: = fn_decl @Foo // CHECK:STDOUT: %Main: = fn_decl @Main @@ -25,7 +29,6 @@ fn Main() { // CHECK:STDOUT: %Foo.ref: = name_reference "Foo", file.%Foo // CHECK:STDOUT: %.loc10_7: i32 = int_literal 1 // CHECK:STDOUT: %.loc10_10: i32 = int_literal 2 -// CHECK:STDOUT: %.loc10_6.1: type = tuple_type () -// CHECK:STDOUT: %.loc10_6.2: init () = call %Foo.ref(%.loc10_7, %.loc10_10) +// CHECK:STDOUT: %.loc10_6: init () = call %Foo.ref(%.loc10_7, %.loc10_10) // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/call/params_two_comma.carbon b/toolchain/check/testdata/function/call/params_two_comma.carbon index 6ed36a864734..edfc03959943 100644 --- a/toolchain/check/testdata/function/call/params_two_comma.carbon +++ b/toolchain/check/testdata/function/call/params_two_comma.carbon @@ -11,6 +11,10 @@ fn Main() { Foo(1, 2,); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "params_two_comma.carbon" { // CHECK:STDOUT: %Foo: = fn_decl @Foo // CHECK:STDOUT: %Main: = fn_decl @Main @@ -26,8 +30,7 @@ fn Main() { // CHECK:STDOUT: %Foo.ref.loc10: = name_reference "Foo", file.%Foo // CHECK:STDOUT: %.loc10_7: i32 = int_literal 1 // CHECK:STDOUT: %.loc10_10: i32 = int_literal 2 -// CHECK:STDOUT: %.loc10_6.1: type = tuple_type () -// CHECK:STDOUT: %.loc10_6.2: init () = call %Foo.ref.loc10(%.loc10_7, %.loc10_10) +// CHECK:STDOUT: %.loc10_6: init () = call %Foo.ref.loc10(%.loc10_7, %.loc10_10) // CHECK:STDOUT: %Foo.ref.loc11: = name_reference "Foo", file.%Foo // CHECK:STDOUT: %.loc11_7: i32 = int_literal 1 // CHECK:STDOUT: %.loc11_10: i32 = int_literal 2 diff --git a/toolchain/check/testdata/function/call/params_zero.carbon b/toolchain/check/testdata/function/call/params_zero.carbon index 67644f092177..557d78ea0a31 100644 --- a/toolchain/check/testdata/function/call/params_zero.carbon +++ b/toolchain/check/testdata/function/call/params_zero.carbon @@ -10,6 +10,10 @@ fn Main() { Foo(); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "params_zero.carbon" { // CHECK:STDOUT: %Foo: = fn_decl @Foo // CHECK:STDOUT: %Main: = fn_decl @Main @@ -23,7 +27,6 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Foo.ref: = name_reference "Foo", file.%Foo -// CHECK:STDOUT: %.loc10_6.1: type = tuple_type () -// CHECK:STDOUT: %.loc10_6.2: init () = call %Foo.ref() +// CHECK:STDOUT: %.loc10: init () = call %Foo.ref() // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/call/return_implicit.carbon b/toolchain/check/testdata/function/call/return_implicit.carbon index dca61214974e..6becffdc7da8 100644 --- a/toolchain/check/testdata/function/call/return_implicit.carbon +++ b/toolchain/check/testdata/function/call/return_implicit.carbon @@ -11,6 +11,10 @@ fn Main() { var b: () = MakeImplicitEmptyTuple(); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc11: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "return_implicit.carbon" { // CHECK:STDOUT: %MakeImplicitEmptyTuple: = fn_decl @MakeImplicitEmptyTuple // CHECK:STDOUT: %Main: = fn_decl @Main @@ -23,8 +27,7 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11_11.1: type = tuple_type () -// CHECK:STDOUT: %.loc11_11.2: () = tuple_literal () +// CHECK:STDOUT: %.loc11_11: () = tuple_literal () // CHECK:STDOUT: %b.var: ref () = var "b" // CHECK:STDOUT: %b: ref () = bind_name "b", %b.var // CHECK:STDOUT: %MakeImplicitEmptyTuple.ref: = name_reference "MakeImplicitEmptyTuple", file.%MakeImplicitEmptyTuple diff --git a/toolchain/check/testdata/function/declaration/simple.carbon b/toolchain/check/testdata/function/declaration/simple.carbon index dd9f5dc0d9a3..1b41cc5394b7 100644 --- a/toolchain/check/testdata/function/declaration/simple.carbon +++ b/toolchain/check/testdata/function/declaration/simple.carbon @@ -8,6 +8,10 @@ fn F(); fn G() { F(); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc9: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "simple.carbon" { // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: %G: = fn_decl @G @@ -18,7 +22,6 @@ fn G() { F(); } // CHECK:STDOUT: fn @G() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %F.ref: = name_reference "F", file.%F -// CHECK:STDOUT: %.loc9_11.1: type = tuple_type () -// CHECK:STDOUT: %.loc9_11.2: init () = call %F.ref() +// CHECK:STDOUT: %.loc9: init () = call %F.ref() // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/if/else.carbon b/toolchain/check/testdata/if/else.carbon index 63022b94bf34..44404e7be5d5 100644 --- a/toolchain/check/testdata/if/else.carbon +++ b/toolchain/check/testdata/if/else.carbon @@ -17,6 +17,10 @@ fn If(b: bool) { H(); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc13: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "else.carbon" { // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: %G: = fn_decl @G @@ -46,8 +50,7 @@ fn If(b: bool) { // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %F.ref: = name_reference "F", file.%F -// CHECK:STDOUT: %.loc13_6.1: type = tuple_type () -// CHECK:STDOUT: %.loc13_6.2: init () = call %F.ref() +// CHECK:STDOUT: %.loc13: init () = call %F.ref() // CHECK:STDOUT: br !if.done // CHECK:STDOUT: // CHECK:STDOUT: !if.else: diff --git a/toolchain/check/testdata/if/no_else.carbon b/toolchain/check/testdata/if/no_else.carbon index 03392d3c50d5..a7d0358d20b9 100644 --- a/toolchain/check/testdata/if/no_else.carbon +++ b/toolchain/check/testdata/if/no_else.carbon @@ -14,6 +14,10 @@ fn If(b: bool) { G(); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc12: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "no_else.carbon" { // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: %G: = fn_decl @G @@ -37,8 +41,7 @@ fn If(b: bool) { // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %F.ref: = name_reference "F", file.%F -// CHECK:STDOUT: %.loc12_6.1: type = tuple_type () -// CHECK:STDOUT: %.loc12_6.2: init () = call %F.ref() +// CHECK:STDOUT: %.loc12: init () = call %F.ref() // CHECK:STDOUT: br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.else: diff --git a/toolchain/check/testdata/if_expression/struct.carbon b/toolchain/check/testdata/if_expression/struct.carbon index 0b12a400a512..0f113b943f3c 100644 --- a/toolchain/check/testdata/if_expression/struct.carbon +++ b/toolchain/check/testdata/if_expression/struct.carbon @@ -11,6 +11,11 @@ fn F(cond: bool) { G(if cond then a else a); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7: type = ptr_type {.a: i32, .b: i32} +// CHECK:STDOUT: %.loc11: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "struct.carbon" { // CHECK:STDOUT: %G: = fn_decl @G // CHECK:STDOUT: %F: = fn_decl @F @@ -21,7 +26,6 @@ fn F(cond: bool) { // CHECK:STDOUT: fn @F(%cond: bool) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc10_27: type = struct_type {.a: i32, .b: i32} -// CHECK:STDOUT: %.loc7: type = ptr_type {.a: i32, .b: i32} // CHECK:STDOUT: %a.var: ref {.a: i32, .b: i32} = var "a" // CHECK:STDOUT: %a: ref {.a: i32, .b: i32} = bind_name "a", %a.var // CHECK:STDOUT: %.loc10_37: i32 = int_literal 1 @@ -57,7 +61,6 @@ fn F(cond: bool) { // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: // CHECK:STDOUT: %.loc11_5: {.a: i32, .b: i32} = block_arg !if.expr.result -// CHECK:STDOUT: %.loc11_4.1: type = tuple_type () -// CHECK:STDOUT: %.loc11_4.2: init () = call %G.ref(%.loc11_5) +// CHECK:STDOUT: %.loc11_4: init () = call %G.ref(%.loc11_5) // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/array_element_access.carbon b/toolchain/check/testdata/index/array_element_access.carbon index 304c8179fe11..96fc7421d524 100644 --- a/toolchain/check/testdata/index/array_element_access.carbon +++ b/toolchain/check/testdata/index/array_element_access.carbon @@ -9,24 +9,27 @@ var b: i32 = 1; var c: i32 = a[0]; var d: i32 = a[b]; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7_15: type = ptr_type [i32; 2] +// CHECK:STDOUT: %.loc7_26: type = tuple_type (i32, i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "array_element_access.carbon" { // CHECK:STDOUT: %.loc7_14: i32 = int_literal 2 -// CHECK:STDOUT: %.loc7_15.1: type = array_type %.loc7_14, i32 -// CHECK:STDOUT: %.loc7_15.2: type = ptr_type [i32; 2] +// CHECK:STDOUT: %.loc7_15: type = array_type %.loc7_14, i32 // CHECK:STDOUT: %a.var: ref [i32; 2] = var "a" // CHECK:STDOUT: %a: ref [i32; 2] = bind_name "a", %a.var // CHECK:STDOUT: %.loc7_20: i32 = int_literal 12 // CHECK:STDOUT: %.loc7_24: i32 = int_literal 24 -// CHECK:STDOUT: %.loc7_26.1: type = tuple_type (i32, i32) -// CHECK:STDOUT: %.loc7_26.2: (i32, i32) = tuple_literal (%.loc7_20, %.loc7_24) -// CHECK:STDOUT: %.loc7_26.3: i32 = int_literal 0 -// CHECK:STDOUT: %.loc7_26.4: ref i32 = array_index %a.var, %.loc7_26.3 -// CHECK:STDOUT: %.loc7_26.5: init i32 = initialize_from %.loc7_20 to %.loc7_26.4 -// CHECK:STDOUT: %.loc7_26.6: i32 = int_literal 1 -// CHECK:STDOUT: %.loc7_26.7: ref i32 = array_index %a.var, %.loc7_26.6 -// CHECK:STDOUT: %.loc7_26.8: init i32 = initialize_from %.loc7_24 to %.loc7_26.7 -// CHECK:STDOUT: %.loc7_26.9: init [i32; 2] = array_init %.loc7_26.2, (%.loc7_26.5, %.loc7_26.8) to %a.var -// CHECK:STDOUT: assign %a.var, %.loc7_26.9 +// CHECK:STDOUT: %.loc7_26.1: (i32, i32) = tuple_literal (%.loc7_20, %.loc7_24) +// CHECK:STDOUT: %.loc7_26.2: i32 = int_literal 0 +// CHECK:STDOUT: %.loc7_26.3: ref i32 = array_index %a.var, %.loc7_26.2 +// CHECK:STDOUT: %.loc7_26.4: init i32 = initialize_from %.loc7_20 to %.loc7_26.3 +// CHECK:STDOUT: %.loc7_26.5: i32 = int_literal 1 +// CHECK:STDOUT: %.loc7_26.6: ref i32 = array_index %a.var, %.loc7_26.5 +// CHECK:STDOUT: %.loc7_26.7: init i32 = initialize_from %.loc7_24 to %.loc7_26.6 +// CHECK:STDOUT: %.loc7_26.8: init [i32; 2] = array_init %.loc7_26.1, (%.loc7_26.4, %.loc7_26.7) to %a.var +// CHECK:STDOUT: assign %a.var, %.loc7_26.8 // CHECK:STDOUT: %b.var: ref i32 = var "b" // CHECK:STDOUT: %b: ref i32 = bind_name "b", %b.var // CHECK:STDOUT: %.loc8: i32 = int_literal 1 diff --git a/toolchain/check/testdata/index/expression_category.carbon b/toolchain/check/testdata/index/expression_category.carbon index 839cb8c791db..b43ec78a5a2a 100644 --- a/toolchain/check/testdata/index/expression_category.carbon +++ b/toolchain/check/testdata/index/expression_category.carbon @@ -24,8 +24,12 @@ fn ValueBinding(b: [i32; 3]) { F()[0]; } -// CHECK:STDOUT: file "expression_category.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc7: type = ptr_type [i32; 3] +// CHECK:STDOUT: %.loc10: type = tuple_type (i32, i32, i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "expression_category.carbon" { // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: %G: = fn_decl @G // CHECK:STDOUT: %ValueBinding: = fn_decl @ValueBinding @@ -42,19 +46,18 @@ fn ValueBinding(b: [i32; 3]) { // CHECK:STDOUT: %.loc10_22: i32 = int_literal 1 // CHECK:STDOUT: %.loc10_25: i32 = int_literal 2 // CHECK:STDOUT: %.loc10_28: i32 = int_literal 3 -// CHECK:STDOUT: %.loc10_29.1: type = tuple_type (i32, i32, i32) -// CHECK:STDOUT: %.loc10_29.2: (i32, i32, i32) = tuple_literal (%.loc10_22, %.loc10_25, %.loc10_28) -// CHECK:STDOUT: %.loc10_29.3: i32 = int_literal 0 -// CHECK:STDOUT: %.loc10_29.4: ref i32 = array_index %a.var, %.loc10_29.3 -// CHECK:STDOUT: %.loc10_29.5: init i32 = initialize_from %.loc10_22 to %.loc10_29.4 -// CHECK:STDOUT: %.loc10_29.6: i32 = int_literal 1 -// CHECK:STDOUT: %.loc10_29.7: ref i32 = array_index %a.var, %.loc10_29.6 -// CHECK:STDOUT: %.loc10_29.8: init i32 = initialize_from %.loc10_25 to %.loc10_29.7 -// CHECK:STDOUT: %.loc10_29.9: i32 = int_literal 2 -// CHECK:STDOUT: %.loc10_29.10: ref i32 = array_index %a.var, %.loc10_29.9 -// CHECK:STDOUT: %.loc10_29.11: init i32 = initialize_from %.loc10_28 to %.loc10_29.10 -// CHECK:STDOUT: %.loc10_29.12: init [i32; 3] = array_init %.loc10_29.2, (%.loc10_29.5, %.loc10_29.8, %.loc10_29.11) to %a.var -// CHECK:STDOUT: assign %a.var, %.loc10_29.12 +// CHECK:STDOUT: %.loc10_29.1: (i32, i32, i32) = tuple_literal (%.loc10_22, %.loc10_25, %.loc10_28) +// CHECK:STDOUT: %.loc10_29.2: i32 = int_literal 0 +// CHECK:STDOUT: %.loc10_29.3: ref i32 = array_index %a.var, %.loc10_29.2 +// CHECK:STDOUT: %.loc10_29.4: init i32 = initialize_from %.loc10_22 to %.loc10_29.3 +// CHECK:STDOUT: %.loc10_29.5: i32 = int_literal 1 +// CHECK:STDOUT: %.loc10_29.6: ref i32 = array_index %a.var, %.loc10_29.5 +// CHECK:STDOUT: %.loc10_29.7: init i32 = initialize_from %.loc10_25 to %.loc10_29.6 +// CHECK:STDOUT: %.loc10_29.8: i32 = int_literal 2 +// CHECK:STDOUT: %.loc10_29.9: ref i32 = array_index %a.var, %.loc10_29.8 +// CHECK:STDOUT: %.loc10_29.10: init i32 = initialize_from %.loc10_28 to %.loc10_29.9 +// CHECK:STDOUT: %.loc10_29.11: init [i32; 3] = array_init %.loc10_29.1, (%.loc10_29.4, %.loc10_29.7, %.loc10_29.10) to %a.var +// CHECK:STDOUT: assign %a.var, %.loc10_29.11 // CHECK:STDOUT: %.loc13_14: type = ptr_type i32 // CHECK:STDOUT: %pa.var: ref i32* = var "pa" // CHECK:STDOUT: %pa: ref i32* = bind_name "pa", %pa.var diff --git a/toolchain/check/testdata/index/fail_array_large_index.carbon b/toolchain/check/testdata/index/fail_array_large_index.carbon index 787798df8418..5c63f99019d9 100644 --- a/toolchain/check/testdata/index/fail_array_large_index.carbon +++ b/toolchain/check/testdata/index/fail_array_large_index.carbon @@ -10,20 +10,23 @@ var a: [i32; 1] = (12,); // CHECK:STDERR: ^ var b: i32 = a[0xFFFFFFFFFFFFFFFFF]; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7_15: type = ptr_type [i32; 1] +// CHECK:STDOUT: %.loc7_23: type = tuple_type (i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_array_large_index.carbon" { // CHECK:STDOUT: %.loc7_14: i32 = int_literal 1 -// CHECK:STDOUT: %.loc7_15.1: type = array_type %.loc7_14, i32 -// CHECK:STDOUT: %.loc7_15.2: type = ptr_type [i32; 1] +// CHECK:STDOUT: %.loc7_15: type = array_type %.loc7_14, i32 // CHECK:STDOUT: %a.var: ref [i32; 1] = var "a" // CHECK:STDOUT: %a: ref [i32; 1] = bind_name "a", %a.var // CHECK:STDOUT: %.loc7_20: i32 = int_literal 12 -// CHECK:STDOUT: %.loc7_23.1: type = tuple_type (i32) -// CHECK:STDOUT: %.loc7_23.2: (i32,) = tuple_literal (%.loc7_20) -// CHECK:STDOUT: %.loc7_23.3: i32 = int_literal 0 -// CHECK:STDOUT: %.loc7_23.4: ref i32 = array_index %a.var, %.loc7_23.3 -// CHECK:STDOUT: %.loc7_23.5: init i32 = initialize_from %.loc7_20 to %.loc7_23.4 -// CHECK:STDOUT: %.loc7_23.6: init [i32; 1] = array_init %.loc7_23.2, (%.loc7_23.5) to %a.var -// CHECK:STDOUT: assign %a.var, %.loc7_23.6 +// CHECK:STDOUT: %.loc7_23.1: (i32,) = tuple_literal (%.loc7_20) +// CHECK:STDOUT: %.loc7_23.2: i32 = int_literal 0 +// CHECK:STDOUT: %.loc7_23.3: ref i32 = array_index %a.var, %.loc7_23.2 +// CHECK:STDOUT: %.loc7_23.4: init i32 = initialize_from %.loc7_20 to %.loc7_23.3 +// CHECK:STDOUT: %.loc7_23.5: init [i32; 1] = array_init %.loc7_23.1, (%.loc7_23.4) to %a.var +// CHECK:STDOUT: assign %a.var, %.loc7_23.5 // CHECK:STDOUT: %b.var: ref i32 = var "b" // CHECK:STDOUT: %b: ref i32 = bind_name "b", %b.var // CHECK:STDOUT: %a.ref: ref [i32; 1] = name_reference "a", %a diff --git a/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon b/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon index df80e59951d8..bdbb3e80c6ba 100644 --- a/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon +++ b/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon @@ -10,20 +10,23 @@ var a: [i32; 1] = (12,); // CHECK:STDERR: ^ var b: i32 = a[2.6]; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7_15: type = ptr_type [i32; 1] +// CHECK:STDOUT: %.loc7_23: type = tuple_type (i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_array_non_int_indexing.carbon" { // CHECK:STDOUT: %.loc7_14: i32 = int_literal 1 -// CHECK:STDOUT: %.loc7_15.1: type = array_type %.loc7_14, i32 -// CHECK:STDOUT: %.loc7_15.2: type = ptr_type [i32; 1] +// CHECK:STDOUT: %.loc7_15: type = array_type %.loc7_14, i32 // CHECK:STDOUT: %a.var: ref [i32; 1] = var "a" // CHECK:STDOUT: %a: ref [i32; 1] = bind_name "a", %a.var // CHECK:STDOUT: %.loc7_20: i32 = int_literal 12 -// CHECK:STDOUT: %.loc7_23.1: type = tuple_type (i32) -// CHECK:STDOUT: %.loc7_23.2: (i32,) = tuple_literal (%.loc7_20) -// CHECK:STDOUT: %.loc7_23.3: i32 = int_literal 0 -// CHECK:STDOUT: %.loc7_23.4: ref i32 = array_index %a.var, %.loc7_23.3 -// CHECK:STDOUT: %.loc7_23.5: init i32 = initialize_from %.loc7_20 to %.loc7_23.4 -// CHECK:STDOUT: %.loc7_23.6: init [i32; 1] = array_init %.loc7_23.2, (%.loc7_23.5) to %a.var -// CHECK:STDOUT: assign %a.var, %.loc7_23.6 +// CHECK:STDOUT: %.loc7_23.1: (i32,) = tuple_literal (%.loc7_20) +// CHECK:STDOUT: %.loc7_23.2: i32 = int_literal 0 +// CHECK:STDOUT: %.loc7_23.3: ref i32 = array_index %a.var, %.loc7_23.2 +// CHECK:STDOUT: %.loc7_23.4: init i32 = initialize_from %.loc7_20 to %.loc7_23.3 +// CHECK:STDOUT: %.loc7_23.5: init [i32; 1] = array_init %.loc7_23.1, (%.loc7_23.4) to %a.var +// CHECK:STDOUT: assign %a.var, %.loc7_23.5 // CHECK:STDOUT: %b.var: ref i32 = var "b" // CHECK:STDOUT: %b: ref i32 = bind_name "b", %b.var // CHECK:STDOUT: %a.ref: ref [i32; 1] = name_reference "a", %a diff --git a/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon b/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon index e3813d9982d9..119f5bf340c3 100644 --- a/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon +++ b/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon @@ -10,20 +10,23 @@ var a: [i32; 1] = (12,); // CHECK:STDERR: ^ var b: i32 = a[2]; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7_15: type = ptr_type [i32; 1] +// CHECK:STDOUT: %.loc7_23: type = tuple_type (i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_array_out_of_bound_access.carbon" { // CHECK:STDOUT: %.loc7_14: i32 = int_literal 1 -// CHECK:STDOUT: %.loc7_15.1: type = array_type %.loc7_14, i32 -// CHECK:STDOUT: %.loc7_15.2: type = ptr_type [i32; 1] +// CHECK:STDOUT: %.loc7_15: type = array_type %.loc7_14, i32 // CHECK:STDOUT: %a.var: ref [i32; 1] = var "a" // CHECK:STDOUT: %a: ref [i32; 1] = bind_name "a", %a.var // CHECK:STDOUT: %.loc7_20: i32 = int_literal 12 -// CHECK:STDOUT: %.loc7_23.1: type = tuple_type (i32) -// CHECK:STDOUT: %.loc7_23.2: (i32,) = tuple_literal (%.loc7_20) -// CHECK:STDOUT: %.loc7_23.3: i32 = int_literal 0 -// CHECK:STDOUT: %.loc7_23.4: ref i32 = array_index %a.var, %.loc7_23.3 -// CHECK:STDOUT: %.loc7_23.5: init i32 = initialize_from %.loc7_20 to %.loc7_23.4 -// CHECK:STDOUT: %.loc7_23.6: init [i32; 1] = array_init %.loc7_23.2, (%.loc7_23.5) to %a.var -// CHECK:STDOUT: assign %a.var, %.loc7_23.6 +// CHECK:STDOUT: %.loc7_23.1: (i32,) = tuple_literal (%.loc7_20) +// CHECK:STDOUT: %.loc7_23.2: i32 = int_literal 0 +// CHECK:STDOUT: %.loc7_23.3: ref i32 = array_index %a.var, %.loc7_23.2 +// CHECK:STDOUT: %.loc7_23.4: init i32 = initialize_from %.loc7_20 to %.loc7_23.3 +// CHECK:STDOUT: %.loc7_23.5: init [i32; 1] = array_init %.loc7_23.1, (%.loc7_23.4) to %a.var +// CHECK:STDOUT: assign %a.var, %.loc7_23.5 // CHECK:STDOUT: %b.var: ref i32 = var "b" // CHECK:STDOUT: %b: ref i32 = bind_name "b", %b.var // CHECK:STDOUT: %a.ref: ref [i32; 1] = name_reference "a", %a diff --git a/toolchain/check/testdata/index/fail_empty_tuple_access.carbon b/toolchain/check/testdata/index/fail_empty_tuple_access.carbon index d82be1478580..7047d7adb4a1 100644 --- a/toolchain/check/testdata/index/fail_empty_tuple_access.carbon +++ b/toolchain/check/testdata/index/fail_empty_tuple_access.carbon @@ -13,6 +13,10 @@ fn Run() { F()[0]; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc13: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_empty_tuple_access.carbon" { // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: %Run: = fn_decl @Run @@ -26,11 +30,10 @@ fn Run() { // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %F.ref: = name_reference "F", file.%F -// CHECK:STDOUT: %.loc13_4.1: type = tuple_type () -// CHECK:STDOUT: %.loc13_4.2: init () = call %F.ref() +// CHECK:STDOUT: %.loc13_4.1: init () = call %F.ref() // CHECK:STDOUT: %.loc13_7: i32 = int_literal 0 -// CHECK:STDOUT: %.loc13_4.3: ref () = temporary_storage -// CHECK:STDOUT: %.loc13_4.4: ref () = temporary %.loc13_4.3, %.loc13_4.2 -// CHECK:STDOUT: %.loc13_8: ref = tuple_index %.loc13_4.4, +// CHECK:STDOUT: %.loc13_4.2: ref () = temporary_storage +// CHECK:STDOUT: %.loc13_4.3: ref () = temporary %.loc13_4.2, %.loc13_4.1 +// CHECK:STDOUT: %.loc13_8: ref = tuple_index %.loc13_4.3, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/fail_expression_category.carbon b/toolchain/check/testdata/index/fail_expression_category.carbon index c517df62717a..03add28cb2f6 100644 --- a/toolchain/check/testdata/index/fail_expression_category.carbon +++ b/toolchain/check/testdata/index/fail_expression_category.carbon @@ -29,8 +29,11 @@ fn G(b: [i32; 3]) { F()[0] = 4; } -// CHECK:STDOUT: file "fail_expression_category.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc7: type = ptr_type [i32; 3] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "fail_expression_category.carbon" { // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: %G: = fn_decl @G // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/fail_invalid_base.carbon b/toolchain/check/testdata/index/fail_invalid_base.carbon index f86330211c3f..65574dcdf7a8 100644 --- a/toolchain/check/testdata/index/fail_invalid_base.carbon +++ b/toolchain/check/testdata/index/fail_invalid_base.carbon @@ -30,6 +30,11 @@ var c: i32 = {.a = 1, .b = 2}[0]; // CHECK:STDERR: ^ var d: i32 = {.a: i32, .b: i32}[0]; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc26_29.1: type = struct_type {.a: i32, .b: i32} +// CHECK:STDOUT: %.loc26_29.2: type = ptr_type {.a: i32, .b: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_invalid_base.carbon" { // CHECK:STDOUT: %.loc11: = namespace {} // CHECK:STDOUT: %a.var: ref i32 = var "a" @@ -47,11 +52,9 @@ var d: i32 = {.a: i32, .b: i32}[0]; // CHECK:STDOUT: %c: ref i32 = bind_name "c", %c.var // CHECK:STDOUT: %.loc26_20: i32 = int_literal 1 // CHECK:STDOUT: %.loc26_28: i32 = int_literal 2 -// CHECK:STDOUT: %.loc26_29.1: type = struct_type {.a: i32, .b: i32} -// CHECK:STDOUT: %.loc26_29.2: {.a: i32, .b: i32} = struct_literal (%.loc26_20, %.loc26_28) +// CHECK:STDOUT: %.loc26_29.1: {.a: i32, .b: i32} = struct_literal (%.loc26_20, %.loc26_28) // CHECK:STDOUT: %.loc26_31: i32 = int_literal 0 -// CHECK:STDOUT: %.loc26_29.3: type = ptr_type {.a: i32, .b: i32} -// CHECK:STDOUT: %.loc26_29.4: {.a: i32, .b: i32} = struct_value %.loc26_29.2, (%.loc26_20, %.loc26_28) +// CHECK:STDOUT: %.loc26_29.2: {.a: i32, .b: i32} = struct_value %.loc26_29.1, (%.loc26_20, %.loc26_28) // CHECK:STDOUT: assign %c.var, // CHECK:STDOUT: %d.var: ref i32 = var "d" // CHECK:STDOUT: %d: ref i32 = bind_name "d", %d.var diff --git a/toolchain/check/testdata/index/fail_negative_indexing.carbon b/toolchain/check/testdata/index/fail_negative_indexing.carbon index ec519e534934..9153035da245 100644 --- a/toolchain/check/testdata/index/fail_negative_indexing.carbon +++ b/toolchain/check/testdata/index/fail_negative_indexing.carbon @@ -10,5 +10,11 @@ var a: (i32, i32) = (12, 6); // CHECK:STDERR: ^ var b: i32 = a[-10]; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7_17.1: type = tuple_type (type, type) +// CHECK:STDOUT: %.loc7_17.2: type = tuple_type (i32, i32) +// CHECK:STDOUT: %.loc7_17.3: type = ptr_type (i32, i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_negative_indexing.carbon" { // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/fail_non_deterministic_type.carbon b/toolchain/check/testdata/index/fail_non_deterministic_type.carbon index 026cf9a10e37..a8c0d4651f52 100644 --- a/toolchain/check/testdata/index/fail_non_deterministic_type.carbon +++ b/toolchain/check/testdata/index/fail_non_deterministic_type.carbon @@ -11,11 +11,14 @@ var b: i32 = 0; // CHECK:STDERR: ^ var c: i32 = a[b]; -// CHECK:STDOUT: file "fail_non_deterministic_type.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc7_17.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc7_17.2: (type, type) = tuple_literal (i32, i32) -// CHECK:STDOUT: %.loc7_17.3: type = tuple_type (i32, i32) -// CHECK:STDOUT: %.loc7_17.4: type = ptr_type (i32, i32) +// CHECK:STDOUT: %.loc7_17.2: type = tuple_type (i32, i32) +// CHECK:STDOUT: %.loc7_17.3: type = ptr_type (i32, i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "fail_non_deterministic_type.carbon" { +// CHECK:STDOUT: %.loc7_17: (type, type) = tuple_literal (i32, i32) // CHECK:STDOUT: %a.var: ref (i32, i32) = var "a" // CHECK:STDOUT: %a: ref (i32, i32) = bind_name "a", %a.var // CHECK:STDOUT: %.loc7_22: i32 = int_literal 2 diff --git a/toolchain/check/testdata/index/fail_tuple_index_error.carbon b/toolchain/check/testdata/index/fail_tuple_index_error.carbon index cb7de27d84fc..0ea7971ddc81 100644 --- a/toolchain/check/testdata/index/fail_tuple_index_error.carbon +++ b/toolchain/check/testdata/index/fail_tuple_index_error.carbon @@ -10,11 +10,14 @@ var a: (i32, i32) = (12, 6); // CHECK:STDERR: ^ var b: i32 = a[oops]; -// CHECK:STDOUT: file "fail_tuple_index_error.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc7_17.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc7_17.2: (type, type) = tuple_literal (i32, i32) -// CHECK:STDOUT: %.loc7_17.3: type = tuple_type (i32, i32) -// CHECK:STDOUT: %.loc7_17.4: type = ptr_type (i32, i32) +// CHECK:STDOUT: %.loc7_17.2: type = tuple_type (i32, i32) +// CHECK:STDOUT: %.loc7_17.3: type = ptr_type (i32, i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "fail_tuple_index_error.carbon" { +// CHECK:STDOUT: %.loc7_17: (type, type) = tuple_literal (i32, i32) // CHECK:STDOUT: %a.var: ref (i32, i32) = var "a" // CHECK:STDOUT: %a: ref (i32, i32) = bind_name "a", %a.var // CHECK:STDOUT: %.loc7_22: i32 = int_literal 12 diff --git a/toolchain/check/testdata/index/fail_tuple_large_index.carbon b/toolchain/check/testdata/index/fail_tuple_large_index.carbon index 62e4094881fc..9efed1c6ee07 100644 --- a/toolchain/check/testdata/index/fail_tuple_large_index.carbon +++ b/toolchain/check/testdata/index/fail_tuple_large_index.carbon @@ -11,10 +11,13 @@ var b: (i32,) = a; // CHECK:STDERR: ^ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; -// CHECK:STDOUT: file "fail_tuple_large_index.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc7_13.1: type = tuple_type (type) -// CHECK:STDOUT: %.loc7_13.2: (type,) = tuple_literal (i32) -// CHECK:STDOUT: %.loc7_13.3: type = tuple_type (i32) +// CHECK:STDOUT: %.loc7_13.2: type = tuple_type (i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "fail_tuple_large_index.carbon" { +// CHECK:STDOUT: %.loc7_13: (type,) = tuple_literal (i32) // CHECK:STDOUT: %a.var: ref (i32,) = var "a" // CHECK:STDOUT: %a: ref (i32,) = bind_name "a", %a.var // CHECK:STDOUT: %.loc7_18: i32 = int_literal 12 diff --git a/toolchain/check/testdata/index/fail_tuple_non_int_indexing.carbon b/toolchain/check/testdata/index/fail_tuple_non_int_indexing.carbon index 22d91b3e5ece..ecc4a15c195a 100644 --- a/toolchain/check/testdata/index/fail_tuple_non_int_indexing.carbon +++ b/toolchain/check/testdata/index/fail_tuple_non_int_indexing.carbon @@ -10,11 +10,14 @@ var a: (i32, i32) = (12, 6); // CHECK:STDERR: ^ var b: i32 = a[2.6]; -// CHECK:STDOUT: file "fail_tuple_non_int_indexing.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc7_17.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc7_17.2: (type, type) = tuple_literal (i32, i32) -// CHECK:STDOUT: %.loc7_17.3: type = tuple_type (i32, i32) -// CHECK:STDOUT: %.loc7_17.4: type = ptr_type (i32, i32) +// CHECK:STDOUT: %.loc7_17.2: type = tuple_type (i32, i32) +// CHECK:STDOUT: %.loc7_17.3: type = ptr_type (i32, i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "fail_tuple_non_int_indexing.carbon" { +// CHECK:STDOUT: %.loc7_17: (type, type) = tuple_literal (i32, i32) // CHECK:STDOUT: %a.var: ref (i32, i32) = var "a" // CHECK:STDOUT: %a: ref (i32, i32) = bind_name "a", %a.var // CHECK:STDOUT: %.loc7_22: i32 = int_literal 12 diff --git a/toolchain/check/testdata/index/fail_tuple_out_of_bound_access.carbon b/toolchain/check/testdata/index/fail_tuple_out_of_bound_access.carbon index 86d3cd80c5db..d1104ee1156a 100644 --- a/toolchain/check/testdata/index/fail_tuple_out_of_bound_access.carbon +++ b/toolchain/check/testdata/index/fail_tuple_out_of_bound_access.carbon @@ -10,11 +10,14 @@ var a: (i32, i32) = (12, 6); // CHECK:STDERR: ^ var b: i32 = a[2]; -// CHECK:STDOUT: file "fail_tuple_out_of_bound_access.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc7_17.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc7_17.2: (type, type) = tuple_literal (i32, i32) -// CHECK:STDOUT: %.loc7_17.3: type = tuple_type (i32, i32) -// CHECK:STDOUT: %.loc7_17.4: type = ptr_type (i32, i32) +// CHECK:STDOUT: %.loc7_17.2: type = tuple_type (i32, i32) +// CHECK:STDOUT: %.loc7_17.3: type = ptr_type (i32, i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "fail_tuple_out_of_bound_access.carbon" { +// CHECK:STDOUT: %.loc7_17: (type, type) = tuple_literal (i32, i32) // CHECK:STDOUT: %a.var: ref (i32, i32) = var "a" // CHECK:STDOUT: %a: ref (i32, i32) = bind_name "a", %a.var // CHECK:STDOUT: %.loc7_22: i32 = int_literal 12 diff --git a/toolchain/check/testdata/index/tuple_element_access.carbon b/toolchain/check/testdata/index/tuple_element_access.carbon index ff84533e5444..0695177d88a5 100644 --- a/toolchain/check/testdata/index/tuple_element_access.carbon +++ b/toolchain/check/testdata/index/tuple_element_access.carbon @@ -8,10 +8,13 @@ var a: (i32,) = (12,); var b: (i32,) = a; var c: i32 = b[0]; -// CHECK:STDOUT: file "tuple_element_access.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc7_13.1: type = tuple_type (type) -// CHECK:STDOUT: %.loc7_13.2: (type,) = tuple_literal (i32) -// CHECK:STDOUT: %.loc7_13.3: type = tuple_type (i32) +// CHECK:STDOUT: %.loc7_13.2: type = tuple_type (i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "tuple_element_access.carbon" { +// CHECK:STDOUT: %.loc7_13: (type,) = tuple_literal (i32) // CHECK:STDOUT: %a.var: ref (i32,) = var "a" // CHECK:STDOUT: %a: ref (i32,) = bind_name "a", %a.var // CHECK:STDOUT: %.loc7_18: i32 = int_literal 12 diff --git a/toolchain/check/testdata/index/tuple_return_value_access.carbon b/toolchain/check/testdata/index/tuple_return_value_access.carbon index 0924bf7ea5a0..5b7eadecdbfb 100644 --- a/toolchain/check/testdata/index/tuple_return_value_access.carbon +++ b/toolchain/check/testdata/index/tuple_return_value_access.carbon @@ -10,6 +10,11 @@ fn Run() -> i32 { return F()[0]; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7_16.1: type = tuple_type (type) +// CHECK:STDOUT: %.loc7_16.2: type = tuple_type (i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "tuple_return_value_access.carbon" { // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: %Run: = fn_decl @Run diff --git a/toolchain/check/testdata/let/convert.carbon b/toolchain/check/testdata/let/convert.carbon index 66747cdd3892..f76411f25258 100644 --- a/toolchain/check/testdata/let/convert.carbon +++ b/toolchain/check/testdata/let/convert.carbon @@ -11,16 +11,19 @@ fn F() -> i32 { return w[1]; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc8_24.1: type = tuple_type (type, type, type) +// CHECK:STDOUT: %.loc8_24.2: type = tuple_type (i32, i32, i32) +// CHECK:STDOUT: %.loc8_24.3: type = ptr_type (i32, i32, i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "convert.carbon" { // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8_24.1: type = tuple_type (type, type, type) -// CHECK:STDOUT: %.loc8_24.2: (type, type, type) = tuple_literal (i32, i32, i32) -// CHECK:STDOUT: %.loc8_24.3: type = tuple_type (i32, i32, i32) -// CHECK:STDOUT: %.loc8_24.4: type = ptr_type (i32, i32, i32) +// CHECK:STDOUT: %.loc8_24: (type, type, type) = tuple_literal (i32, i32, i32) // CHECK:STDOUT: %v.var: ref (i32, i32, i32) = var "v" // CHECK:STDOUT: %v: ref (i32, i32, i32) = bind_name "v", %v.var // CHECK:STDOUT: %.loc8_29: i32 = int_literal 1 diff --git a/toolchain/check/testdata/namespace/function.carbon b/toolchain/check/testdata/namespace/function.carbon index cae13f6dab22..41a7550f0879 100644 --- a/toolchain/check/testdata/namespace/function.carbon +++ b/toolchain/check/testdata/namespace/function.carbon @@ -17,6 +17,10 @@ fn Bar() { Foo.Baz(); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc17: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "function.carbon" { // CHECK:STDOUT: %.loc7: = namespace {.Baz = %Baz.loc13} // CHECK:STDOUT: %Baz.loc10: = fn_decl @Baz.1 @@ -38,7 +42,6 @@ fn Bar() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Foo.ref: = name_reference "Foo", file.%.loc7 // CHECK:STDOUT: %Baz.ref: = name_reference "Baz", file.%Baz.loc13 -// CHECK:STDOUT: %.loc17_10.1: type = tuple_type () -// CHECK:STDOUT: %.loc17_10.2: init () = call %Baz.ref() +// CHECK:STDOUT: %.loc17: init () = call %Baz.ref() // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/namespace/nested.carbon b/toolchain/check/testdata/namespace/nested.carbon index de37fb2f817e..e01afce3b9c0 100644 --- a/toolchain/check/testdata/namespace/nested.carbon +++ b/toolchain/check/testdata/namespace/nested.carbon @@ -14,6 +14,10 @@ fn Foo.Bar.Baz() { Foo.Bar.Wiz(); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc14: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "nested.carbon" { // CHECK:STDOUT: %.loc7: = namespace {.Bar = %.loc8} // CHECK:STDOUT: %.loc8: = namespace {.Wiz = %Wiz, .Baz = %Baz} @@ -31,7 +35,6 @@ fn Foo.Bar.Baz() { // CHECK:STDOUT: %Foo.ref: = name_reference "Foo", file.%.loc7 // CHECK:STDOUT: %Bar.ref: = name_reference "Bar", file.%.loc8 // CHECK:STDOUT: %Wiz.ref: = name_reference "Wiz", file.%Wiz -// CHECK:STDOUT: %.loc14_14.1: type = tuple_type () -// CHECK:STDOUT: %.loc14_14.2: init () = call %Wiz.ref() +// CHECK:STDOUT: %.loc14: init () = call %Wiz.ref() // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/operators/assignment.carbon b/toolchain/check/testdata/operators/assignment.carbon index 3407a1ce01a7..b563cd96c61d 100644 --- a/toolchain/check/testdata/operators/assignment.carbon +++ b/toolchain/check/testdata/operators/assignment.carbon @@ -22,6 +22,13 @@ fn Main() { *(if true then p else &a) = 10; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc11_19.1: type = tuple_type (type, type) +// CHECK:STDOUT: %.loc11_19.2: type = tuple_type (i32, i32) +// CHECK:STDOUT: %.loc11_19.3: type = ptr_type (i32, i32) +// CHECK:STDOUT: %.loc15: type = ptr_type {.a: i32, .b: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "assignment.carbon" { // CHECK:STDOUT: %Main: = fn_decl @Main // CHECK:STDOUT: } @@ -35,10 +42,7 @@ fn Main() { // CHECK:STDOUT: %a.ref.loc9: ref i32 = name_reference "a", %a // CHECK:STDOUT: %.loc9: i32 = int_literal 9 // CHECK:STDOUT: assign %a.ref.loc9, %.loc9 -// CHECK:STDOUT: %.loc11_19.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc11_19.2: (type, type) = tuple_literal (i32, i32) -// CHECK:STDOUT: %.loc11_19.3: type = tuple_type (i32, i32) -// CHECK:STDOUT: %.loc11_19.4: type = ptr_type (i32, i32) +// CHECK:STDOUT: %.loc11_19: (type, type) = tuple_literal (i32, i32) // CHECK:STDOUT: %b.var: ref (i32, i32) = var "b" // CHECK:STDOUT: %b: ref (i32, i32) = bind_name "b", %b.var // CHECK:STDOUT: %.loc11_24: i32 = int_literal 1 @@ -60,8 +64,7 @@ fn Main() { // CHECK:STDOUT: %.loc13_6: ref i32 = tuple_index %b.ref.loc13, %.loc13_5 // CHECK:STDOUT: %.loc13_10: i32 = int_literal 4 // CHECK:STDOUT: assign %.loc13_6, %.loc13_10 -// CHECK:STDOUT: %.loc15_27.1: type = struct_type {.a: i32, .b: i32} -// CHECK:STDOUT: %.loc15_27.2: type = ptr_type {.a: i32, .b: i32} +// CHECK:STDOUT: %.loc15_27: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %c.var: ref {.a: i32, .b: i32} = var "c" // CHECK:STDOUT: %c: ref {.a: i32, .b: i32} = bind_name "c", %c.var // CHECK:STDOUT: %.loc15_37: i32 = int_literal 1 diff --git a/toolchain/check/testdata/operators/fail_assignment_to_non_assignable.carbon b/toolchain/check/testdata/operators/fail_assignment_to_non_assignable.carbon index ce8c98a5f33f..87e02bff08a4 100644 --- a/toolchain/check/testdata/operators/fail_assignment_to_non_assignable.carbon +++ b/toolchain/check/testdata/operators/fail_assignment_to_non_assignable.carbon @@ -45,6 +45,13 @@ fn Main() { (if true then a else a) = 10; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc21_8.1: type = tuple_type (i32, i32) +// CHECK:STDOUT: %.loc21_8.2: type = ptr_type (i32, i32) +// CHECK:STDOUT: %.loc34_18.1: type = struct_type {.x: i32, .y: i32} +// CHECK:STDOUT: %.loc34_18.2: type = ptr_type {.x: i32, .y: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_assignment_to_non_assignable.carbon" { // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: %Main: = fn_decl @Main @@ -63,19 +70,17 @@ fn Main() { // CHECK:STDOUT: assign %.loc17_4, %.loc17_9 // CHECK:STDOUT: %.loc21_4: i32 = int_literal 1 // CHECK:STDOUT: %.loc21_7: i32 = int_literal 2 -// CHECK:STDOUT: %.loc21_8.1: type = tuple_type (i32, i32) -// CHECK:STDOUT: %.loc21_8.2: (i32, i32) = tuple_literal (%.loc21_4, %.loc21_7) +// CHECK:STDOUT: %.loc21_8.1: (i32, i32) = tuple_literal (%.loc21_4, %.loc21_7) // CHECK:STDOUT: %.loc21_13: i32 = int_literal 3 // CHECK:STDOUT: %.loc21_16: i32 = int_literal 4 // CHECK:STDOUT: %.loc21_17.1: (i32, i32) = tuple_literal (%.loc21_13, %.loc21_16) -// CHECK:STDOUT: %.loc21_8.3: type = ptr_type (i32, i32) -// CHECK:STDOUT: %.loc21_17.2: i32 = tuple_access %.loc21_8.2, member0 +// CHECK:STDOUT: %.loc21_17.2: i32 = tuple_access %.loc21_8.1, member0 // CHECK:STDOUT: %.loc21_17.3: init i32 = initialize_from %.loc21_13 to %.loc21_17.2 -// CHECK:STDOUT: %.loc21_17.4: i32 = tuple_access %.loc21_8.2, member1 +// CHECK:STDOUT: %.loc21_17.4: i32 = tuple_access %.loc21_8.1, member1 // CHECK:STDOUT: %.loc21_17.5: init i32 = initialize_from %.loc21_16 to %.loc21_17.4 // CHECK:STDOUT: %.loc21_17.6: init (i32, i32) = tuple_init %.loc21_17.1, (%.loc21_17.3, %.loc21_17.5) -// CHECK:STDOUT: assign %.loc21_8.2, %.loc21_17.6 -// CHECK:STDOUT: %.loc21_8.4: (i32, i32) = tuple_value %.loc21_8.2, (%.loc21_4, %.loc21_7) +// CHECK:STDOUT: assign %.loc21_8.1, %.loc21_17.6 +// CHECK:STDOUT: %.loc21_8.2: (i32, i32) = tuple_value %.loc21_8.1, (%.loc21_4, %.loc21_7) // CHECK:STDOUT: %n.var: ref i32 = var "n" // CHECK:STDOUT: %n: ref i32 = bind_name "n", %n.var // CHECK:STDOUT: %.loc22: i32 = int_literal 0 @@ -99,19 +104,17 @@ fn Main() { // CHECK:STDOUT: assign i32, %.loc30 // CHECK:STDOUT: %.loc34_9: i32 = int_literal 1 // CHECK:STDOUT: %.loc34_17: i32 = int_literal 2 -// CHECK:STDOUT: %.loc34_18.1: type = struct_type {.x: i32, .y: i32} -// CHECK:STDOUT: %.loc34_18.2: {.x: i32, .y: i32} = struct_literal (%.loc34_9, %.loc34_17) +// CHECK:STDOUT: %.loc34_18.1: {.x: i32, .y: i32} = struct_literal (%.loc34_9, %.loc34_17) // CHECK:STDOUT: %.loc34_28: i32 = int_literal 3 // CHECK:STDOUT: %.loc34_36: i32 = int_literal 4 // CHECK:STDOUT: %.loc34_37.1: {.x: i32, .y: i32} = struct_literal (%.loc34_28, %.loc34_36) -// CHECK:STDOUT: %.loc34_18.3: type = ptr_type {.x: i32, .y: i32} -// CHECK:STDOUT: %.loc34_37.2: i32 = struct_access %.loc34_18.2, member0 +// CHECK:STDOUT: %.loc34_37.2: i32 = struct_access %.loc34_18.1, member0 // CHECK:STDOUT: %.loc34_37.3: init i32 = initialize_from %.loc34_28 to %.loc34_37.2 -// CHECK:STDOUT: %.loc34_37.4: i32 = struct_access %.loc34_18.2, member1 +// CHECK:STDOUT: %.loc34_37.4: i32 = struct_access %.loc34_18.1, member1 // CHECK:STDOUT: %.loc34_37.5: init i32 = initialize_from %.loc34_36 to %.loc34_37.4 // CHECK:STDOUT: %.loc34_37.6: init {.x: i32, .y: i32} = struct_init %.loc34_37.1, (%.loc34_37.3, %.loc34_37.5) -// CHECK:STDOUT: assign %.loc34_18.2, %.loc34_37.6 -// CHECK:STDOUT: %.loc34_18.4: {.x: i32, .y: i32} = struct_value %.loc34_18.2, (%.loc34_9, %.loc34_17) +// CHECK:STDOUT: assign %.loc34_18.1, %.loc34_37.6 +// CHECK:STDOUT: %.loc34_18.2: {.x: i32, .y: i32} = struct_value %.loc34_18.1, (%.loc34_9, %.loc34_17) // CHECK:STDOUT: %.loc38_7: bool = bool_literal true // CHECK:STDOUT: if %.loc38_7 br !if.expr.then.loc38 else br !if.expr.else.loc38 // CHECK:STDOUT: diff --git a/toolchain/check/testdata/pointer/address_of_deref.carbon b/toolchain/check/testdata/pointer/address_of_deref.carbon index b55e7f1a32cd..a02257808405 100644 --- a/toolchain/check/testdata/pointer/address_of_deref.carbon +++ b/toolchain/check/testdata/pointer/address_of_deref.carbon @@ -9,6 +9,10 @@ fn F() -> i32 { return *&*&n; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc9: type = ptr_type i32 +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "address_of_deref.carbon" { // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: } @@ -20,9 +24,8 @@ fn F() -> i32 { // CHECK:STDOUT: %.loc8: i32 = int_literal 0 // CHECK:STDOUT: assign %n.var, %.loc8 // CHECK:STDOUT: %n.ref: ref i32 = name_reference "n", %n -// CHECK:STDOUT: %.loc9_13.1: type = ptr_type i32 -// CHECK:STDOUT: %.loc9_13.2: i32* = address_of %n.ref -// CHECK:STDOUT: %.loc9_12: ref i32 = dereference %.loc9_13.2 +// CHECK:STDOUT: %.loc9_13: i32* = address_of %n.ref +// CHECK:STDOUT: %.loc9_12: ref i32 = dereference %.loc9_13 // CHECK:STDOUT: %.loc9_11: i32* = address_of %.loc9_12 // CHECK:STDOUT: %.loc9_10.1: ref i32 = dereference %.loc9_11 // CHECK:STDOUT: %.loc9_10.2: i32 = bind_value %.loc9_10.1 diff --git a/toolchain/check/testdata/pointer/address_of_lvalue.carbon b/toolchain/check/testdata/pointer/address_of_lvalue.carbon index 98a0166947e1..c33f73cdf0c7 100644 --- a/toolchain/check/testdata/pointer/address_of_lvalue.carbon +++ b/toolchain/check/testdata/pointer/address_of_lvalue.carbon @@ -16,14 +16,20 @@ fn F() { var t1: i32* = &t[1]; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc8: type = ptr_type {.a: i32, .b: i32} +// CHECK:STDOUT: %.loc14_19.1: type = tuple_type (type, type) +// CHECK:STDOUT: %.loc14_19.2: type = tuple_type (i32, i32) +// CHECK:STDOUT: %.loc14_19.3: type = ptr_type (i32, i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "address_of_lvalue.carbon" { // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8_27.1: type = struct_type {.a: i32, .b: i32} -// CHECK:STDOUT: %.loc8_27.2: type = ptr_type {.a: i32, .b: i32} +// CHECK:STDOUT: %.loc8_27: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %s.var: ref {.a: i32, .b: i32} = var "s" // CHECK:STDOUT: %s: ref {.a: i32, .b: i32} = bind_name "s", %s.var // CHECK:STDOUT: %.loc8_37: i32 = int_literal 1 @@ -56,10 +62,7 @@ fn F() { // CHECK:STDOUT: %.loc12_19: ref i32 = struct_access %s.ref.loc12, member1 // CHECK:STDOUT: %.loc12_17: i32* = address_of %.loc12_19 // CHECK:STDOUT: assign %r.var, %.loc12_17 -// CHECK:STDOUT: %.loc14_19.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc14_19.2: (type, type) = tuple_literal (i32, i32) -// CHECK:STDOUT: %.loc14_19.3: type = tuple_type (i32, i32) -// CHECK:STDOUT: %.loc14_19.4: type = ptr_type (i32, i32) +// CHECK:STDOUT: %.loc14_19: (type, type) = tuple_literal (i32, i32) // CHECK:STDOUT: %t.var: ref (i32, i32) = var "t" // CHECK:STDOUT: %t: ref (i32, i32) = bind_name "t", %t.var // CHECK:STDOUT: %.loc14_24: i32 = int_literal 1 diff --git a/toolchain/check/testdata/pointer/fail_address_of_error.carbon b/toolchain/check/testdata/pointer/fail_address_of_error.carbon index 54e7eceae70f..14e52545b838 100644 --- a/toolchain/check/testdata/pointer/fail_address_of_error.carbon +++ b/toolchain/check/testdata/pointer/fail_address_of_error.carbon @@ -18,6 +18,11 @@ fn Test() { &(&undeclared); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc11: type = ptr_type +// CHECK:STDOUT: %.loc18: type = ptr_type * +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_address_of_error.carbon" { // CHECK:STDOUT: %Test: = fn_decl @Test // CHECK:STDOUT: } @@ -25,11 +30,9 @@ fn Test() { // CHECK:STDOUT: fn @Test() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %undeclared.ref.loc11: = name_reference "undeclared", -// CHECK:STDOUT: %.loc11_3.1: type = ptr_type -// CHECK:STDOUT: %.loc11_3.2: * = address_of %undeclared.ref.loc11 +// CHECK:STDOUT: %.loc11: * = address_of %undeclared.ref.loc11 // CHECK:STDOUT: %undeclared.ref.loc18: = name_reference "undeclared", // CHECK:STDOUT: %.loc18_5: * = address_of %undeclared.ref.loc18 -// CHECK:STDOUT: %.loc18_3.1: type = ptr_type * -// CHECK:STDOUT: %.loc18_3.2: ** = address_of %.loc18_5 +// CHECK:STDOUT: %.loc18_3: ** = address_of %.loc18_5 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/pointer/fail_address_of_value.carbon b/toolchain/check/testdata/pointer/fail_address_of_value.carbon index ae20983d15dd..f42017897197 100644 --- a/toolchain/check/testdata/pointer/fail_address_of_value.carbon +++ b/toolchain/check/testdata/pointer/fail_address_of_value.carbon @@ -82,6 +82,17 @@ fn AddressOfParameter(param: i32) { var param_addr: i32* = ¶m; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc15: type = ptr_type i32 +// CHECK:STDOUT: %.loc19: type = ptr_type bool +// CHECK:STDOUT: %.loc23: type = ptr_type f64 +// CHECK:STDOUT: %.1: type = ptr_type String +// CHECK:STDOUT: %.loc31_9: type = tuple_type (i32, i32) +// CHECK:STDOUT: %.loc31_3: type = ptr_type (i32, i32) +// CHECK:STDOUT: %.loc35: type = ptr_type {.a: i32} +// CHECK:STDOUT: %.loc64: type = ptr_type type +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_address_of_value.carbon" { // CHECK:STDOUT: %G: = fn_decl @G // CHECK:STDOUT: %H: = fn_decl @H @@ -100,27 +111,20 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: fn @AddressOfLiteral() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc15_4: i32 = int_literal 0 -// CHECK:STDOUT: %.loc15_3.1: type = ptr_type i32 -// CHECK:STDOUT: %.loc15_3.2: i32* = address_of %.loc15_4 +// CHECK:STDOUT: %.loc15_3: i32* = address_of %.loc15_4 // CHECK:STDOUT: %.loc19_4: bool = bool_literal true -// CHECK:STDOUT: %.loc19_3.1: type = ptr_type bool -// CHECK:STDOUT: %.loc19_3.2: bool* = address_of %.loc19_4 +// CHECK:STDOUT: %.loc19_3: bool* = address_of %.loc19_4 // CHECK:STDOUT: %.loc23_4: f64 = real_literal 10e-1 -// CHECK:STDOUT: %.loc23_3.1: type = ptr_type f64 -// CHECK:STDOUT: %.loc23_3.2: f64* = address_of %.loc23_4 -// CHECK:STDOUT: %.1: type = ptr_type String +// CHECK:STDOUT: %.loc23_3: f64* = address_of %.loc23_4 // CHECK:STDOUT: %.loc27_4: String = string_literal "Hello" // CHECK:STDOUT: %.loc27_3: String* = address_of %.loc27_4 // CHECK:STDOUT: %.loc31_5: i32 = int_literal 1 // CHECK:STDOUT: %.loc31_8: i32 = int_literal 2 -// CHECK:STDOUT: %.loc31_9.1: type = tuple_type (i32, i32) -// CHECK:STDOUT: %.loc31_9.2: (i32, i32) = tuple_literal (%.loc31_5, %.loc31_8) -// CHECK:STDOUT: %.loc31_3.1: type = ptr_type (i32, i32) -// CHECK:STDOUT: %.loc31_3.2: (i32, i32)* = address_of %.loc31_9.2 +// CHECK:STDOUT: %.loc31_9: (i32, i32) = tuple_literal (%.loc31_5, %.loc31_8) +// CHECK:STDOUT: %.loc31_3: (i32, i32)* = address_of %.loc31_9 // CHECK:STDOUT: %.loc35_10: i32 = int_literal 5 // CHECK:STDOUT: %.loc35_11: {.a: i32} = struct_literal (%.loc35_10) -// CHECK:STDOUT: %.loc35_3.1: type = ptr_type {.a: i32} -// CHECK:STDOUT: %.loc35_3.2: {.a: i32}* = address_of %.loc35_11 +// CHECK:STDOUT: %.loc35_3: {.a: i32}* = address_of %.loc35_11 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -152,8 +156,7 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: // CHECK:STDOUT: fn @AddressOfType() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc64_3.1: type = ptr_type type -// CHECK:STDOUT: %.loc64_3.2: type* = address_of i32 +// CHECK:STDOUT: %.loc64: type* = address_of i32 // CHECK:STDOUT: %.loc68_5: type = const_type i32 // CHECK:STDOUT: %.loc68_14: type = ptr_type const i32 // CHECK:STDOUT: %.loc68_3: type* = address_of %.loc68_14 diff --git a/toolchain/check/testdata/pointer/fail_dereference_not_pointer.carbon b/toolchain/check/testdata/pointer/fail_dereference_not_pointer.carbon index b15cb298ee76..d8339145ba8d 100644 --- a/toolchain/check/testdata/pointer/fail_dereference_not_pointer.carbon +++ b/toolchain/check/testdata/pointer/fail_dereference_not_pointer.carbon @@ -19,6 +19,11 @@ fn Deref(n: i32) { *{}; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc15: type = tuple_type () +// CHECK:STDOUT: %.loc19: type = struct_type {} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_dereference_not_pointer.carbon" { // CHECK:STDOUT: %Deref: = fn_decl @Deref // CHECK:STDOUT: } @@ -27,13 +32,11 @@ fn Deref(n: i32) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %n.ref: i32 = name_reference "n", %n // CHECK:STDOUT: %.loc11: ref = dereference %n.ref -// CHECK:STDOUT: %.loc15_5.1: type = tuple_type () -// CHECK:STDOUT: %.loc15_5.2: () = tuple_literal () -// CHECK:STDOUT: %.loc15_5.3: () = tuple_value %.loc15_5.2, () -// CHECK:STDOUT: %.loc15_3: ref = dereference %.loc15_5.3 -// CHECK:STDOUT: %.loc19_5.1: type = struct_type {} -// CHECK:STDOUT: %.loc19_5.2: {} = struct_literal () -// CHECK:STDOUT: %.loc19_5.3: {} = struct_value %.loc19_5.2, () -// CHECK:STDOUT: %.loc19_3: ref = dereference %.loc19_5.3 +// CHECK:STDOUT: %.loc15_5.1: () = tuple_literal () +// CHECK:STDOUT: %.loc15_5.2: () = tuple_value %.loc15_5.1, () +// CHECK:STDOUT: %.loc15_3: ref = dereference %.loc15_5.2 +// CHECK:STDOUT: %.loc19_5.1: {} = struct_literal () +// CHECK:STDOUT: %.loc19_5.2: {} = struct_value %.loc19_5.1, () +// CHECK:STDOUT: %.loc19_3: ref = dereference %.loc19_5.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/pointer/fail_type_mismatch.carbon b/toolchain/check/testdata/pointer/fail_type_mismatch.carbon index 0f3298f2e82d..c95b4b79d985 100644 --- a/toolchain/check/testdata/pointer/fail_type_mismatch.carbon +++ b/toolchain/check/testdata/pointer/fail_type_mismatch.carbon @@ -11,6 +11,10 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { return p; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7: type = struct_type {} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_type_mismatch.carbon" { // CHECK:STDOUT: %ConstMismatch: = fn_decl @ConstMismatch // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/return/fail_missing_return_empty_tuple.carbon b/toolchain/check/testdata/return/fail_missing_return_empty_tuple.carbon index 40734c6ff6f5..a5538d86edf7 100644 --- a/toolchain/check/testdata/return/fail_missing_return_empty_tuple.carbon +++ b/toolchain/check/testdata/return/fail_missing_return_empty_tuple.carbon @@ -10,6 +10,10 @@ fn F() -> () { // CHECK:STDERR: ^ } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_missing_return_empty_tuple.carbon" { // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/return/tuple.carbon b/toolchain/check/testdata/return/tuple.carbon index 3bf5c1813fbf..f312545a6897 100644 --- a/toolchain/check/testdata/return/tuple.carbon +++ b/toolchain/check/testdata/return/tuple.carbon @@ -9,8 +9,13 @@ fn Main() -> (i32, i32) { return (15, 35); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc8_23.1: type = tuple_type (type, type) +// CHECK:STDOUT: %.loc8_23.2: type = tuple_type (i32, i32) +// CHECK:STDOUT: %.loc8_23.3: type = ptr_type (i32, i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "tuple.carbon" { -// CHECK:STDOUT: %.loc8: type = ptr_type (i32, i32) // CHECK:STDOUT: %Main: = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/empty.carbon b/toolchain/check/testdata/struct/empty.carbon index c865b28714a1..df26b8cf620c 100644 --- a/toolchain/check/testdata/struct/empty.carbon +++ b/toolchain/check/testdata/struct/empty.carbon @@ -7,10 +7,13 @@ var x: {} = {}; var y: {} = x; -// CHECK:STDOUT: file "empty.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc7_9.1: type = struct_type {} -// CHECK:STDOUT: %.loc7_9.2: {} = struct_literal () -// CHECK:STDOUT: %.loc7_9.3: type = tuple_type () +// CHECK:STDOUT: %.loc7_9.2: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "empty.carbon" { +// CHECK:STDOUT: %.loc7_9: {} = struct_literal () // CHECK:STDOUT: %x.var: ref {} = var "x" // CHECK:STDOUT: %x: ref {} = bind_name "x", %x.var // CHECK:STDOUT: %.loc7_14.1: {} = struct_literal () diff --git a/toolchain/check/testdata/struct/fail_assign_empty.carbon b/toolchain/check/testdata/struct/fail_assign_empty.carbon index bc64f7e6a3b9..b1cf7c01e9ed 100644 --- a/toolchain/check/testdata/struct/fail_assign_empty.carbon +++ b/toolchain/check/testdata/struct/fail_assign_empty.carbon @@ -9,11 +9,14 @@ // CHECK:STDERR: ^ var x: {.a: i32} = {}; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10: type = struct_type {} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_assign_empty.carbon" { // CHECK:STDOUT: %.loc10_16: type = struct_type {.a: i32} // CHECK:STDOUT: %x.var: ref {.a: i32} = var "x" // CHECK:STDOUT: %x: ref {.a: i32} = bind_name "x", %x.var -// CHECK:STDOUT: %.loc10_21.1: type = struct_type {} -// CHECK:STDOUT: %.loc10_21.2: {} = struct_literal () +// CHECK:STDOUT: %.loc10_21: {} = struct_literal () // CHECK:STDOUT: assign %x.var, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/struct/fail_assign_nested.carbon b/toolchain/check/testdata/struct/fail_assign_nested.carbon index 2185addfdf1a..c360032449cc 100644 --- a/toolchain/check/testdata/struct/fail_assign_nested.carbon +++ b/toolchain/check/testdata/struct/fail_assign_nested.carbon @@ -9,16 +9,19 @@ // CHECK:STDERR: ^ var x: {.a: {}} = {.b = {}}; -// CHECK:STDOUT: file "fail_assign_nested.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc10_14.1: type = struct_type {} -// CHECK:STDOUT: %.loc10_14.2: {} = struct_literal () -// CHECK:STDOUT: %.loc10_15.1: type = struct_type {.a: {}} -// CHECK:STDOUT: %.loc10_14.3: type = tuple_type () -// CHECK:STDOUT: %.loc10_15.2: type = struct_type {.a: ()} +// CHECK:STDOUT: %.loc10_14.2: type = tuple_type () +// CHECK:STDOUT: %.loc10_15: type = struct_type {.a: ()} +// CHECK:STDOUT: %.loc10_27: type = struct_type {.b: {}} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "fail_assign_nested.carbon" { +// CHECK:STDOUT: %.loc10_14: {} = struct_literal () +// CHECK:STDOUT: %.loc10_15: type = struct_type {.a: {}} // CHECK:STDOUT: %x.var: ref {.a: {}} = var "x" // CHECK:STDOUT: %x: ref {.a: {}} = bind_name "x", %x.var // CHECK:STDOUT: %.loc10_26: {} = struct_literal () -// CHECK:STDOUT: %.loc10_27.1: type = struct_type {.b: {}} -// CHECK:STDOUT: %.loc10_27.2: {.b: {}} = struct_literal (%.loc10_26) +// CHECK:STDOUT: %.loc10_27: {.b: {}} = struct_literal (%.loc10_26) // CHECK:STDOUT: assign %x.var, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/struct/fail_assign_to_empty.carbon b/toolchain/check/testdata/struct/fail_assign_to_empty.carbon index e1b0ddf2bcc3..e4d6ed6bd674 100644 --- a/toolchain/check/testdata/struct/fail_assign_to_empty.carbon +++ b/toolchain/check/testdata/struct/fail_assign_to_empty.carbon @@ -9,14 +9,17 @@ // CHECK:STDERR: ^ var x: {} = {.a = 1}; -// CHECK:STDOUT: file "fail_assign_to_empty.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc10_9.1: type = struct_type {} -// CHECK:STDOUT: %.loc10_9.2: {} = struct_literal () -// CHECK:STDOUT: %.loc10_9.3: type = tuple_type () +// CHECK:STDOUT: %.loc10_9.2: type = tuple_type () +// CHECK:STDOUT: %.loc10_20: type = struct_type {.a: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "fail_assign_to_empty.carbon" { +// CHECK:STDOUT: %.loc10_9: {} = struct_literal () // CHECK:STDOUT: %x.var: ref {} = var "x" // CHECK:STDOUT: %x: ref {} = bind_name "x", %x.var // CHECK:STDOUT: %.loc10_19: i32 = int_literal 1 -// CHECK:STDOUT: %.loc10_20.1: type = struct_type {.a: i32} -// CHECK:STDOUT: %.loc10_20.2: {.a: i32} = struct_literal (%.loc10_19) +// CHECK:STDOUT: %.loc10_20: {.a: i32} = struct_literal (%.loc10_19) // CHECK:STDOUT: assign %x.var, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/struct/fail_field_name_mismatch.carbon b/toolchain/check/testdata/struct/fail_field_name_mismatch.carbon index ec2c4898f5b6..feb768f5e879 100644 --- a/toolchain/check/testdata/struct/fail_field_name_mismatch.carbon +++ b/toolchain/check/testdata/struct/fail_field_name_mismatch.carbon @@ -14,13 +14,16 @@ var x: {.a: i32} = {.b = 1}; // CHECK:STDERR: ^ var y: {.b: i32} = x; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10: type = struct_type {.b: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_field_name_mismatch.carbon" { // CHECK:STDOUT: %.loc10_16: type = struct_type {.a: i32} // CHECK:STDOUT: %x.var: ref {.a: i32} = var "x" // CHECK:STDOUT: %x: ref {.a: i32} = bind_name "x", %x.var // CHECK:STDOUT: %.loc10_26: i32 = int_literal 1 -// CHECK:STDOUT: %.loc10_27.1: type = struct_type {.b: i32} -// CHECK:STDOUT: %.loc10_27.2: {.b: i32} = struct_literal (%.loc10_26) +// CHECK:STDOUT: %.loc10_27: {.b: i32} = struct_literal (%.loc10_26) // CHECK:STDOUT: assign %x.var, // CHECK:STDOUT: %.loc15: type = struct_type {.b: i32} // CHECK:STDOUT: %y.var: ref {.b: i32} = var "y" diff --git a/toolchain/check/testdata/struct/fail_field_type_mismatch.carbon b/toolchain/check/testdata/struct/fail_field_type_mismatch.carbon index e3012e41943d..c06072db719b 100644 --- a/toolchain/check/testdata/struct/fail_field_type_mismatch.carbon +++ b/toolchain/check/testdata/struct/fail_field_type_mismatch.carbon @@ -9,12 +9,15 @@ // CHECK:STDERR: ^ var x: {.a: i32} = {.b = 1.0}; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10: type = struct_type {.b: f64} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_field_type_mismatch.carbon" { // CHECK:STDOUT: %.loc10_16: type = struct_type {.a: i32} // CHECK:STDOUT: %x.var: ref {.a: i32} = var "x" // CHECK:STDOUT: %x: ref {.a: i32} = bind_name "x", %x.var // CHECK:STDOUT: %.loc10_26: f64 = real_literal 10e-1 -// CHECK:STDOUT: %.loc10_29.1: type = struct_type {.b: f64} -// CHECK:STDOUT: %.loc10_29.2: {.b: f64} = struct_literal (%.loc10_26) +// CHECK:STDOUT: %.loc10_29: {.b: f64} = struct_literal (%.loc10_26) // CHECK:STDOUT: assign %x.var, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/struct/fail_nested_incomplete.carbon b/toolchain/check/testdata/struct/fail_nested_incomplete.carbon index 757b85bcc85e..d2ef5a423310 100644 --- a/toolchain/check/testdata/struct/fail_nested_incomplete.carbon +++ b/toolchain/check/testdata/struct/fail_nested_incomplete.carbon @@ -19,6 +19,10 @@ var s: {.a: Incomplete}; // CHECK:STDERR: ^ var p: Incomplete* = &s.a; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc20: type = ptr_type +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_nested_incomplete.carbon" { // CHECK:STDOUT: class_declaration @Incomplete, () // CHECK:STDOUT: %Incomplete: type = class_type @Incomplete @@ -31,8 +35,7 @@ var p: Incomplete* = &s.a; // CHECK:STDOUT: %p.var: ref Incomplete* = var "p" // CHECK:STDOUT: %p: ref Incomplete* = bind_name "p", %p.var // CHECK:STDOUT: %s.ref: ref = name_reference "s", %s -// CHECK:STDOUT: %.loc20_22.1: type = ptr_type -// CHECK:STDOUT: %.loc20_22.2: * = address_of +// CHECK:STDOUT: %.loc20_22: * = address_of // CHECK:STDOUT: assign %p.var, // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/fail_too_few_values.carbon b/toolchain/check/testdata/struct/fail_too_few_values.carbon index 56378ddab7e2..712b7cf4a7b0 100644 --- a/toolchain/check/testdata/struct/fail_too_few_values.carbon +++ b/toolchain/check/testdata/struct/fail_too_few_values.carbon @@ -9,13 +9,16 @@ // CHECK:STDERR: ^ var x: {.a: i32, .b: i32} = {.a = 1}; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10_25: type = ptr_type {.a: i32, .b: i32} +// CHECK:STDOUT: %.loc10_36: type = struct_type {.a: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_too_few_values.carbon" { -// CHECK:STDOUT: %.loc10_25.1: type = struct_type {.a: i32, .b: i32} -// CHECK:STDOUT: %.loc10_25.2: type = ptr_type {.a: i32, .b: i32} +// CHECK:STDOUT: %.loc10_25: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %x.var: ref {.a: i32, .b: i32} = var "x" // CHECK:STDOUT: %x: ref {.a: i32, .b: i32} = bind_name "x", %x.var // CHECK:STDOUT: %.loc10_35: i32 = int_literal 1 -// CHECK:STDOUT: %.loc10_36.1: type = struct_type {.a: i32} -// CHECK:STDOUT: %.loc10_36.2: {.a: i32} = struct_literal (%.loc10_35) +// CHECK:STDOUT: %.loc10_36: {.a: i32} = struct_literal (%.loc10_35) // CHECK:STDOUT: assign %x.var, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/struct/fail_value_as_type.carbon b/toolchain/check/testdata/struct/fail_value_as_type.carbon index 0eaeee30614e..a527c93b81df 100644 --- a/toolchain/check/testdata/struct/fail_value_as_type.carbon +++ b/toolchain/check/testdata/struct/fail_value_as_type.carbon @@ -9,10 +9,13 @@ // CHECK:STDERR: ^ var x: {.a = 1}; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10: type = struct_type {.a: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_value_as_type.carbon" { // CHECK:STDOUT: %.loc10_14: i32 = int_literal 1 -// CHECK:STDOUT: %.loc10_15.1: type = struct_type {.a: i32} -// CHECK:STDOUT: %.loc10_15.2: {.a: i32} = struct_literal (%.loc10_14) +// CHECK:STDOUT: %.loc10_15: {.a: i32} = struct_literal (%.loc10_14) // CHECK:STDOUT: %x.var: ref = var "x" // CHECK:STDOUT: %x: ref = bind_name "x", %x.var // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/struct/literal_member_access.carbon b/toolchain/check/testdata/struct/literal_member_access.carbon index a9d6388341d1..e7267e48aac0 100644 --- a/toolchain/check/testdata/struct/literal_member_access.carbon +++ b/toolchain/check/testdata/struct/literal_member_access.carbon @@ -10,8 +10,14 @@ fn F() -> i32 { return {.a = 1, .b = G(), .c = 3}.b.y; } -// CHECK:STDOUT: file "literal_member_access.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc7: type = ptr_type {.x: i32, .y: i32, .z: i32} +// CHECK:STDOUT: %.loc10_35.1: type = struct_type {.a: i32, .b: {.x: i32, .y: i32, .z: i32}, .c: i32} +// CHECK:STDOUT: %.loc10_35.2: type = struct_type {.a: i32, .b: {.x: i32, .y: i32, .z: i32}*, .c: i32} +// CHECK:STDOUT: %.loc10_35.3: type = ptr_type {.a: i32, .b: {.x: i32, .y: i32, .z: i32}*, .c: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "literal_member_access.carbon" { // CHECK:STDOUT: %G: = fn_decl @G // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: } @@ -25,10 +31,7 @@ fn F() -> i32 { // CHECK:STDOUT: %.loc10_25.1: ref {.x: i32, .y: i32, .z: i32} = temporary_storage // CHECK:STDOUT: %.loc10_25.2: init {.x: i32, .y: i32, .z: i32} = call %G.ref() to %.loc10_25.1 // CHECK:STDOUT: %.loc10_34: i32 = int_literal 3 -// CHECK:STDOUT: %.loc10_35.1: type = struct_type {.a: i32, .b: {.x: i32, .y: i32, .z: i32}, .c: i32} -// CHECK:STDOUT: %.loc10_35.2: {.a: i32, .b: {.x: i32, .y: i32, .z: i32}, .c: i32} = struct_literal (%.loc10_16, %.loc10_25.2, %.loc10_34) -// CHECK:STDOUT: %.loc10_35.3: type = struct_type {.a: i32, .b: {.x: i32, .y: i32, .z: i32}*, .c: i32} -// CHECK:STDOUT: %.loc10_35.4: type = ptr_type {.a: i32, .b: {.x: i32, .y: i32, .z: i32}*, .c: i32} +// CHECK:STDOUT: %.loc10_35.1: {.a: i32, .b: {.x: i32, .y: i32, .z: i32}, .c: i32} = struct_literal (%.loc10_16, %.loc10_25.2, %.loc10_34) // CHECK:STDOUT: %.loc10_25.3: ref {.x: i32, .y: i32, .z: i32} = temporary %.loc10_25.1, %.loc10_25.2 // CHECK:STDOUT: %.loc10_25.4: ref i32 = struct_access %.loc10_25.3, member0 // CHECK:STDOUT: %.loc10_25.5: i32 = bind_value %.loc10_25.4 @@ -37,8 +40,8 @@ fn F() -> i32 { // CHECK:STDOUT: %.loc10_25.8: ref i32 = struct_access %.loc10_25.3, member2 // CHECK:STDOUT: %.loc10_25.9: i32 = bind_value %.loc10_25.8 // CHECK:STDOUT: %.loc10_25.10: {.x: i32, .y: i32, .z: i32} = struct_value %.loc10_25.3, (%.loc10_25.5, %.loc10_25.7, %.loc10_25.9) -// CHECK:STDOUT: %.loc10_35.5: {.a: i32, .b: {.x: i32, .y: i32, .z: i32}, .c: i32} = struct_value %.loc10_35.2, (%.loc10_16, %.loc10_25.10, %.loc10_34) -// CHECK:STDOUT: %.loc10_36: {.x: i32, .y: i32, .z: i32} = struct_access %.loc10_35.5, member1 +// CHECK:STDOUT: %.loc10_35.2: {.a: i32, .b: {.x: i32, .y: i32, .z: i32}, .c: i32} = struct_value %.loc10_35.1, (%.loc10_16, %.loc10_25.10, %.loc10_34) +// CHECK:STDOUT: %.loc10_36: {.x: i32, .y: i32, .z: i32} = struct_access %.loc10_35.2, member1 // CHECK:STDOUT: %.loc10_38: i32 = struct_access %.loc10_36, member1 // CHECK:STDOUT: return %.loc10_38 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/struct/member_access.carbon b/toolchain/check/testdata/struct/member_access.carbon index 7b1c1fa17bd7..32d523d9b521 100644 --- a/toolchain/check/testdata/struct/member_access.carbon +++ b/toolchain/check/testdata/struct/member_access.carbon @@ -8,9 +8,12 @@ var x: {.a: f64, .b: i32} = {.a = 0.0, .b = 1}; var y: i32 = x.b; var z: i32 = y; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7: type = ptr_type {.a: f64, .b: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "member_access.carbon" { -// CHECK:STDOUT: %.loc7_25.1: type = struct_type {.a: f64, .b: i32} -// CHECK:STDOUT: %.loc7_25.2: type = ptr_type {.a: f64, .b: i32} +// CHECK:STDOUT: %.loc7_25: type = struct_type {.a: f64, .b: i32} // CHECK:STDOUT: %x.var: ref {.a: f64, .b: i32} = var "x" // CHECK:STDOUT: %x: ref {.a: f64, .b: i32} = bind_name "x", %x.var // CHECK:STDOUT: %.loc7_35: f64 = real_literal 0e-1 diff --git a/toolchain/check/testdata/struct/nested_struct_in_place.carbon b/toolchain/check/testdata/struct/nested_struct_in_place.carbon index e58947a148be..504f076028d4 100644 --- a/toolchain/check/testdata/struct/nested_struct_in_place.carbon +++ b/toolchain/check/testdata/struct/nested_struct_in_place.carbon @@ -10,8 +10,15 @@ fn G() { var v: {.a: (i32, i32, i32), .b: (i32, i32, i32)} = {.a = F(), .b = F()}; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7_25.1: type = tuple_type (type, type, type) +// CHECK:STDOUT: %.loc7_25.2: type = tuple_type (i32, i32, i32) +// CHECK:STDOUT: %.loc7_25.3: type = ptr_type (i32, i32, i32) +// CHECK:STDOUT: %.loc10_51.1: type = struct_type {.a: (i32, i32, i32)*, .b: (i32, i32, i32)*} +// CHECK:STDOUT: %.loc10_51.2: type = ptr_type {.a: (i32, i32, i32)*, .b: (i32, i32, i32)*} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "nested_struct_in_place.carbon" { -// CHECK:STDOUT: %.loc7: type = ptr_type (i32, i32, i32) // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: %G: = fn_decl @G // CHECK:STDOUT: } @@ -22,9 +29,7 @@ fn G() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc10_29: (type, type, type) = tuple_literal (i32, i32, i32) // CHECK:STDOUT: %.loc10_50: (type, type, type) = tuple_literal (i32, i32, i32) -// CHECK:STDOUT: %.loc10_51.1: type = struct_type {.a: (i32, i32, i32), .b: (i32, i32, i32)} -// CHECK:STDOUT: %.loc10_51.2: type = struct_type {.a: (i32, i32, i32)*, .b: (i32, i32, i32)*} -// CHECK:STDOUT: %.loc10_51.3: type = ptr_type {.a: (i32, i32, i32)*, .b: (i32, i32, i32)*} +// CHECK:STDOUT: %.loc10_51: type = struct_type {.a: (i32, i32, i32), .b: (i32, i32, i32)} // CHECK:STDOUT: %v.var: ref {.a: (i32, i32, i32), .b: (i32, i32, i32)} = var "v" // CHECK:STDOUT: %v: ref {.a: (i32, i32, i32), .b: (i32, i32, i32)} = bind_name "v", %v.var // CHECK:STDOUT: %F.ref.loc10_61: = name_reference "F", file.%F diff --git a/toolchain/check/testdata/struct/reorder_fields.carbon b/toolchain/check/testdata/struct/reorder_fields.carbon index e992369ce1e6..9132ab2d67a7 100644 --- a/toolchain/check/testdata/struct/reorder_fields.carbon +++ b/toolchain/check/testdata/struct/reorder_fields.carbon @@ -13,10 +13,15 @@ fn F() -> {.a: i32, .b: f64} { return y; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10: type = ptr_type {.a: i32, .b: f64} +// CHECK:STDOUT: %.loc11_62.1: type = struct_type {.b: f64, .a: i32} +// CHECK:STDOUT: %.loc11_62.2: type = ptr_type {.b: f64, .a: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "reorder_fields.carbon" { // CHECK:STDOUT: %MakeI32: = fn_decl @MakeI32 // CHECK:STDOUT: %MakeF64: = fn_decl @MakeF64 -// CHECK:STDOUT: %.loc10: type = ptr_type {.a: i32, .b: f64} // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: @@ -31,14 +36,12 @@ fn F() -> {.a: i32, .b: f64} { // CHECK:STDOUT: %.loc11_44: init f64 = call %MakeF64.ref() // CHECK:STDOUT: %MakeI32.ref: = name_reference "MakeI32", file.%MakeI32 // CHECK:STDOUT: %.loc11_60: init i32 = call %MakeI32.ref() -// CHECK:STDOUT: %.loc11_62.1: type = struct_type {.b: f64, .a: i32} -// CHECK:STDOUT: %.loc11_62.2: {.b: f64, .a: i32} = struct_literal (%.loc11_44, %.loc11_60) -// CHECK:STDOUT: %.loc11_62.3: i32 = value_of_initializer %.loc11_60 -// CHECK:STDOUT: %.loc11_62.4: f64 = value_of_initializer %.loc11_44 -// CHECK:STDOUT: %.loc11_62.5: {.a: i32, .b: f64} = struct_value %.loc11_62.2, (%.loc11_62.3, %.loc11_62.4) -// CHECK:STDOUT: %x: {.a: i32, .b: f64} = bind_name "x", %.loc11_62.5 +// CHECK:STDOUT: %.loc11_62.1: {.b: f64, .a: i32} = struct_literal (%.loc11_44, %.loc11_60) +// CHECK:STDOUT: %.loc11_62.2: i32 = value_of_initializer %.loc11_60 +// CHECK:STDOUT: %.loc11_62.3: f64 = value_of_initializer %.loc11_44 +// CHECK:STDOUT: %.loc11_62.4: {.a: i32, .b: f64} = struct_value %.loc11_62.1, (%.loc11_62.2, %.loc11_62.3) +// CHECK:STDOUT: %x: {.a: i32, .b: f64} = bind_name "x", %.loc11_62.4 // CHECK:STDOUT: %.loc12_27: type = struct_type {.b: f64, .a: i32} -// CHECK:STDOUT: %.loc11_62.6: type = ptr_type {.b: f64, .a: i32} // CHECK:STDOUT: %x.ref: {.a: i32, .b: f64} = name_reference "x", %x // CHECK:STDOUT: %.loc12_31.1: f64 = struct_access %x.ref, member1 // CHECK:STDOUT: %.loc12_31.2: i32 = struct_access %x.ref, member0 diff --git a/toolchain/check/testdata/struct/tuple_as_element.carbon b/toolchain/check/testdata/struct/tuple_as_element.carbon index 281f06f788e9..5263430675b8 100644 --- a/toolchain/check/testdata/struct/tuple_as_element.carbon +++ b/toolchain/check/testdata/struct/tuple_as_element.carbon @@ -7,12 +7,15 @@ var x: {.a: i32, .b: (i32,)} = {.a = 1, .b = (2,)}; var y: {.a: i32, .b: (i32,)} = x; -// CHECK:STDOUT: file "tuple_as_element.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc7_27.1: type = tuple_type (type) -// CHECK:STDOUT: %.loc7_27.2: (type,) = tuple_literal (i32) -// CHECK:STDOUT: %.loc7_27.3: type = tuple_type (i32) -// CHECK:STDOUT: %.loc7_28.1: type = struct_type {.a: i32, .b: (i32,)} -// CHECK:STDOUT: %.loc7_28.2: type = ptr_type {.a: i32, .b: (i32,)} +// CHECK:STDOUT: %.loc7_27.2: type = tuple_type (i32) +// CHECK:STDOUT: %.loc7_28: type = ptr_type {.a: i32, .b: (i32,)} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "tuple_as_element.carbon" { +// CHECK:STDOUT: %.loc7_27: (type,) = tuple_literal (i32) +// CHECK:STDOUT: %.loc7_28: type = struct_type {.a: i32, .b: (i32,)} // CHECK:STDOUT: %x.var: ref {.a: i32, .b: (i32,)} = var "x" // CHECK:STDOUT: %x: ref {.a: i32, .b: (i32,)} = bind_name "x", %x.var // CHECK:STDOUT: %.loc7_38: i32 = int_literal 1 diff --git a/toolchain/check/testdata/struct/two_entries.carbon b/toolchain/check/testdata/struct/two_entries.carbon index 2f594eb379d5..5742a9f86ed8 100644 --- a/toolchain/check/testdata/struct/two_entries.carbon +++ b/toolchain/check/testdata/struct/two_entries.carbon @@ -7,9 +7,12 @@ var x: {.a: i32, .b: i32} = {.a = 1, .b = 2}; var y: {.a: i32, .b: i32} = x; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7: type = ptr_type {.a: i32, .b: i32} +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "two_entries.carbon" { -// CHECK:STDOUT: %.loc7_25.1: type = struct_type {.a: i32, .b: i32} -// CHECK:STDOUT: %.loc7_25.2: type = ptr_type {.a: i32, .b: i32} +// CHECK:STDOUT: %.loc7_25: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %x.var: ref {.a: i32, .b: i32} = var "x" // CHECK:STDOUT: %x: ref {.a: i32, .b: i32} = bind_name "x", %x.var // CHECK:STDOUT: %.loc7_35: i32 = int_literal 1 diff --git a/toolchain/check/testdata/tuples/empty.carbon b/toolchain/check/testdata/tuples/empty.carbon index e4b84b999255..385fdb92cdfb 100644 --- a/toolchain/check/testdata/tuples/empty.carbon +++ b/toolchain/check/testdata/tuples/empty.carbon @@ -7,9 +7,12 @@ var x: () = (); var y: () = x; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "empty.carbon" { -// CHECK:STDOUT: %.loc7_9.1: type = tuple_type () -// CHECK:STDOUT: %.loc7_9.2: () = tuple_literal () +// CHECK:STDOUT: %.loc7_9: () = tuple_literal () // CHECK:STDOUT: %x.var: ref () = var "x" // CHECK:STDOUT: %x: ref () = bind_name "x", %x.var // CHECK:STDOUT: %.loc7_14.1: () = tuple_literal () diff --git a/toolchain/check/testdata/tuples/fail_assign_empty.carbon b/toolchain/check/testdata/tuples/fail_assign_empty.carbon index 95cc1313e15c..f6313efb3866 100644 --- a/toolchain/check/testdata/tuples/fail_assign_empty.carbon +++ b/toolchain/check/testdata/tuples/fail_assign_empty.carbon @@ -9,13 +9,16 @@ // CHECK:STDERR: ^ var x: (i32,) = (); -// CHECK:STDOUT: file "fail_assign_empty.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc10_13.1: type = tuple_type (type) -// CHECK:STDOUT: %.loc10_13.2: (type,) = tuple_literal (i32) -// CHECK:STDOUT: %.loc10_13.3: type = tuple_type (i32) +// CHECK:STDOUT: %.loc10_13.2: type = tuple_type (i32) +// CHECK:STDOUT: %.loc10_18: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "fail_assign_empty.carbon" { +// CHECK:STDOUT: %.loc10_13: (type,) = tuple_literal (i32) // CHECK:STDOUT: %x.var: ref (i32,) = var "x" // CHECK:STDOUT: %x: ref (i32,) = bind_name "x", %x.var -// CHECK:STDOUT: %.loc10_18.1: type = tuple_type () -// CHECK:STDOUT: %.loc10_18.2: () = tuple_literal () +// CHECK:STDOUT: %.loc10_18: () = tuple_literal () // CHECK:STDOUT: assign %x.var, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/tuples/fail_assign_nested.carbon b/toolchain/check/testdata/tuples/fail_assign_nested.carbon index 85ba92438317..8dea88f42c7a 100644 --- a/toolchain/check/testdata/tuples/fail_assign_nested.carbon +++ b/toolchain/check/testdata/tuples/fail_assign_nested.carbon @@ -9,29 +9,32 @@ // CHECK:STDERR: ^ var x: ((i32, i32), (i32, i32)) = ((1, 2, 3), (4, 5, 6)); -// CHECK:STDOUT: file "fail_assign_nested.carbon" { -// CHECK:STDOUT: %.loc10_18.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc10_18.2: (type, type) = tuple_literal (i32, i32) -// CHECK:STDOUT: %.loc10_30: (type, type) = tuple_literal (i32, i32) +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10_18: type = tuple_type (type, type) // CHECK:STDOUT: %.loc10_31.1: type = tuple_type ((type, type), (type, type)) -// CHECK:STDOUT: %.loc10_31.2: ((type, type), (type, type)) = tuple_literal (%.loc10_18.2, %.loc10_30) -// CHECK:STDOUT: %.loc10_31.3: type = tuple_type (i32, i32) -// CHECK:STDOUT: %.loc10_31.4: type = tuple_type ((i32, i32), (i32, i32)) -// CHECK:STDOUT: %.loc10_31.5: type = ptr_type (i32, i32) -// CHECK:STDOUT: %.loc10_31.6: type = tuple_type ((i32, i32)*, (i32, i32)*) -// CHECK:STDOUT: %.loc10_31.7: type = ptr_type ((i32, i32)*, (i32, i32)*) +// CHECK:STDOUT: %.loc10_31.2: type = tuple_type (i32, i32) +// CHECK:STDOUT: %.loc10_31.3: type = tuple_type ((i32, i32), (i32, i32)) +// CHECK:STDOUT: %.loc10_31.4: type = ptr_type (i32, i32) +// CHECK:STDOUT: %.loc10_31.5: type = tuple_type ((i32, i32)*, (i32, i32)*) +// CHECK:STDOUT: %.loc10_31.6: type = ptr_type ((i32, i32)*, (i32, i32)*) +// CHECK:STDOUT: %.loc10_44: type = tuple_type (i32, i32, i32) +// CHECK:STDOUT: %.loc10_56: type = tuple_type ((i32, i32, i32), (i32, i32, i32)) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "fail_assign_nested.carbon" { +// CHECK:STDOUT: %.loc10_18: (type, type) = tuple_literal (i32, i32) +// CHECK:STDOUT: %.loc10_30: (type, type) = tuple_literal (i32, i32) +// CHECK:STDOUT: %.loc10_31: ((type, type), (type, type)) = tuple_literal (%.loc10_18, %.loc10_30) // CHECK:STDOUT: %x.var: ref ((i32, i32), (i32, i32)) = var "x" // CHECK:STDOUT: %x: ref ((i32, i32), (i32, i32)) = bind_name "x", %x.var // CHECK:STDOUT: %.loc10_37: i32 = int_literal 1 // CHECK:STDOUT: %.loc10_40: i32 = int_literal 2 // CHECK:STDOUT: %.loc10_43: i32 = int_literal 3 -// CHECK:STDOUT: %.loc10_44.1: type = tuple_type (i32, i32, i32) -// CHECK:STDOUT: %.loc10_44.2: (i32, i32, i32) = tuple_literal (%.loc10_37, %.loc10_40, %.loc10_43) +// CHECK:STDOUT: %.loc10_44: (i32, i32, i32) = tuple_literal (%.loc10_37, %.loc10_40, %.loc10_43) // CHECK:STDOUT: %.loc10_48: i32 = int_literal 4 // CHECK:STDOUT: %.loc10_51: i32 = int_literal 5 // CHECK:STDOUT: %.loc10_54: i32 = int_literal 6 // CHECK:STDOUT: %.loc10_55: (i32, i32, i32) = tuple_literal (%.loc10_48, %.loc10_51, %.loc10_54) -// CHECK:STDOUT: %.loc10_56.1: type = tuple_type ((i32, i32, i32), (i32, i32, i32)) -// CHECK:STDOUT: %.loc10_56.2: ((i32, i32, i32), (i32, i32, i32)) = tuple_literal (%.loc10_44.2, %.loc10_55) +// CHECK:STDOUT: %.loc10_56: ((i32, i32, i32), (i32, i32, i32)) = tuple_literal (%.loc10_44, %.loc10_55) // CHECK:STDOUT: assign %x.var, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/tuples/fail_assign_to_empty.carbon b/toolchain/check/testdata/tuples/fail_assign_to_empty.carbon index d0821d9f8046..5d882021d3f5 100644 --- a/toolchain/check/testdata/tuples/fail_assign_to_empty.carbon +++ b/toolchain/check/testdata/tuples/fail_assign_to_empty.carbon @@ -9,9 +9,12 @@ // CHECK:STDERR: ^ var x: () = (66); +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_assign_to_empty.carbon" { -// CHECK:STDOUT: %.loc10_9.1: type = tuple_type () -// CHECK:STDOUT: %.loc10_9.2: () = tuple_literal () +// CHECK:STDOUT: %.loc10_9: () = tuple_literal () // CHECK:STDOUT: %x.var: ref () = var "x" // CHECK:STDOUT: %x: ref () = bind_name "x", %x.var // CHECK:STDOUT: %.loc10_14: i32 = int_literal 66 diff --git a/toolchain/check/testdata/tuples/fail_element_type_mismatch.carbon b/toolchain/check/testdata/tuples/fail_element_type_mismatch.carbon index 06929313c19b..5c783aee140b 100644 --- a/toolchain/check/testdata/tuples/fail_element_type_mismatch.carbon +++ b/toolchain/check/testdata/tuples/fail_element_type_mismatch.carbon @@ -9,18 +9,21 @@ // CHECK:STDERR: ^ var x: (i32, i32) = (2, 65.89); -// CHECK:STDOUT: file "fail_element_type_mismatch.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc10_17.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc10_17.2: (type, type) = tuple_literal (i32, i32) -// CHECK:STDOUT: %.loc10_17.3: type = tuple_type (i32, i32) -// CHECK:STDOUT: %.loc10_17.4: type = ptr_type (i32, i32) +// CHECK:STDOUT: %.loc10_17.2: type = tuple_type (i32, i32) +// CHECK:STDOUT: %.loc10_17.3: type = ptr_type (i32, i32) +// CHECK:STDOUT: %.loc10_30: type = tuple_type (i32, f64) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "fail_element_type_mismatch.carbon" { +// CHECK:STDOUT: %.loc10_17: (type, type) = tuple_literal (i32, i32) // CHECK:STDOUT: %x.var: ref (i32, i32) = var "x" // CHECK:STDOUT: %x: ref (i32, i32) = bind_name "x", %x.var // CHECK:STDOUT: %.loc10_22: i32 = int_literal 2 // CHECK:STDOUT: %.loc10_25: f64 = real_literal 6589e-2 -// CHECK:STDOUT: %.loc10_30.1: type = tuple_type (i32, f64) -// CHECK:STDOUT: %.loc10_30.2: (i32, f64) = tuple_literal (%.loc10_22, %.loc10_25) -// CHECK:STDOUT: %.loc10_30.3: ref i32 = tuple_access %x.var, member0 -// CHECK:STDOUT: %.loc10_30.4: init i32 = initialize_from %.loc10_22 to %.loc10_30.3 +// CHECK:STDOUT: %.loc10_30.1: (i32, f64) = tuple_literal (%.loc10_22, %.loc10_25) +// CHECK:STDOUT: %.loc10_30.2: ref i32 = tuple_access %x.var, member0 +// CHECK:STDOUT: %.loc10_30.3: init i32 = initialize_from %.loc10_22 to %.loc10_30.2 // CHECK:STDOUT: assign %x.var, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/tuples/fail_nested_incomplete.carbon b/toolchain/check/testdata/tuples/fail_nested_incomplete.carbon index d8ee632f8cd7..ee55f1f279ac 100644 --- a/toolchain/check/testdata/tuples/fail_nested_incomplete.carbon +++ b/toolchain/check/testdata/tuples/fail_nested_incomplete.carbon @@ -19,13 +19,17 @@ var t: (i32, Incomplete); // CHECK:STDERR: ^ var p: Incomplete* = &t[1]; +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc15_24.1: type = tuple_type (type, type) +// CHECK:STDOUT: %.loc15_24.2: type = tuple_type (i32, Incomplete) +// CHECK:STDOUT: %.loc20: type = ptr_type +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_nested_incomplete.carbon" { // CHECK:STDOUT: class_declaration @Incomplete, () // CHECK:STDOUT: %Incomplete: type = class_type @Incomplete // CHECK:STDOUT: %Incomplete.ref.loc15: type = name_reference "Incomplete", %Incomplete -// CHECK:STDOUT: %.loc15_24.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc15_24.2: (type, type) = tuple_literal (i32, %Incomplete.ref.loc15) -// CHECK:STDOUT: %.loc15_24.3: type = tuple_type (i32, Incomplete) +// CHECK:STDOUT: %.loc15: (type, type) = tuple_literal (i32, %Incomplete.ref.loc15) // CHECK:STDOUT: %t.var: ref = var "t" // CHECK:STDOUT: %t: ref = bind_name "t", %t.var // CHECK:STDOUT: %Incomplete.ref.loc20: type = name_reference "Incomplete", %Incomplete @@ -34,8 +38,7 @@ var p: Incomplete* = &t[1]; // CHECK:STDOUT: %p: ref Incomplete* = bind_name "p", %p.var // CHECK:STDOUT: %t.ref: ref = name_reference "t", %t // CHECK:STDOUT: %.loc20_25: i32 = int_literal 1 -// CHECK:STDOUT: %.loc20_22.1: type = ptr_type -// CHECK:STDOUT: %.loc20_22.2: * = address_of +// CHECK:STDOUT: %.loc20_22: * = address_of // CHECK:STDOUT: assign %p.var, // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/tuples/fail_too_few_element.carbon b/toolchain/check/testdata/tuples/fail_too_few_element.carbon index 61a002d4a4fa..51023099039e 100644 --- a/toolchain/check/testdata/tuples/fail_too_few_element.carbon +++ b/toolchain/check/testdata/tuples/fail_too_few_element.carbon @@ -9,15 +9,18 @@ // CHECK:STDERR: ^ var x: (i32, i32) = (2, ); -// CHECK:STDOUT: file "fail_too_few_element.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc10_17.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc10_17.2: (type, type) = tuple_literal (i32, i32) -// CHECK:STDOUT: %.loc10_17.3: type = tuple_type (i32, i32) -// CHECK:STDOUT: %.loc10_17.4: type = ptr_type (i32, i32) +// CHECK:STDOUT: %.loc10_17.2: type = tuple_type (i32, i32) +// CHECK:STDOUT: %.loc10_17.3: type = ptr_type (i32, i32) +// CHECK:STDOUT: %.loc10_25: type = tuple_type (i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "fail_too_few_element.carbon" { +// CHECK:STDOUT: %.loc10_17: (type, type) = tuple_literal (i32, i32) // CHECK:STDOUT: %x.var: ref (i32, i32) = var "x" // CHECK:STDOUT: %x: ref (i32, i32) = bind_name "x", %x.var // CHECK:STDOUT: %.loc10_22: i32 = int_literal 2 -// CHECK:STDOUT: %.loc10_25.1: type = tuple_type (i32) -// CHECK:STDOUT: %.loc10_25.2: (i32,) = tuple_literal (%.loc10_22) +// CHECK:STDOUT: %.loc10_25: (i32,) = tuple_literal (%.loc10_22) // CHECK:STDOUT: assign %x.var, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/tuples/fail_type_assign.carbon b/toolchain/check/testdata/tuples/fail_type_assign.carbon index 486ff5dbdba1..2f579373e997 100644 --- a/toolchain/check/testdata/tuples/fail_type_assign.carbon +++ b/toolchain/check/testdata/tuples/fail_type_assign.carbon @@ -9,10 +9,13 @@ // CHECK:STDERR: ^ var x: (i32, ) = (i32, ); -// CHECK:STDOUT: file "fail_type_assign.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc10_14.1: type = tuple_type (type) -// CHECK:STDOUT: %.loc10_14.2: (type,) = tuple_literal (i32) -// CHECK:STDOUT: %.loc10_14.3: type = tuple_type (i32) +// CHECK:STDOUT: %.loc10_14.2: type = tuple_type (i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "fail_type_assign.carbon" { +// CHECK:STDOUT: %.loc10_14: (type,) = tuple_literal (i32) // CHECK:STDOUT: %x.var: ref (i32,) = var "x" // CHECK:STDOUT: %x: ref (i32,) = bind_name "x", %x.var // CHECK:STDOUT: %.loc10_24: (type,) = tuple_literal (i32) diff --git a/toolchain/check/testdata/tuples/fail_value_as_type.carbon b/toolchain/check/testdata/tuples/fail_value_as_type.carbon index d4a58c8983a8..f5e7d564da51 100644 --- a/toolchain/check/testdata/tuples/fail_value_as_type.carbon +++ b/toolchain/check/testdata/tuples/fail_value_as_type.carbon @@ -9,11 +9,14 @@ // CHECK:STDERR: ^ var x: (1, ); +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc10_12.1: type = tuple_type (i32) +// CHECK:STDOUT: %.loc10_12.2: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_value_as_type.carbon" { // CHECK:STDOUT: %.loc10_9: i32 = int_literal 1 -// CHECK:STDOUT: %.loc10_12.1: type = tuple_type (i32) -// CHECK:STDOUT: %.loc10_12.2: (i32,) = tuple_literal (%.loc10_9) -// CHECK:STDOUT: %.loc10_12.3: type = tuple_type () +// CHECK:STDOUT: %.loc10_12: (i32,) = tuple_literal (%.loc10_9) // CHECK:STDOUT: %x.var: ref (,) = var "x" // CHECK:STDOUT: %x: ref (,) = bind_name "x", %x.var // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/tuples/nested_tuple.carbon b/toolchain/check/testdata/tuples/nested_tuple.carbon index 8a62f3f06341..a42e10e65976 100644 --- a/toolchain/check/testdata/tuples/nested_tuple.carbon +++ b/toolchain/check/testdata/tuples/nested_tuple.carbon @@ -6,16 +6,19 @@ var x: ((i32, i32), i32) = ((12, 76), 6); -// CHECK:STDOUT: file "nested_tuple.carbon" { -// CHECK:STDOUT: %.loc7_18.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc7_18.2: (type, type) = tuple_literal (i32, i32) +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7_18: type = tuple_type (type, type) // CHECK:STDOUT: %.loc7_24.1: type = tuple_type ((type, type), type) -// CHECK:STDOUT: %.loc7_24.2: ((type, type), type) = tuple_literal (%.loc7_18.2, i32) -// CHECK:STDOUT: %.loc7_24.3: type = tuple_type (i32, i32) -// CHECK:STDOUT: %.loc7_24.4: type = tuple_type ((i32, i32), i32) -// CHECK:STDOUT: %.loc7_24.5: type = ptr_type (i32, i32) -// CHECK:STDOUT: %.loc7_24.6: type = tuple_type ((i32, i32)*, i32) -// CHECK:STDOUT: %.loc7_24.7: type = ptr_type ((i32, i32)*, i32) +// CHECK:STDOUT: %.loc7_24.2: type = tuple_type (i32, i32) +// CHECK:STDOUT: %.loc7_24.3: type = tuple_type ((i32, i32), i32) +// CHECK:STDOUT: %.loc7_24.4: type = ptr_type (i32, i32) +// CHECK:STDOUT: %.loc7_24.5: type = tuple_type ((i32, i32)*, i32) +// CHECK:STDOUT: %.loc7_24.6: type = ptr_type ((i32, i32)*, i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "nested_tuple.carbon" { +// CHECK:STDOUT: %.loc7_18: (type, type) = tuple_literal (i32, i32) +// CHECK:STDOUT: %.loc7_24: ((type, type), type) = tuple_literal (%.loc7_18, i32) // CHECK:STDOUT: %x.var: ref ((i32, i32), i32) = var "x" // CHECK:STDOUT: %x: ref ((i32, i32), i32) = bind_name "x", %x.var // CHECK:STDOUT: %.loc7_30: i32 = int_literal 12 diff --git a/toolchain/check/testdata/tuples/nested_tuple_in_place.carbon b/toolchain/check/testdata/tuples/nested_tuple_in_place.carbon index d0fefd703c74..6cb257553ef5 100644 --- a/toolchain/check/testdata/tuples/nested_tuple_in_place.carbon +++ b/toolchain/check/testdata/tuples/nested_tuple_in_place.carbon @@ -14,8 +14,21 @@ fn H() { var v: (i32, (i32, i32, i32), i32) = (1, F(), 2); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc7_25.1: type = tuple_type (type, type, type) +// CHECK:STDOUT: %.loc7_25.2: type = tuple_type (i32, i32, i32) +// CHECK:STDOUT: %.loc7_25.3: type = ptr_type (i32, i32, i32) +// CHECK:STDOUT: %.loc10_43.1: type = tuple_type ((type, type, type), (type, type, type)) +// CHECK:STDOUT: %.loc10_43.2: type = tuple_type ((i32, i32, i32), (i32, i32, i32)) +// CHECK:STDOUT: %.loc10_43.3: type = tuple_type ((i32, i32, i32)*, (i32, i32, i32)*) +// CHECK:STDOUT: %.loc10_43.4: type = ptr_type ((i32, i32, i32)*, (i32, i32, i32)*) +// CHECK:STDOUT: %.loc14_36.1: type = tuple_type (type, (type, type, type), type) +// CHECK:STDOUT: %.loc14_36.2: type = tuple_type (i32, (i32, i32, i32), i32) +// CHECK:STDOUT: %.loc14_36.3: type = tuple_type (i32, (i32, i32, i32)*, i32) +// CHECK:STDOUT: %.loc14_36.4: type = ptr_type (i32, (i32, i32, i32)*, i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "nested_tuple_in_place.carbon" { -// CHECK:STDOUT: %.loc7: type = ptr_type (i32, i32, i32) // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: %G: = fn_decl @G // CHECK:STDOUT: %H: = fn_decl @H @@ -27,11 +40,7 @@ fn H() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc10_25: (type, type, type) = tuple_literal (i32, i32, i32) // CHECK:STDOUT: %.loc10_42: (type, type, type) = tuple_literal (i32, i32, i32) -// CHECK:STDOUT: %.loc10_43.1: type = tuple_type ((type, type, type), (type, type, type)) -// CHECK:STDOUT: %.loc10_43.2: ((type, type, type), (type, type, type)) = tuple_literal (%.loc10_25, %.loc10_42) -// CHECK:STDOUT: %.loc10_43.3: type = tuple_type ((i32, i32, i32), (i32, i32, i32)) -// CHECK:STDOUT: %.loc10_43.4: type = tuple_type ((i32, i32, i32)*, (i32, i32, i32)*) -// CHECK:STDOUT: %.loc10_43.5: type = ptr_type ((i32, i32, i32)*, (i32, i32, i32)*) +// CHECK:STDOUT: %.loc10_43: ((type, type, type), (type, type, type)) = tuple_literal (%.loc10_25, %.loc10_42) // CHECK:STDOUT: %v.var: ref ((i32, i32, i32), (i32, i32, i32)) = var "v" // CHECK:STDOUT: %v: ref ((i32, i32, i32), (i32, i32, i32)) = bind_name "v", %v.var // CHECK:STDOUT: %F.ref.loc10_48: = name_reference "F", file.%F @@ -49,11 +58,7 @@ fn H() { // CHECK:STDOUT: fn @H() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc14_30: (type, type, type) = tuple_literal (i32, i32, i32) -// CHECK:STDOUT: %.loc14_36.1: type = tuple_type (type, (type, type, type), type) -// CHECK:STDOUT: %.loc14_36.2: (type, (type, type, type), type) = tuple_literal (i32, %.loc14_30, i32) -// CHECK:STDOUT: %.loc14_36.3: type = tuple_type (i32, (i32, i32, i32), i32) -// CHECK:STDOUT: %.loc14_36.4: type = tuple_type (i32, (i32, i32, i32)*, i32) -// CHECK:STDOUT: %.loc14_36.5: type = ptr_type (i32, (i32, i32, i32)*, i32) +// CHECK:STDOUT: %.loc14_36: (type, (type, type, type), type) = tuple_literal (i32, %.loc14_30, i32) // CHECK:STDOUT: %v.var: ref (i32, (i32, i32, i32), i32) = var "v" // CHECK:STDOUT: %v: ref (i32, (i32, i32, i32), i32) = bind_name "v", %v.var // CHECK:STDOUT: %.loc14_41: i32 = int_literal 1 diff --git a/toolchain/check/testdata/tuples/one_element.carbon b/toolchain/check/testdata/tuples/one_element.carbon index ff7f72338b97..73c77237ef50 100644 --- a/toolchain/check/testdata/tuples/one_element.carbon +++ b/toolchain/check/testdata/tuples/one_element.carbon @@ -7,10 +7,13 @@ var x: (i32,) = (4,); var y: (i32,) = x; -// CHECK:STDOUT: file "one_element.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc7_13.1: type = tuple_type (type) -// CHECK:STDOUT: %.loc7_13.2: (type,) = tuple_literal (i32) -// CHECK:STDOUT: %.loc7_13.3: type = tuple_type (i32) +// CHECK:STDOUT: %.loc7_13.2: type = tuple_type (i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "one_element.carbon" { +// CHECK:STDOUT: %.loc7_13: (type,) = tuple_literal (i32) // CHECK:STDOUT: %x.var: ref (i32,) = var "x" // CHECK:STDOUT: %x: ref (i32,) = bind_name "x", %x.var // CHECK:STDOUT: %.loc7_18: i32 = int_literal 4 diff --git a/toolchain/check/testdata/tuples/two_elements.carbon b/toolchain/check/testdata/tuples/two_elements.carbon index 7cf08a4a45eb..858e7a03a9ba 100644 --- a/toolchain/check/testdata/tuples/two_elements.carbon +++ b/toolchain/check/testdata/tuples/two_elements.carbon @@ -7,11 +7,14 @@ var x: (i32, i32) = (4, 102); var y: (i32, i32) = x; -// CHECK:STDOUT: file "two_elements.carbon" { +// CHECK:STDOUT: constants { // CHECK:STDOUT: %.loc7_17.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc7_17.2: (type, type) = tuple_literal (i32, i32) -// CHECK:STDOUT: %.loc7_17.3: type = tuple_type (i32, i32) -// CHECK:STDOUT: %.loc7_17.4: type = ptr_type (i32, i32) +// CHECK:STDOUT: %.loc7_17.2: type = tuple_type (i32, i32) +// CHECK:STDOUT: %.loc7_17.3: type = ptr_type (i32, i32) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file "two_elements.carbon" { +// CHECK:STDOUT: %.loc7_17: (type, type) = tuple_literal (i32, i32) // CHECK:STDOUT: %x.var: ref (i32, i32) = var "x" // CHECK:STDOUT: %x: ref (i32, i32) = bind_name "x", %x.var // CHECK:STDOUT: %.loc7_22: i32 = int_literal 4 diff --git a/toolchain/check/testdata/var/fail_not_copyable.carbon b/toolchain/check/testdata/var/fail_not_copyable.carbon index 2d8479e6e17a..8bfaa95451b9 100644 --- a/toolchain/check/testdata/var/fail_not_copyable.carbon +++ b/toolchain/check/testdata/var/fail_not_copyable.carbon @@ -22,10 +22,16 @@ fn F(x: X) { var y: X = x; } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc8_1.1: type = struct_type {} +// CHECK:STDOUT: %.loc8_1.2: type = tuple_type () +// CHECK:STDOUT: %.loc7: type = ptr_type {} +// CHECK:STDOUT: %.1: type = ptr_type String +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_not_copyable.carbon" { // CHECK:STDOUT: class_declaration @X, () // CHECK:STDOUT: %X: type = class_type @X -// CHECK:STDOUT: %.loc8: type = struct_type {} // CHECK:STDOUT: %F: = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: @@ -36,9 +42,6 @@ fn F(x: X) { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%x: X) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8: type = tuple_type () -// CHECK:STDOUT: %.loc7: type = ptr_type {} -// CHECK:STDOUT: %.1: type = ptr_type String // CHECK:STDOUT: %s.var: ref String = var "s" // CHECK:STDOUT: %s: ref String = bind_name "s", %s.var // CHECK:STDOUT: %.loc16: String = string_literal "hello" diff --git a/toolchain/check/testdata/while/fail_bad_condition.carbon b/toolchain/check/testdata/while/fail_bad_condition.carbon index afbec5013c16..6433ce5ccc81 100644 --- a/toolchain/check/testdata/while/fail_bad_condition.carbon +++ b/toolchain/check/testdata/while/fail_bad_condition.carbon @@ -11,6 +11,10 @@ fn While() { while ("Hello") {} } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = ptr_type String +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "fail_bad_condition.carbon" { // CHECK:STDOUT: %While: = fn_decl @While // CHECK:STDOUT: } @@ -20,7 +24,6 @@ fn While() { // CHECK:STDOUT: br !while.cond // CHECK:STDOUT: // CHECK:STDOUT: !while.cond: -// CHECK:STDOUT: %.1: type = ptr_type String // CHECK:STDOUT: %.loc11: String = string_literal "Hello" // CHECK:STDOUT: if br !while.body else br !while.done // CHECK:STDOUT: diff --git a/toolchain/check/testdata/while/unreachable_end.carbon b/toolchain/check/testdata/while/unreachable_end.carbon index 32fdcb5948b8..5b3c9a4aca71 100644 --- a/toolchain/check/testdata/while/unreachable_end.carbon +++ b/toolchain/check/testdata/while/unreachable_end.carbon @@ -19,6 +19,10 @@ fn While() { H(); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc14: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "unreachable_end.carbon" { // CHECK:STDOUT: %Cond: = fn_decl @Cond // CHECK:STDOUT: %F: = fn_decl @F @@ -38,8 +42,7 @@ fn While() { // CHECK:STDOUT: fn @While() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %F.ref: = name_reference "F", file.%F -// CHECK:STDOUT: %.loc14_4.1: type = tuple_type () -// CHECK:STDOUT: %.loc14_4.2: init () = call %F.ref() +// CHECK:STDOUT: %.loc14: init () = call %F.ref() // CHECK:STDOUT: br !while.cond // CHECK:STDOUT: // CHECK:STDOUT: !while.cond: diff --git a/toolchain/check/testdata/while/while.carbon b/toolchain/check/testdata/while/while.carbon index 0b00176db47a..d50369066ea4 100644 --- a/toolchain/check/testdata/while/while.carbon +++ b/toolchain/check/testdata/while/while.carbon @@ -18,6 +18,10 @@ fn While() { H(); } +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.loc14: type = tuple_type () +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file "while.carbon" { // CHECK:STDOUT: %Cond: = fn_decl @Cond // CHECK:STDOUT: %F: = fn_decl @F @@ -37,8 +41,7 @@ fn While() { // CHECK:STDOUT: fn @While() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %F.ref: = name_reference "F", file.%F -// CHECK:STDOUT: %.loc14_4.1: type = tuple_type () -// CHECK:STDOUT: %.loc14_4.2: init () = call %F.ref() +// CHECK:STDOUT: %.loc14: init () = call %F.ref() // CHECK:STDOUT: br !while.cond // CHECK:STDOUT: // CHECK:STDOUT: !while.cond: diff --git a/toolchain/sem_ir/file.h b/toolchain/sem_ir/file.h index 475aa595b904..58be76bb6b13 100644 --- a/toolchain/sem_ir/file.h +++ b/toolchain/sem_ir/file.h @@ -301,6 +301,8 @@ class File : public Printable { auto insts() const -> const InstStore& { return insts_; } auto inst_blocks() -> InstBlockStore& { return inst_blocks_; } auto inst_blocks() const -> const InstBlockStore& { return inst_blocks_; } + auto constants() -> ConstantStore& { return constants_; } + auto constants() const -> const ConstantStore& { return constants_; } // A list of types that were completed in this file, in the order in which // they were completed. Earlier types in this list cannot contain instances of @@ -367,6 +369,10 @@ class File : public Printable { // The top instruction block ID. InstBlockId top_inst_block_id_ = InstBlockId::Invalid; + + // Storage for instructions that represent computed global constants, such as + // types. + ConstantStore constants_; }; // The expression category of a sem_ir instruction. See /docs/design/values.md diff --git a/toolchain/sem_ir/formatter.cpp b/toolchain/sem_ir/formatter.cpp index cb9b6496eacf..41d787d3be3a 100644 --- a/toolchain/sem_ir/formatter.cpp +++ b/toolchain/sem_ir/formatter.cpp @@ -29,6 +29,8 @@ class InstNamer { enum class ScopeIndex : int32_t { None = -1, File = 0, + Constants = 1, + FirstFunction = 2, }; static_assert(sizeof(ScopeIndex) == sizeof(FunctionId)); @@ -39,7 +41,13 @@ class InstNamer { sem_ir_(sem_ir) { insts.resize(sem_ir.insts().size()); labels.resize(sem_ir.inst_blocks().size()); - scopes.resize(1 + sem_ir.functions().size() + sem_ir.classes().size()); + scopes.resize(static_cast(ScopeIndex::FirstFunction) + + sem_ir.functions().size() + sem_ir.classes().size()); + + // Build the constants scope. + GetScopeInfo(ScopeIndex::Constants).name = + globals.AddNameUnchecked("constants"); + CollectNamesInBlock(ScopeIndex::Constants, sem_ir.constants().array_ref()); // Build the file scope. GetScopeInfo(ScopeIndex::File).name = globals.AddNameUnchecked("file"); @@ -95,13 +103,15 @@ class InstNamer { // Returns the scope index corresponding to a function. auto GetScopeFor(FunctionId fn_id) -> ScopeIndex { - return static_cast(1 + fn_id.index); + return static_cast( + static_cast(ScopeIndex::FirstFunction) + fn_id.index); } // Returns the scope index corresponding to a class. auto GetScopeFor(ClassId class_id) -> ScopeIndex { - return static_cast(1 + sem_ir_.functions().size() + - class_id.index); + return static_cast( + static_cast(ScopeIndex::FirstFunction) + + sem_ir_.functions().size() + class_id.index); } // Returns the IR name to use for a function. @@ -372,14 +382,17 @@ class InstNamer { } auto CollectNamesInBlock(ScopeIndex scope_idx, InstBlockId block_id) -> void { - if (!block_id.is_valid()) { - return; + if (block_id.is_valid()) { + CollectNamesInBlock(scope_idx, sem_ir_.inst_blocks().Get(block_id)); } + } + auto CollectNamesInBlock(ScopeIndex scope_idx, llvm::ArrayRef block) + -> void { Scope& scope = GetScopeInfo(scope_idx); // Use bound names where available. Otherwise, assign a backup name. - for (auto inst_id : sem_ir_.inst_blocks().Get(block_id)) { + for (auto inst_id : block) { if (!inst_id.is_valid()) { continue; } @@ -483,6 +496,8 @@ class Formatter { inst_namer_(tokenized_buffer, parse_tree, sem_ir) {} auto Format() -> void { + FormatConstants(); + out_ << "file \"" << sem_ir_.filename() << "\" {\n"; // TODO: Include information from the `package` declaration, once we // fully support it. @@ -504,6 +519,18 @@ class Formatter { } } + auto FormatConstants() -> void { + if (!sem_ir_.constants().size()) { + return; + } + + llvm::SaveAndRestore constants_scope(scope_, + InstNamer::ScopeIndex::Constants); + out_ << "constants {\n"; + FormatCodeBlock(sem_ir_.constants().array_ref()); + out_ << "}\n\n"; + } + auto FormatClass(ClassId id) -> void { const Class& class_info = sem_ir_.classes().Get(id); @@ -531,7 +558,7 @@ class Formatter { llvm::SaveAndRestore function_scope(scope_, inst_namer_.GetScopeFor(id)); - if (fn.implicit_param_refs_id != SemIR::InstBlockId::Empty) { + if (fn.implicit_param_refs_id != InstBlockId::Empty) { out_ << "["; FormatParameterList(fn.implicit_param_refs_id); out_ << "]"; @@ -583,11 +610,13 @@ class Formatter { } auto FormatCodeBlock(InstBlockId block_id) -> void { - if (!block_id.is_valid()) { - return; + if (block_id.is_valid()) { + FormatCodeBlock(sem_ir_.inst_blocks().Get(block_id)); } + } - for (const InstId inst_id : sem_ir_.inst_blocks().Get(block_id)) { + auto FormatCodeBlock(llvm::ArrayRef block) -> void { + for (const InstId inst_id : block) { FormatInstruction(inst_id); } } diff --git a/toolchain/sem_ir/value_stores.h b/toolchain/sem_ir/value_stores.h index 154b2619cef9..71aaa7dae670 100644 --- a/toolchain/sem_ir/value_stores.h +++ b/toolchain/sem_ir/value_stores.h @@ -45,6 +45,19 @@ class InstStore { ValueStore values_; }; +// Provides storage for instructions representing global constants. +class ConstantStore { + public: + // Add a constant instruction. + auto Add(InstId inst_id) -> void { values_.push_back(inst_id); } + + auto array_ref() const -> llvm::ArrayRef { return values_; } + auto size() const -> int { return values_.size(); } + + private: + llvm::SmallVector values_; +}; + // Provides a ValueStore wrapper for an API specific to name scopes. class NameScopeStore { public: