From 4685890d633b18221dcbb7b711fb6aff52b2146a Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 5 Aug 2025 15:34:34 -0700 Subject: [PATCH] Rename FloatLiteral to FloatValue. (#5911) In preparation for `FloatValue` being used more generally, and not only for literals. --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- toolchain/check/eval.cpp | 12 +++++----- toolchain/check/handle_literal.cpp | 2 +- .../testdata/basics/numeric_literals.carbon | 24 +++++++++---------- .../function/call/fail_param_type.carbon | 4 ++-- .../call/fail_return_type_mismatch.carbon | 4 ++-- .../index/fail_array_non_int_indexing.carbon | 4 ++-- .../function/arithmetic_types_bridged.carbon | 4 ++-- .../cpp/function/param_unsupported.carbon | 8 +++---- .../fail_type_mismatch_assignment.carbon | 4 ++-- .../builtin/fail_type_mismatch_once.carbon | 4 ++-- .../pointer/fail_address_of_value.carbon | 4 ++-- .../return/fail_returned_var_type.carbon | 4 ++-- .../testdata/return/fail_type_mismatch.carbon | 4 ++-- .../struct/fail_field_type_mismatch.carbon | 4 ++-- .../struct/fail_member_access_type.carbon | 4 ++-- .../testdata/struct/member_access.carbon | 4 ++-- toolchain/lower/constant.cpp | 2 +- toolchain/lower/testdata/array/base.carbon | 4 ++-- .../testdata/basics/numeric_literals.carbon | 4 ++-- toolchain/sem_ir/expr_info.cpp | 2 +- toolchain/sem_ir/formatter.cpp | 2 +- toolchain/sem_ir/inst_kind.def | 2 +- toolchain/sem_ir/inst_namer.cpp | 8 +++---- toolchain/sem_ir/typed_insts.h | 10 ++++---- 24 files changed, 64 insertions(+), 64 deletions(-) diff --git a/toolchain/check/eval.cpp b/toolchain/check/eval.cpp index ca78e0ac495e..d3f96ce059be 100644 --- a/toolchain/check/eval.cpp +++ b/toolchain/check/eval.cpp @@ -336,7 +336,7 @@ static auto MakeFloatResult(Context& context, SemIR::TypeId type_id, llvm::APFloat value) -> SemIR::ConstantId { auto result = context.floats().Add(std::move(value)); return MakeConstantResult( - context, SemIR::FloatLiteral{.type_id = type_id, .float_id = result}, + context, SemIR::FloatValue{.type_id = type_id, .float_id = result}, Phase::Concrete); } @@ -1405,7 +1405,7 @@ static auto PerformBuiltinUnaryFloatOp(Context& context, SemIR::BuiltinFunctionKind builtin_kind, SemIR::InstId arg_id) -> SemIR::ConstantId { - auto op = context.insts().GetAs(arg_id); + auto op = context.insts().GetAs(arg_id); auto op_val = context.floats().Get(op.float_id); switch (builtin_kind) { @@ -1425,8 +1425,8 @@ static auto PerformBuiltinBinaryFloatOp(Context& context, SemIR::InstId lhs_id, SemIR::InstId rhs_id) -> SemIR::ConstantId { - auto lhs = context.insts().GetAs(lhs_id); - auto rhs = context.insts().GetAs(rhs_id); + auto lhs = context.insts().GetAs(lhs_id); + auto rhs = context.insts().GetAs(rhs_id); auto lhs_val = context.floats().Get(lhs.float_id); auto rhs_val = context.floats().Get(rhs.float_id); @@ -1457,8 +1457,8 @@ static auto PerformBuiltinFloatComparison( Context& context, SemIR::BuiltinFunctionKind builtin_kind, SemIR::InstId lhs_id, SemIR::InstId rhs_id, SemIR::TypeId bool_type_id) -> SemIR::ConstantId { - auto lhs = context.insts().GetAs(lhs_id); - auto rhs = context.insts().GetAs(rhs_id); + auto lhs = context.insts().GetAs(lhs_id); + auto rhs = context.insts().GetAs(rhs_id); const auto& lhs_val = context.floats().Get(lhs.float_id); const auto& rhs_val = context.floats().Get(rhs.float_id); diff --git a/toolchain/check/handle_literal.cpp b/toolchain/check/handle_literal.cpp index 02edd203e1a1..b991c078493a 100644 --- a/toolchain/check/handle_literal.cpp +++ b/toolchain/check/handle_literal.cpp @@ -80,7 +80,7 @@ auto HandleParseNode(Context& context, Parse::RealLiteralId node_id) -> bool { real_value.exponent.getSExtValue()); auto float_id = context.sem_ir().floats().Add(llvm::APFloat(double_val)); - AddInstAndPush( + AddInstAndPush( context, node_id, {.type_id = GetSingletonType(context, SemIR::LegacyFloatType::TypeInstId), .float_id = float_id}); diff --git a/toolchain/check/testdata/basics/numeric_literals.carbon b/toolchain/check/testdata/basics/numeric_literals.carbon index 051eb8a2d9d7..037d4e583a3d 100644 --- a/toolchain/check/testdata/basics/numeric_literals.carbon +++ b/toolchain/check/testdata/basics/numeric_literals.carbon @@ -95,12 +95,12 @@ let e: f64 = 5.0e39999999999999999993; // CHECK:STDOUT: %int_8.b85: Core.IntLiteral = int_value 8 [concrete] // CHECK:STDOUT: %int_9.988: Core.IntLiteral = int_value 9 [concrete] // CHECK:STDOUT: %int_2147483647.d89: Core.IntLiteral = int_value 2147483647 [concrete] -// CHECK:STDOUT: %float.952: f64 = float_literal 0.90000000000000002 [concrete] -// CHECK:STDOUT: %float.298: f64 = float_literal 8 [concrete] -// CHECK:STDOUT: %float.dcb: f64 = float_literal 80 [concrete] -// CHECK:STDOUT: %float.1d0: f64 = float_literal 1.0E+7 [concrete] -// CHECK:STDOUT: %float.9f6: f64 = float_literal 1.0E+8 [concrete] -// CHECK:STDOUT: %float.401: f64 = float_literal 1.0E-8 [concrete] +// CHECK:STDOUT: %float.2c5: f64 = float_value 0.90000000000000002 [concrete] +// CHECK:STDOUT: %float.613: f64 = float_value 8 [concrete] +// CHECK:STDOUT: %float.707: f64 = float_value 80 [concrete] +// CHECK:STDOUT: %float.213: f64 = float_value 1.0E+7 [concrete] +// CHECK:STDOUT: %float.577: f64 = float_value 1.0E+8 [concrete] +// CHECK:STDOUT: %float.ef9: f64 = float_value 1.0E-8 [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -116,12 +116,12 @@ let e: f64 = 5.0e39999999999999999993; // CHECK:STDOUT: %int_2147483647.loc13: Core.IntLiteral = int_value 2147483647 [concrete = constants.%int_2147483647.d89] // CHECK:STDOUT: %int_2147483647.loc14: Core.IntLiteral = int_value 2147483647 [concrete = constants.%int_2147483647.d89] // CHECK:STDOUT: -// CHECK:STDOUT: %float.loc19: f64 = float_literal 0.90000000000000002 [concrete = constants.%float.952] -// CHECK:STDOUT: %float.loc20: f64 = float_literal 8 [concrete = constants.%float.298] -// CHECK:STDOUT: %float.loc21: f64 = float_literal 80 [concrete = constants.%float.dcb] -// CHECK:STDOUT: %float.loc22: f64 = float_literal 1.0E+7 [concrete = constants.%float.1d0] -// CHECK:STDOUT: %float.loc23: f64 = float_literal 1.0E+8 [concrete = constants.%float.9f6] -// CHECK:STDOUT: %float.loc24: f64 = float_literal 1.0E-8 [concrete = constants.%float.401] +// CHECK:STDOUT: %float.loc19: f64 = float_value 0.90000000000000002 [concrete = constants.%float.2c5] +// CHECK:STDOUT: %float.loc20: f64 = float_value 8 [concrete = constants.%float.613] +// CHECK:STDOUT: %float.loc21: f64 = float_value 80 [concrete = constants.%float.707] +// CHECK:STDOUT: %float.loc22: f64 = float_value 1.0E+7 [concrete = constants.%float.213] +// CHECK:STDOUT: %float.loc23: f64 = float_value 1.0E+8 [concrete = constants.%float.577] +// CHECK:STDOUT: %float.loc24: f64 = float_value 1.0E-8 [concrete = constants.%float.ef9] // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/call/fail_param_type.carbon b/toolchain/check/testdata/function/call/fail_param_type.carbon index 0a88c6c22bdc..6f221cd9d4e9 100644 --- a/toolchain/check/testdata/function/call/fail_param_type.carbon +++ b/toolchain/check/testdata/function/call/fail_param_type.carbon @@ -41,7 +41,7 @@ fn F() { // CHECK:STDOUT: %G: %G.type = struct_value () [concrete] // CHECK:STDOUT: %F.type: type = fn_type @F [concrete] // CHECK:STDOUT: %F: %F.type = struct_value () [concrete] -// CHECK:STDOUT: %float: f64 = float_literal 1 [concrete] +// CHECK:STDOUT: %float: f64 = float_value 1 [concrete] // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete] // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete] // CHECK:STDOUT: } @@ -86,7 +86,7 @@ fn F() { // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %G.ref: %G.type = name_ref G, file.%G.decl [concrete = constants.%G] -// CHECK:STDOUT: %float: f64 = float_literal 1 [concrete = constants.%float] +// CHECK:STDOUT: %float: f64 = float_value 1 [concrete = constants.%float] // CHECK:STDOUT: %.loc28: %i32 = converted %float, [concrete = ] // CHECK:STDOUT: %G.call: init %empty_tuple.type = call %G.ref() // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon b/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon index dec361a19ab7..cd8ebaf61ad2 100644 --- a/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon +++ b/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon @@ -35,7 +35,7 @@ fn Run() { // CHECK:STDOUT: %Foo.type: type = fn_type @Foo [concrete] // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] // CHECK:STDOUT: %Foo: %Foo.type = struct_value () [concrete] -// CHECK:STDOUT: %float: f64 = float_literal 1 [concrete] +// CHECK:STDOUT: %float: f64 = float_value 1 [concrete] // CHECK:STDOUT: %Run.type: type = fn_type @Run [concrete] // CHECK:STDOUT: %Run: %Run.type = struct_value () [concrete] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] @@ -90,7 +90,7 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Foo() -> f64 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %float: f64 = float_literal 1 [concrete = constants.%float] +// CHECK:STDOUT: %float: f64 = float_value 1 [concrete = constants.%float] // CHECK:STDOUT: return %float // 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 8d02027f73c9..d52d866ace4d 100644 --- a/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon +++ b/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon @@ -53,7 +53,7 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: %bound_method: = bound_method %int_12.6a3, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] // CHECK:STDOUT: %int_12.1e1: %i32 = int_value 12 [concrete] // CHECK:STDOUT: %array: %array_type = tuple_value (%int_12.1e1) [concrete] -// CHECK:STDOUT: %float: f64 = float_literal 2.6000000000000001 [concrete] +// CHECK:STDOUT: %float: f64 = float_value 2.6000000000000001 [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -117,7 +117,7 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: %.loc15_1: init %array_type = converted %.loc15_28.1, %.loc15_28.5 [concrete = constants.%array] // CHECK:STDOUT: assign file.%a.var, %.loc15_1 // CHECK:STDOUT: %a.ref: ref %array_type = name_ref a, file.%a [concrete = file.%a.var] -// CHECK:STDOUT: %float: f64 = float_literal 2.6000000000000001 [concrete = constants.%float] +// CHECK:STDOUT: %float: f64 = float_value 2.6000000000000001 [concrete = constants.%float] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %.loc23_16: %i32 = converted %float, [concrete = ] diff --git a/toolchain/check/testdata/interop/cpp/function/arithmetic_types_bridged.carbon b/toolchain/check/testdata/interop/cpp/function/arithmetic_types_bridged.carbon index 8abfc059eca3..f4dd0bb45325 100644 --- a/toolchain/check/testdata/interop/cpp/function/arithmetic_types_bridged.carbon +++ b/toolchain/check/testdata/interop/cpp/function/arithmetic_types_bridged.carbon @@ -1096,7 +1096,7 @@ fn F() { // CHECK:STDOUT: %Float: %Float.type = struct_value () [concrete] // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete] // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete] -// CHECK:STDOUT: %float: f64 = float_literal 0.80000000000000004 [concrete] +// CHECK:STDOUT: %float: f64 = float_value 0.80000000000000004 [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -1115,7 +1115,7 @@ fn F() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Cpp.ref: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo] -// CHECK:STDOUT: %float: f64 = float_literal 0.80000000000000004 [concrete = constants.%float] +// CHECK:STDOUT: %float: f64 = float_value 0.80000000000000004 [concrete = constants.%float] // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] // CHECK:STDOUT: %Float.call: init type = call constants.%Float(%int_64) [concrete = f64] // CHECK:STDOUT: %.loc8_18.1: type = value_of_initializer %Float.call [concrete = f64] diff --git a/toolchain/check/testdata/interop/cpp/function/param_unsupported.carbon b/toolchain/check/testdata/interop/cpp/function/param_unsupported.carbon index 3a2f6176f6ae..1afc49615c55 100644 --- a/toolchain/check/testdata/interop/cpp/function/param_unsupported.carbon +++ b/toolchain/check/testdata/interop/cpp/function/param_unsupported.carbon @@ -67,7 +67,7 @@ fn F() { // CHECK:STDOUT: --- fail_todo_import_unsupported_primitive_type.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { -// CHECK:STDOUT: %float: f64 = float_literal 1.1000000000000001 [concrete] +// CHECK:STDOUT: %float: f64 = float_value 1.1000000000000001 [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -81,7 +81,7 @@ fn F() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Cpp.ref: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] // CHECK:STDOUT: %foo.ref: = name_ref foo, [concrete = ] -// CHECK:STDOUT: %float: f64 = float_literal 1.1000000000000001 [concrete = constants.%float] +// CHECK:STDOUT: %float: f64 = float_value 1.1000000000000001 [concrete = constants.%float] // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: @@ -89,7 +89,7 @@ fn F() { // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete] -// CHECK:STDOUT: %float: f64 = float_literal 2 [concrete] +// CHECK:STDOUT: %float: f64 = float_value 2 [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -104,7 +104,7 @@ fn F() { // CHECK:STDOUT: %Cpp.ref: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] // CHECK:STDOUT: %foo.ref: = name_ref foo, [concrete = ] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] -// CHECK:STDOUT: %float: f64 = float_literal 2 [concrete = constants.%float] +// CHECK:STDOUT: %float: f64 = float_value 2 [concrete = constants.%float] // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/operators/builtin/fail_type_mismatch_assignment.carbon b/toolchain/check/testdata/operators/builtin/fail_type_mismatch_assignment.carbon index 61ec8ebfb789..57eed8ae2610 100644 --- a/toolchain/check/testdata/operators/builtin/fail_type_mismatch_assignment.carbon +++ b/toolchain/check/testdata/operators/builtin/fail_type_mismatch_assignment.carbon @@ -53,7 +53,7 @@ fn Main() { // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.956, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_32) [concrete] // CHECK:STDOUT: %bound_method: = bound_method %int_3.1ba, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] // CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [concrete] -// CHECK:STDOUT: %float: f64 = float_literal 5.6000000000000005 [concrete] +// CHECK:STDOUT: %float: f64 = float_value 5.6000000000000005 [concrete] // CHECK:STDOUT: %T.as.Destroy.impl.Op.type.a17: type = fn_type @T.as.Destroy.impl.Op, @T.as.Destroy.impl(%i32) [concrete] // CHECK:STDOUT: %T.as.Destroy.impl.Op.e6a: %T.as.Destroy.impl.Op.type.a17 = struct_value () [concrete] // CHECK:STDOUT: %ptr.235: type = ptr_type %i32 [concrete] @@ -105,7 +105,7 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var // CHECK:STDOUT: %a.ref: ref %i32 = name_ref a, %a -// CHECK:STDOUT: %float: f64 = float_literal 5.6000000000000005 [concrete = constants.%float] +// CHECK:STDOUT: %float: f64 = float_value 5.6000000000000005 [concrete = constants.%float] // CHECK:STDOUT: %.loc24: %i32 = converted %float, [concrete = ] // CHECK:STDOUT: assign %a.ref, // CHECK:STDOUT: %T.as.Destroy.impl.Op.bound: = bound_method %a.var, constants.%T.as.Destroy.impl.Op.e6a diff --git a/toolchain/check/testdata/operators/builtin/fail_type_mismatch_once.carbon b/toolchain/check/testdata/operators/builtin/fail_type_mismatch_once.carbon index a60e51424d0e..7b23948eda6c 100644 --- a/toolchain/check/testdata/operators/builtin/fail_type_mismatch_once.carbon +++ b/toolchain/check/testdata/operators/builtin/fail_type_mismatch_once.carbon @@ -33,7 +33,7 @@ fn Main() -> i32 { // CHECK:STDOUT: %Main.type: type = fn_type @Main [concrete] // CHECK:STDOUT: %Main: %Main.type = struct_value () [concrete] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] -// CHECK:STDOUT: %float: f64 = float_literal 3.4000000000000004 [concrete] +// CHECK:STDOUT: %float: f64 = float_value 3.4000000000000004 [concrete] // CHECK:STDOUT: %AddWith.type.e05: type = generic_interface_type @AddWith [concrete] // CHECK:STDOUT: %AddWith.generic: %AddWith.type.e05 = struct_value () [concrete] // CHECK:STDOUT: %int_12: Core.IntLiteral = int_value 12 [concrete] @@ -70,7 +70,7 @@ fn Main() -> i32 { // CHECK:STDOUT: fn @Main() -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc22: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %float: f64 = float_literal 3.4000000000000004 [concrete = constants.%float] +// CHECK:STDOUT: %float: f64 = float_value 3.4000000000000004 [concrete = constants.%float] // CHECK:STDOUT: %int_12: Core.IntLiteral = int_value 12 [concrete = constants.%int_12] // CHECK:STDOUT: %impl.elem1: = impl_witness_access , element1 [concrete = ] // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/pointer/fail_address_of_value.carbon b/toolchain/check/testdata/pointer/fail_address_of_value.carbon index c42a578ae788..0009dbd00c9a 100644 --- a/toolchain/check/testdata/pointer/fail_address_of_value.carbon +++ b/toolchain/check/testdata/pointer/fail_address_of_value.carbon @@ -125,7 +125,7 @@ fn AddressOfParam(param: i32) { // CHECK:STDOUT: %ptr.1d1: type = ptr_type Core.IntLiteral [concrete] // CHECK:STDOUT: %true: bool = bool_literal true [concrete] // CHECK:STDOUT: %ptr.bb2: type = ptr_type bool [concrete] -// CHECK:STDOUT: %float: f64 = float_literal 1 [concrete] +// CHECK:STDOUT: %float: f64 = float_value 1 [concrete] // CHECK:STDOUT: %ptr.ef1: type = ptr_type f64 [concrete] // CHECK:STDOUT: %ptr.a45: type = ptr_type String [concrete] // CHECK:STDOUT: %str: String = string_literal "Hello" [concrete] @@ -235,7 +235,7 @@ fn AddressOfParam(param: i32) { // CHECK:STDOUT: %addr.loc24: %ptr.1d1 = addr_of [concrete = ] // CHECK:STDOUT: %true: bool = bool_literal true [concrete = constants.%true] // CHECK:STDOUT: %addr.loc29: %ptr.bb2 = addr_of [concrete = ] -// CHECK:STDOUT: %float: f64 = float_literal 1 [concrete = constants.%float] +// CHECK:STDOUT: %float: f64 = float_value 1 [concrete = constants.%float] // CHECK:STDOUT: %addr.loc34: %ptr.ef1 = addr_of [concrete = ] // CHECK:STDOUT: %str: String = string_literal "Hello" [concrete = constants.%str] // CHECK:STDOUT: %addr.loc39: %ptr.a45 = addr_of [concrete = ] diff --git a/toolchain/check/testdata/return/fail_returned_var_type.carbon b/toolchain/check/testdata/return/fail_returned_var_type.carbon index afb6dbf206f7..58af16b8f029 100644 --- a/toolchain/check/testdata/return/fail_returned_var_type.carbon +++ b/toolchain/check/testdata/return/fail_returned_var_type.carbon @@ -39,7 +39,7 @@ fn Mismatch() -> i32 { // CHECK:STDOUT: %Float.type: type = fn_type @Float [concrete] // CHECK:STDOUT: %Float: %Float.type = struct_value () [concrete] // CHECK:STDOUT: %pattern_type.3de: type = pattern_type f64 [concrete] -// CHECK:STDOUT: %float: f64 = float_literal 0 [concrete] +// CHECK:STDOUT: %float: f64 = float_value 0 [concrete] // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete] // CHECK:STDOUT: %T.as.Destroy.impl.Op.type.3ef: type = fn_type @T.as.Destroy.impl.Op, @T.as.Destroy.impl(f64) [concrete] // CHECK:STDOUT: %T.as.Destroy.impl.Op.868: %T.as.Destroy.impl.Op.type.3ef = struct_value () [concrete] @@ -84,7 +84,7 @@ fn Mismatch() -> i32 { // CHECK:STDOUT: %v.var_patt: %pattern_type.3de = var_pattern %v.patt [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref f64 = var %v.var_patt -// CHECK:STDOUT: %float: f64 = float_literal 0 [concrete = constants.%float] +// CHECK:STDOUT: %float: f64 = float_value 0 [concrete = constants.%float] // CHECK:STDOUT: assign %v.var, %float // CHECK:STDOUT: %.loc23_19.1: type = splice_block %.loc23_19.3 [concrete = f64] { // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] diff --git a/toolchain/check/testdata/return/fail_type_mismatch.carbon b/toolchain/check/testdata/return/fail_type_mismatch.carbon index 5bf7dac5f92b..20f8a51560cf 100644 --- a/toolchain/check/testdata/return/fail_type_mismatch.carbon +++ b/toolchain/check/testdata/return/fail_type_mismatch.carbon @@ -33,7 +33,7 @@ fn Main() -> i32 { // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete] // CHECK:STDOUT: %Main.type: type = fn_type @Main [concrete] // CHECK:STDOUT: %Main: %Main.type = struct_value () [concrete] -// CHECK:STDOUT: %float: f64 = float_literal 1 [concrete] +// CHECK:STDOUT: %float: f64 = float_value 1 [concrete] // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete] // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete] // CHECK:STDOUT: } @@ -68,7 +68,7 @@ fn Main() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() -> %i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %float: f64 = float_literal 1 [concrete = constants.%float] +// CHECK:STDOUT: %float: f64 = float_value 1 [concrete = constants.%float] // CHECK:STDOUT: %.loc23: %i32 = converted %float, [concrete = ] // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/struct/fail_field_type_mismatch.carbon b/toolchain/check/testdata/struct/fail_field_type_mismatch.carbon index 797fa7c14cd1..cb0bf41b5651 100644 --- a/toolchain/check/testdata/struct/fail_field_type_mismatch.carbon +++ b/toolchain/check/testdata/struct/fail_field_type_mismatch.carbon @@ -27,7 +27,7 @@ var x: {.a: i32} = {.b = 1.0}; // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] // CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %i32} [concrete] // CHECK:STDOUT: %pattern_type.268: type = pattern_type %struct_type.a [concrete] -// CHECK:STDOUT: %float: f64 = float_literal 1 [concrete] +// CHECK:STDOUT: %float: f64 = float_value 1 [concrete] // CHECK:STDOUT: %struct_type.b: type = struct_type {.b: f64} [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -61,7 +61,7 @@ var x: {.a: i32} = {.b = 1.0}; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %float: f64 = float_literal 1 [concrete = constants.%float] +// CHECK:STDOUT: %float: f64 = float_value 1 [concrete = constants.%float] // CHECK:STDOUT: %.loc19: %struct_type.b = struct_literal (%float) // CHECK:STDOUT: assign file.%x.var, // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/struct/fail_member_access_type.carbon b/toolchain/check/testdata/struct/fail_member_access_type.carbon index c892b912fce4..8b8c8d670228 100644 --- a/toolchain/check/testdata/struct/fail_member_access_type.carbon +++ b/toolchain/check/testdata/struct/fail_member_access_type.carbon @@ -27,7 +27,7 @@ var y: i32 = x.b; // CHECK:STDOUT: %Float: %Float.type = struct_value () [concrete] // CHECK:STDOUT: %struct_type.a: type = struct_type {.a: f64} [concrete] // CHECK:STDOUT: %pattern_type.d08: type = pattern_type %struct_type.a [concrete] -// CHECK:STDOUT: %float: f64 = float_literal 4 [concrete] +// CHECK:STDOUT: %float: f64 = float_value 4 [concrete] // CHECK:STDOUT: %struct: %struct_type.a = struct_value (%float) [concrete] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete] @@ -81,7 +81,7 @@ var y: i32 = x.b; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %float: f64 = float_literal 4 [concrete = constants.%float] +// CHECK:STDOUT: %float: f64 = float_value 4 [concrete = constants.%float] // CHECK:STDOUT: %.loc15_29.1: %struct_type.a = struct_literal (%float) // CHECK:STDOUT: %.loc15_29.2: init %struct_type.a = struct_init (%float) to file.%x.var [concrete = constants.%struct] // CHECK:STDOUT: %.loc15_1: init %struct_type.a = converted %.loc15_29.1, %.loc15_29.2 [concrete = constants.%struct] diff --git a/toolchain/check/testdata/struct/member_access.carbon b/toolchain/check/testdata/struct/member_access.carbon index 7911ae1f1fcb..84a43eff1fe5 100644 --- a/toolchain/check/testdata/struct/member_access.carbon +++ b/toolchain/check/testdata/struct/member_access.carbon @@ -28,7 +28,7 @@ var z: i32 = y; // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] // CHECK:STDOUT: %struct_type.a.b.ddf: type = struct_type {.a: f64, .b: %i32} [concrete] // CHECK:STDOUT: %pattern_type.7fd: type = pattern_type %struct_type.a.b.ddf [concrete] -// CHECK:STDOUT: %float: f64 = float_literal 0 [concrete] +// CHECK:STDOUT: %float: f64 = float_value 0 [concrete] // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete] // CHECK:STDOUT: %struct_type.a.b.fbb: type = struct_type {.a: f64, .b: Core.IntLiteral} [concrete] // CHECK:STDOUT: %.984: ref f64 = struct_access file.%x.var, element0 [concrete] @@ -115,7 +115,7 @@ var z: i32 = y; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %float: f64 = float_literal 0 [concrete = constants.%float] +// CHECK:STDOUT: %float: f64 = float_value 0 [concrete = constants.%float] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] // CHECK:STDOUT: %.loc15_46.1: %struct_type.a.b.fbb = struct_literal (%float, %int_1) // CHECK:STDOUT: %.loc15_46.2: ref f64 = struct_access file.%x.var, element0 [concrete = constants.%.984] diff --git a/toolchain/lower/constant.cpp b/toolchain/lower/constant.cpp index 6b35a7ef272e..6bf6948fafad 100644 --- a/toolchain/lower/constant.cpp +++ b/toolchain/lower/constant.cpp @@ -222,7 +222,7 @@ static auto EmitAsConstant(ConstantContext& context, SemIR::FieldDecl inst) return context.GetUnusedConstant(inst.type_id); } -static auto EmitAsConstant(ConstantContext& context, SemIR::FloatLiteral inst) +static auto EmitAsConstant(ConstantContext& context, SemIR::FloatValue inst) -> llvm::Constant* { const llvm::APFloat& value = context.sem_ir().floats().Get(inst.float_id); return llvm::ConstantFP::get(context.GetType(inst.type_id), value); diff --git a/toolchain/lower/testdata/array/base.carbon b/toolchain/lower/testdata/array/base.carbon index dd15b8616f6c..1e5804657e84 100644 --- a/toolchain/lower/testdata/array/base.carbon +++ b/toolchain/lower/testdata/array/base.carbon @@ -22,7 +22,7 @@ fn Run() { // CHECK:STDOUT: source_filename = "base.carbon" // CHECK:STDOUT: // CHECK:STDOUT: @array.237.loc14_3 = internal constant [1 x i32] [i32 1] -// CHECK:STDOUT: @array.6a2.loc15_3 = internal constant [2 x double] [double 0x4026333333333334, double 2.200000e+00] +// CHECK:STDOUT: @array.13b.loc15_3 = internal constant [2 x double] [double 0x4026333333333334, double 2.200000e+00] // CHECK:STDOUT: @array.1cb.loc16_3 = internal constant [5 x {}] zeroinitializer // CHECK:STDOUT: @tuple.loc17_3 = internal constant { i32, i32, i32 } { i32 1, i32 2, i32 3 } // CHECK:STDOUT: @@ -39,7 +39,7 @@ fn Run() { // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 16, ptr %b.var), !dbg !8 // CHECK:STDOUT: %.loc15_37.2.array.index = getelementptr inbounds [2 x double], ptr %b.var, i32 0, i64 0, !dbg !13 // CHECK:STDOUT: %.loc15_37.4.array.index = getelementptr inbounds [2 x double], ptr %b.var, i32 0, i64 1, !dbg !13 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %b.var, ptr align 8 @array.6a2.loc15_3, i64 16, i1 false), !dbg !8 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %b.var, ptr align 8 @array.13b.loc15_3, i64 16, i1 false), !dbg !8 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 0, ptr %c.var), !dbg !9 // CHECK:STDOUT: %.loc16_45.2.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 0, !dbg !14 // CHECK:STDOUT: %.loc16_45.4.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 1, !dbg !14 diff --git a/toolchain/lower/testdata/basics/numeric_literals.carbon b/toolchain/lower/testdata/basics/numeric_literals.carbon index 51e5f71de9a0..98fb1330d73d 100644 --- a/toolchain/lower/testdata/basics/numeric_literals.carbon +++ b/toolchain/lower/testdata/basics/numeric_literals.carbon @@ -33,7 +33,7 @@ fn F() { // CHECK:STDOUT: source_filename = "numeric_literals.carbon" // CHECK:STDOUT: // CHECK:STDOUT: @array.712.loc16_3 = internal constant [4 x i32] [i32 8, i32 9, i32 8, i32 8] -// CHECK:STDOUT: @array.a2f.loc22_3 = internal constant [6 x double] [double 9.000000e-01, double 8.000000e+00, double 8.000000e+01, double 1.000000e+07, double 1.000000e+08, double 1.000000e-08] +// CHECK:STDOUT: @array.f02.loc22_3 = internal constant [6 x double] [double 9.000000e-01, double 8.000000e+00, double 8.000000e+01, double 1.000000e+07, double 1.000000e+08, double 1.000000e-08] // CHECK:STDOUT: // CHECK:STDOUT: define void @_CF.Main() !dbg !4 { // CHECK:STDOUT: entry: @@ -52,7 +52,7 @@ fn F() { // CHECK:STDOUT: %.loc29_3.8.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i64 3, !dbg !10 // CHECK:STDOUT: %.loc29_3.10.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i64 4, !dbg !10 // CHECK:STDOUT: %.loc29_3.12.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i64 5, !dbg !10 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %floats.var, ptr align 8 @array.a2f.loc22_3, i64 48, i1 false), !dbg !8 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %floats.var, ptr align 8 @array.f02.loc22_3, i64 48, i1 false), !dbg !8 // CHECK:STDOUT: ret void, !dbg !11 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/sem_ir/expr_info.cpp b/toolchain/sem_ir/expr_info.cpp index 1cb4fe91bb18..2df01cdf43a2 100644 --- a/toolchain/sem_ir/expr_info.cpp +++ b/toolchain/sem_ir/expr_info.cpp @@ -113,8 +113,8 @@ auto GetExprCategory(const File& file, InstId inst_id) -> ExprCategory { case FacetAccessType::Kind: case FacetType::Kind: case FacetValue::Kind: - case FloatLiteral::Kind: case FloatType::Kind: + case FloatValue::Kind: case FunctionType::Kind: case FunctionTypeWithSelfType::Kind: case GenericClassType::Kind: diff --git a/toolchain/sem_ir/formatter.cpp b/toolchain/sem_ir/formatter.cpp index ad164d7f07f4..66d22b77873d 100644 --- a/toolchain/sem_ir/formatter.cpp +++ b/toolchain/sem_ir/formatter.cpp @@ -1023,7 +1023,7 @@ auto Formatter::FormatInstRhs(Inst inst) -> void { return; } - case CARBON_KIND(FloatLiteral value): { + case CARBON_KIND(FloatValue value): { llvm::SmallVector buffer; sem_ir_->floats().Get(value.float_id).toString(buffer); out_ << " " << buffer; diff --git a/toolchain/sem_ir/inst_kind.def b/toolchain/sem_ir/inst_kind.def index 7bb97a0f5f70..33d97d21301f 100644 --- a/toolchain/sem_ir/inst_kind.def +++ b/toolchain/sem_ir/inst_kind.def @@ -63,8 +63,8 @@ CARBON_SEM_IR_INST_KIND(FacetAccessType) CARBON_SEM_IR_INST_KIND(FacetType) CARBON_SEM_IR_INST_KIND(FacetValue) CARBON_SEM_IR_INST_KIND(FieldDecl) -CARBON_SEM_IR_INST_KIND(FloatLiteral) CARBON_SEM_IR_INST_KIND(FloatType) +CARBON_SEM_IR_INST_KIND(FloatValue) CARBON_SEM_IR_INST_KIND(FunctionDecl) CARBON_SEM_IR_INST_KIND(FunctionType) CARBON_SEM_IR_INST_KIND(FunctionTypeWithSelfType) diff --git a/toolchain/sem_ir/inst_namer.cpp b/toolchain/sem_ir/inst_namer.cpp index 24a616e8a842..aa9470c86140 100644 --- a/toolchain/sem_ir/inst_namer.cpp +++ b/toolchain/sem_ir/inst_namer.cpp @@ -845,14 +845,14 @@ auto InstNamer::NamingContext::NameInst() -> void { AddInstName("facet_value"); return; } - case FloatLiteral::Kind: { - AddInstName("float"); - return; - } case CARBON_KIND(FloatType inst): { AddIntOrFloatTypeName('f', inst.bit_width_id); return; } + case FloatValue::Kind: { + AddInstName("float"); + return; + } case CARBON_KIND(FunctionDecl inst): { AddEntityNameAndMaybePush(inst.function_id, ".decl"); auto function_scope_id = inst_namer_->GetScopeFor(inst.function_id); diff --git a/toolchain/sem_ir/typed_insts.h b/toolchain/sem_ir/typed_insts.h index b051b9094024..d956512e6398 100644 --- a/toolchain/sem_ir/typed_insts.h +++ b/toolchain/sem_ir/typed_insts.h @@ -662,11 +662,11 @@ struct FieldDecl { ElementIndex index; }; -// A literal floating point value. -struct FloatLiteral { +// A floating point value. +struct FloatValue { static constexpr auto Kind = - InstKind::FloatLiteral.Define( - {.ir_name = "float_literal", + InstKind::FloatValue.Define( + {.ir_name = "float_value", .constant_kind = InstConstantKind::Always}); TypeId type_id; @@ -1026,7 +1026,7 @@ struct IntType { InstId bit_width_id; }; -// A literal integer value. +// An integer value. struct IntValue { // TODO: Make Parse::NodeId more specific. static constexpr auto Kind = InstKind::IntValue.Define(