From 4363af39395d1c267a5e24a2c8efbda2b1cc1ec2 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 3 Dec 2024 08:33:32 +0000 Subject: [PATCH 1/2] Factor out machinery for forming int type literals. Use it in the remaining few places where we currently hardcode `i32`: as the index type in array indexing, as the type for literals in `if` expressions, and as a valid return type for `Run`. In preparation for changing `Core.Int` to be a class. --- toolchain/check/BUILD | 2 + toolchain/check/context.cpp | 11 ---- toolchain/check/context.h | 3 -- toolchain/check/handle_function.cpp | 8 ++- toolchain/check/handle_if_expr.cpp | 7 ++- toolchain/check/handle_index.cpp | 6 ++- toolchain/check/handle_literal.cpp | 16 +----- toolchain/check/literal.cpp | 36 +++++++++++++ toolchain/check/literal.h | 29 +++++++++++ .../fail_out_of_bound_non_literal.carbon | 10 ++-- .../testdata/array/function_param.carbon | 12 +++-- .../testdata/array/index_not_literal.carbon | 10 ++-- .../check/testdata/basics/fail_bad_run.carbon | 9 ++++ .../check/testdata/basics/run_i32.carbon | 4 ++ toolchain/check/testdata/class/basic.carbon | 4 ++ .../check/testdata/class/static_method.carbon | 4 ++ toolchain/check/testdata/deduce/array.carbon | 34 ++++++++---- .../check/testdata/eval/fail_aggregate.carbon | 8 ++- toolchain/check/testdata/if_expr/basic.carbon | 20 ++++--- .../if_expr/fail_not_in_function.carbon | 4 +- .../check/testdata/if_expr/nested.carbon | 42 +++++++++------ .../index/array_element_access.carbon | 20 ++++--- .../check/testdata/index/expr_category.carbon | 46 +++++++++++----- .../index/fail_array_large_index.carbon | 20 ++++--- .../index/fail_array_non_int_indexing.carbon | 10 ++-- .../fail_array_out_of_bound_access.carbon | 10 ++-- .../testdata/index/fail_expr_category.carbon | 52 ++++++++++++------- .../index/fail_negative_indexing.carbon | 10 ++-- .../fail_assignment_to_non_assignable.carbon | 18 ++++--- .../tuple/access/return_value_access.carbon | 4 ++ .../testdata/array/function_param.carbon | 6 +-- .../index/array_element_access.carbon | 12 ++--- 32 files changed, 339 insertions(+), 148 deletions(-) create mode 100644 toolchain/check/literal.cpp create mode 100644 toolchain/check/literal.h diff --git a/toolchain/check/BUILD b/toolchain/check/BUILD index 89bcf4debbee8..d6a7b15da04de 100644 --- a/toolchain/check/BUILD +++ b/toolchain/check/BUILD @@ -28,6 +28,7 @@ cc_library( "import.cpp", "import_ref.cpp", "inst_block_stack.cpp", + "literal.cpp", "member_access.cpp", "merge.cpp", "modifiers.cpp", @@ -54,6 +55,7 @@ cc_library( "import_ref.h", "inst_block_stack.h", "keyword_modifier_set.h", + "literal.h", "member_access.h", "merge.h", "modifiers.h", diff --git a/toolchain/check/context.cpp b/toolchain/check/context.cpp index 0620507d4b7cf..a8b351e810136 100644 --- a/toolchain/check/context.cpp +++ b/toolchain/check/context.cpp @@ -1377,17 +1377,6 @@ auto Context::GetGenericInterfaceType(SemIR::InterfaceId interface_id, *this, interface_id, enclosing_specific_id); } -auto Context::GetInt32Type() -> SemIR::TypeId { - auto bit_width_const_id = TryEvalInst( - *this, SemIR::InstId::Invalid, - SemIR::IntValue{ - .type_id = GetBuiltinType(SemIR::BuiltinInstKind::IntLiteralType), - .int_id = ints().Add(32)}); - return GetCompleteTypeImpl( - *this, SemIR::IntKind::Signed, - constant_values().GetInstId(bit_width_const_id)); -} - auto Context::GetInterfaceType(SemIR::InterfaceId interface_id, SemIR::SpecificId specific_id) -> SemIR::TypeId { return GetTypeImpl( diff --git a/toolchain/check/context.h b/toolchain/check/context.h index a281ce359893e..2857223bf55d4 100644 --- a/toolchain/check/context.h +++ b/toolchain/check/context.h @@ -411,9 +411,6 @@ class Context { SemIR::SpecificId enclosing_specific_id) -> SemIR::TypeId; - // Returns the type `i32`. - auto GetInt32Type() -> SemIR::TypeId; - // Gets the facet type corresponding to a particular interface. auto GetInterfaceType(SemIR::InterfaceId interface_id, SemIR::SpecificId specific_id) -> SemIR::TypeId; diff --git a/toolchain/check/handle_function.cpp b/toolchain/check/handle_function.cpp index 1239384857f03..ff82a49bdbe26 100644 --- a/toolchain/check/handle_function.cpp +++ b/toolchain/check/handle_function.cpp @@ -12,6 +12,7 @@ #include "toolchain/check/handle.h" #include "toolchain/check/import_ref.h" #include "toolchain/check/interface.h" +#include "toolchain/check/literal.h" #include "toolchain/check/merge.h" #include "toolchain/check/modifiers.h" #include "toolchain/check/name_component.h" @@ -303,8 +304,11 @@ static auto BuildFunctionDecl(Context& context, !function_info.param_patterns_id.is_valid() || !context.inst_blocks().Get(function_info.param_patterns_id).empty() || (return_type_id.is_valid() && - return_type_id != context.GetInt32Type() && - return_type_id != context.GetTupleType({}))) { + return_type_id != context.GetTupleType({}) && + // TODO: Decide on valid return types for `i32`. Perhaps we should have + // an interface for this. + return_type_id != MakeIntType(context, node_id, SemIR::IntKind::Signed, + context.ints().Add(32)))) { CARBON_DIAGNOSTIC(InvalidMainRunSignature, Error, "invalid signature for `Main.Run` function; expected " "`fn ()` or `fn () -> i32`"); diff --git a/toolchain/check/handle_if_expr.cpp b/toolchain/check/handle_if_expr.cpp index d08190ca8819a..5db094a27ddce 100644 --- a/toolchain/check/handle_if_expr.cpp +++ b/toolchain/check/handle_if_expr.cpp @@ -5,6 +5,7 @@ #include "toolchain/check/context.h" #include "toolchain/check/convert.h" #include "toolchain/check/handle.h" +#include "toolchain/check/literal.h" #include "toolchain/sem_ir/builtin_inst_kind.h" namespace Carbon::Check { @@ -38,8 +39,10 @@ static auto DecayIntLiteralToSizedInt(Context& context, Parse::NodeId node_id, -> SemIR::InstId { if (context.types().GetInstId(context.insts().Get(operand_id).type_id()) == SemIR::InstId::BuiltinIntLiteralType) { - operand_id = ConvertToValueOfType(context, node_id, operand_id, - context.GetInt32Type()); + operand_id = ConvertToValueOfType( + context, node_id, operand_id, + MakeIntType(context, node_id, SemIR::IntKind::Signed, + context.ints().Add(32))); } return operand_id; } diff --git a/toolchain/check/handle_index.cpp b/toolchain/check/handle_index.cpp index 667be17ff6a5c..1a8261a0935af 100644 --- a/toolchain/check/handle_index.cpp +++ b/toolchain/check/handle_index.cpp @@ -8,6 +8,7 @@ #include "toolchain/check/context.h" #include "toolchain/check/convert.h" #include "toolchain/check/handle.h" +#include "toolchain/check/literal.h" #include "toolchain/check/operator.h" #include "toolchain/diagnostics/diagnostic.h" #include "toolchain/sem_ir/builtin_inst_kind.h" @@ -133,7 +134,10 @@ auto HandleParseNode(Context& context, Parse::IndexExprId node_id) -> bool { case CARBON_KIND(SemIR::ArrayType array_type): { auto index_loc_id = context.insts().GetLocId(index_inst_id); auto cast_index_id = ConvertToValueOfType( - context, index_loc_id, index_inst_id, context.GetInt32Type()); + context, index_loc_id, index_inst_id, + // TODO: Replace this with impl lookup rather than hardcoding `i32`. + MakeIntType(context, node_id, SemIR::IntKind::Signed, + context.ints().Add(32))); auto array_cat = SemIR::GetExprCategory(context.sem_ir(), operand_inst_id); if (array_cat == SemIR::ExprCategory::Value) { diff --git a/toolchain/check/handle_literal.cpp b/toolchain/check/handle_literal.cpp index b5e00f7091713..61ee2908c01a5 100644 --- a/toolchain/check/handle_literal.cpp +++ b/toolchain/check/handle_literal.cpp @@ -5,6 +5,7 @@ #include "toolchain/check/call.h" #include "toolchain/check/context.h" #include "toolchain/check/handle.h" +#include "toolchain/check/literal.h" #include "toolchain/diagnostics/format_providers.h" #include "toolchain/sem_ir/typed_insts.h" @@ -28,16 +29,6 @@ auto HandleParseNode(Context& context, Parse::BoolLiteralTrueId node_id) return true; } -// Forms an IntValue instruction with type `IntLiteral` for a given literal -// integer value, which is assumed to be unsigned. -static auto MakeIntLiteral(Context& context, Parse::NodeId node_id, - IntId int_id) -> SemIR::InstId { - return context.AddInst( - node_id, {.type_id = context.GetBuiltinType( - SemIR::BuiltinInstKind::IntLiteralType), - .int_id = int_id}); -} - auto HandleParseNode(Context& context, Parse::IntLiteralId node_id) -> bool { auto int_literal_id = MakeIntLiteral( context, node_id, @@ -121,10 +112,7 @@ static auto HandleIntOrUnsignedIntTypeLiteral(Context& context, node_id, IntWidthNotMultipleOf8, int_kind.is_signed(), llvm::APSInt(context.ints().Get(size_id), /*isUnsigned=*/true)); } - auto width_id = MakeIntLiteral(context, node_id, size_id); - auto fn_inst_id = context.LookupNameInCore( - node_id, int_kind == SemIR::IntKind::Signed ? "Int" : "UInt"); - auto type_inst_id = PerformCall(context, node_id, fn_inst_id, {width_id}); + auto type_inst_id = MakeIntTypeLiteral(context, node_id, int_kind, size_id); context.node_stack().Push(node_id, type_inst_id); return true; } diff --git a/toolchain/check/literal.cpp b/toolchain/check/literal.cpp new file mode 100644 index 0000000000000..fe0d6739f8f48 --- /dev/null +++ b/toolchain/check/literal.cpp @@ -0,0 +1,36 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "toolchain/check/literal.h" + +#include "toolchain/check/call.h" +#include "toolchain/check/context.h" +#include "toolchain/check/convert.h" + +namespace Carbon::Check { + +auto MakeIntLiteral(Context& context, Parse::NodeId node_id, IntId int_id) + -> SemIR::InstId { + return context.AddInst( + node_id, {.type_id = context.GetBuiltinType( + SemIR::BuiltinInstKind::IntLiteralType), + .int_id = int_id}); +} + +auto MakeIntTypeLiteral(Context& context, Parse::NodeId node_id, + SemIR::IntKind int_kind, IntId size_id) + -> SemIR::InstId { + auto width_id = MakeIntLiteral(context, node_id, size_id); + auto fn_inst_id = context.LookupNameInCore( + node_id, int_kind == SemIR::IntKind::Signed ? "Int" : "UInt"); + return PerformCall(context, node_id, fn_inst_id, {width_id}); +} + +auto MakeIntType(Context& context, Parse::NodeId node_id, + SemIR::IntKind int_kind, IntId size_id) -> SemIR::TypeId { + auto type_inst_id = MakeIntTypeLiteral(context, node_id, int_kind, size_id); + return ExprAsType(context, node_id, type_inst_id).type_id; +} + +} // namespace Carbon::Check diff --git a/toolchain/check/literal.h b/toolchain/check/literal.h new file mode 100644 index 0000000000000..36f6903bc2a5b --- /dev/null +++ b/toolchain/check/literal.h @@ -0,0 +1,29 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef CARBON_TOOLCHAIN_CHECK_LITERAL_H_ +#define CARBON_TOOLCHAIN_CHECK_LITERAL_H_ + +#include "toolchain/check/context.h" +#include "toolchain/sem_ir/ids.h" + +namespace Carbon::Check { + +// Forms an IntValue instruction with type `IntLiteral` for a given literal +// integer value, which is assumed to be unsigned. +auto MakeIntLiteral(Context& context, Parse::NodeId node_id, IntId int_id) + -> SemIR::InstId; + +// Forms an integer type expression for either an `iN` or `uN` literal. +auto MakeIntTypeLiteral(Context& context, Parse::NodeId node_id, + SemIR::IntKind int_kind, IntId size_id) + -> SemIR::InstId; + +// Forms an integer type of the specified kind and bit-width. +auto MakeIntType(Context& context, Parse::NodeId node_id, + SemIR::IntKind int_kind, IntId size_id) -> SemIR::TypeId; + +} // namespace Carbon::Check + +#endif // CARBON_TOOLCHAIN_CHECK_LITERAL_H_ diff --git a/toolchain/check/testdata/array/fail_out_of_bound_non_literal.carbon b/toolchain/check/testdata/array/fail_out_of_bound_non_literal.carbon index 78e24584fd53b..0ab5ef9bf7567 100644 --- a/toolchain/check/testdata/array/fail_out_of_bound_non_literal.carbon +++ b/toolchain/check/testdata/array/fail_out_of_bound_non_literal.carbon @@ -116,15 +116,19 @@ var b: i32 = a[{.index = 3}.index]; // CHECK:STDOUT: %struct: %.41 = struct_value (%.loc15_26) [template = constants.%struct] // CHECK:STDOUT: %.loc15_27.2: %.41 = converted %.loc15_27.1, %struct [template = constants.%struct] // CHECK:STDOUT: %.loc15_28.1: Core.IntLiteral = struct_access %.loc15_27.2, element0 [template = constants.%.2] +// CHECK:STDOUT: %.loc15_34.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc15_34.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc15_34.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32] +// CHECK:STDOUT: %.loc15_34.3: type = converted %int.make_type_signed, %.loc15_34.2 [template = constants.%i32] // CHECK:STDOUT: %.loc15_28.2: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc15_28.3: = bound_method %.loc15_28.1, %.loc15_28.2 [template = constants.%.38] // CHECK:STDOUT: %.loc15_28.4: = specific_function %.loc15_28.3, @Convert.2(constants.%.1) [template = constants.%.39] // CHECK:STDOUT: %int.convert_checked.loc15: init %i32 = call %.loc15_28.4(%.loc15_28.1) [template = constants.%.40] // CHECK:STDOUT: %.loc15_28.5: %i32 = value_of_initializer %int.convert_checked.loc15 [template = constants.%.40] // CHECK:STDOUT: %.loc15_28.6: %i32 = converted %.loc15_28.1, %.loc15_28.5 [template = constants.%.40] -// CHECK:STDOUT: %.loc15_34.1: ref %i32 = array_index %a.ref, %.loc15_28.6 [template = ] -// CHECK:STDOUT: %.loc15_34.2: %i32 = bind_value %.loc15_34.1 -// CHECK:STDOUT: assign file.%b.var, %.loc15_34.2 +// CHECK:STDOUT: %.loc15_34.4: ref %i32 = array_index %a.ref, %.loc15_28.6 [template = ] +// CHECK:STDOUT: %.loc15_34.5: %i32 = bind_value %.loc15_34.4 +// CHECK:STDOUT: assign file.%b.var, %.loc15_34.5 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/array/function_param.carbon b/toolchain/check/testdata/array/function_param.carbon index c3fe00596b8ad..3049993447d0b 100644 --- a/toolchain/check/testdata/array/function_param.carbon +++ b/toolchain/check/testdata/array/function_param.carbon @@ -111,10 +111,14 @@ fn G() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %arr.ref: %.3 = name_ref arr, %arr // CHECK:STDOUT: %i.ref: %i32 = name_ref i, %i -// CHECK:STDOUT: %.loc12_15.1: ref %.3 = value_as_ref %arr.ref -// CHECK:STDOUT: %.loc12_15.2: ref %i32 = array_index %.loc12_15.1, %i.ref -// CHECK:STDOUT: %.loc12_15.3: %i32 = bind_value %.loc12_15.2 -// CHECK:STDOUT: return %.loc12_15.3 +// CHECK:STDOUT: %.loc12_15.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc12: init type = call constants.%Int(%.loc12_15.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc12_15.2: type = value_of_initializer %int.make_type_signed.loc12 [template = constants.%i32] +// CHECK:STDOUT: %.loc12_15.3: type = converted %int.make_type_signed.loc12, %.loc12_15.2 [template = constants.%i32] +// CHECK:STDOUT: %.loc12_15.4: ref %.3 = value_as_ref %arr.ref +// CHECK:STDOUT: %.loc12_15.5: ref %i32 = array_index %.loc12_15.4, %i.ref +// CHECK:STDOUT: %.loc12_15.6: %i32 = bind_value %.loc12_15.5 +// CHECK:STDOUT: return %.loc12_15.6 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> %i32 { diff --git a/toolchain/check/testdata/array/index_not_literal.carbon b/toolchain/check/testdata/array/index_not_literal.carbon index c893c2779e2be..3b757e3136ac7 100644 --- a/toolchain/check/testdata/array/index_not_literal.carbon +++ b/toolchain/check/testdata/array/index_not_literal.carbon @@ -113,15 +113,19 @@ var b: i32 = a[{.index = 2}.index]; // CHECK:STDOUT: %struct: %.41 = struct_value (%.loc12_26) [template = constants.%struct] // CHECK:STDOUT: %.loc12_27.2: %.41 = converted %.loc12_27.1, %struct [template = constants.%struct] // CHECK:STDOUT: %.loc12_28.1: Core.IntLiteral = struct_access %.loc12_27.2, element0 [template = constants.%.6] +// CHECK:STDOUT: %.loc12_34.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc12_34.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc12_34.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32] +// CHECK:STDOUT: %.loc12_34.3: type = converted %int.make_type_signed, %.loc12_34.2 [template = constants.%i32] // CHECK:STDOUT: %.loc12_28.2: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc12_28.3: = bound_method %.loc12_28.1, %.loc12_28.2 [template = constants.%.35] // CHECK:STDOUT: %.loc12_28.4: = specific_function %.loc12_28.3, @Convert.2(constants.%.1) [template = constants.%.36] // CHECK:STDOUT: %int.convert_checked.loc12: init %i32 = call %.loc12_28.4(%.loc12_28.1) [template = constants.%.37] // CHECK:STDOUT: %.loc12_28.5: %i32 = value_of_initializer %int.convert_checked.loc12 [template = constants.%.37] // CHECK:STDOUT: %.loc12_28.6: %i32 = converted %.loc12_28.1, %.loc12_28.5 [template = constants.%.37] -// CHECK:STDOUT: %.loc12_34.1: ref %i32 = array_index %a.ref, %.loc12_28.6 -// CHECK:STDOUT: %.loc12_34.2: %i32 = bind_value %.loc12_34.1 -// CHECK:STDOUT: assign file.%b.var, %.loc12_34.2 +// CHECK:STDOUT: %.loc12_34.4: ref %i32 = array_index %a.ref, %.loc12_28.6 +// CHECK:STDOUT: %.loc12_34.5: %i32 = bind_value %.loc12_34.4 +// CHECK:STDOUT: assign file.%b.var, %.loc12_34.5 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/basics/fail_bad_run.carbon b/toolchain/check/testdata/basics/fail_bad_run.carbon index 5ac963f3d2867..a8948568c243c 100644 --- a/toolchain/check/testdata/basics/fail_bad_run.carbon +++ b/toolchain/check/testdata/basics/fail_bad_run.carbon @@ -22,10 +22,15 @@ fn Run() -> String {} // CHECK:STDOUT: constants { // CHECK:STDOUT: %Run.type: type = fn_type @Run [template] // CHECK:STDOUT: %Run: %Run.type = struct_value () [template] +// CHECK:STDOUT: %.1: Core.IntLiteral = int_value 32 [template] +// CHECK:STDOUT: %Int.type: type = fn_type @Int [template] +// CHECK:STDOUT: %Int: %Int.type = struct_value () [template] +// CHECK:STDOUT: %i32: type = int_type signed, %.1 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int = %import_ref // CHECK:STDOUT: import Core//prelude // CHECK:STDOUT: import Core//prelude/... // CHECK:STDOUT: } @@ -44,6 +49,10 @@ fn Run() -> String {} // CHECK:STDOUT: %return.param: ref String = out_param runtime_param0 // CHECK:STDOUT: %return: ref String = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: %.loc18_20.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc18_20.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc18_20.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32] +// CHECK:STDOUT: %.loc18_20.3: type = converted %int.make_type_signed, %.loc18_20.2 [template = constants.%i32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() -> %return: String { diff --git a/toolchain/check/testdata/basics/run_i32.carbon b/toolchain/check/testdata/basics/run_i32.carbon index 84e60b7c74549..7297180c75698 100644 --- a/toolchain/check/testdata/basics/run_i32.carbon +++ b/toolchain/check/testdata/basics/run_i32.carbon @@ -55,6 +55,10 @@ fn Run() -> i32 { return 0; } // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: %.loc11_17.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc11_17.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc11_17.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32] +// CHECK:STDOUT: %.loc11_17.3: type = converted %int.make_type_signed, %.loc11_17.2 [template = constants.%i32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() -> %i32 { diff --git a/toolchain/check/testdata/class/basic.carbon b/toolchain/check/testdata/class/basic.carbon index 71647b1e024c7..f4c3aa5960a98 100644 --- a/toolchain/check/testdata/class/basic.carbon +++ b/toolchain/check/testdata/class/basic.carbon @@ -100,6 +100,10 @@ fn Run() -> i32 { // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: %.loc25_17.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc25_17.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc25_17.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32] +// CHECK:STDOUT: %.loc25_17.3: type = converted %int.make_type_signed, %.loc25_17.2 [template = constants.%i32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Class { diff --git a/toolchain/check/testdata/class/static_method.carbon b/toolchain/check/testdata/class/static_method.carbon index fb204b65062cf..644f5e79c763b 100644 --- a/toolchain/check/testdata/class/static_method.carbon +++ b/toolchain/check/testdata/class/static_method.carbon @@ -60,6 +60,10 @@ fn Run() -> i32 { // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: %.loc15_17.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc15_17.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc15_17.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32] +// CHECK:STDOUT: %.loc15_17.3: type = converted %int.make_type_signed, %.loc15_17.2 [template = constants.%i32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Class { diff --git a/toolchain/check/testdata/deduce/array.carbon b/toolchain/check/testdata/deduce/array.carbon index 73409cdd47a27..1bef6daefed20 100644 --- a/toolchain/check/testdata/deduce/array.carbon +++ b/toolchain/check/testdata/deduce/array.carbon @@ -111,6 +111,8 @@ fn G() -> C { // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: %.6: Core.IntLiteral = int_value 0 [template] // CHECK:STDOUT: %.7: Core.IntLiteral = int_value 32 [template] +// CHECK:STDOUT: %Int.type: type = fn_type @Int [template] +// CHECK:STDOUT: %Int: %Int.type = struct_value () [template] // CHECK:STDOUT: %i32: type = int_type signed, %.7 [template] // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template] // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.1(%.7) [template] @@ -132,7 +134,8 @@ fn G() -> C { // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { -// CHECK:STDOUT: .ImplicitAs = %import_ref.1 +// CHECK:STDOUT: .Int = %import_ref.1 +// CHECK:STDOUT: .ImplicitAs = %import_ref.2 // CHECK:STDOUT: import Core//prelude // CHECK:STDOUT: import Core//prelude/... // CHECK:STDOUT: } @@ -195,16 +198,20 @@ fn G() -> C { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a.ref: @F.%.loc6_24.2 (%.4) = name_ref a, %a // CHECK:STDOUT: %.loc6_43.1: Core.IntLiteral = int_value 0 [template = constants.%.6] +// CHECK:STDOUT: %.loc6_44.1: Core.IntLiteral = int_value 32 [template = constants.%.7] +// CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc6_44.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc6_44.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32] +// CHECK:STDOUT: %.loc6_44.3: type = converted %int.make_type_signed, %.loc6_44.2 [template = constants.%i32] // CHECK:STDOUT: %.loc6_43.2: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc6_43.3: = bound_method %.loc6_43.1, %.loc6_43.2 [template = constants.%.32] // CHECK:STDOUT: %.loc6_43.4: = specific_function %.loc6_43.3, @Convert.2(constants.%.7) [template = constants.%.33] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %.loc6_43.4(%.loc6_43.1) [template = constants.%.34] // CHECK:STDOUT: %.loc6_43.5: %i32 = value_of_initializer %int.convert_checked [template = constants.%.34] // CHECK:STDOUT: %.loc6_43.6: %i32 = converted %.loc6_43.1, %.loc6_43.5 [template = constants.%.34] -// CHECK:STDOUT: %.loc6_44.1: ref @F.%.loc6_24.2 (%.4) = value_as_ref %a.ref -// CHECK:STDOUT: %.loc6_44.2: ref @F.%T.loc6_6.2 (%T) = array_index %.loc6_44.1, %.loc6_43.6 -// CHECK:STDOUT: %.loc6_44.3: @F.%T.loc6_6.2 (%T) = bind_value %.loc6_44.2 -// CHECK:STDOUT: return %.loc6_44.3 +// CHECK:STDOUT: %.loc6_44.4: ref @F.%.loc6_24.2 (%.4) = value_as_ref %a.ref +// CHECK:STDOUT: %.loc6_44.5: ref @F.%T.loc6_6.2 (%T) = array_index %.loc6_44.4, %.loc6_43.6 +// CHECK:STDOUT: %.loc6_44.6: @F.%T.loc6_6.2 (%T) = bind_value %.loc6_44.5 +// CHECK:STDOUT: return %.loc6_44.6 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -584,6 +591,8 @@ fn G() -> C { // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: %.6: Core.IntLiteral = int_value 0 [template] // CHECK:STDOUT: %.7: Core.IntLiteral = int_value 32 [template] +// CHECK:STDOUT: %Int.type: type = fn_type @Int [template] +// CHECK:STDOUT: %Int: %Int.type = struct_value () [template] // CHECK:STDOUT: %i32: type = int_type signed, %.7 [template] // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template] // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.1(%.7) [template] @@ -606,7 +615,8 @@ fn G() -> C { // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { -// CHECK:STDOUT: .ImplicitAs = %import_ref.1 +// CHECK:STDOUT: .Int = %import_ref.1 +// CHECK:STDOUT: .ImplicitAs = %import_ref.2 // CHECK:STDOUT: import Core//prelude // CHECK:STDOUT: import Core//prelude/... // CHECK:STDOUT: } @@ -669,16 +679,20 @@ fn G() -> C { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a.ref: @F.%.loc6_24.2 (%.4) = name_ref a, %a // CHECK:STDOUT: %.loc6_43.1: Core.IntLiteral = int_value 0 [template = constants.%.6] +// CHECK:STDOUT: %.loc6_44.1: Core.IntLiteral = int_value 32 [template = constants.%.7] +// CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc6_44.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc6_44.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32] +// CHECK:STDOUT: %.loc6_44.3: type = converted %int.make_type_signed, %.loc6_44.2 [template = constants.%i32] // CHECK:STDOUT: %.loc6_43.2: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc6_43.3: = bound_method %.loc6_43.1, %.loc6_43.2 [template = constants.%.32] // CHECK:STDOUT: %.loc6_43.4: = specific_function %.loc6_43.3, @Convert.2(constants.%.7) [template = constants.%.33] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %.loc6_43.4(%.loc6_43.1) [template = constants.%.34] // CHECK:STDOUT: %.loc6_43.5: %i32 = value_of_initializer %int.convert_checked [template = constants.%.34] // CHECK:STDOUT: %.loc6_43.6: %i32 = converted %.loc6_43.1, %.loc6_43.5 [template = constants.%.34] -// CHECK:STDOUT: %.loc6_44.1: ref @F.%.loc6_24.2 (%.4) = value_as_ref %a.ref -// CHECK:STDOUT: %.loc6_44.2: ref @F.%T.loc6_6.2 (%T) = array_index %.loc6_44.1, %.loc6_43.6 -// CHECK:STDOUT: %.loc6_44.3: @F.%T.loc6_6.2 (%T) = bind_value %.loc6_44.2 -// CHECK:STDOUT: return %.loc6_44.3 +// CHECK:STDOUT: %.loc6_44.4: ref @F.%.loc6_24.2 (%.4) = value_as_ref %a.ref +// CHECK:STDOUT: %.loc6_44.5: ref @F.%T.loc6_6.2 (%T) = array_index %.loc6_44.4, %.loc6_43.6 +// CHECK:STDOUT: %.loc6_44.6: @F.%T.loc6_6.2 (%T) = bind_value %.loc6_44.5 +// CHECK:STDOUT: return %.loc6_44.6 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/eval/fail_aggregate.carbon b/toolchain/check/testdata/eval/fail_aggregate.carbon index 08e6e5db92c2d..32e307aef643b 100644 --- a/toolchain/check/testdata/eval/fail_aggregate.carbon +++ b/toolchain/check/testdata/eval/fail_aggregate.carbon @@ -135,14 +135,18 @@ var array_index: [i32; 1] = (0,) as [i32; ((5, 7, 1, 9) as [i32; 4])[2]]; // CHECK:STDOUT: %.loc16_57.1: init %.10 = converted %.loc16_55.1, %.loc16_55.31 [template = constants.%array] // CHECK:STDOUT: %.loc16_70.1: Core.IntLiteral = int_value 2 [template = constants.%.42] // CHECK:STDOUT: %.loc16_57.2: ref %.10 = temporary %.loc16_55.6, %.loc16_57.1 +// CHECK:STDOUT: %.loc16_71.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc16_71: init type = call constants.%Int(%.loc16_71.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc16_71.2: type = value_of_initializer %int.make_type_signed.loc16_71 [template = constants.%i32] +// CHECK:STDOUT: %.loc16_71.3: type = converted %int.make_type_signed.loc16_71, %.loc16_71.2 [template = constants.%i32] // CHECK:STDOUT: %.loc16_70.2: %Convert.type.2 = interface_witness_access constants.%.35, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc16_70.3: = bound_method %.loc16_70.1, %.loc16_70.2 [template = constants.%.50] // CHECK:STDOUT: %.loc16_70.4: = specific_function %.loc16_70.3, @Convert.2(constants.%.1) [template = constants.%.51] // CHECK:STDOUT: %int.convert_checked.loc16_70: init %i32 = call %.loc16_70.4(%.loc16_70.1) [template = constants.%.52] // CHECK:STDOUT: %.loc16_70.5: %i32 = value_of_initializer %int.convert_checked.loc16_70 [template = constants.%.52] // CHECK:STDOUT: %.loc16_70.6: %i32 = converted %.loc16_70.1, %.loc16_70.5 [template = constants.%.52] -// CHECK:STDOUT: %.loc16_71.1: ref %i32 = array_index %.loc16_57.2, %.loc16_70.6 -// CHECK:STDOUT: %.loc16_71.2: %i32 = bind_value %.loc16_71.1 +// CHECK:STDOUT: %.loc16_71.4: ref %i32 = array_index %.loc16_57.2, %.loc16_70.6 +// CHECK:STDOUT: %.loc16_71.5: %i32 = bind_value %.loc16_71.4 // CHECK:STDOUT: %.loc16_38.2: type = value_of_initializer %int.make_type_signed.loc16_38 [template = constants.%i32] // CHECK:STDOUT: %.loc16_38.3: type = converted %int.make_type_signed.loc16_38, %.loc16_38.2 [template = constants.%i32] // CHECK:STDOUT: assign file.%array_index.var, diff --git a/toolchain/check/testdata/if_expr/basic.carbon b/toolchain/check/testdata/if_expr/basic.carbon index f9a788e55bac3..d6e0ffc7f6e23 100644 --- a/toolchain/check/testdata/if_expr/basic.carbon +++ b/toolchain/check/testdata/if_expr/basic.carbon @@ -119,16 +119,24 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: !if.expr.then: // CHECK:STDOUT: %x.ref.loc13_20: ref %.3 = name_ref x, %x // CHECK:STDOUT: %m.ref: %i32 = name_ref m, %m -// CHECK:STDOUT: %.loc13_23.1: ref %i32 = array_index %x.ref.loc13_20, %m.ref -// CHECK:STDOUT: %.loc13_23.2: %i32 = bind_value %.loc13_23.1 -// CHECK:STDOUT: br !if.expr.result(%.loc13_23.2) +// CHECK:STDOUT: %.loc13_23.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc13_23: init type = call constants.%Int(%.loc13_23.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc13_23.2: type = value_of_initializer %int.make_type_signed.loc13_23 [template = constants.%i32] +// CHECK:STDOUT: %.loc13_23.3: type = converted %int.make_type_signed.loc13_23, %.loc13_23.2 [template = constants.%i32] +// CHECK:STDOUT: %.loc13_23.4: ref %i32 = array_index %x.ref.loc13_20, %m.ref +// CHECK:STDOUT: %.loc13_23.5: %i32 = bind_value %.loc13_23.4 +// CHECK:STDOUT: br !if.expr.result(%.loc13_23.5) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: // CHECK:STDOUT: %x.ref.loc13_30: ref %.3 = name_ref x, %x // CHECK:STDOUT: %n.ref: %i32 = name_ref n, %n -// CHECK:STDOUT: %.loc13_33.1: ref %i32 = array_index %x.ref.loc13_30, %n.ref -// CHECK:STDOUT: %.loc13_33.2: %i32 = bind_value %.loc13_33.1 -// CHECK:STDOUT: br !if.expr.result(%.loc13_33.2) +// CHECK:STDOUT: %.loc13_33.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc13_33: init type = call constants.%Int(%.loc13_33.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc13_33.2: type = value_of_initializer %int.make_type_signed.loc13_33 [template = constants.%i32] +// CHECK:STDOUT: %.loc13_33.3: type = converted %int.make_type_signed.loc13_33, %.loc13_33.2 [template = constants.%i32] +// CHECK:STDOUT: %.loc13_33.4: ref %i32 = array_index %x.ref.loc13_30, %n.ref +// CHECK:STDOUT: %.loc13_33.5: %i32 = bind_value %.loc13_33.4 +// CHECK:STDOUT: br !if.expr.result(%.loc13_33.5) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: // CHECK:STDOUT: %.loc13_10: %i32 = block_arg !if.expr.result diff --git a/toolchain/check/testdata/if_expr/fail_not_in_function.carbon b/toolchain/check/testdata/if_expr/fail_not_in_function.carbon index e11768b45bb85..af880b6182da2 100644 --- a/toolchain/check/testdata/if_expr/fail_not_in_function.carbon +++ b/toolchain/check/testdata/if_expr/fail_not_in_function.carbon @@ -78,8 +78,8 @@ class C { // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = constants.%C -// CHECK:STDOUT: .n = .inst+369.loc37_8 -// CHECK:STDOUT: complete_type_witness = .inst+371.loc38_1 +// CHECK:STDOUT: .n = .inst+373.loc37_8 +// CHECK:STDOUT: complete_type_witness = .inst+375.loc38_1 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { diff --git a/toolchain/check/testdata/if_expr/nested.carbon b/toolchain/check/testdata/if_expr/nested.carbon index af900e09955ec..393e75082064b 100644 --- a/toolchain/check/testdata/if_expr/nested.carbon +++ b/toolchain/check/testdata/if_expr/nested.carbon @@ -81,9 +81,9 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: %.loc11_27.1: type = value_of_initializer %bool.make_type.loc11_27 [template = bool] // CHECK:STDOUT: %.loc11_27.2: type = converted %bool.make_type.loc11_27, %.loc11_27.1 [template = bool] // CHECK:STDOUT: %.loc11_36.1: Core.IntLiteral = int_value 32 [template = constants.%.1] -// CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc11_36.1) [template = constants.%i32] -// CHECK:STDOUT: %.loc11_36.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32] -// CHECK:STDOUT: %.loc11_36.3: type = converted %int.make_type_signed, %.loc11_36.2 [template = constants.%i32] +// CHECK:STDOUT: %int.make_type_signed.loc11: init type = call constants.%Int(%.loc11_36.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc11_36.2: type = value_of_initializer %int.make_type_signed.loc11 [template = constants.%i32] +// CHECK:STDOUT: %.loc11_36.3: type = converted %int.make_type_signed.loc11, %.loc11_36.2 [template = constants.%i32] // CHECK:STDOUT: %a.param: bool = value_param runtime_param0 // CHECK:STDOUT: %a: bool = bind_name a, %a.param // CHECK:STDOUT: %b.param: bool = value_param runtime_param1 @@ -106,13 +106,17 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then.loc12_20: // CHECK:STDOUT: %.loc12_30: Core.IntLiteral = int_value 1 [template = constants.%.2] -// CHECK:STDOUT: %.loc12_25.1: %Convert.type.2 = interface_witness_access constants.%.26, element0 [template = constants.%Convert.14] -// CHECK:STDOUT: %.loc12_25.2: = bound_method %.loc12_30, %.loc12_25.1 [template = constants.%.27] -// CHECK:STDOUT: %.loc12_25.3: = specific_function %.loc12_25.2, @Convert.2(constants.%.1) [template = constants.%.28] -// CHECK:STDOUT: %int.convert_checked.loc12_25: init %i32 = call %.loc12_25.3(%.loc12_30) [template = constants.%.29] -// CHECK:STDOUT: %.loc12_25.4: %i32 = value_of_initializer %int.convert_checked.loc12_25 [template = constants.%.29] -// CHECK:STDOUT: %.loc12_25.5: %i32 = converted %.loc12_30, %.loc12_25.4 [template = constants.%.29] -// CHECK:STDOUT: br !if.expr.result.loc12_20(%.loc12_25.5) +// CHECK:STDOUT: %.loc12_25.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc12_25: init type = call constants.%Int(%.loc12_25.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc12_25.2: type = value_of_initializer %int.make_type_signed.loc12_25 [template = constants.%i32] +// CHECK:STDOUT: %.loc12_25.3: type = converted %int.make_type_signed.loc12_25, %.loc12_25.2 [template = constants.%i32] +// CHECK:STDOUT: %.loc12_25.4: %Convert.type.2 = interface_witness_access constants.%.26, element0 [template = constants.%Convert.14] +// CHECK:STDOUT: %.loc12_25.5: = bound_method %.loc12_30, %.loc12_25.4 [template = constants.%.27] +// CHECK:STDOUT: %.loc12_25.6: = specific_function %.loc12_25.5, @Convert.2(constants.%.1) [template = constants.%.28] +// CHECK:STDOUT: %int.convert_checked.loc12_25: init %i32 = call %.loc12_25.6(%.loc12_30) [template = constants.%.29] +// CHECK:STDOUT: %.loc12_25.7: %i32 = value_of_initializer %int.convert_checked.loc12_25 [template = constants.%.29] +// CHECK:STDOUT: %.loc12_25.8: %i32 = converted %.loc12_30, %.loc12_25.7 [template = constants.%.29] +// CHECK:STDOUT: br !if.expr.result.loc12_20(%.loc12_25.8) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else.loc12_20: // CHECK:STDOUT: %.loc12_37: Core.IntLiteral = int_value 2 [template = constants.%.30] @@ -134,13 +138,17 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then.loc12_44: // CHECK:STDOUT: %.loc12_54: Core.IntLiteral = int_value 3 [template = constants.%.34] -// CHECK:STDOUT: %.loc12_49.1: %Convert.type.2 = interface_witness_access constants.%.26, element0 [template = constants.%Convert.14] -// CHECK:STDOUT: %.loc12_49.2: = bound_method %.loc12_54, %.loc12_49.1 [template = constants.%.35] -// CHECK:STDOUT: %.loc12_49.3: = specific_function %.loc12_49.2, @Convert.2(constants.%.1) [template = constants.%.36] -// CHECK:STDOUT: %int.convert_checked.loc12_49: init %i32 = call %.loc12_49.3(%.loc12_54) [template = constants.%.37] -// CHECK:STDOUT: %.loc12_49.4: %i32 = value_of_initializer %int.convert_checked.loc12_49 [template = constants.%.37] -// CHECK:STDOUT: %.loc12_49.5: %i32 = converted %.loc12_54, %.loc12_49.4 [template = constants.%.37] -// CHECK:STDOUT: br !if.expr.result.loc12_44(%.loc12_49.5) +// CHECK:STDOUT: %.loc12_49.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc12_49: init type = call constants.%Int(%.loc12_49.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc12_49.2: type = value_of_initializer %int.make_type_signed.loc12_49 [template = constants.%i32] +// CHECK:STDOUT: %.loc12_49.3: type = converted %int.make_type_signed.loc12_49, %.loc12_49.2 [template = constants.%i32] +// CHECK:STDOUT: %.loc12_49.4: %Convert.type.2 = interface_witness_access constants.%.26, element0 [template = constants.%Convert.14] +// CHECK:STDOUT: %.loc12_49.5: = bound_method %.loc12_54, %.loc12_49.4 [template = constants.%.35] +// CHECK:STDOUT: %.loc12_49.6: = specific_function %.loc12_49.5, @Convert.2(constants.%.1) [template = constants.%.36] +// CHECK:STDOUT: %int.convert_checked.loc12_49: init %i32 = call %.loc12_49.6(%.loc12_54) [template = constants.%.37] +// CHECK:STDOUT: %.loc12_49.7: %i32 = value_of_initializer %int.convert_checked.loc12_49 [template = constants.%.37] +// CHECK:STDOUT: %.loc12_49.8: %i32 = converted %.loc12_54, %.loc12_49.7 [template = constants.%.37] +// CHECK:STDOUT: br !if.expr.result.loc12_44(%.loc12_49.8) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else.loc12_44: // CHECK:STDOUT: %.loc12_61: Core.IntLiteral = int_value 4 [template = constants.%.38] diff --git a/toolchain/check/testdata/index/array_element_access.carbon b/toolchain/check/testdata/index/array_element_access.carbon index ea3461ce87277..19bc89f960358 100644 --- a/toolchain/check/testdata/index/array_element_access.carbon +++ b/toolchain/check/testdata/index/array_element_access.carbon @@ -125,21 +125,29 @@ var d: i32 = a[b]; // CHECK:STDOUT: assign file.%b.var, %.loc12_15.4 // CHECK:STDOUT: %a.ref.loc13: ref %.3 = name_ref a, file.%a // CHECK:STDOUT: %.loc13_16.1: Core.IntLiteral = int_value 0 [template = constants.%.7] +// CHECK:STDOUT: %.loc13_17.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc13: init type = call constants.%Int(%.loc13_17.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc13_17.2: type = value_of_initializer %int.make_type_signed.loc13 [template = constants.%i32] +// CHECK:STDOUT: %.loc13_17.3: type = converted %int.make_type_signed.loc13, %.loc13_17.2 [template = constants.%i32] // CHECK:STDOUT: %.loc13_16.2: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc13_16.3: = bound_method %.loc13_16.1, %.loc13_16.2 [template = constants.%.42] // CHECK:STDOUT: %.loc13_16.4: = specific_function %.loc13_16.3, @Convert.2(constants.%.1) [template = constants.%.43] // CHECK:STDOUT: %int.convert_checked.loc13: init %i32 = call %.loc13_16.4(%.loc13_16.1) [template = constants.%.44] // CHECK:STDOUT: %.loc13_16.5: %i32 = value_of_initializer %int.convert_checked.loc13 [template = constants.%.44] // CHECK:STDOUT: %.loc13_16.6: %i32 = converted %.loc13_16.1, %.loc13_16.5 [template = constants.%.44] -// CHECK:STDOUT: %.loc13_17.1: ref %i32 = array_index %a.ref.loc13, %.loc13_16.6 -// CHECK:STDOUT: %.loc13_17.2: %i32 = bind_value %.loc13_17.1 -// CHECK:STDOUT: assign file.%c.var, %.loc13_17.2 +// CHECK:STDOUT: %.loc13_17.4: ref %i32 = array_index %a.ref.loc13, %.loc13_16.6 +// CHECK:STDOUT: %.loc13_17.5: %i32 = bind_value %.loc13_17.4 +// CHECK:STDOUT: assign file.%c.var, %.loc13_17.5 // CHECK:STDOUT: %a.ref.loc14: ref %.3 = name_ref a, file.%a // CHECK:STDOUT: %b.ref: ref %i32 = name_ref b, file.%b +// CHECK:STDOUT: %.loc14_17.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc14: init type = call constants.%Int(%.loc14_17.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc14_17.2: type = value_of_initializer %int.make_type_signed.loc14 [template = constants.%i32] +// CHECK:STDOUT: %.loc14_17.3: type = converted %int.make_type_signed.loc14, %.loc14_17.2 [template = constants.%i32] // CHECK:STDOUT: %.loc14_16: %i32 = bind_value %b.ref -// CHECK:STDOUT: %.loc14_17.1: ref %i32 = array_index %a.ref.loc14, %.loc14_16 -// CHECK:STDOUT: %.loc14_17.2: %i32 = bind_value %.loc14_17.1 -// CHECK:STDOUT: assign file.%d.var, %.loc14_17.2 +// CHECK:STDOUT: %.loc14_17.4: ref %i32 = array_index %a.ref.loc14, %.loc14_16 +// CHECK:STDOUT: %.loc14_17.5: %i32 = bind_value %.loc14_17.4 +// CHECK:STDOUT: assign file.%d.var, %.loc14_17.5 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/index/expr_category.carbon b/toolchain/check/testdata/index/expr_category.carbon index 1a01386f8ece7..a6f6a3f247462 100644 --- a/toolchain/check/testdata/index/expr_category.carbon +++ b/toolchain/check/testdata/index/expr_category.carbon @@ -173,39 +173,47 @@ fn ValueBinding(b: [i32; 3]) { // CHECK:STDOUT: %.loc14_30: init %.3 = converted %.loc14_29.1, %.loc14_29.23 [template = constants.%array] // CHECK:STDOUT: assign %a.var, %.loc14_30 // CHECK:STDOUT: %.loc17_11: Core.IntLiteral = int_value 32 [template = constants.%.1] -// CHECK:STDOUT: %int.make_type_signed.loc17: init type = call constants.%Int(%.loc17_11) [template = constants.%i32] -// CHECK:STDOUT: %.loc17_14.1: type = value_of_initializer %int.make_type_signed.loc17 [template = constants.%i32] -// CHECK:STDOUT: %.loc17_14.2: type = converted %int.make_type_signed.loc17, %.loc17_14.1 [template = constants.%i32] +// CHECK:STDOUT: %int.make_type_signed.loc17_11: init type = call constants.%Int(%.loc17_11) [template = constants.%i32] +// CHECK:STDOUT: %.loc17_14.1: type = value_of_initializer %int.make_type_signed.loc17_11 [template = constants.%i32] +// CHECK:STDOUT: %.loc17_14.2: type = converted %int.make_type_signed.loc17_11, %.loc17_14.1 [template = constants.%i32] // CHECK:STDOUT: %.loc17_14.3: type = ptr_type %i32 [template = constants.%.41] // CHECK:STDOUT: %pa.var: ref %.41 = var pa // CHECK:STDOUT: %pa: ref %.41 = bind_name pa, %pa.var // CHECK:STDOUT: %a.ref.loc17: ref %.3 = name_ref a, %a // CHECK:STDOUT: %.loc17_21.1: Core.IntLiteral = int_value 0 [template = constants.%.7] +// CHECK:STDOUT: %.loc17_22.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc17_22: init type = call constants.%Int(%.loc17_22.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc17_22.2: type = value_of_initializer %int.make_type_signed.loc17_22 [template = constants.%i32] +// CHECK:STDOUT: %.loc17_22.3: type = converted %int.make_type_signed.loc17_22, %.loc17_22.2 [template = constants.%i32] // CHECK:STDOUT: %.loc17_21.2: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc17_21.3: = bound_method %.loc17_21.1, %.loc17_21.2 [template = constants.%.42] // CHECK:STDOUT: %.loc17_21.4: = specific_function %.loc17_21.3, @Convert.2(constants.%.1) [template = constants.%.43] // CHECK:STDOUT: %int.convert_checked.loc17: init %i32 = call %.loc17_21.4(%.loc17_21.1) [template = constants.%.44] // CHECK:STDOUT: %.loc17_21.5: %i32 = value_of_initializer %int.convert_checked.loc17 [template = constants.%.44] // CHECK:STDOUT: %.loc17_21.6: %i32 = converted %.loc17_21.1, %.loc17_21.5 [template = constants.%.44] -// CHECK:STDOUT: %.loc17_22: ref %i32 = array_index %a.ref.loc17, %.loc17_21.6 -// CHECK:STDOUT: %.loc17_18: %.41 = addr_of %.loc17_22 +// CHECK:STDOUT: %.loc17_22.4: ref %i32 = array_index %a.ref.loc17, %.loc17_21.6 +// CHECK:STDOUT: %.loc17_18: %.41 = addr_of %.loc17_22.4 // CHECK:STDOUT: assign %pa.var, %.loc17_18 // CHECK:STDOUT: %a.ref.loc18: ref %.3 = name_ref a, %a // CHECK:STDOUT: %.loc18_5.1: Core.IntLiteral = int_value 0 [template = constants.%.7] +// CHECK:STDOUT: %.loc18_6.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc18: init type = call constants.%Int(%.loc18_6.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc18_6.2: type = value_of_initializer %int.make_type_signed.loc18 [template = constants.%i32] +// CHECK:STDOUT: %.loc18_6.3: type = converted %int.make_type_signed.loc18, %.loc18_6.2 [template = constants.%i32] // CHECK:STDOUT: %.loc18_5.2: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc18_5.3: = bound_method %.loc18_5.1, %.loc18_5.2 [template = constants.%.42] // CHECK:STDOUT: %.loc18_5.4: = specific_function %.loc18_5.3, @Convert.2(constants.%.1) [template = constants.%.43] // CHECK:STDOUT: %int.convert_checked.loc18_5: init %i32 = call %.loc18_5.4(%.loc18_5.1) [template = constants.%.44] // CHECK:STDOUT: %.loc18_5.5: %i32 = value_of_initializer %int.convert_checked.loc18_5 [template = constants.%.44] // CHECK:STDOUT: %.loc18_5.6: %i32 = converted %.loc18_5.1, %.loc18_5.5 [template = constants.%.44] -// CHECK:STDOUT: %.loc18_6: ref %i32 = array_index %a.ref.loc18, %.loc18_5.6 +// CHECK:STDOUT: %.loc18_6.4: ref %i32 = array_index %a.ref.loc18, %.loc18_5.6 // CHECK:STDOUT: %.loc18_10: Core.IntLiteral = int_value 4 [template = constants.%.45] // CHECK:STDOUT: %.loc18_8.1: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc18_8.2: = bound_method %.loc18_10, %.loc18_8.1 [template = constants.%.46] // CHECK:STDOUT: %.loc18_8.3: = specific_function %.loc18_8.2, @Convert.2(constants.%.1) [template = constants.%.47] // CHECK:STDOUT: %int.convert_checked.loc18_8: init %i32 = call %.loc18_8.3(%.loc18_10) [template = constants.%.48] // CHECK:STDOUT: %.loc18_8.4: init %i32 = converted %.loc18_10, %int.convert_checked.loc18_8 [template = constants.%.48] -// CHECK:STDOUT: assign %.loc18_6, %.loc18_8.4 +// CHECK:STDOUT: assign %.loc18_6.4, %.loc18_8.4 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -252,37 +260,49 @@ fn ValueBinding(b: [i32; 3]) { // CHECK:STDOUT: assign %a.var, %.loc22_30 // CHECK:STDOUT: %a.ref: ref %.3 = name_ref a, %a // CHECK:STDOUT: %.loc26_5.1: Core.IntLiteral = int_value 0 [template = constants.%.7] +// CHECK:STDOUT: %.loc26_6.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc26: init type = call constants.%Int(%.loc26_6.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc26_6.2: type = value_of_initializer %int.make_type_signed.loc26 [template = constants.%i32] +// CHECK:STDOUT: %.loc26_6.3: type = converted %int.make_type_signed.loc26, %.loc26_6.2 [template = constants.%i32] // CHECK:STDOUT: %.loc26_5.2: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc26_5.3: = bound_method %.loc26_5.1, %.loc26_5.2 [template = constants.%.42] // CHECK:STDOUT: %.loc26_5.4: = specific_function %.loc26_5.3, @Convert.2(constants.%.1) [template = constants.%.43] // CHECK:STDOUT: %int.convert_checked.loc26: init %i32 = call %.loc26_5.4(%.loc26_5.1) [template = constants.%.44] // CHECK:STDOUT: %.loc26_5.5: %i32 = value_of_initializer %int.convert_checked.loc26 [template = constants.%.44] // CHECK:STDOUT: %.loc26_5.6: %i32 = converted %.loc26_5.1, %.loc26_5.5 [template = constants.%.44] -// CHECK:STDOUT: %.loc26_6: ref %i32 = array_index %a.ref, %.loc26_5.6 +// CHECK:STDOUT: %.loc26_6.4: ref %i32 = array_index %a.ref, %.loc26_5.6 // CHECK:STDOUT: %b.ref: %.3 = name_ref b, %b // CHECK:STDOUT: %.loc27_5.1: Core.IntLiteral = int_value 0 [template = constants.%.7] +// CHECK:STDOUT: %.loc27_6.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc27: init type = call constants.%Int(%.loc27_6.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc27_6.2: type = value_of_initializer %int.make_type_signed.loc27 [template = constants.%i32] +// CHECK:STDOUT: %.loc27_6.3: type = converted %int.make_type_signed.loc27, %.loc27_6.2 [template = constants.%i32] // CHECK:STDOUT: %.loc27_5.2: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc27_5.3: = bound_method %.loc27_5.1, %.loc27_5.2 [template = constants.%.42] // CHECK:STDOUT: %.loc27_5.4: = specific_function %.loc27_5.3, @Convert.2(constants.%.1) [template = constants.%.43] // CHECK:STDOUT: %int.convert_checked.loc27: init %i32 = call %.loc27_5.4(%.loc27_5.1) [template = constants.%.44] // CHECK:STDOUT: %.loc27_5.5: %i32 = value_of_initializer %int.convert_checked.loc27 [template = constants.%.44] // CHECK:STDOUT: %.loc27_5.6: %i32 = converted %.loc27_5.1, %.loc27_5.5 [template = constants.%.44] -// CHECK:STDOUT: %.loc27_6.1: ref %.3 = value_as_ref %b.ref -// CHECK:STDOUT: %.loc27_6.2: ref %i32 = array_index %.loc27_6.1, %.loc27_5.6 -// CHECK:STDOUT: %.loc27_6.3: %i32 = bind_value %.loc27_6.2 +// CHECK:STDOUT: %.loc27_6.4: ref %.3 = value_as_ref %b.ref +// CHECK:STDOUT: %.loc27_6.5: ref %i32 = array_index %.loc27_6.4, %.loc27_5.6 +// CHECK:STDOUT: %.loc27_6.6: %i32 = bind_value %.loc27_6.5 // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] // CHECK:STDOUT: %.loc28_5.1: ref %.3 = temporary_storage // CHECK:STDOUT: %F.call: init %.3 = call %F.ref() to %.loc28_5.1 // CHECK:STDOUT: %.loc28_7.1: Core.IntLiteral = int_value 0 [template = constants.%.7] // CHECK:STDOUT: %.loc28_5.2: ref %.3 = temporary %.loc28_5.1, %F.call +// CHECK:STDOUT: %.loc28_8.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc28: init type = call constants.%Int(%.loc28_8.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc28_8.2: type = value_of_initializer %int.make_type_signed.loc28 [template = constants.%i32] +// CHECK:STDOUT: %.loc28_8.3: type = converted %int.make_type_signed.loc28, %.loc28_8.2 [template = constants.%i32] // CHECK:STDOUT: %.loc28_7.2: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc28_7.3: = bound_method %.loc28_7.1, %.loc28_7.2 [template = constants.%.42] // CHECK:STDOUT: %.loc28_7.4: = specific_function %.loc28_7.3, @Convert.2(constants.%.1) [template = constants.%.43] // CHECK:STDOUT: %int.convert_checked.loc28: init %i32 = call %.loc28_7.4(%.loc28_7.1) [template = constants.%.44] // CHECK:STDOUT: %.loc28_7.5: %i32 = value_of_initializer %int.convert_checked.loc28 [template = constants.%.44] // CHECK:STDOUT: %.loc28_7.6: %i32 = converted %.loc28_7.1, %.loc28_7.5 [template = constants.%.44] -// CHECK:STDOUT: %.loc28_8.1: ref %i32 = array_index %.loc28_5.2, %.loc28_7.6 -// CHECK:STDOUT: %.loc28_8.2: %i32 = bind_value %.loc28_8.1 +// CHECK:STDOUT: %.loc28_8.4: ref %i32 = array_index %.loc28_5.2, %.loc28_7.6 +// CHECK:STDOUT: %.loc28_8.5: %i32 = bind_value %.loc28_8.4 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/index/fail_array_large_index.carbon b/toolchain/check/testdata/index/fail_array_large_index.carbon index fe7a0c421a7a6..e0d357f4bf582 100644 --- a/toolchain/check/testdata/index/fail_array_large_index.carbon +++ b/toolchain/check/testdata/index/fail_array_large_index.carbon @@ -106,26 +106,34 @@ var c: i32 = a[0x7FFF_FFFF]; // CHECK:STDOUT: assign file.%a.var, %.loc11_24 // CHECK:STDOUT: %a.ref.loc17: ref %.3 = name_ref a, file.%a // CHECK:STDOUT: %.loc17_16.1: Core.IntLiteral = int_value 1 [template = constants.%.2] +// CHECK:STDOUT: %.loc17_17.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc17: init type = call constants.%Int(%.loc17_17.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc17_17.2: type = value_of_initializer %int.make_type_signed.loc17 [template = constants.%i32] +// CHECK:STDOUT: %.loc17_17.3: type = converted %int.make_type_signed.loc17, %.loc17_17.2 [template = constants.%i32] // CHECK:STDOUT: %.loc17_16.2: %Convert.type.2 = interface_witness_access constants.%.30, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc17_16.3: = bound_method %.loc17_16.1, %.loc17_16.2 [template = constants.%.34] // CHECK:STDOUT: %.loc17_16.4: = specific_function %.loc17_16.3, @Convert.2(constants.%.1) [template = constants.%.35] // CHECK:STDOUT: %int.convert_checked.loc17: init %i32 = call %.loc17_16.4(%.loc17_16.1) [template = constants.%.36] // CHECK:STDOUT: %.loc17_16.5: %i32 = value_of_initializer %int.convert_checked.loc17 [template = constants.%.36] // CHECK:STDOUT: %.loc17_16.6: %i32 = converted %.loc17_16.1, %.loc17_16.5 [template = constants.%.36] -// CHECK:STDOUT: %.loc17_17.1: ref %i32 = array_index %a.ref.loc17, %.loc17_16.6 [template = ] -// CHECK:STDOUT: %.loc17_17.2: %i32 = bind_value %.loc17_17.1 -// CHECK:STDOUT: assign file.%b.var, %.loc17_17.2 +// CHECK:STDOUT: %.loc17_17.4: ref %i32 = array_index %a.ref.loc17, %.loc17_16.6 [template = ] +// CHECK:STDOUT: %.loc17_17.5: %i32 = bind_value %.loc17_17.4 +// CHECK:STDOUT: assign file.%b.var, %.loc17_17.5 // CHECK:STDOUT: %a.ref.loc22: ref %.3 = name_ref a, file.%a // CHECK:STDOUT: %.loc22_16.1: Core.IntLiteral = int_value 2147483647 [template = constants.%.37] +// CHECK:STDOUT: %.loc22_27.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc22: init type = call constants.%Int(%.loc22_27.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc22_27.2: type = value_of_initializer %int.make_type_signed.loc22 [template = constants.%i32] +// CHECK:STDOUT: %.loc22_27.3: type = converted %int.make_type_signed.loc22, %.loc22_27.2 [template = constants.%i32] // CHECK:STDOUT: %.loc22_16.2: %Convert.type.2 = interface_witness_access constants.%.30, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc22_16.3: = bound_method %.loc22_16.1, %.loc22_16.2 [template = constants.%.38] // CHECK:STDOUT: %.loc22_16.4: = specific_function %.loc22_16.3, @Convert.2(constants.%.1) [template = constants.%.39] // CHECK:STDOUT: %int.convert_checked.loc22: init %i32 = call %.loc22_16.4(%.loc22_16.1) [template = constants.%.40] // CHECK:STDOUT: %.loc22_16.5: %i32 = value_of_initializer %int.convert_checked.loc22 [template = constants.%.40] // CHECK:STDOUT: %.loc22_16.6: %i32 = converted %.loc22_16.1, %.loc22_16.5 [template = constants.%.40] -// CHECK:STDOUT: %.loc22_27.1: ref %i32 = array_index %a.ref.loc22, %.loc22_16.6 [template = ] -// CHECK:STDOUT: %.loc22_27.2: %i32 = bind_value %.loc22_27.1 -// CHECK:STDOUT: assign file.%c.var, %.loc22_27.2 +// CHECK:STDOUT: %.loc22_27.4: ref %i32 = array_index %a.ref.loc22, %.loc22_16.6 [template = ] +// CHECK:STDOUT: %.loc22_27.5: %i32 = bind_value %.loc22_27.4 +// CHECK:STDOUT: assign file.%c.var, %.loc22_27.5 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: 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 928aaece47cde..c428b312b3c9c 100644 --- a/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon +++ b/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon @@ -89,10 +89,14 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: assign file.%a.var, %.loc11_24 // CHECK:STDOUT: %a.ref: ref %.3 = name_ref a, file.%a // CHECK:STDOUT: %.loc18_16.1: f64 = float_literal 2.6000000000000001 [template = constants.%.34] +// CHECK:STDOUT: %.loc18_19.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc18_19.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc18_19.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32] +// CHECK:STDOUT: %.loc18_19.3: type = converted %int.make_type_signed, %.loc18_19.2 [template = constants.%i32] // CHECK:STDOUT: %.loc18_16.2: %i32 = converted %.loc18_16.1, [template = ] -// CHECK:STDOUT: %.loc18_19.1: ref %i32 = array_index %a.ref, [template = ] -// CHECK:STDOUT: %.loc18_19.2: %i32 = bind_value %.loc18_19.1 -// CHECK:STDOUT: assign file.%b.var, %.loc18_19.2 +// CHECK:STDOUT: %.loc18_19.4: ref %i32 = array_index %a.ref, [template = ] +// CHECK:STDOUT: %.loc18_19.5: %i32 = bind_value %.loc18_19.4 +// CHECK:STDOUT: assign file.%b.var, %.loc18_19.5 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: 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 0099afe5192e1..21928c05fb12b 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 @@ -88,15 +88,19 @@ var b: i32 = a[1]; // CHECK:STDOUT: assign file.%a.var, %.loc11_24 // CHECK:STDOUT: %a.ref: ref %.3 = name_ref a, file.%a // CHECK:STDOUT: %.loc15_16.1: Core.IntLiteral = int_value 1 [template = constants.%.2] +// CHECK:STDOUT: %.loc15_17.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc15_17.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc15_17.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32] +// CHECK:STDOUT: %.loc15_17.3: type = converted %int.make_type_signed, %.loc15_17.2 [template = constants.%i32] // CHECK:STDOUT: %.loc15_16.2: %Convert.type.2 = interface_witness_access constants.%.30, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc15_16.3: = bound_method %.loc15_16.1, %.loc15_16.2 [template = constants.%.34] // CHECK:STDOUT: %.loc15_16.4: = specific_function %.loc15_16.3, @Convert.2(constants.%.1) [template = constants.%.35] // CHECK:STDOUT: %int.convert_checked.loc15: init %i32 = call %.loc15_16.4(%.loc15_16.1) [template = constants.%.36] // CHECK:STDOUT: %.loc15_16.5: %i32 = value_of_initializer %int.convert_checked.loc15 [template = constants.%.36] // CHECK:STDOUT: %.loc15_16.6: %i32 = converted %.loc15_16.1, %.loc15_16.5 [template = constants.%.36] -// CHECK:STDOUT: %.loc15_17.1: ref %i32 = array_index %a.ref, %.loc15_16.6 [template = ] -// CHECK:STDOUT: %.loc15_17.2: %i32 = bind_value %.loc15_17.1 -// CHECK:STDOUT: assign file.%b.var, %.loc15_17.2 +// CHECK:STDOUT: %.loc15_17.4: ref %i32 = array_index %a.ref, %.loc15_16.6 [template = ] +// CHECK:STDOUT: %.loc15_17.5: %i32 = bind_value %.loc15_17.4 +// CHECK:STDOUT: assign file.%b.var, %.loc15_17.5 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/index/fail_expr_category.carbon b/toolchain/check/testdata/index/fail_expr_category.carbon index 08dbc5b9245f5..7a82d72661fc3 100644 --- a/toolchain/check/testdata/index/fail_expr_category.carbon +++ b/toolchain/check/testdata/index/fail_expr_category.carbon @@ -113,47 +113,55 @@ fn G(b: [i32; 3]) { // CHECK:STDOUT: fn @G(%b.param_patt: %.3) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc19_11: Core.IntLiteral = int_value 32 [template = constants.%.1] -// CHECK:STDOUT: %int.make_type_signed.loc19: init type = call constants.%Int(%.loc19_11) [template = constants.%i32] -// CHECK:STDOUT: %.loc19_14.1: type = value_of_initializer %int.make_type_signed.loc19 [template = constants.%i32] -// CHECK:STDOUT: %.loc19_14.2: type = converted %int.make_type_signed.loc19, %.loc19_14.1 [template = constants.%i32] +// CHECK:STDOUT: %int.make_type_signed.loc19_11: init type = call constants.%Int(%.loc19_11) [template = constants.%i32] +// CHECK:STDOUT: %.loc19_14.1: type = value_of_initializer %int.make_type_signed.loc19_11 [template = constants.%i32] +// CHECK:STDOUT: %.loc19_14.2: type = converted %int.make_type_signed.loc19_11, %.loc19_14.1 [template = constants.%i32] // CHECK:STDOUT: %.loc19_14.3: type = ptr_type %i32 [template = constants.%.5] // CHECK:STDOUT: %pb.var: ref %.5 = var pb // CHECK:STDOUT: %pb: ref %.5 = bind_name pb, %pb.var // CHECK:STDOUT: %b.ref.loc19: %.3 = name_ref b, %b // CHECK:STDOUT: %.loc19_21.1: Core.IntLiteral = int_value 0 [template = constants.%.6] +// CHECK:STDOUT: %.loc19_22.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc19_22: init type = call constants.%Int(%.loc19_22.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc19_22.2: type = value_of_initializer %int.make_type_signed.loc19_22 [template = constants.%i32] +// CHECK:STDOUT: %.loc19_22.3: type = converted %int.make_type_signed.loc19_22, %.loc19_22.2 [template = constants.%i32] // CHECK:STDOUT: %.loc19_21.2: %Convert.type.2 = interface_witness_access constants.%.30, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc19_21.3: = bound_method %.loc19_21.1, %.loc19_21.2 [template = constants.%.31] // CHECK:STDOUT: %.loc19_21.4: = specific_function %.loc19_21.3, @Convert.2(constants.%.1) [template = constants.%.32] // CHECK:STDOUT: %int.convert_checked.loc19: init %i32 = call %.loc19_21.4(%.loc19_21.1) [template = constants.%.33] // CHECK:STDOUT: %.loc19_21.5: %i32 = value_of_initializer %int.convert_checked.loc19 [template = constants.%.33] // CHECK:STDOUT: %.loc19_21.6: %i32 = converted %.loc19_21.1, %.loc19_21.5 [template = constants.%.33] -// CHECK:STDOUT: %.loc19_22.1: ref %.3 = value_as_ref %b.ref.loc19 -// CHECK:STDOUT: %.loc19_22.2: ref %i32 = array_index %.loc19_22.1, %.loc19_21.6 -// CHECK:STDOUT: %.loc19_22.3: %i32 = bind_value %.loc19_22.2 +// CHECK:STDOUT: %.loc19_22.4: ref %.3 = value_as_ref %b.ref.loc19 +// CHECK:STDOUT: %.loc19_22.5: ref %i32 = array_index %.loc19_22.4, %.loc19_21.6 +// CHECK:STDOUT: %.loc19_22.6: %i32 = bind_value %.loc19_22.5 // CHECK:STDOUT: %.loc19_18: %.5 = addr_of [template = ] // CHECK:STDOUT: assign %pb.var, %.loc19_18 // CHECK:STDOUT: %b.ref.loc24: %.3 = name_ref b, %b // CHECK:STDOUT: %.loc24_5.1: Core.IntLiteral = int_value 0 [template = constants.%.6] +// CHECK:STDOUT: %.loc24_6.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc24: init type = call constants.%Int(%.loc24_6.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc24_6.2: type = value_of_initializer %int.make_type_signed.loc24 [template = constants.%i32] +// CHECK:STDOUT: %.loc24_6.3: type = converted %int.make_type_signed.loc24, %.loc24_6.2 [template = constants.%i32] // CHECK:STDOUT: %.loc24_5.2: %Convert.type.2 = interface_witness_access constants.%.30, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc24_5.3: = bound_method %.loc24_5.1, %.loc24_5.2 [template = constants.%.31] // CHECK:STDOUT: %.loc24_5.4: = specific_function %.loc24_5.3, @Convert.2(constants.%.1) [template = constants.%.32] // CHECK:STDOUT: %int.convert_checked.loc24_5: init %i32 = call %.loc24_5.4(%.loc24_5.1) [template = constants.%.33] // CHECK:STDOUT: %.loc24_5.5: %i32 = value_of_initializer %int.convert_checked.loc24_5 [template = constants.%.33] // CHECK:STDOUT: %.loc24_5.6: %i32 = converted %.loc24_5.1, %.loc24_5.5 [template = constants.%.33] -// CHECK:STDOUT: %.loc24_6.1: ref %.3 = value_as_ref %b.ref.loc24 -// CHECK:STDOUT: %.loc24_6.2: ref %i32 = array_index %.loc24_6.1, %.loc24_5.6 -// CHECK:STDOUT: %.loc24_6.3: %i32 = bind_value %.loc24_6.2 +// CHECK:STDOUT: %.loc24_6.4: ref %.3 = value_as_ref %b.ref.loc24 +// CHECK:STDOUT: %.loc24_6.5: ref %i32 = array_index %.loc24_6.4, %.loc24_5.6 +// CHECK:STDOUT: %.loc24_6.6: %i32 = bind_value %.loc24_6.5 // CHECK:STDOUT: %.loc24_10: Core.IntLiteral = int_value 4 [template = constants.%.34] // CHECK:STDOUT: %.loc24_8.1: %Convert.type.2 = interface_witness_access constants.%.30, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc24_8.2: = bound_method %.loc24_10, %.loc24_8.1 [template = constants.%.35] // CHECK:STDOUT: %.loc24_8.3: = specific_function %.loc24_8.2, @Convert.2(constants.%.1) [template = constants.%.36] // CHECK:STDOUT: %int.convert_checked.loc24_8: init %i32 = call %.loc24_8.3(%.loc24_10) [template = constants.%.37] // CHECK:STDOUT: %.loc24_8.4: init %i32 = converted %.loc24_10, %int.convert_checked.loc24_8 [template = constants.%.37] -// CHECK:STDOUT: assign %.loc24_6.3, %.loc24_8.4 +// CHECK:STDOUT: assign %.loc24_6.6, %.loc24_8.4 // CHECK:STDOUT: %.loc32_11: Core.IntLiteral = int_value 32 [template = constants.%.1] -// CHECK:STDOUT: %int.make_type_signed.loc32: init type = call constants.%Int(%.loc32_11) [template = constants.%i32] -// CHECK:STDOUT: %.loc32_14.1: type = value_of_initializer %int.make_type_signed.loc32 [template = constants.%i32] -// CHECK:STDOUT: %.loc32_14.2: type = converted %int.make_type_signed.loc32, %.loc32_14.1 [template = constants.%i32] +// CHECK:STDOUT: %int.make_type_signed.loc32_11: init type = call constants.%Int(%.loc32_11) [template = constants.%i32] +// CHECK:STDOUT: %.loc32_14.1: type = value_of_initializer %int.make_type_signed.loc32_11 [template = constants.%i32] +// CHECK:STDOUT: %.loc32_14.2: type = converted %int.make_type_signed.loc32_11, %.loc32_14.1 [template = constants.%i32] // CHECK:STDOUT: %.loc32_14.3: type = ptr_type %i32 [template = constants.%.5] // CHECK:STDOUT: %pf.var: ref %.5 = var pf // CHECK:STDOUT: %pf: ref %.5 = bind_name pf, %pf.var @@ -162,14 +170,18 @@ fn G(b: [i32; 3]) { // CHECK:STDOUT: %F.call.loc32: init %.3 = call %F.ref.loc32() to %.loc32_21.1 // CHECK:STDOUT: %.loc32_23.1: Core.IntLiteral = int_value 0 [template = constants.%.6] // CHECK:STDOUT: %.loc32_21.2: ref %.3 = temporary %.loc32_21.1, %F.call.loc32 +// CHECK:STDOUT: %.loc32_24.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc32_24: init type = call constants.%Int(%.loc32_24.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc32_24.2: type = value_of_initializer %int.make_type_signed.loc32_24 [template = constants.%i32] +// CHECK:STDOUT: %.loc32_24.3: type = converted %int.make_type_signed.loc32_24, %.loc32_24.2 [template = constants.%i32] // CHECK:STDOUT: %.loc32_23.2: %Convert.type.2 = interface_witness_access constants.%.30, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc32_23.3: = bound_method %.loc32_23.1, %.loc32_23.2 [template = constants.%.31] // CHECK:STDOUT: %.loc32_23.4: = specific_function %.loc32_23.3, @Convert.2(constants.%.1) [template = constants.%.32] // CHECK:STDOUT: %int.convert_checked.loc32: init %i32 = call %.loc32_23.4(%.loc32_23.1) [template = constants.%.33] // CHECK:STDOUT: %.loc32_23.5: %i32 = value_of_initializer %int.convert_checked.loc32 [template = constants.%.33] // CHECK:STDOUT: %.loc32_23.6: %i32 = converted %.loc32_23.1, %.loc32_23.5 [template = constants.%.33] -// CHECK:STDOUT: %.loc32_24.1: ref %i32 = array_index %.loc32_21.2, %.loc32_23.6 -// CHECK:STDOUT: %.loc32_24.2: %i32 = bind_value %.loc32_24.1 +// CHECK:STDOUT: %.loc32_24.4: ref %i32 = array_index %.loc32_21.2, %.loc32_23.6 +// CHECK:STDOUT: %.loc32_24.5: %i32 = bind_value %.loc32_24.4 // CHECK:STDOUT: %.loc32_18: %.5 = addr_of [template = ] // CHECK:STDOUT: assign %pf.var, %.loc32_18 // CHECK:STDOUT: %F.ref.loc36: %F.type = name_ref F, file.%F.decl [template = constants.%F] @@ -177,21 +189,25 @@ fn G(b: [i32; 3]) { // CHECK:STDOUT: %F.call.loc36: init %.3 = call %F.ref.loc36() to %.loc36_5.1 // CHECK:STDOUT: %.loc36_7.1: Core.IntLiteral = int_value 0 [template = constants.%.6] // CHECK:STDOUT: %.loc36_5.2: ref %.3 = temporary %.loc36_5.1, %F.call.loc36 +// CHECK:STDOUT: %.loc36_8.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc36: init type = call constants.%Int(%.loc36_8.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc36_8.2: type = value_of_initializer %int.make_type_signed.loc36 [template = constants.%i32] +// CHECK:STDOUT: %.loc36_8.3: type = converted %int.make_type_signed.loc36, %.loc36_8.2 [template = constants.%i32] // CHECK:STDOUT: %.loc36_7.2: %Convert.type.2 = interface_witness_access constants.%.30, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc36_7.3: = bound_method %.loc36_7.1, %.loc36_7.2 [template = constants.%.31] // CHECK:STDOUT: %.loc36_7.4: = specific_function %.loc36_7.3, @Convert.2(constants.%.1) [template = constants.%.32] // CHECK:STDOUT: %int.convert_checked.loc36_7: init %i32 = call %.loc36_7.4(%.loc36_7.1) [template = constants.%.33] // CHECK:STDOUT: %.loc36_7.5: %i32 = value_of_initializer %int.convert_checked.loc36_7 [template = constants.%.33] // CHECK:STDOUT: %.loc36_7.6: %i32 = converted %.loc36_7.1, %.loc36_7.5 [template = constants.%.33] -// CHECK:STDOUT: %.loc36_8.1: ref %i32 = array_index %.loc36_5.2, %.loc36_7.6 -// CHECK:STDOUT: %.loc36_8.2: %i32 = bind_value %.loc36_8.1 +// CHECK:STDOUT: %.loc36_8.4: ref %i32 = array_index %.loc36_5.2, %.loc36_7.6 +// CHECK:STDOUT: %.loc36_8.5: %i32 = bind_value %.loc36_8.4 // CHECK:STDOUT: %.loc36_12: Core.IntLiteral = int_value 4 [template = constants.%.34] // CHECK:STDOUT: %.loc36_10.1: %Convert.type.2 = interface_witness_access constants.%.30, element0 [template = constants.%Convert.14] // CHECK:STDOUT: %.loc36_10.2: = bound_method %.loc36_12, %.loc36_10.1 [template = constants.%.35] // CHECK:STDOUT: %.loc36_10.3: = specific_function %.loc36_10.2, @Convert.2(constants.%.1) [template = constants.%.36] // CHECK:STDOUT: %int.convert_checked.loc36_10: init %i32 = call %.loc36_10.3(%.loc36_12) [template = constants.%.37] // CHECK:STDOUT: %.loc36_10.4: init %i32 = converted %.loc36_12, %int.convert_checked.loc36_10 [template = constants.%.37] -// CHECK:STDOUT: assign %.loc36_8.2, %.loc36_10.4 +// CHECK:STDOUT: assign %.loc36_8.5, %.loc36_10.4 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/index/fail_negative_indexing.carbon b/toolchain/check/testdata/index/fail_negative_indexing.carbon index 9d2a288b75fb5..2af2e2edcef04 100644 --- a/toolchain/check/testdata/index/fail_negative_indexing.carbon +++ b/toolchain/check/testdata/index/fail_negative_indexing.carbon @@ -98,9 +98,13 @@ var d: i32 = c[-10]; // CHECK:STDOUT: assign file.%c.var, %.loc11_27 // CHECK:STDOUT: %c.ref: ref %.3 = name_ref c, file.%c // CHECK:STDOUT: %.loc15_17: Core.IntLiteral = int_value 10 [template = constants.%.35] -// CHECK:STDOUT: %.loc15_19.1: ref %i32 = array_index %c.ref, [template = ] -// CHECK:STDOUT: %.loc15_19.2: %i32 = bind_value %.loc15_19.1 -// CHECK:STDOUT: assign file.%d.var, %.loc15_19.2 +// CHECK:STDOUT: %.loc15_19.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc15_19.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc15_19.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32] +// CHECK:STDOUT: %.loc15_19.3: type = converted %int.make_type_signed, %.loc15_19.2 [template = constants.%i32] +// CHECK:STDOUT: %.loc15_19.4: ref %i32 = array_index %c.ref, [template = ] +// CHECK:STDOUT: %.loc15_19.5: %i32 = bind_value %.loc15_19.4 +// CHECK:STDOUT: assign file.%d.var, %.loc15_19.5 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/operators/builtin/fail_assignment_to_non_assignable.carbon b/toolchain/check/testdata/operators/builtin/fail_assignment_to_non_assignable.carbon index b74782c1f00d3..452d112dfbada 100644 --- a/toolchain/check/testdata/operators/builtin/fail_assignment_to_non_assignable.carbon +++ b/toolchain/check/testdata/operators/builtin/fail_assignment_to_non_assignable.carbon @@ -233,13 +233,17 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then.loc49: // CHECK:STDOUT: %.loc49_17: Core.IntLiteral = int_value 1 [template = constants.%.2] -// CHECK:STDOUT: %.loc49_12.1: %Convert.type.2 = interface_witness_access constants.%.27, element0 [template = constants.%Convert.14] -// CHECK:STDOUT: %.loc49_12.2: = bound_method %.loc49_17, %.loc49_12.1 [template = constants.%.28] -// CHECK:STDOUT: %.loc49_12.3: = specific_function %.loc49_12.2, @Convert.2(constants.%.1) [template = constants.%.29] -// CHECK:STDOUT: %int.convert_checked.loc49_12: init %i32 = call %.loc49_12.3(%.loc49_17) [template = constants.%.30] -// CHECK:STDOUT: %.loc49_12.4: %i32 = value_of_initializer %int.convert_checked.loc49_12 [template = constants.%.30] -// CHECK:STDOUT: %.loc49_12.5: %i32 = converted %.loc49_17, %.loc49_12.4 [template = constants.%.30] -// CHECK:STDOUT: br !if.expr.result.loc49(%.loc49_12.5) +// CHECK:STDOUT: %.loc49_12.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed.loc49: init type = call constants.%Int(%.loc49_12.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc49_12.2: type = value_of_initializer %int.make_type_signed.loc49 [template = constants.%i32] +// CHECK:STDOUT: %.loc49_12.3: type = converted %int.make_type_signed.loc49, %.loc49_12.2 [template = constants.%i32] +// CHECK:STDOUT: %.loc49_12.4: %Convert.type.2 = interface_witness_access constants.%.27, element0 [template = constants.%Convert.14] +// CHECK:STDOUT: %.loc49_12.5: = bound_method %.loc49_17, %.loc49_12.4 [template = constants.%.28] +// CHECK:STDOUT: %.loc49_12.6: = specific_function %.loc49_12.5, @Convert.2(constants.%.1) [template = constants.%.29] +// CHECK:STDOUT: %int.convert_checked.loc49_12: init %i32 = call %.loc49_12.6(%.loc49_17) [template = constants.%.30] +// CHECK:STDOUT: %.loc49_12.7: %i32 = value_of_initializer %int.convert_checked.loc49_12 [template = constants.%.30] +// CHECK:STDOUT: %.loc49_12.8: %i32 = converted %.loc49_17, %.loc49_12.7 [template = constants.%.30] +// CHECK:STDOUT: br !if.expr.result.loc49(%.loc49_12.8) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else.loc49: // CHECK:STDOUT: %.loc49_24: Core.IntLiteral = int_value 2 [template = constants.%.3] diff --git a/toolchain/check/testdata/tuple/access/return_value_access.carbon b/toolchain/check/testdata/tuple/access/return_value_access.carbon index 84ba8ca64d2b9..09531c7e1a905 100644 --- a/toolchain/check/testdata/tuple/access/return_value_access.carbon +++ b/toolchain/check/testdata/tuple/access/return_value_access.carbon @@ -79,6 +79,10 @@ fn Run() -> i32 { // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: %.loc13_17.1: Core.IntLiteral = int_value 32 [template = constants.%.1] +// CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc13_17.1) [template = constants.%i32] +// CHECK:STDOUT: %.loc13_17.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32] +// CHECK:STDOUT: %.loc13_17.3: type = converted %int.make_type_signed, %.loc13_17.2 [template = constants.%i32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> %tuple.type.2 { diff --git a/toolchain/lower/testdata/array/function_param.carbon b/toolchain/lower/testdata/array/function_param.carbon index 4422516eaef1b..4d2b56523e527 100644 --- a/toolchain/lower/testdata/array/function_param.carbon +++ b/toolchain/lower/testdata/array/function_param.carbon @@ -23,9 +23,9 @@ fn G() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: define i32 @_CF.Main(ptr %arr, i32 %i) !dbg !4 { // CHECK:STDOUT: entry: -// CHECK:STDOUT: %.loc12_15.2.array.index = getelementptr inbounds [3 x i32], ptr %arr, i32 0, i32 %i, !dbg !7 -// CHECK:STDOUT: %.loc12_15.3 = load i32, ptr %.loc12_15.2.array.index, align 4, !dbg !7 -// CHECK:STDOUT: ret i32 %.loc12_15.3, !dbg !8 +// CHECK:STDOUT: %.loc12_15.5.array.index = getelementptr inbounds [3 x i32], ptr %arr, i32 0, i32 %i, !dbg !7 +// CHECK:STDOUT: %.loc12_15.6 = load i32, ptr %.loc12_15.5.array.index, align 4, !dbg !7 +// CHECK:STDOUT: ret i32 %.loc12_15.6, !dbg !8 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: define i32 @_CG.Main() !dbg !9 { diff --git a/toolchain/lower/testdata/index/array_element_access.carbon b/toolchain/lower/testdata/index/array_element_access.carbon index 734cff18d2ba8..bdd7c9380ef28 100644 --- a/toolchain/lower/testdata/index/array_element_access.carbon +++ b/toolchain/lower/testdata/index/array_element_access.carbon @@ -57,15 +57,15 @@ fn Run() { // CHECK:STDOUT: store i32 1, ptr %b.var, align 4, !dbg !16 // CHECK:STDOUT: %c.var = alloca i32, align 4, !dbg !17 // CHECK:STDOUT: %.loc17_18 = load i32, ptr %b.var, align 4, !dbg !18 -// CHECK:STDOUT: %.loc17_19.1.array.index = getelementptr inbounds [2 x i32], ptr %a.var, i32 0, i32 %.loc17_18, !dbg !19 -// CHECK:STDOUT: %.loc17_19.2 = load i32, ptr %.loc17_19.1.array.index, align 4, !dbg !19 -// CHECK:STDOUT: store i32 %.loc17_19.2, ptr %c.var, align 4, !dbg !20 +// CHECK:STDOUT: %.loc17_19.4.array.index = getelementptr inbounds [2 x i32], ptr %a.var, i32 0, i32 %.loc17_18, !dbg !19 +// CHECK:STDOUT: %.loc17_19.5 = load i32, ptr %.loc17_19.4.array.index, align 4, !dbg !19 +// CHECK:STDOUT: store i32 %.loc17_19.5, ptr %c.var, align 4, !dbg !20 // CHECK:STDOUT: %d.var = alloca i32, align 4, !dbg !21 // CHECK:STDOUT: %.loc18_18.1.temp = alloca [2 x i32], align 4, !dbg !22 // CHECK:STDOUT: call void @_CB.Main(ptr %.loc18_18.1.temp), !dbg !22 -// CHECK:STDOUT: %.loc18_21.1.array.index = getelementptr inbounds [2 x i32], ptr %.loc18_18.1.temp, i32 0, i32 1, !dbg !22 -// CHECK:STDOUT: %.loc18_21.2 = load i32, ptr %.loc18_21.1.array.index, align 4, !dbg !22 -// CHECK:STDOUT: store i32 %.loc18_21.2, ptr %d.var, align 4, !dbg !23 +// CHECK:STDOUT: %.loc18_21.4.array.index = getelementptr inbounds [2 x i32], ptr %.loc18_18.1.temp, i32 0, i32 1, !dbg !22 +// CHECK:STDOUT: %.loc18_21.5 = load i32, ptr %.loc18_21.4.array.index, align 4, !dbg !22 +// CHECK:STDOUT: store i32 %.loc18_21.5, ptr %d.var, align 4, !dbg !23 // CHECK:STDOUT: ret void, !dbg !24 // CHECK:STDOUT: } // CHECK:STDOUT: From a53014d63ae43b10aee1baf24957a2348a9ee906 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 3 Dec 2024 10:34:49 -0800 Subject: [PATCH 2/2] Fix typo. Co-authored-by: Jon Ross-Perkins --- toolchain/check/handle_function.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toolchain/check/handle_function.cpp b/toolchain/check/handle_function.cpp index ff82a49bdbe26..476d313401a80 100644 --- a/toolchain/check/handle_function.cpp +++ b/toolchain/check/handle_function.cpp @@ -305,8 +305,8 @@ static auto BuildFunctionDecl(Context& context, !context.inst_blocks().Get(function_info.param_patterns_id).empty() || (return_type_id.is_valid() && return_type_id != context.GetTupleType({}) && - // TODO: Decide on valid return types for `i32`. Perhaps we should have - // an interface for this. + // TODO: Decide on valid return types for `Main.Run`. Perhaps we should + // have an interface for this. return_type_id != MakeIntType(context, node_id, SemIR::IntKind::Signed, context.ints().Add(32)))) { CARBON_DIAGNOSTIC(InvalidMainRunSignature, Error,