From 28103b8f2e689edd9868a57aa4507ac99e5c70f9 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 12 Aug 2025 11:55:38 -0700 Subject: [PATCH] Convert LegacyFloatType into FloatLiteralType. (#5939) * Rename the type. * Change lowering to lower FloatLiteralType values as the placeholder `{}` value we use for literals instead of as an LLVM f64. * Change eval to convert the type as part of a floating point conversion, so that lowering can lower converted constants properly. For now we still represent a value of FloatLiteralType as a double-precision APFloat. (That will need to change so that we can losslessly convert literals to f80 / f128 values, and so that we can convert literals to f32 values without double-rounding.) --- toolchain/check/convert.cpp | 26 +--- toolchain/check/eval.cpp | 26 +++- toolchain/check/handle_literal.cpp | 3 +- .../basics/raw_sem_ir/builtins.carbon | 4 +- .../check/testdata/builtins/float/add.carbon | 30 ++++ .../testdata/builtins/float/add_assign.carbon | 15 +- .../builtins/float/convert_checked.carbon | 139 ++++++++++-------- .../check/testdata/builtins/float/div.carbon | 32 ++++ .../testdata/builtins/float/div_assign.carbon | 15 +- .../check/testdata/builtins/float/eq.carbon | 35 +++++ .../testdata/builtins/float/less_eq.carbon | 35 +++++ .../check/testdata/builtins/float/mul.carbon | 30 ++++ .../testdata/builtins/float/mul_assign.carbon | 15 +- .../check/testdata/builtins/float/sub.carbon | 30 ++++ .../testdata/builtins/float/sub_assign.carbon | 15 +- .../call/fail_return_type_mismatch.carbon | 15 +- .../function/arithmetic_types_bridged.carbon | 15 +- .../return/fail_returned_var_type.carbon | 13 +- .../struct/fail_member_access_type.carbon | 15 +- .../testdata/struct/member_access.carbon | 17 ++- toolchain/check/type_completion.cpp | 4 +- toolchain/lower/constant.cpp | 25 +++- toolchain/lower/context.h | 6 +- toolchain/lower/file_context.cpp | 12 +- toolchain/lower/file_context.h | 6 +- toolchain/lower/function_context.h | 6 +- toolchain/lower/mangler.cpp | 2 +- toolchain/lower/testdata/array/base.carbon | 4 +- .../testdata/basics/numeric_literals.carbon | 4 +- toolchain/sem_ir/builtin_function_kind.cpp | 83 ++++++----- toolchain/sem_ir/expr_info.cpp | 2 +- toolchain/sem_ir/inst_kind.def | 2 +- toolchain/sem_ir/singleton_insts.h | 21 +-- toolchain/sem_ir/type.cpp | 20 +++ toolchain/sem_ir/type.h | 7 + toolchain/sem_ir/type_iterator.cpp | 2 +- toolchain/sem_ir/typed_insts.h | 31 ++-- 37 files changed, 529 insertions(+), 233 deletions(-) diff --git a/toolchain/check/convert.cpp b/toolchain/check/convert.cpp index 4722a8e17873..572ff38d479f 100644 --- a/toolchain/check/convert.cpp +++ b/toolchain/check/convert.cpp @@ -762,25 +762,6 @@ static auto CanUseValueOfInitializer(const SemIR::File& sem_ir, return InitReprIsCopyOfValueRepr(sem_ir, type_id); } -// Returns the non-adapter type that is compatible with the specified type. -static auto GetTransitiveAdaptedType(Context& context, SemIR::TypeId type_id) - -> SemIR::TypeId { - // If the type is an adapter, its object representation type is its compatible - // non-adapter type. - while (auto class_type = - context.types().TryGetAs(type_id)) { - auto& class_info = context.classes().Get(class_type->class_id); - auto adapted_type_id = - class_info.GetAdaptedType(context.sem_ir(), class_type->specific_id); - if (!adapted_type_id.has_value()) { - break; - } - type_id = adapted_type_id; - } - - // Otherwise, the type itself is a non-adapter type. - return type_id; -} static auto DiagnoseConversionFailureToConstraintValue( Context& context, SemIR::LocId loc_id, SemIR::InstId expr_id, SemIR::TypeId target_type_id) -> void { @@ -885,7 +866,7 @@ static auto PerformBuiltinConversion( // shortcut to doing the explicit calls to walk the parts of the // tuple/struct which happens inside PerformBuiltinConversion(). if (auto foundation_type_id = - GetTransitiveAdaptedType(context, value_type_id); + context.types().GetTransitiveAdaptedType(value_type_id); foundation_type_id != value_type_id && (context.types().Is(foundation_type_id) || context.types().Is(foundation_type_id))) { @@ -932,8 +913,9 @@ static auto PerformBuiltinConversion( if (target.kind == ConversionTarget::Kind::ExplicitAs && target.type_id != value_type_id) { auto target_foundation_id = - GetTransitiveAdaptedType(context, target.type_id); - auto value_foundation_id = GetTransitiveAdaptedType(context, value_type_id); + context.types().GetTransitiveAdaptedType(target.type_id); + auto value_foundation_id = + context.types().GetTransitiveAdaptedType(value_type_id); if (target_foundation_id == value_foundation_id) { // For a struct or tuple literal, perform a category conversion if // necessary. diff --git a/toolchain/check/eval.cpp b/toolchain/check/eval.cpp index 8af527443e10..b617904ea2da 100644 --- a/toolchain/check/eval.cpp +++ b/toolchain/check/eval.cpp @@ -1071,6 +1071,22 @@ static auto PerformCheckedIntConvert(Context& context, SemIR::LocId loc_id, Phase::Concrete); } +// Performs a conversion between floating-point types, diagnosing if the value +// doesn't fit in the destination type. +static auto PerformCheckedFloatConvert(Context& context, + SemIR::LocId /*loc_id*/, + SemIR::InstId arg_id, + SemIR::TypeId dest_type_id) + -> SemIR::ConstantId { + auto arg = context.insts().GetAs(arg_id); + // TODO: Perform a conversion if necessary. For now, all FloatValues are + // represented as double-precision APFloats, so no conversion is needed. + return MakeConstantResult( + context, + SemIR::FloatValue{.type_id = dest_type_id, .float_id = arg.float_id}, + Phase::Concrete); +} + // Issues a diagnostic for a compile-time division by zero. static auto DiagnoseDivisionByZero(Context& context, SemIR::LocId loc_id) -> void { @@ -1644,7 +1660,7 @@ static auto MakeConstantForBuiltinCall(EvalContext& eval_context, } case SemIR::BuiltinFunctionKind::FloatLiteralMakeType: { - return context.constant_values().Get(SemIR::LegacyFloatType::TypeInstId); + return context.constant_values().Get(SemIR::FloatLiteralType::TypeInstId); } case SemIR::BuiltinFunctionKind::IntLiteralMakeType: { @@ -1751,9 +1767,11 @@ static auto MakeConstantForBuiltinCall(EvalContext& eval_context, // Floating-point conversions. case SemIR::BuiltinFunctionKind::FloatConvertChecked: { - // TODO: Perform a conversion if necessary. For now, all FloatValues are - // represented as double-precision APFloats, so no conversion is needed. - return context.constant_values().Get(arg_ids[0]); + if (phase != Phase::Concrete) { + return MakeConstantResult(context, call, phase); + } + return PerformCheckedFloatConvert(context, loc_id, arg_ids[0], + call.type_id); } // Unary float -> float operations. diff --git a/toolchain/check/handle_literal.cpp b/toolchain/check/handle_literal.cpp index 28cf4fd1480d..0930715e2833 100644 --- a/toolchain/check/handle_literal.cpp +++ b/toolchain/check/handle_literal.cpp @@ -93,7 +93,8 @@ auto HandleParseNode(Context& context, Parse::RealLiteralId node_id) -> bool { auto float_id = context.sem_ir().floats().Add(llvm::APFloat(double_val)); AddInstAndPush( context, node_id, - {.type_id = GetSingletonType(context, SemIR::LegacyFloatType::TypeInstId), + {.type_id = + GetSingletonType(context, SemIR::FloatLiteralType::TypeInstId), .float_id = float_id}); return true; } diff --git a/toolchain/check/testdata/basics/raw_sem_ir/builtins.carbon b/toolchain/check/testdata/basics/raw_sem_ir/builtins.carbon index 42cbe8f5d5ac..92e9624a0d13 100644 --- a/toolchain/check/testdata/basics/raw_sem_ir/builtins.carbon +++ b/toolchain/check/testdata/basics/raw_sem_ir/builtins.carbon @@ -41,10 +41,10 @@ // CHECK:STDOUT: 'inst(BoundMethodType)': {kind: BoundMethodType, type: type(TypeType)} // CHECK:STDOUT: 'inst(CharLiteralType)': {kind: CharLiteralType, type: type(TypeType)} // CHECK:STDOUT: 'inst(ErrorInst)': {kind: ErrorInst, type: type(Error)} +// CHECK:STDOUT: 'inst(FloatLiteralType)': {kind: FloatLiteralType, type: type(TypeType)} // CHECK:STDOUT: 'inst(ImplWitnessTablePlaceholder)': {kind: ImplWitnessTablePlaceholder, type: type(TypeType)} // CHECK:STDOUT: 'inst(InstType)': {kind: InstType, type: type(TypeType)} // CHECK:STDOUT: 'inst(IntLiteralType)': {kind: IntLiteralType, type: type(TypeType)} -// CHECK:STDOUT: 'inst(LegacyFloatType)': {kind: LegacyFloatType, type: type(TypeType)} // CHECK:STDOUT: 'inst(NamespaceType)': {kind: NamespaceType, type: type(TypeType)} // CHECK:STDOUT: 'inst(SpecificFunctionType)': {kind: SpecificFunctionType, type: type(TypeType)} // CHECK:STDOUT: 'inst(StringType)': {kind: StringType, type: type(TypeType)} @@ -59,10 +59,10 @@ // CHECK:STDOUT: 'inst(BoundMethodType)': concrete_constant(inst(BoundMethodType)) // CHECK:STDOUT: 'inst(CharLiteralType)': concrete_constant(inst(CharLiteralType)) // CHECK:STDOUT: 'inst(ErrorInst)': concrete_constant(inst(ErrorInst)) +// CHECK:STDOUT: 'inst(FloatLiteralType)': concrete_constant(inst(FloatLiteralType)) // CHECK:STDOUT: 'inst(ImplWitnessTablePlaceholder)': concrete_constant(inst(ImplWitnessTablePlaceholder)) // CHECK:STDOUT: 'inst(InstType)': concrete_constant(inst(InstType)) // CHECK:STDOUT: 'inst(IntLiteralType)': concrete_constant(inst(IntLiteralType)) -// CHECK:STDOUT: 'inst(LegacyFloatType)': concrete_constant(inst(LegacyFloatType)) // CHECK:STDOUT: 'inst(NamespaceType)': concrete_constant(inst(NamespaceType)) // CHECK:STDOUT: 'inst(SpecificFunctionType)': concrete_constant(inst(SpecificFunctionType)) // CHECK:STDOUT: 'inst(StringType)': concrete_constant(inst(StringType)) diff --git a/toolchain/check/testdata/builtins/float/add.carbon b/toolchain/check/testdata/builtins/float/add.carbon index d0cf80385c14..2421135a6646 100644 --- a/toolchain/check/testdata/builtins/float/add.carbon +++ b/toolchain/check/testdata/builtins/float/add.carbon @@ -57,6 +57,36 @@ fn RuntimeCallIsValidBadReturnType(a: f64, b: f64) -> bool { return BadReturnType(a, b); } +// --- literal.carbon + +library "[[@TEST_NAME]]"; + +fn Literal() -> type = "float_literal.make_type"; +fn AddLiteral(a: Literal(), b: Literal()) -> Literal() = "float.add"; + +// --- literal_comptime.carbon + +library "[[@TEST_NAME]]"; +import library "literal"; + +let n: Literal() = AddLiteral(1.0, 2.0); + +// --- fail_literal_runtime.carbon + +library "[[@TEST_NAME]]"; +import library "literal"; + +var m: Literal(); +// CHECK:STDERR: fail_literal_runtime.carbon:[[@LINE+8]]:20: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] +// CHECK:STDERR: let n: Literal() = AddLiteral(1.0, m); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_literal_runtime.carbon:[[@LINE-6]]:1: in import [InImport] +// CHECK:STDERR: literal.carbon:5:1: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] +// CHECK:STDERR: fn AddLiteral(a: Literal(), b: Literal()) -> Literal() = "float.add"; +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let n: Literal() = AddLiteral(1.0, m); + // CHECK:STDOUT: --- float_add.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { diff --git a/toolchain/check/testdata/builtins/float/add_assign.carbon b/toolchain/check/testdata/builtins/float/add_assign.carbon index aa3f22ab4c09..9ca1c1b65031 100644 --- a/toolchain/check/testdata/builtins/float/add_assign.carbon +++ b/toolchain/check/testdata/builtins/float/add_assign.carbon @@ -12,7 +12,7 @@ // --- call.carbon -library "call"; +library "[[@TEST_NAME]]"; fn Builtin(a: f64*, b: f64) = "float.add_assign"; @@ -22,7 +22,7 @@ fn Call(a: f64*, b: f64) { // --- fail_bad_decl.carbon -library "fail_bad_decl"; +library "[[@TEST_NAME]]"; // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "float.add_assign" [InvalidBuiltinSignature] // CHECK:STDERR: fn NotPtr(a: f64, b: f64) = "float.add_assign"; @@ -42,3 +42,14 @@ fn NotPtr(a: f64, b: f64) = "float.add_assign"; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fn MixedTypes(a: f64*, b: f32) = "float.add_assign"; + +// --- fail_literal.carbon + +library "[[@TEST_NAME]]"; + +fn Literal() -> type = "float_literal.make_type"; +// CHECK:STDERR: fail_literal.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "float.add_assign" [InvalidBuiltinSignature] +// CHECK:STDERR: fn LiteralRuntime(a: Literal()*, b: Literal()) = "float.add_assign"; +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +fn LiteralRuntime(a: Literal()*, b: Literal()) = "float.add_assign"; diff --git a/toolchain/check/testdata/builtins/float/convert_checked.carbon b/toolchain/check/testdata/builtins/float/convert_checked.carbon index ea2f9331168a..3bb3fd8930ce 100644 --- a/toolchain/check/testdata/builtins/float/convert_checked.carbon +++ b/toolchain/check/testdata/builtins/float/convert_checked.carbon @@ -247,8 +247,11 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %FloatLiteralToFloat64.type: type = fn_type @FloatLiteralToFloat64 [concrete] // CHECK:STDOUT: %FloatLiteralToFloat64: %FloatLiteralToFloat64.type = struct_value () [concrete] // CHECK:STDOUT: %float.be6: Core.FloatLiteral = float_value 0 [concrete] +// CHECK:STDOUT: %float.0a8: %f64.d77 = float_value 0 [concrete] // CHECK:STDOUT: %float.a31: Core.FloatLiteral = float_value 1 [concrete] +// CHECK:STDOUT: %float.d20: %f64.d77 = float_value 1 [concrete] // CHECK:STDOUT: %float.9a4: Core.FloatLiteral = float_value 1.0E+308 [concrete] +// CHECK:STDOUT: %float.bde: %f64.d77 = float_value 1.0E+308 [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -263,8 +266,8 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %int_64.loc6: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] // CHECK:STDOUT: %f64.loc6: type = class_type @Float, @Float(constants.%int_64) [concrete = constants.%f64.d77] // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc6_39.1: %f64.d77 = value_of_initializer @__global_init.%FloatLiteralToFloat64.call.loc6 [concrete = constants.%float.be6] -// CHECK:STDOUT: %.loc6_39.2: %f64.d77 = converted @__global_init.%FloatLiteralToFloat64.call.loc6, %.loc6_39.1 [concrete = constants.%float.be6] +// CHECK:STDOUT: %.loc6_39.1: %f64.d77 = value_of_initializer @__global_init.%FloatLiteralToFloat64.call.loc6 [concrete = constants.%float.0a8] +// CHECK:STDOUT: %.loc6_39.2: %f64.d77 = converted @__global_init.%FloatLiteralToFloat64.call.loc6, %.loc6_39.1 [concrete = constants.%float.0a8] // CHECK:STDOUT: %a: %f64.d77 = bind_name a, %.loc6_39.2 // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %b.patt: %pattern_type.0ae = binding_pattern b [concrete] @@ -273,8 +276,8 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %int_64.loc7: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] // CHECK:STDOUT: %f64.loc7: type = class_type @Float, @Float(constants.%int_64) [concrete = constants.%f64.d77] // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc7_39.1: %f64.d77 = value_of_initializer @__global_init.%FloatLiteralToFloat64.call.loc7 [concrete = constants.%float.a31] -// CHECK:STDOUT: %.loc7_39.2: %f64.d77 = converted @__global_init.%FloatLiteralToFloat64.call.loc7, %.loc7_39.1 [concrete = constants.%float.a31] +// CHECK:STDOUT: %.loc7_39.1: %f64.d77 = value_of_initializer @__global_init.%FloatLiteralToFloat64.call.loc7 [concrete = constants.%float.d20] +// CHECK:STDOUT: %.loc7_39.2: %f64.d77 = converted @__global_init.%FloatLiteralToFloat64.call.loc7, %.loc7_39.1 [concrete = constants.%float.d20] // CHECK:STDOUT: %b: %f64.d77 = bind_name b, %.loc7_39.2 // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %c.patt: %pattern_type.0ae = binding_pattern c [concrete] @@ -283,8 +286,8 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %int_64.loc8: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] // CHECK:STDOUT: %f64.loc8: type = class_type @Float, @Float(constants.%int_64) [concrete = constants.%f64.d77] // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc8_43.1: %f64.d77 = value_of_initializer @__global_init.%FloatLiteralToFloat64.call.loc8 [concrete = constants.%float.9a4] -// CHECK:STDOUT: %.loc8_43.2: %f64.d77 = converted @__global_init.%FloatLiteralToFloat64.call.loc8, %.loc8_43.1 [concrete = constants.%float.9a4] +// CHECK:STDOUT: %.loc8_43.1: %f64.d77 = value_of_initializer @__global_init.%FloatLiteralToFloat64.call.loc8 [concrete = constants.%float.bde] +// CHECK:STDOUT: %.loc8_43.2: %f64.d77 = converted @__global_init.%FloatLiteralToFloat64.call.loc8, %.loc8_43.1 [concrete = constants.%float.bde] // CHECK:STDOUT: %c: %f64.d77 = bind_name c, %.loc8_43.2 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -292,13 +295,13 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: !entry: // CHECK:STDOUT: %FloatLiteralToFloat64.ref.loc6: %FloatLiteralToFloat64.type = name_ref FloatLiteralToFloat64, imports.%Main.FloatLiteralToFloat64 [concrete = constants.%FloatLiteralToFloat64] // CHECK:STDOUT: %float.loc6: Core.FloatLiteral = float_value 0 [concrete = constants.%float.be6] -// CHECK:STDOUT: %FloatLiteralToFloat64.call.loc6: init %f64.d77 = call %FloatLiteralToFloat64.ref.loc6(%float.loc6) [concrete = constants.%float.be6] +// CHECK:STDOUT: %FloatLiteralToFloat64.call.loc6: init %f64.d77 = call %FloatLiteralToFloat64.ref.loc6(%float.loc6) [concrete = constants.%float.0a8] // CHECK:STDOUT: %FloatLiteralToFloat64.ref.loc7: %FloatLiteralToFloat64.type = name_ref FloatLiteralToFloat64, imports.%Main.FloatLiteralToFloat64 [concrete = constants.%FloatLiteralToFloat64] // CHECK:STDOUT: %float.loc7: Core.FloatLiteral = float_value 1 [concrete = constants.%float.a31] -// CHECK:STDOUT: %FloatLiteralToFloat64.call.loc7: init %f64.d77 = call %FloatLiteralToFloat64.ref.loc7(%float.loc7) [concrete = constants.%float.a31] +// CHECK:STDOUT: %FloatLiteralToFloat64.call.loc7: init %f64.d77 = call %FloatLiteralToFloat64.ref.loc7(%float.loc7) [concrete = constants.%float.d20] // CHECK:STDOUT: %FloatLiteralToFloat64.ref.loc8: %FloatLiteralToFloat64.type = name_ref FloatLiteralToFloat64, imports.%Main.FloatLiteralToFloat64 [concrete = constants.%FloatLiteralToFloat64] // CHECK:STDOUT: %float.loc8: Core.FloatLiteral = float_value 1.0E+308 [concrete = constants.%float.9a4] -// CHECK:STDOUT: %FloatLiteralToFloat64.call.loc8: init %f64.d77 = call %FloatLiteralToFloat64.ref.loc8(%float.loc8) [concrete = constants.%float.9a4] +// CHECK:STDOUT: %FloatLiteralToFloat64.call.loc8: init %f64.d77 = call %FloatLiteralToFloat64.ref.loc8(%float.loc8) [concrete = constants.%float.bde] // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: @@ -388,12 +391,15 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.93b: = bound_method %float.be6, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03 [concrete] // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(%int_64) [concrete] // CHECK:STDOUT: %bound_method.71f: = bound_method %float.be6, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.0a8: %f64.d77 = float_value 0 [concrete] // CHECK:STDOUT: %float.a31: Core.FloatLiteral = float_value 1 [concrete] // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.64b: = bound_method %float.a31, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03 [concrete] // CHECK:STDOUT: %bound_method.20c: = bound_method %float.a31, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.d20: %f64.d77 = float_value 1 [concrete] // CHECK:STDOUT: %float.9a4: Core.FloatLiteral = float_value 1.0E+308 [concrete] // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.260: = bound_method %float.9a4, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03 [concrete] // CHECK:STDOUT: %bound_method.aa0: = bound_method %float.9a4, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.bde: %f64.d77 = float_value 1.0E+308 [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -410,8 +416,8 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %int_64.loc6: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] // CHECK:STDOUT: %f64.loc6: type = class_type @Float, @Float(constants.%int_64) [concrete = constants.%f64.d77] // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc6_34.1: %f64.d77 = value_of_initializer @__global_init.%Float64ToFloat64.call.loc6 [concrete = constants.%float.be6] -// CHECK:STDOUT: %.loc6_34.2: %f64.d77 = converted @__global_init.%Float64ToFloat64.call.loc6, %.loc6_34.1 [concrete = constants.%float.be6] +// CHECK:STDOUT: %.loc6_34.1: %f64.d77 = value_of_initializer @__global_init.%Float64ToFloat64.call.loc6 [concrete = constants.%float.0a8] +// CHECK:STDOUT: %.loc6_34.2: %f64.d77 = converted @__global_init.%Float64ToFloat64.call.loc6, %.loc6_34.1 [concrete = constants.%float.0a8] // CHECK:STDOUT: %a: %f64.d77 = bind_name a, %.loc6_34.2 // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %b.patt: %pattern_type.0ae = binding_pattern b [concrete] @@ -420,8 +426,8 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %int_64.loc7: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] // CHECK:STDOUT: %f64.loc7: type = class_type @Float, @Float(constants.%int_64) [concrete = constants.%f64.d77] // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc7_34.1: %f64.d77 = value_of_initializer @__global_init.%Float64ToFloat64.call.loc7 [concrete = constants.%float.a31] -// CHECK:STDOUT: %.loc7_34.2: %f64.d77 = converted @__global_init.%Float64ToFloat64.call.loc7, %.loc7_34.1 [concrete = constants.%float.a31] +// CHECK:STDOUT: %.loc7_34.1: %f64.d77 = value_of_initializer @__global_init.%Float64ToFloat64.call.loc7 [concrete = constants.%float.d20] +// CHECK:STDOUT: %.loc7_34.2: %f64.d77 = converted @__global_init.%Float64ToFloat64.call.loc7, %.loc7_34.1 [concrete = constants.%float.d20] // CHECK:STDOUT: %b: %f64.d77 = bind_name b, %.loc7_34.2 // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %c.patt: %pattern_type.0ae = binding_pattern c [concrete] @@ -430,8 +436,8 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %int_64.loc8: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] // CHECK:STDOUT: %f64.loc8: type = class_type @Float, @Float(constants.%int_64) [concrete = constants.%f64.d77] // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc8_38.1: %f64.d77 = value_of_initializer @__global_init.%Float64ToFloat64.call.loc8 [concrete = constants.%float.9a4] -// CHECK:STDOUT: %.loc8_38.2: %f64.d77 = converted @__global_init.%Float64ToFloat64.call.loc8, %.loc8_38.1 [concrete = constants.%float.9a4] +// CHECK:STDOUT: %.loc8_38.1: %f64.d77 = value_of_initializer @__global_init.%Float64ToFloat64.call.loc8 [concrete = constants.%float.bde] +// CHECK:STDOUT: %.loc8_38.2: %f64.d77 = converted @__global_init.%Float64ToFloat64.call.loc8, %.loc8_38.1 [concrete = constants.%float.bde] // CHECK:STDOUT: %c: %f64.d77 = bind_name c, %.loc8_38.2 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -443,30 +449,30 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %bound_method.loc6_31.1: = bound_method %float.loc6, %impl.elem0.loc6 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.93b] // CHECK:STDOUT: %specific_fn.loc6: = specific_function %impl.elem0.loc6, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc6_31.2: = bound_method %float.loc6, %specific_fn.loc6 [concrete = constants.%bound_method.71f] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc6: init %f64.d77 = call %bound_method.loc6_31.2(%float.loc6) [concrete = constants.%float.be6] -// CHECK:STDOUT: %.loc6_31.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc6 [concrete = constants.%float.be6] -// CHECK:STDOUT: %.loc6_31.2: %f64.d77 = converted %float.loc6, %.loc6_31.1 [concrete = constants.%float.be6] -// CHECK:STDOUT: %Float64ToFloat64.call.loc6: init %f64.d77 = call %Float64ToFloat64.ref.loc6(%.loc6_31.2) [concrete = constants.%float.be6] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc6: init %f64.d77 = call %bound_method.loc6_31.2(%float.loc6) [concrete = constants.%float.0a8] +// CHECK:STDOUT: %.loc6_31.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc6 [concrete = constants.%float.0a8] +// CHECK:STDOUT: %.loc6_31.2: %f64.d77 = converted %float.loc6, %.loc6_31.1 [concrete = constants.%float.0a8] +// CHECK:STDOUT: %Float64ToFloat64.call.loc6: init %f64.d77 = call %Float64ToFloat64.ref.loc6(%.loc6_31.2) [concrete = constants.%float.0a8] // CHECK:STDOUT: %Float64ToFloat64.ref.loc7: %Float64ToFloat64.type = name_ref Float64ToFloat64, imports.%Main.Float64ToFloat64 [concrete = constants.%Float64ToFloat64] // CHECK:STDOUT: %float.loc7: Core.FloatLiteral = float_value 1 [concrete = constants.%float.a31] // CHECK:STDOUT: %impl.elem0.loc7: %.678 = impl_witness_access constants.%ImplicitAs.impl_witness.857, element0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03] // CHECK:STDOUT: %bound_method.loc7_31.1: = bound_method %float.loc7, %impl.elem0.loc7 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.64b] // CHECK:STDOUT: %specific_fn.loc7: = specific_function %impl.elem0.loc7, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc7_31.2: = bound_method %float.loc7, %specific_fn.loc7 [concrete = constants.%bound_method.20c] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc7: init %f64.d77 = call %bound_method.loc7_31.2(%float.loc7) [concrete = constants.%float.a31] -// CHECK:STDOUT: %.loc7_31.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc7 [concrete = constants.%float.a31] -// CHECK:STDOUT: %.loc7_31.2: %f64.d77 = converted %float.loc7, %.loc7_31.1 [concrete = constants.%float.a31] -// CHECK:STDOUT: %Float64ToFloat64.call.loc7: init %f64.d77 = call %Float64ToFloat64.ref.loc7(%.loc7_31.2) [concrete = constants.%float.a31] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc7: init %f64.d77 = call %bound_method.loc7_31.2(%float.loc7) [concrete = constants.%float.d20] +// CHECK:STDOUT: %.loc7_31.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc7 [concrete = constants.%float.d20] +// CHECK:STDOUT: %.loc7_31.2: %f64.d77 = converted %float.loc7, %.loc7_31.1 [concrete = constants.%float.d20] +// CHECK:STDOUT: %Float64ToFloat64.call.loc7: init %f64.d77 = call %Float64ToFloat64.ref.loc7(%.loc7_31.2) [concrete = constants.%float.d20] // CHECK:STDOUT: %Float64ToFloat64.ref.loc8: %Float64ToFloat64.type = name_ref Float64ToFloat64, imports.%Main.Float64ToFloat64 [concrete = constants.%Float64ToFloat64] // CHECK:STDOUT: %float.loc8: Core.FloatLiteral = float_value 1.0E+308 [concrete = constants.%float.9a4] // CHECK:STDOUT: %impl.elem0.loc8: %.678 = impl_witness_access constants.%ImplicitAs.impl_witness.857, element0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03] // CHECK:STDOUT: %bound_method.loc8_31.1: = bound_method %float.loc8, %impl.elem0.loc8 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.260] // CHECK:STDOUT: %specific_fn.loc8: = specific_function %impl.elem0.loc8, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc8_31.2: = bound_method %float.loc8, %specific_fn.loc8 [concrete = constants.%bound_method.aa0] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc8: init %f64.d77 = call %bound_method.loc8_31.2(%float.loc8) [concrete = constants.%float.9a4] -// CHECK:STDOUT: %.loc8_31.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc8 [concrete = constants.%float.9a4] -// CHECK:STDOUT: %.loc8_31.2: %f64.d77 = converted %float.loc8, %.loc8_31.1 [concrete = constants.%float.9a4] -// CHECK:STDOUT: %Float64ToFloat64.call.loc8: init %f64.d77 = call %Float64ToFloat64.ref.loc8(%.loc8_31.2) [concrete = constants.%float.9a4] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc8: init %f64.d77 = call %bound_method.loc8_31.2(%float.loc8) [concrete = constants.%float.bde] +// CHECK:STDOUT: %.loc8_31.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc8 [concrete = constants.%float.bde] +// CHECK:STDOUT: %.loc8_31.2: %f64.d77 = converted %float.loc8, %.loc8_31.1 [concrete = constants.%float.bde] +// CHECK:STDOUT: %Float64ToFloat64.call.loc8: init %f64.d77 = call %Float64ToFloat64.ref.loc8(%.loc8_31.2) [concrete = constants.%float.bde] // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: @@ -492,12 +498,15 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.02c: = bound_method %float.be6, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.1a3 [concrete] // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.FloatLiteral.as.ImplicitAs.impl.Convert.1a3, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(%int_32) [concrete] // CHECK:STDOUT: %bound_method.a33: = bound_method %float.be6, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.540: %f32 = float_value 0 [concrete] // CHECK:STDOUT: %float.a31: Core.FloatLiteral = float_value 1 [concrete] // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.bcb: = bound_method %float.a31, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.1a3 [concrete] // CHECK:STDOUT: %bound_method.495: = bound_method %float.a31, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.3b9: %f32 = float_value 1 [concrete] // CHECK:STDOUT: %float.cf6: Core.FloatLiteral = float_value 9.9999999999999997E+37 [concrete] // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.82a: = bound_method %float.cf6, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.1a3 [concrete] // CHECK:STDOUT: %bound_method.492: = bound_method %float.cf6, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.a77: %f32 = float_value 9.9999999999999997E+37 [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -547,9 +556,9 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %bound_method.loc13_31.1: = bound_method %float.loc13, %impl.elem0.loc13 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.02c] // CHECK:STDOUT: %specific_fn.loc13: = specific_function %impl.elem0.loc13, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc13_31.2: = bound_method %float.loc13, %specific_fn.loc13 [concrete = constants.%bound_method.a33] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc13: init %f32 = call %bound_method.loc13_31.2(%float.loc13) [concrete = constants.%float.be6] -// CHECK:STDOUT: %.loc13_31.1: %f32 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc13 [concrete = constants.%float.be6] -// CHECK:STDOUT: %.loc13_31.2: %f32 = converted %float.loc13, %.loc13_31.1 [concrete = constants.%float.be6] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc13: init %f32 = call %bound_method.loc13_31.2(%float.loc13) [concrete = constants.%float.540] +// CHECK:STDOUT: %.loc13_31.1: %f32 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc13 [concrete = constants.%float.540] +// CHECK:STDOUT: %.loc13_31.2: %f32 = converted %float.loc13, %.loc13_31.1 [concrete = constants.%float.540] // CHECK:STDOUT: %Float32ToFloat32.call.loc13: init %f32 = call %Float32ToFloat32.ref.loc13(%.loc13_31.2) // CHECK:STDOUT: %Float32ToFloat32.ref.loc14: %Float32ToFloat32.type = name_ref Float32ToFloat32, imports.%Main.Float32ToFloat32 [concrete = constants.%Float32ToFloat32] // CHECK:STDOUT: %float.loc14: Core.FloatLiteral = float_value 1 [concrete = constants.%float.a31] @@ -557,9 +566,9 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %bound_method.loc14_31.1: = bound_method %float.loc14, %impl.elem0.loc14 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.bcb] // CHECK:STDOUT: %specific_fn.loc14: = specific_function %impl.elem0.loc14, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc14_31.2: = bound_method %float.loc14, %specific_fn.loc14 [concrete = constants.%bound_method.495] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc14: init %f32 = call %bound_method.loc14_31.2(%float.loc14) [concrete = constants.%float.a31] -// CHECK:STDOUT: %.loc14_31.1: %f32 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc14 [concrete = constants.%float.a31] -// CHECK:STDOUT: %.loc14_31.2: %f32 = converted %float.loc14, %.loc14_31.1 [concrete = constants.%float.a31] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc14: init %f32 = call %bound_method.loc14_31.2(%float.loc14) [concrete = constants.%float.3b9] +// CHECK:STDOUT: %.loc14_31.1: %f32 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc14 [concrete = constants.%float.3b9] +// CHECK:STDOUT: %.loc14_31.2: %f32 = converted %float.loc14, %.loc14_31.1 [concrete = constants.%float.3b9] // CHECK:STDOUT: %Float32ToFloat32.call.loc14: init %f32 = call %Float32ToFloat32.ref.loc14(%.loc14_31.2) // CHECK:STDOUT: %Float32ToFloat32.ref.loc15: %Float32ToFloat32.type = name_ref Float32ToFloat32, imports.%Main.Float32ToFloat32 [concrete = constants.%Float32ToFloat32] // CHECK:STDOUT: %float.loc15: Core.FloatLiteral = float_value 9.9999999999999997E+37 [concrete = constants.%float.cf6] @@ -567,9 +576,9 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %bound_method.loc15_31.1: = bound_method %float.loc15, %impl.elem0.loc15 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.82a] // CHECK:STDOUT: %specific_fn.loc15: = specific_function %impl.elem0.loc15, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc15_31.2: = bound_method %float.loc15, %specific_fn.loc15 [concrete = constants.%bound_method.492] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc15: init %f32 = call %bound_method.loc15_31.2(%float.loc15) [concrete = constants.%float.cf6] -// CHECK:STDOUT: %.loc15_31.1: %f32 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc15 [concrete = constants.%float.cf6] -// CHECK:STDOUT: %.loc15_31.2: %f32 = converted %float.loc15, %.loc15_31.1 [concrete = constants.%float.cf6] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc15: init %f32 = call %bound_method.loc15_31.2(%float.loc15) [concrete = constants.%float.a77] +// CHECK:STDOUT: %.loc15_31.1: %f32 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc15 [concrete = constants.%float.a77] +// CHECK:STDOUT: %.loc15_31.2: %f32 = converted %float.loc15, %.loc15_31.1 [concrete = constants.%float.a77] // CHECK:STDOUT: %Float32ToFloat32.call.loc15: init %f32 = call %Float32ToFloat32.ref.loc15(%.loc15_31.2) // CHECK:STDOUT: // CHECK:STDOUT: } @@ -584,7 +593,7 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %Float64ToFloat32: %Float64ToFloat32.type = struct_value () [concrete] // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete] // CHECK:STDOUT: %f64.d77: type = class_type @Float, @Float(%int_64) [concrete] -// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 1 [concrete] +// CHECK:STDOUT: %float.a31: Core.FloatLiteral = float_value 1 [concrete] // CHECK:STDOUT: %ImplicitAs.type.6ec: type = facet_type <@ImplicitAs, @ImplicitAs(%f64.d77)> [concrete] // CHECK:STDOUT: %ImplicitAs.Convert.type.726: type = fn_type @ImplicitAs.Convert, @ImplicitAs(%f64.d77) [concrete] // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic] @@ -595,9 +604,10 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.baf = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.6ec = facet_value Core.FloatLiteral, (%ImplicitAs.impl_witness.857) [concrete] // CHECK:STDOUT: %.678: type = fn_type_with_self_type %ImplicitAs.Convert.type.726, %ImplicitAs.facet [concrete] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound: = bound_method %float, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03 [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound: = bound_method %float.a31, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03 [concrete] // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(%int_64) [concrete] -// CHECK:STDOUT: %bound_method: = bound_method %float, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %bound_method: = bound_method %float.a31, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.d20: %f64.d77 = float_value 1 [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -622,14 +632,14 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Float64ToFloat32.ref: %Float64ToFloat32.type = name_ref Float64ToFloat32, imports.%Main.Float64ToFloat32 [concrete = constants.%Float64ToFloat32] -// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 1 [concrete = constants.%float] +// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 1 [concrete = constants.%float.a31] // CHECK:STDOUT: %impl.elem0: %.678 = impl_witness_access constants.%ImplicitAs.impl_witness.857, element0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03] // CHECK:STDOUT: %bound_method.loc13_31.1: = bound_method %float, %impl.elem0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound] // CHECK:STDOUT: %specific_fn: = specific_function %impl.elem0, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc13_31.2: = bound_method %float, %specific_fn [concrete = constants.%bound_method] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call: init %f64.d77 = call %bound_method.loc13_31.2(%float) [concrete = constants.%float] -// CHECK:STDOUT: %.loc13_31.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%float] -// CHECK:STDOUT: %.loc13_31.2: %f64.d77 = converted %float, %.loc13_31.1 [concrete = constants.%float] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call: init %f64.d77 = call %bound_method.loc13_31.2(%float) [concrete = constants.%float.d20] +// CHECK:STDOUT: %.loc13_31.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%float.d20] +// CHECK:STDOUT: %.loc13_31.2: %f64.d77 = converted %float, %.loc13_31.1 [concrete = constants.%float.d20] // CHECK:STDOUT: %Float64ToFloat32.call: init %f32 = call %Float64ToFloat32.ref(%.loc13_31.2) // CHECK:STDOUT: // CHECK:STDOUT: } @@ -659,11 +669,13 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound: = bound_method %float.629, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03 [concrete] // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(%int_64) [concrete] // CHECK:STDOUT: %bound_method: = bound_method %float.629, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.c37: %f64.d77 = float_value 9.9999999999999994E+38 [concrete] // CHECK:STDOUT: %FloatLiteralToFloat32.type: type = fn_type @FloatLiteralToFloat32 [concrete] // CHECK:STDOUT: %FloatLiteralToFloat32: %FloatLiteralToFloat32.type = struct_value () [concrete] // CHECK:STDOUT: %FloatLiteralToFloat64.type: type = fn_type @FloatLiteralToFloat64 [concrete] // CHECK:STDOUT: %FloatLiteralToFloat64: %FloatLiteralToFloat64.type = struct_value () [concrete] // CHECK:STDOUT: %float.669: Core.FloatLiteral = float_value +Inf [concrete] +// CHECK:STDOUT: %float.181: %f64.d77 = float_value +Inf [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -702,8 +714,8 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] // CHECK:STDOUT: %f64: type = class_type @Float, @Float(constants.%int_64) [concrete = constants.%f64.d77] // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc18_43.1: %f64.d77 = value_of_initializer @__global_init.%FloatLiteralToFloat64.call [concrete = constants.%float.669] -// CHECK:STDOUT: %.loc18_43.2: %f64.d77 = converted @__global_init.%FloatLiteralToFloat64.call, %.loc18_43.1 [concrete = constants.%float.669] +// CHECK:STDOUT: %.loc18_43.1: %f64.d77 = value_of_initializer @__global_init.%FloatLiteralToFloat64.call [concrete = constants.%float.181] +// CHECK:STDOUT: %.loc18_43.2: %f64.d77 = converted @__global_init.%FloatLiteralToFloat64.call, %.loc18_43.1 [concrete = constants.%float.181] // CHECK:STDOUT: %c: %f64.d77 = bind_name c, %.loc18_43.2 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -715,16 +727,16 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %bound_method.loc16_31.1: = bound_method %float.loc16, %impl.elem0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound] // CHECK:STDOUT: %specific_fn: = specific_function %impl.elem0, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc16_31.2: = bound_method %float.loc16, %specific_fn [concrete = constants.%bound_method] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call: init %f64.d77 = call %bound_method.loc16_31.2(%float.loc16) [concrete = constants.%float.629] -// CHECK:STDOUT: %.loc16_31.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%float.629] -// CHECK:STDOUT: %.loc16_31.2: %f64.d77 = converted %float.loc16, %.loc16_31.1 [concrete = constants.%float.629] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call: init %f64.d77 = call %bound_method.loc16_31.2(%float.loc16) [concrete = constants.%float.c37] +// CHECK:STDOUT: %.loc16_31.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%float.c37] +// CHECK:STDOUT: %.loc16_31.2: %f64.d77 = converted %float.loc16, %.loc16_31.1 [concrete = constants.%float.c37] // CHECK:STDOUT: %Float64ToFloat32.call: init %f32 = call %Float64ToFloat32.ref(%.loc16_31.2) // CHECK:STDOUT: %FloatLiteralToFloat32.ref: %FloatLiteralToFloat32.type = name_ref FloatLiteralToFloat32, imports.%Main.FloatLiteralToFloat32 [concrete = constants.%FloatLiteralToFloat32] // CHECK:STDOUT: %float.loc17: Core.FloatLiteral = float_value 9.9999999999999994E+38 [concrete = constants.%float.629] // CHECK:STDOUT: %FloatLiteralToFloat32.call: init %f32 = call %FloatLiteralToFloat32.ref(%float.loc17) // CHECK:STDOUT: %FloatLiteralToFloat64.ref: %FloatLiteralToFloat64.type = name_ref FloatLiteralToFloat64, imports.%Main.FloatLiteralToFloat64 [concrete = constants.%FloatLiteralToFloat64] // CHECK:STDOUT: %float.loc18: Core.FloatLiteral = float_value +Inf [concrete = constants.%float.669] -// CHECK:STDOUT: %FloatLiteralToFloat64.call: init %f64.d77 = call %FloatLiteralToFloat64.ref(%float.loc18) [concrete = constants.%float.669] +// CHECK:STDOUT: %FloatLiteralToFloat64.call: init %f64.d77 = call %FloatLiteralToFloat64.ref(%float.loc18) [concrete = constants.%float.181] // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: @@ -752,9 +764,11 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.bcb: = bound_method %float.a31, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.1a3 [concrete] // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.FloatLiteral.as.ImplicitAs.impl.Convert.1a3, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(%int_32) [concrete] // CHECK:STDOUT: %bound_method.495: = bound_method %float.a31, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.3b9: %f32 = float_value 1 [concrete] // CHECK:STDOUT: %float.f26: Core.FloatLiteral = float_value 9.9999999999999988E+29 [concrete] // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.6ef: = bound_method %float.f26, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.1a3 [concrete] // CHECK:STDOUT: %bound_method.f39: = bound_method %float.f26, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.2d0: %f32 = float_value 9.9999999999999988E+29 [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -794,9 +808,9 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %bound_method.loc6_31.1: = bound_method %float.loc6, %impl.elem0.loc6 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.bcb] // CHECK:STDOUT: %specific_fn.loc6: = specific_function %impl.elem0.loc6, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc6_31.2: = bound_method %float.loc6, %specific_fn.loc6 [concrete = constants.%bound_method.495] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc6: init %f32 = call %bound_method.loc6_31.2(%float.loc6) [concrete = constants.%float.a31] -// CHECK:STDOUT: %.loc6_31.1: %f32 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc6 [concrete = constants.%float.a31] -// CHECK:STDOUT: %.loc6_31.2: %f32 = converted %float.loc6, %.loc6_31.1 [concrete = constants.%float.a31] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc6: init %f32 = call %bound_method.loc6_31.2(%float.loc6) [concrete = constants.%float.3b9] +// CHECK:STDOUT: %.loc6_31.1: %f32 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc6 [concrete = constants.%float.3b9] +// CHECK:STDOUT: %.loc6_31.2: %f32 = converted %float.loc6, %.loc6_31.1 [concrete = constants.%float.3b9] // CHECK:STDOUT: %Float32ToFloat64.call.loc6: init %f64.d77 = call %Float32ToFloat64.ref.loc6(%.loc6_31.2) // CHECK:STDOUT: %Float32ToFloat64.ref.loc7: %Float32ToFloat64.type = name_ref Float32ToFloat64, imports.%Main.Float32ToFloat64 [concrete = constants.%Float32ToFloat64] // CHECK:STDOUT: %float.loc7: Core.FloatLiteral = float_value 9.9999999999999988E+29 [concrete = constants.%float.f26] @@ -804,9 +818,9 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %bound_method.loc7_31.1: = bound_method %float.loc7, %impl.elem0.loc7 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.6ef] // CHECK:STDOUT: %specific_fn.loc7: = specific_function %impl.elem0.loc7, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc7_31.2: = bound_method %float.loc7, %specific_fn.loc7 [concrete = constants.%bound_method.f39] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc7: init %f32 = call %bound_method.loc7_31.2(%float.loc7) [concrete = constants.%float.f26] -// CHECK:STDOUT: %.loc7_31.1: %f32 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc7 [concrete = constants.%float.f26] -// CHECK:STDOUT: %.loc7_31.2: %f32 = converted %float.loc7, %.loc7_31.1 [concrete = constants.%float.f26] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc7: init %f32 = call %bound_method.loc7_31.2(%float.loc7) [concrete = constants.%float.2d0] +// CHECK:STDOUT: %.loc7_31.1: %f32 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc7 [concrete = constants.%float.2d0] +// CHECK:STDOUT: %.loc7_31.2: %f32 = converted %float.loc7, %.loc7_31.1 [concrete = constants.%float.2d0] // CHECK:STDOUT: %Float32ToFloat64.call.loc7: init %f64.d77 = call %Float32ToFloat64.ref.loc7(%.loc7_31.2) // CHECK:STDOUT: // CHECK:STDOUT: } @@ -817,7 +831,7 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete] // CHECK:STDOUT: %f64.d77: type = class_type @Float, @Float(%int_64) [concrete] // CHECK:STDOUT: %pattern_type.0ae: type = pattern_type %f64.d77 [concrete] -// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 0 [concrete] +// CHECK:STDOUT: %float.be6: Core.FloatLiteral = float_value 0 [concrete] // CHECK:STDOUT: %ImplicitAs.type.6ec: type = facet_type <@ImplicitAs, @ImplicitAs(%f64.d77)> [concrete] // CHECK:STDOUT: %ImplicitAs.Convert.type.726: type = fn_type @ImplicitAs.Convert, @ImplicitAs(%f64.d77) [concrete] // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic] @@ -828,9 +842,10 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.baf = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.6ec = facet_value Core.FloatLiteral, (%ImplicitAs.impl_witness.857) [concrete] // CHECK:STDOUT: %.678: type = fn_type_with_self_type %ImplicitAs.Convert.type.726, %ImplicitAs.facet [concrete] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound: = bound_method %float, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03 [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound: = bound_method %float.be6, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03 [concrete] // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(%int_64) [concrete] -// CHECK:STDOUT: %bound_method: = bound_method %float, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %bound_method: = bound_method %float.be6, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.0a8: %f64.d77 = float_value 0 [concrete] // CHECK:STDOUT: %Float64ToFloat64.type: type = fn_type @Float64ToFloat64 [concrete] // CHECK:STDOUT: %Float64ToFloat64: %Float64ToFloat64.type = struct_value () [concrete] // CHECK:STDOUT: } @@ -853,9 +868,9 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: %bound_method.loc6_28.1: = bound_method @__global_init.%float, %impl.elem0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound] // CHECK:STDOUT: %specific_fn: = specific_function %impl.elem0, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc6_28.2: = bound_method @__global_init.%float, %specific_fn [concrete = constants.%bound_method] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call: init %f64.d77 = call %bound_method.loc6_28.2(@__global_init.%float) [concrete = constants.%float] -// CHECK:STDOUT: %.loc6_28.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%float] -// CHECK:STDOUT: %.loc6_28.2: %f64.d77 = converted @__global_init.%float, %.loc6_28.1 [concrete = constants.%float] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call: init %f64.d77 = call %bound_method.loc6_28.2(@__global_init.%float) [concrete = constants.%float.0a8] +// CHECK:STDOUT: %.loc6_28.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%float.0a8] +// CHECK:STDOUT: %.loc6_28.2: %f64.d77 = converted @__global_init.%float, %.loc6_28.1 [concrete = constants.%float.0a8] // CHECK:STDOUT: %not_constant_64: %f64.d77 = bind_name not_constant_64, %.loc6_28.2 // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %convert_not_constant.patt: %pattern_type.0ae = binding_pattern convert_not_constant [concrete] @@ -871,7 +886,7 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 0 [concrete = constants.%float] +// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 0 [concrete = constants.%float.be6] // CHECK:STDOUT: %Float64ToFloat64.ref: %Float64ToFloat64.type = name_ref Float64ToFloat64, imports.%Main.Float64ToFloat64 [concrete = constants.%Float64ToFloat64] // CHECK:STDOUT: %not_constant_64.ref: %f64.d77 = name_ref not_constant_64, file.%not_constant_64 // CHECK:STDOUT: %Float64ToFloat64.call: init %f64.d77 = call %Float64ToFloat64.ref(%not_constant_64.ref) diff --git a/toolchain/check/testdata/builtins/float/div.carbon b/toolchain/check/testdata/builtins/float/div.carbon index eee0f3d1d46a..08824b737c06 100644 --- a/toolchain/check/testdata/builtins/float/div.carbon +++ b/toolchain/check/testdata/builtins/float/div.carbon @@ -56,6 +56,8 @@ fn RuntimeCallIsValidTooMany(a: f64, b: f64, c: f64) -> f64 { // --- fail_bad_return_type.carbon +library "[[@TEST_NAME]]"; + // CHECK:STDERR: fail_bad_return_type.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "float.div" [InvalidBuiltinSignature] // CHECK:STDERR: fn BadReturnType(a: f64, b: f64) -> bool = "float.div"; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -66,6 +68,36 @@ fn RuntimeCallIsValidBadReturnType(a: f64, b: f64) -> bool { return BadReturnType(a, b); } +// --- literal.carbon + +library "[[@TEST_NAME]]"; + +fn Literal() -> type = "float_literal.make_type"; +fn DivLiteral(a: Literal(), b: Literal()) -> Literal() = "float.div"; + +// --- literal_comptime.carbon + +library "[[@TEST_NAME]]"; +import library "literal"; + +let n: Literal() = DivLiteral(1.0, 2.0); + +// --- fail_literal_runtime.carbon + +library "[[@TEST_NAME]]"; +import library "literal"; + +var m: Literal(); +// CHECK:STDERR: fail_literal_runtime.carbon:[[@LINE+8]]:20: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] +// CHECK:STDERR: let n: Literal() = DivLiteral(1.0, m); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_literal_runtime.carbon:[[@LINE-6]]:1: in import [InImport] +// CHECK:STDERR: literal.carbon:5:1: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] +// CHECK:STDERR: fn DivLiteral(a: Literal(), b: Literal()) -> Literal() = "float.div"; +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let n: Literal() = DivLiteral(1.0, m); + // CHECK:STDOUT: --- float_div.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { diff --git a/toolchain/check/testdata/builtins/float/div_assign.carbon b/toolchain/check/testdata/builtins/float/div_assign.carbon index 9fafd79006b8..6cbf6dd3ff55 100644 --- a/toolchain/check/testdata/builtins/float/div_assign.carbon +++ b/toolchain/check/testdata/builtins/float/div_assign.carbon @@ -12,7 +12,7 @@ // --- call.carbon -library "call"; +library "[[@TEST_NAME]]"; fn Builtin(a: f64*, b: f64) = "float.div_assign"; @@ -22,7 +22,7 @@ fn Call(a: f64*, b: f64) { // --- fail_bad_decl.carbon -library "fail_bad_decl"; +library "[[@TEST_NAME]]"; // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "float.div_assign" [InvalidBuiltinSignature] // CHECK:STDERR: fn NotPtr(a: f64, b: f64) = "float.div_assign"; @@ -42,3 +42,14 @@ fn NotPtr(a: f64, b: f64) = "float.div_assign"; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fn MixedTypes(a: f64*, b: f32) = "float.div_assign"; + +// --- fail_literal.carbon + +library "[[@TEST_NAME]]"; + +fn Literal() -> type = "float_literal.make_type"; +// CHECK:STDERR: fail_literal.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "float.div_assign" [InvalidBuiltinSignature] +// CHECK:STDERR: fn LiteralRuntime(a: Literal()*, b: Literal()) = "float.div_assign"; +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +fn LiteralRuntime(a: Literal()*, b: Literal()) = "float.div_assign"; diff --git a/toolchain/check/testdata/builtins/float/eq.carbon b/toolchain/check/testdata/builtins/float/eq.carbon index 5df603fbed9d..d1fe56aa89b5 100644 --- a/toolchain/check/testdata/builtins/float/eq.carbon +++ b/toolchain/check/testdata/builtins/float/eq.carbon @@ -38,6 +38,41 @@ library "[[@TEST_NAME]]"; // CHECK:STDERR: fn WrongResult(a: f64, b: f64) -> f64 = "float.eq"; +// --- fail_runtime_literal.carbon + +library "[[@TEST_NAME]]"; + +fn Eq(a: Core.FloatLiteral(), b: Core.FloatLiteral()) -> bool = "float.eq"; + +fn Test(n: Core.FloatLiteral()) { + // OK + Eq(1.0, 1.0); + // CHECK:STDERR: fail_runtime_literal.carbon:[[@LINE+7]]:3: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] + // CHECK:STDERR: Eq(n, 1.0); + // CHECK:STDERR: ^~~~~~~~~~ + // CHECK:STDERR: fail_runtime_literal.carbon:[[@LINE-8]]:1: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] + // CHECK:STDERR: fn Eq(a: Core.FloatLiteral(), b: Core.FloatLiteral()) -> bool = "float.eq"; + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: + Eq(n, 1.0); + // CHECK:STDERR: fail_runtime_literal.carbon:[[@LINE+7]]:3: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] + // CHECK:STDERR: Eq(1.0, n); + // CHECK:STDERR: ^~~~~~~~~~ + // CHECK:STDERR: fail_runtime_literal.carbon:[[@LINE-16]]:1: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] + // CHECK:STDERR: fn Eq(a: Core.FloatLiteral(), b: Core.FloatLiteral()) -> bool = "float.eq"; + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: + Eq(1.0, n); + // CHECK:STDERR: fail_runtime_literal.carbon:[[@LINE+7]]:3: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] + // CHECK:STDERR: Eq(n, n); + // CHECK:STDERR: ^~~~~~~~ + // CHECK:STDERR: fail_runtime_literal.carbon:[[@LINE-24]]:1: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] + // CHECK:STDERR: fn Eq(a: Core.FloatLiteral(), b: Core.FloatLiteral()) -> bool = "float.eq"; + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: + Eq(n, n); +} + // CHECK:STDOUT: --- float_eq.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { diff --git a/toolchain/check/testdata/builtins/float/less_eq.carbon b/toolchain/check/testdata/builtins/float/less_eq.carbon index 7fe6e0f615e6..8f3e787bbe06 100644 --- a/toolchain/check/testdata/builtins/float/less_eq.carbon +++ b/toolchain/check/testdata/builtins/float/less_eq.carbon @@ -32,6 +32,41 @@ fn RuntimeCallIsValid(a: f64, b: f64) -> bool { //@dump-sem-ir-end } +// --- fail_runtime_literal.carbon + +library "[[@TEST_NAME]]"; + +fn LessEq(a: Core.FloatLiteral(), b: Core.FloatLiteral()) -> bool = "float.less_eq"; + +fn Test(n: Core.FloatLiteral()) { + // OK + LessEq(1.0, 1.0); + // CHECK:STDERR: fail_runtime_literal.carbon:[[@LINE+7]]:3: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] + // CHECK:STDERR: LessEq(n, 1.0); + // CHECK:STDERR: ^~~~~~~~~~~~~~ + // CHECK:STDERR: fail_runtime_literal.carbon:[[@LINE-8]]:1: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] + // CHECK:STDERR: fn LessEq(a: Core.FloatLiteral(), b: Core.FloatLiteral()) -> bool = "float.less_eq"; + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: + LessEq(n, 1.0); + // CHECK:STDERR: fail_runtime_literal.carbon:[[@LINE+7]]:3: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] + // CHECK:STDERR: LessEq(1.0, n); + // CHECK:STDERR: ^~~~~~~~~~~~~~ + // CHECK:STDERR: fail_runtime_literal.carbon:[[@LINE-16]]:1: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] + // CHECK:STDERR: fn LessEq(a: Core.FloatLiteral(), b: Core.FloatLiteral()) -> bool = "float.less_eq"; + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: + LessEq(1.0, n); + // CHECK:STDERR: fail_runtime_literal.carbon:[[@LINE+7]]:3: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] + // CHECK:STDERR: LessEq(n, n); + // CHECK:STDERR: ^~~~~~~~~~~~ + // CHECK:STDERR: fail_runtime_literal.carbon:[[@LINE-24]]:1: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] + // CHECK:STDERR: fn LessEq(a: Core.FloatLiteral(), b: Core.FloatLiteral()) -> bool = "float.less_eq"; + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: + LessEq(n, n); +} + // CHECK:STDOUT: --- float_less_eq.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { diff --git a/toolchain/check/testdata/builtins/float/mul.carbon b/toolchain/check/testdata/builtins/float/mul.carbon index 2f42786e4c68..bed17df8898d 100644 --- a/toolchain/check/testdata/builtins/float/mul.carbon +++ b/toolchain/check/testdata/builtins/float/mul.carbon @@ -66,6 +66,36 @@ fn RuntimeCallIsValidBadReturnType(a: f64, b: f64) -> bool { return BadReturnType(a, b); } +// --- literal.carbon + +library "[[@TEST_NAME]]"; + +fn Literal() -> type = "float_literal.make_type"; +fn MulLiteral(a: Literal(), b: Literal()) -> Literal() = "float.mul"; + +// --- literal_comptime.carbon + +library "[[@TEST_NAME]]"; +import library "literal"; + +let n: Literal() = MulLiteral(1.0, 2.0); + +// --- fail_literal_runtime.carbon + +library "[[@TEST_NAME]]"; +import library "literal"; + +var m: Literal(); +// CHECK:STDERR: fail_literal_runtime.carbon:[[@LINE+8]]:20: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] +// CHECK:STDERR: let n: Literal() = MulLiteral(1.0, m); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_literal_runtime.carbon:[[@LINE-6]]:1: in import [InImport] +// CHECK:STDERR: literal.carbon:5:1: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] +// CHECK:STDERR: fn MulLiteral(a: Literal(), b: Literal()) -> Literal() = "float.mul"; +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let n: Literal() = MulLiteral(1.0, m); + // CHECK:STDOUT: --- mul_sub.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { diff --git a/toolchain/check/testdata/builtins/float/mul_assign.carbon b/toolchain/check/testdata/builtins/float/mul_assign.carbon index d84d1ca20947..43dfa6a69132 100644 --- a/toolchain/check/testdata/builtins/float/mul_assign.carbon +++ b/toolchain/check/testdata/builtins/float/mul_assign.carbon @@ -12,7 +12,7 @@ // --- call.carbon -library "call"; +library "[[@TEST_NAME]]"; fn Builtin(a: f64*, b: f64) = "float.mul_assign"; @@ -22,7 +22,7 @@ fn Call(a: f64*, b: f64) { // --- fail_bad_decl.carbon -library "fail_bad_decl"; +library "[[@TEST_NAME]]"; // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "float.mul_assign" [InvalidBuiltinSignature] // CHECK:STDERR: fn NotPtr(a: f64, b: f64) = "float.mul_assign"; @@ -42,3 +42,14 @@ fn NotPtr(a: f64, b: f64) = "float.mul_assign"; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fn MixedTypes(a: f64*, b: f32) = "float.mul_assign"; + +// --- fail_literal.carbon + +library "[[@TEST_NAME]]"; + +fn Literal() -> type = "float_literal.make_type"; +// CHECK:STDERR: fail_literal.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "float.mul_assign" [InvalidBuiltinSignature] +// CHECK:STDERR: fn LiteralRuntime(a: Literal()*, b: Literal()) = "float.mul_assign"; +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +fn LiteralRuntime(a: Literal()*, b: Literal()) = "float.mul_assign"; diff --git a/toolchain/check/testdata/builtins/float/sub.carbon b/toolchain/check/testdata/builtins/float/sub.carbon index 85facdffba72..db109dcf2c23 100644 --- a/toolchain/check/testdata/builtins/float/sub.carbon +++ b/toolchain/check/testdata/builtins/float/sub.carbon @@ -66,6 +66,36 @@ fn RuntimeCallIsValidBadReturnType(a: f64, b: f64) -> bool { return BadReturnType(a, b); } +// --- literal.carbon + +library "[[@TEST_NAME]]"; + +fn Literal() -> type = "float_literal.make_type"; +fn SubLiteral(a: Literal(), b: Literal()) -> Literal() = "float.sub"; + +// --- literal_comptime.carbon + +library "[[@TEST_NAME]]"; +import library "literal"; + +let n: Literal() = SubLiteral(1.0, 2.0); + +// --- fail_literal_runtime.carbon + +library "[[@TEST_NAME]]"; +import library "literal"; + +var m: Literal(); +// CHECK:STDERR: fail_literal_runtime.carbon:[[@LINE+8]]:20: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] +// CHECK:STDERR: let n: Literal() = SubLiteral(1.0, m); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_literal_runtime.carbon:[[@LINE-6]]:1: in import [InImport] +// CHECK:STDERR: literal.carbon:5:1: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] +// CHECK:STDERR: fn SubLiteral(a: Literal(), b: Literal()) -> Literal() = "float.sub"; +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let n: Literal() = SubLiteral(1.0, m); + // CHECK:STDOUT: --- float_sub.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { diff --git a/toolchain/check/testdata/builtins/float/sub_assign.carbon b/toolchain/check/testdata/builtins/float/sub_assign.carbon index 160e0494b086..35d368b4666f 100644 --- a/toolchain/check/testdata/builtins/float/sub_assign.carbon +++ b/toolchain/check/testdata/builtins/float/sub_assign.carbon @@ -12,7 +12,7 @@ // --- call.carbon -library "call"; +library "[[@TEST_NAME]]"; fn Builtin(a: f64*, b: f64) = "float.sub_assign"; @@ -22,7 +22,7 @@ fn Call(a: f64*, b: f64) { // --- fail_bad_decl.carbon -library "fail_bad_decl"; +library "[[@TEST_NAME]]"; // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "float.sub_assign" [InvalidBuiltinSignature] // CHECK:STDERR: fn NotPtr(a: f64, b: f64) = "float.sub_assign"; @@ -42,3 +42,14 @@ fn NotPtr(a: f64, b: f64) = "float.sub_assign"; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fn MixedTypes(a: f64*, b: f32) = "float.sub_assign"; + +// --- fail_literal.carbon + +library "[[@TEST_NAME]]"; + +fn Literal() -> type = "float_literal.make_type"; +// CHECK:STDERR: fail_literal.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "float.sub_assign" [InvalidBuiltinSignature] +// CHECK:STDERR: fn LiteralRuntime(a: Literal()*, b: Literal()) = "float.sub_assign"; +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +fn LiteralRuntime(a: Literal()*, b: Literal()) = "float.sub_assign"; 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 b170ee4c3a9b..8d3d79c5352f 100644 --- a/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon +++ b/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon @@ -36,7 +36,7 @@ fn Run() { // CHECK:STDOUT: %pattern_type.0ae: type = pattern_type %f64.d77 [concrete] // CHECK:STDOUT: %Foo.type: type = fn_type @Foo [concrete] // CHECK:STDOUT: %Foo: %Foo.type = struct_value () [concrete] -// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 1 [concrete] +// CHECK:STDOUT: %float.a31: Core.FloatLiteral = 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: %ImplicitAs.type.6ec: type = facet_type <@ImplicitAs, @ImplicitAs(%f64.d77)> [concrete] @@ -50,9 +50,10 @@ fn Run() { // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.baf = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.6ec = facet_value Core.FloatLiteral, (%ImplicitAs.impl_witness.857) [concrete] // CHECK:STDOUT: %.678: type = fn_type_with_self_type %ImplicitAs.Convert.type.726, %ImplicitAs.facet [concrete] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound: = bound_method %float, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03 [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound: = bound_method %float.a31, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03 [concrete] // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(%int_64) [concrete] -// CHECK:STDOUT: %bound_method: = bound_method %float, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %bound_method: = bound_method %float.a31, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.d20: %f64.d77 = 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] @@ -104,14 +105,14 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Foo() -> %f64.d77 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 1 [concrete = constants.%float] +// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 1 [concrete = constants.%float.a31] // CHECK:STDOUT: %impl.elem0: %.678 = impl_witness_access constants.%ImplicitAs.impl_witness.857, element0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03] // CHECK:STDOUT: %bound_method.loc15_29.1: = bound_method %float, %impl.elem0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound] // CHECK:STDOUT: %specific_fn: = specific_function %impl.elem0, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc15_29.2: = bound_method %float, %specific_fn [concrete = constants.%bound_method] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call: init %f64.d77 = call %bound_method.loc15_29.2(%float) [concrete = constants.%float] -// CHECK:STDOUT: %.loc15_29.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%float] -// CHECK:STDOUT: %.loc15_29.2: %f64.d77 = converted %float, %.loc15_29.1 [concrete = constants.%float] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call: init %f64.d77 = call %bound_method.loc15_29.2(%float) [concrete = constants.%float.d20] +// CHECK:STDOUT: %.loc15_29.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%float.d20] +// CHECK:STDOUT: %.loc15_29.2: %f64.d77 = converted %float, %.loc15_29.1 [concrete = constants.%float.d20] // CHECK:STDOUT: return %.loc15_29.2 // CHECK:STDOUT: } // CHECK:STDOUT: 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 c59559767efc..0fa490a543d8 100644 --- a/toolchain/check/testdata/interop/cpp/function/arithmetic_types_bridged.carbon +++ b/toolchain/check/testdata/interop/cpp/function/arithmetic_types_bridged.carbon @@ -1342,7 +1342,7 @@ fn F() { // CHECK:STDOUT: %ptr.bcc: type = ptr_type %f64.d77 [concrete] // CHECK:STDOUT: %foo__carbon_thunk.type: type = fn_type @foo__carbon_thunk [concrete] // CHECK:STDOUT: %foo__carbon_thunk: %foo__carbon_thunk.type = struct_value () [concrete] -// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 0.80000000000000004 [concrete] +// CHECK:STDOUT: %float.c15: Core.FloatLiteral = float_value 0.80000000000000004 [concrete] // CHECK:STDOUT: %As.type.6d2: type = facet_type <@As, @As(%f64.d77)> [concrete] // CHECK:STDOUT: %As.Convert.type.8fc: type = fn_type @As.Convert, @As(%f64.d77) [concrete] // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic] @@ -1353,9 +1353,10 @@ fn F() { // CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.6ae: %Core.FloatLiteral.as.As.impl.Convert.type.12c = struct_value () [concrete] // CHECK:STDOUT: %As.facet: %As.type.6d2 = facet_value Core.FloatLiteral, (%As.impl_witness.a23) [concrete] // CHECK:STDOUT: %.d03: type = fn_type_with_self_type %As.Convert.type.8fc, %As.facet [concrete] -// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.bound: = bound_method %float, %Core.FloatLiteral.as.As.impl.Convert.6ae [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.bound: = bound_method %float.c15, %Core.FloatLiteral.as.As.impl.Convert.6ae [concrete] // CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.specific_fn: = specific_function %Core.FloatLiteral.as.As.impl.Convert.6ae, @Core.FloatLiteral.as.As.impl.Convert(%int_64) [concrete] -// CHECK:STDOUT: %bound_method: = bound_method %float, %Core.FloatLiteral.as.As.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %bound_method: = bound_method %float.c15, %Core.FloatLiteral.as.As.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.0fc: %f64.d77 = float_value 0.80000000000000004 [concrete] // CHECK:STDOUT: %Float.as.Destroy.impl.Op.type.cd5: type = fn_type @Float.as.Destroy.impl.Op, @Float.as.Destroy.impl(%int_64) [concrete] // CHECK:STDOUT: %Float.as.Destroy.impl.Op.b8c: %Float.as.Destroy.impl.Op.type.cd5 = struct_value () [concrete] // CHECK:STDOUT: } @@ -1383,16 +1384,16 @@ 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: Core.FloatLiteral = float_value 0.80000000000000004 [concrete = constants.%float] +// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 0.80000000000000004 [concrete = constants.%float.c15] // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] // CHECK:STDOUT: %f64: type = class_type @Float, @Float(constants.%int_64) [concrete = constants.%f64.d77] // CHECK:STDOUT: %impl.elem0: %.d03 = impl_witness_access constants.%As.impl_witness.a23, element0 [concrete = constants.%Core.FloatLiteral.as.As.impl.Convert.6ae] // CHECK:STDOUT: %bound_method.loc8_15.1: = bound_method %float, %impl.elem0 [concrete = constants.%Core.FloatLiteral.as.As.impl.Convert.bound] // CHECK:STDOUT: %specific_fn: = specific_function %impl.elem0, @Core.FloatLiteral.as.As.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.As.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc8_15.2: = bound_method %float, %specific_fn [concrete = constants.%bound_method] -// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.call: init %f64.d77 = call %bound_method.loc8_15.2(%float) [concrete = constants.%float] -// CHECK:STDOUT: %.loc8_15.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.As.impl.Convert.call [concrete = constants.%float] -// CHECK:STDOUT: %.loc8_15.2: %f64.d77 = converted %float, %.loc8_15.1 [concrete = constants.%float] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.call: init %f64.d77 = call %bound_method.loc8_15.2(%float) [concrete = constants.%float.0fc] +// CHECK:STDOUT: %.loc8_15.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.As.impl.Convert.call [concrete = constants.%float.0fc] +// CHECK:STDOUT: %.loc8_15.2: %f64.d77 = converted %float, %.loc8_15.1 [concrete = constants.%float.0fc] // CHECK:STDOUT: %.loc8_15.3: ref %f64.d77 = temporary_storage // CHECK:STDOUT: %.loc8_15.4: ref %f64.d77 = temporary %.loc8_15.3, %.loc8_15.2 // CHECK:STDOUT: %addr.loc8_21: %ptr.bcc = addr_of %.loc8_15.4 diff --git a/toolchain/check/testdata/return/fail_returned_var_type.carbon b/toolchain/check/testdata/return/fail_returned_var_type.carbon index e7ea145deae5..edd8fd8013a9 100644 --- a/toolchain/check/testdata/return/fail_returned_var_type.carbon +++ b/toolchain/check/testdata/return/fail_returned_var_type.carbon @@ -40,7 +40,7 @@ fn Mismatch() -> i32 { // CHECK:STDOUT: %Float.generic: %Float.type = struct_value () [concrete] // CHECK:STDOUT: %f64.d77: type = class_type @Float, @Float(%int_64) [concrete] // CHECK:STDOUT: %pattern_type.0ae: type = pattern_type %f64.d77 [concrete] -// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 0 [concrete] +// CHECK:STDOUT: %float.be6: Core.FloatLiteral = float_value 0 [concrete] // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete] // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.type.6ec: type = facet_type <@ImplicitAs, @ImplicitAs(%f64.d77)> [concrete] @@ -54,9 +54,10 @@ fn Mismatch() -> i32 { // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.baf = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.6ec = facet_value Core.FloatLiteral, (%ImplicitAs.impl_witness.857) [concrete] // CHECK:STDOUT: %.678: type = fn_type_with_self_type %ImplicitAs.Convert.type.726, %ImplicitAs.facet [concrete] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound: = bound_method %float, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03 [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound: = bound_method %float.be6, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03 [concrete] // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(%int_64) [concrete] -// CHECK:STDOUT: %bound_method: = bound_method %float, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %bound_method: = bound_method %float.be6, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.0a8: %f64.d77 = float_value 0 [concrete] // CHECK:STDOUT: %Float.as.Destroy.impl.Op.type.cd5: type = fn_type @Float.as.Destroy.impl.Op, @Float.as.Destroy.impl(%int_64) [concrete] // CHECK:STDOUT: %Float.as.Destroy.impl.Op.b8c: %Float.as.Destroy.impl.Op.type.cd5 = struct_value () [concrete] // CHECK:STDOUT: %ptr.bcc: type = ptr_type %f64.d77 [concrete] @@ -104,13 +105,13 @@ fn Mismatch() -> i32 { // CHECK:STDOUT: %v.var_patt: %pattern_type.0ae = var_pattern %v.patt [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %f64.d77 = var %v.var_patt -// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 0 [concrete = constants.%float] +// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 0 [concrete = constants.%float.be6] // CHECK:STDOUT: %impl.elem0: %.678 = impl_witness_access constants.%ImplicitAs.impl_witness.857, element0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03] // CHECK:STDOUT: %bound_method.loc23_12.1: = bound_method %float, %impl.elem0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound] // CHECK:STDOUT: %specific_fn: = specific_function %impl.elem0, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc23_12.2: = bound_method %float, %specific_fn [concrete = constants.%bound_method] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call: init %f64.d77 = call %bound_method.loc23_12.2(%float) [concrete = constants.%float] -// CHECK:STDOUT: %.loc23_12: init %f64.d77 = converted %float, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%float] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call: init %f64.d77 = call %bound_method.loc23_12.2(%float) [concrete = constants.%float.0a8] +// CHECK:STDOUT: %.loc23_12: init %f64.d77 = converted %float, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%float.0a8] // CHECK:STDOUT: assign %v.var, %.loc23_12 // CHECK:STDOUT: %.loc23_19: type = splice_block %f64 [concrete = constants.%f64.d77] { // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] diff --git a/toolchain/check/testdata/struct/fail_member_access_type.carbon b/toolchain/check/testdata/struct/fail_member_access_type.carbon index ff14fc7f5334..ca26c14b1cda 100644 --- a/toolchain/check/testdata/struct/fail_member_access_type.carbon +++ b/toolchain/check/testdata/struct/fail_member_access_type.carbon @@ -28,7 +28,7 @@ var y: i32 = x.b; // CHECK:STDOUT: %f64.d77: type = class_type @Float, @Float(%int_64) [concrete] // CHECK:STDOUT: %struct_type.a.5e8: type = struct_type {.a: %f64.d77} [concrete] // CHECK:STDOUT: %pattern_type.8ce: type = pattern_type %struct_type.a.5e8 [concrete] -// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 4 [concrete] +// CHECK:STDOUT: %float.3ab: Core.FloatLiteral = float_value 4 [concrete] // CHECK:STDOUT: %struct_type.a.b4b: type = struct_type {.a: Core.FloatLiteral} [concrete] // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete] // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete] @@ -42,10 +42,11 @@ var y: i32 = x.b; // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.baf = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.6ec = facet_value Core.FloatLiteral, (%ImplicitAs.impl_witness.857) [concrete] // CHECK:STDOUT: %.678: type = fn_type_with_self_type %ImplicitAs.Convert.type.726, %ImplicitAs.facet [concrete] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound: = bound_method %float, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03 [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound: = bound_method %float.3ab, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03 [concrete] // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(%int_64) [concrete] -// CHECK:STDOUT: %bound_method: = bound_method %float, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] -// CHECK:STDOUT: %struct: %struct_type.a.5e8 = struct_value (%float) [concrete] +// CHECK:STDOUT: %bound_method: = bound_method %float.3ab, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.d15: %f64.d77 = float_value 4 [concrete] +// CHECK:STDOUT: %struct: %struct_type.a.5e8 = struct_value (%float.d15) [concrete] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete] // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete] @@ -100,14 +101,14 @@ var y: i32 = x.b; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 4 [concrete = constants.%float] +// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 4 [concrete = constants.%float.3ab] // CHECK:STDOUT: %.loc15_29.1: %struct_type.a.b4b = struct_literal (%float) // CHECK:STDOUT: %impl.elem0: %.678 = impl_witness_access constants.%ImplicitAs.impl_witness.857, element0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03] // CHECK:STDOUT: %bound_method.loc15_29.1: = bound_method %float, %impl.elem0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound] // CHECK:STDOUT: %specific_fn: = specific_function %impl.elem0, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc15_29.2: = bound_method %float, %specific_fn [concrete = constants.%bound_method] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call: init %f64.d77 = call %bound_method.loc15_29.2(%float) [concrete = constants.%float] -// CHECK:STDOUT: %.loc15_29.2: init %f64.d77 = converted %float, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%float] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call: init %f64.d77 = call %bound_method.loc15_29.2(%float) [concrete = constants.%float.d15] +// CHECK:STDOUT: %.loc15_29.2: init %f64.d77 = converted %float, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%float.d15] // CHECK:STDOUT: %.loc15_29.3: init %struct_type.a.5e8 = struct_init (%.loc15_29.2) to file.%x.var [concrete = constants.%struct] // CHECK:STDOUT: %.loc15_1: init %struct_type.a.5e8 = converted %.loc15_29.1, %.loc15_29.3 [concrete = constants.%struct] // CHECK:STDOUT: assign file.%x.var, %.loc15_1 diff --git a/toolchain/check/testdata/struct/member_access.carbon b/toolchain/check/testdata/struct/member_access.carbon index aa5a1dd37802..823e11e18338 100644 --- a/toolchain/check/testdata/struct/member_access.carbon +++ b/toolchain/check/testdata/struct/member_access.carbon @@ -29,7 +29,7 @@ var z: i32 = y; // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] // CHECK:STDOUT: %struct_type.a.b.d2f: type = struct_type {.a: %f64.d77, .b: %i32} [concrete] // CHECK:STDOUT: %pattern_type.a7a: type = pattern_type %struct_type.a.b.d2f [concrete] -// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 0 [concrete] +// CHECK:STDOUT: %float.be6: Core.FloatLiteral = float_value 0 [concrete] // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete] // CHECK:STDOUT: %struct_type.a.b.0cc: type = struct_type {.a: Core.FloatLiteral, .b: Core.IntLiteral} [concrete] // CHECK:STDOUT: %.bc0: ref %f64.d77 = struct_access file.%x.var, element0 [concrete] @@ -45,9 +45,10 @@ var z: i32 = y; // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.baf = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet.8d0: %ImplicitAs.type.6ec = facet_value Core.FloatLiteral, (%ImplicitAs.impl_witness.857) [concrete] // CHECK:STDOUT: %.678: type = fn_type_with_self_type %ImplicitAs.Convert.type.726, %ImplicitAs.facet.8d0 [concrete] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound: = bound_method %float, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03 [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound: = bound_method %float.be6, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03 [concrete] // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(%int_64) [concrete] -// CHECK:STDOUT: %bound_method.71f: = bound_method %float, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %bound_method.71f: = bound_method %float.be6, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.0a8: %f64.d77 = float_value 0 [concrete] // CHECK:STDOUT: %.a00: ref %i32 = struct_access file.%x.var, element1 [concrete] // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete] // CHECK:STDOUT: %ImplicitAs.Convert.type.1b6: type = fn_type @ImplicitAs.Convert, @ImplicitAs(%i32) [concrete] @@ -63,7 +64,7 @@ var z: i32 = y; // 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.9a1: = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete] -// CHECK:STDOUT: %struct: %struct_type.a.b.d2f = struct_value (%float, %int_1.5d2) [concrete] +// CHECK:STDOUT: %struct: %struct_type.a.b.d2f = struct_value (%float.0a8, %int_1.5d2) [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -128,17 +129,17 @@ var z: i32 = y; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 0 [concrete = constants.%float] +// CHECK:STDOUT: %float: Core.FloatLiteral = float_value 0 [concrete = constants.%float.be6] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] // CHECK:STDOUT: %.loc15_46.1: %struct_type.a.b.0cc = struct_literal (%float, %int_1) // CHECK:STDOUT: %impl.elem0.loc15_46.1: %.678 = impl_witness_access constants.%ImplicitAs.impl_witness.857, element0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.a03] // CHECK:STDOUT: %bound_method.loc15_46.1: = bound_method %float, %impl.elem0.loc15_46.1 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound] // CHECK:STDOUT: %specific_fn.loc15_46.1: = specific_function %impl.elem0.loc15_46.1, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc15_46.2: = bound_method %float, %specific_fn.loc15_46.1 [concrete = constants.%bound_method.71f] -// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call: init %f64.d77 = call %bound_method.loc15_46.2(%float) [concrete = constants.%float] -// CHECK:STDOUT: %.loc15_46.2: init %f64.d77 = converted %float, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%float] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call: init %f64.d77 = call %bound_method.loc15_46.2(%float) [concrete = constants.%float.0a8] +// CHECK:STDOUT: %.loc15_46.2: init %f64.d77 = converted %float, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%float.0a8] // CHECK:STDOUT: %.loc15_46.3: ref %f64.d77 = struct_access file.%x.var, element0 [concrete = constants.%.bc0] -// CHECK:STDOUT: %.loc15_46.4: init %f64.d77 = initialize_from %.loc15_46.2 to %.loc15_46.3 [concrete = constants.%float] +// CHECK:STDOUT: %.loc15_46.4: init %f64.d77 = initialize_from %.loc15_46.2 to %.loc15_46.3 [concrete = constants.%float.0a8] // CHECK:STDOUT: %impl.elem0.loc15_46.2: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.956] // CHECK:STDOUT: %bound_method.loc15_46.3: = bound_method %int_1, %impl.elem0.loc15_46.2 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] // CHECK:STDOUT: %specific_fn.loc15_46.2: = specific_function %impl.elem0.loc15_46.2, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] diff --git a/toolchain/check/type_completion.cpp b/toolchain/check/type_completion.cpp index 16d100b4006b..741db74bec97 100644 --- a/toolchain/check/type_completion.cpp +++ b/toolchain/check/type_completion.cpp @@ -89,8 +89,8 @@ class TypeCompleter { requires(InstT::Kind.template IsAnyOf< SemIR::AutoType, SemIR::BoolType, SemIR::BoundMethodType, SemIR::CharLiteralType, SemIR::ErrorInst, SemIR::FacetType, - SemIR::FloatType, SemIR::IntType, SemIR::IntLiteralType, - SemIR::LegacyFloatType, SemIR::NamespaceType, SemIR::PatternType, + SemIR::FloatLiteralType, SemIR::FloatType, SemIR::IntType, + SemIR::IntLiteralType, SemIR::NamespaceType, SemIR::PatternType, SemIR::PointerType, SemIR::SpecificFunctionType, SemIR::TypeType, SemIR::VtableType, SemIR::WitnessType>()) auto BuildInfoForInst(SemIR::TypeId type_id, InstT /*inst*/) const diff --git a/toolchain/lower/constant.cpp b/toolchain/lower/constant.cpp index 12cc4ad8a769..858c8947a436 100644 --- a/toolchain/lower/constant.cpp +++ b/toolchain/lower/constant.cpp @@ -49,9 +49,9 @@ class ConstantContext { return nullptr; } - // Gets the value to use for an integer literal. - auto GetIntLiteralAsValue() const -> llvm::Constant* { - return file_context_->GetIntLiteralAsValue(); + // Gets the value to use for a literal. + auto GetLiteralAsValue() const -> llvm::Constant* { + return file_context_->GetLiteralAsValue(); } // Gets a callable's function. Returns nullptr for a builtin. @@ -215,8 +215,7 @@ static auto EmitAsConstant(ConstantContext& context, SemIR::BoundMethod inst) static auto EmitAsConstant(ConstantContext& context, SemIR::CharLiteralValue /*inst*/) -> llvm::Constant* { - return llvm::ConstantStruct::get( - llvm::StructType::get(context.llvm_context())); + return context.GetLiteralAsValue(); } static auto EmitAsConstant(ConstantContext& context, @@ -231,6 +230,16 @@ static auto EmitAsConstant(ConstantContext& context, SemIR::FieldDecl inst) static auto EmitAsConstant(ConstantContext& context, SemIR::FloatValue inst) -> llvm::Constant* { + auto* type = context.GetType(inst.type_id); + + // FloatLiteral is represented as an empty struct. All other floating-point + // types are represented as LLVM floating-point types. + if (!type->isFloatingPointTy()) { + auto* literal_value = context.GetLiteralAsValue(); + CARBON_CHECK(literal_value->getType() == type); + return literal_value; + } + const llvm::APFloat& value = context.sem_ir().floats().Get(inst.float_id); return llvm::ConstantFP::get(context.GetType(inst.type_id), value); } @@ -243,9 +252,9 @@ static auto EmitAsConstant(ConstantContext& context, SemIR::IntValue inst) // represented as an LLVM integer type. auto* int_type = dyn_cast(type); if (!int_type) { - auto* int_literal_value = context.GetIntLiteralAsValue(); - CARBON_CHECK(int_literal_value->getType() == type); - return int_literal_value; + auto* literal_value = context.GetLiteralAsValue(); + CARBON_CHECK(literal_value->getType() == type); + return literal_value; } int bit_width = int_type->getBitWidth(); diff --git a/toolchain/lower/context.h b/toolchain/lower/context.h index aac7e736a256..84fa7108d124 100644 --- a/toolchain/lower/context.h +++ b/toolchain/lower/context.h @@ -75,9 +75,9 @@ class Context { return llvm::ConstantStruct::get(GetTypeType()); } - // Returns a lowered value to use for a value of int literal type. - auto GetIntLiteralAsValue() -> llvm::Constant* { - // TODO: Consider adding a named struct type for integer literals. + // Returns a lowered value to use for a value of literal type. + auto GetLiteralAsValue() -> llvm::Constant* { + // TODO: Consider adding a named struct type for literals. return llvm::ConstantStruct::get(llvm::StructType::get(llvm_context())); } diff --git a/toolchain/lower/file_context.cpp b/toolchain/lower/file_context.cpp index 0e734be2b851..c266b1ab92d8 100644 --- a/toolchain/lower/file_context.cpp +++ b/toolchain/lower/file_context.cpp @@ -810,11 +810,6 @@ static auto BuildTypeForInst(FileContext& context, SemIR::IntType inst) context.sem_ir().ints().Get(width->int_id).getZExtValue()); } -static auto BuildTypeForInst(FileContext& context, - SemIR::LegacyFloatType /*inst*/) -> llvm::Type* { - return llvm::Type::getDoubleTy(context.llvm_context()); -} - static auto BuildTypeForInst(FileContext& context, SemIR::PointerType /*inst*/) -> llvm::Type* { return llvm::PointerType::get(context.llvm_context(), /*AddressSpace=*/0); @@ -872,9 +867,10 @@ static auto BuildTypeForInst(FileContext& context, InstT /*inst*/) } template - requires(InstT::Kind.template IsAnyOf< - SemIR::BoundMethodType, SemIR::CharLiteralType, - SemIR::IntLiteralType, SemIR::NamespaceType, SemIR::WitnessType>()) + requires(InstT::Kind + .template IsAnyOf()) static auto BuildTypeForInst(FileContext& context, InstT /*inst*/) -> llvm::Type* { // Return an empty struct as a placeholder. diff --git a/toolchain/lower/file_context.h b/toolchain/lower/file_context.h index 0987f87e5bfa..649ecddec960 100644 --- a/toolchain/lower/file_context.h +++ b/toolchain/lower/file_context.h @@ -72,9 +72,9 @@ class FileContext { return context().GetTypeAsValue(); } - // Returns a lowered value to use for a value of int literal type. - auto GetIntLiteralAsValue() -> llvm::Constant* { - return context().GetIntLiteralAsValue(); + // Returns a lowered value to use for a value of literal type. + auto GetLiteralAsValue() -> llvm::Constant* { + return context().GetLiteralAsValue(); } // Returns a value for the given constant. If specified, `use_inst_id` is the diff --git a/toolchain/lower/function_context.h b/toolchain/lower/function_context.h index 9becd7b4d207..5009ebc7d62f 100644 --- a/toolchain/lower/function_context.h +++ b/toolchain/lower/function_context.h @@ -170,9 +170,9 @@ class FunctionContext { return file_context_->GetTypeAsValue(); } - // Returns a lowered value to use for a value of int literal type. - auto GetIntLiteralAsValue() -> llvm::Constant* { - return file_context_->GetIntLiteralAsValue(); + // Returns a lowered value to use for a value of literal type. + auto GetLiteralAsValue() -> llvm::Constant* { + return file_context_->GetLiteralAsValue(); } // Create a synthetic block that corresponds to no SemIR::InstBlockId. Such diff --git a/toolchain/lower/mangler.cpp b/toolchain/lower/mangler.cpp index 3491688c746d..682cfc029da7 100644 --- a/toolchain/lower/mangler.cpp +++ b/toolchain/lower/mangler.cpp @@ -86,8 +86,8 @@ auto Mangler::MangleInverseQualifiedNameScope(llvm::raw_ostream& os, case SemIR::AutoType::Kind: case SemIR::BoolType::Kind: case SemIR::BoundMethodType::Kind: + case SemIR::FloatLiteralType::Kind: case SemIR::IntLiteralType::Kind: - case SemIR::LegacyFloatType::Kind: case SemIR::NamespaceType::Kind: case SemIR::SpecificFunctionType::Kind: case SemIR::StringType::Kind: diff --git a/toolchain/lower/testdata/array/base.carbon b/toolchain/lower/testdata/array/base.carbon index 1db76e9c77de..b441a9ed344b 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.fc9.loc15_3 = internal constant [2 x double] [double 0x4026333333333334, double 2.200000e+00] +// CHECK:STDOUT: @array.42a.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.3.array.index = getelementptr inbounds [2 x double], ptr %b.var, i32 0, i64 0, !dbg !13 // CHECK:STDOUT: %.loc15_37.6.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.fc9.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.42a.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 cceafbf181c3..fa9d87be7931 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.165.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.6e0.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.12.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i64 3, !dbg !10 // CHECK:STDOUT: %.loc29_3.15.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i64 4, !dbg !10 // CHECK:STDOUT: %.loc29_3.18.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.165.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.6e0.loc22_3, i64 48, i1 false), !dbg !8 // CHECK:STDOUT: ret void, !dbg !11 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/sem_ir/builtin_function_kind.cpp b/toolchain/sem_ir/builtin_function_kind.cpp index a989cb30be0d..8ffe7a7b941a 100644 --- a/toolchain/sem_ir/builtin_function_kind.cpp +++ b/toolchain/sem_ir/builtin_function_kind.cpp @@ -148,8 +148,8 @@ struct AnyFloat { static auto Check(const File& sem_ir, ValidateState& state, TypeId type_id) -> bool { return AnySizedFloat::Check(sem_ir, state, type_id) || - BuiltinType::Check(sem_ir, state, - type_id); + BuiltinType::Check(sem_ir, state, + type_id); } }; @@ -166,13 +166,7 @@ auto Check(const File& sem_ir, ValidateState& state, TypeId type_id) -> bool { } // Also allow a class type that adapts a matching type. - auto class_type = sem_ir.types().TryGetAs(type_id); - if (!class_type) { - break; - } - type_id = sem_ir.classes() - .Get(class_type->class_id) - .GetAdaptedType(sem_ir, class_type->specific_id); + type_id = sem_ir.types().GetAdaptedType(type_id); } return false; } @@ -263,6 +257,10 @@ using FloatT = TypeParam<0, AnyFloat>; // generic type parameter that is constrained to be an float type. using FloatU = TypeParam<1, AnyFloat>; +// Convenience name used in the builtin type signatures below for a first +// generic type parameter that is constrained to be a sized float type. +using SizedFloatT = TypeParam<0, AnySizedFloat>; + // Not a builtin function. constexpr BuiltinInfo None = {"", nullptr}; @@ -516,22 +514,22 @@ constexpr BuiltinInfo FloatDiv = { // "float.add_assign": float in-place addition. constexpr BuiltinInfo FloatAddAssign = { "float.add_assign", - ValidateSignature, FloatT)->NoReturn>}; + ValidateSignature, SizedFloatT)->NoReturn>}; // "float.sub_assign": float in-place subtraction. constexpr BuiltinInfo FloatSubAssign = { "float.sub_assign", - ValidateSignature, FloatT)->NoReturn>}; + ValidateSignature, SizedFloatT)->NoReturn>}; // "float.mul_assign": float in-place multiplication. constexpr BuiltinInfo FloatMulAssign = { "float.mul_assign", - ValidateSignature, FloatT)->NoReturn>}; + ValidateSignature, SizedFloatT)->NoReturn>}; // "float.div_assign": float in-place division. constexpr BuiltinInfo FloatDivAssign = { "float.div_assign", - ValidateSignature, FloatT)->NoReturn>}; + ValidateSignature, SizedFloatT)->NoReturn>}; // Converts between floating-point types, with a diagnostic if the value doesn't // fit. @@ -605,39 +603,45 @@ auto BuiltinFunctionKind::IsValidType(const File& sem_ir, return ValidateFns[AsInt()](sem_ir, arg_types, return_type); } -// Determines whether a builtin call involves an integer literal in its -// arguments or return type. If so, for many builtins we want to treat the call -// as being compile-time-only. This is because `Core.IntLiteral` has an empty -// runtime representation, and a value of that type isn't necessarily a -// compile-time constant, so an arbitrary runtime value of type -// `Core.IntLiteral` may not have a value available for the builtin to use. For -// example, given: +static auto IsLiteralType(const File& sem_ir, TypeId type_id) -> bool { + // Unwrap adapters. + type_id = sem_ir.types().GetTransitiveAdaptedType(type_id); + auto type_inst_id = sem_ir.types().GetAsInst(type_id); + return type_inst_id.Is() || + type_inst_id.Is(); +} + +// Determines whether a builtin call involves an integer or floating-point +// literal in its arguments or return type. If so, for many builtins we want to +// treat the call as being compile-time-only. This is because `Core.IntLiteral` +// and `Core.FloatLiteral` have an empty runtime representation, and a value of +// such a type isn't necessarily a compile-time constant, so an arbitrary +// runtime value of such a type may not have a value available for the builtin +// to use. For example, given: // // var n: Core.IntLiteral() = 123; // // we would be unable to lower a runtime operation such as `(1 as i32) << n` // because the runtime representation of `n` doesn't track its value at all. // -// For now, we treat all operations involving `Core.IntLiteral` as being -// compile-time-only. +// For now, we treat all operations involving `Core.IntLiteral` or +// `Core.FloatLiteral` as being compile-time-only. // // TODO: We will need to accept things like `some_i32 << 5` eventually. We could // allow builtin calls at runtime if all the IntLiteral arguments have constant // values, or add logic to the prelude to promote the `IntLiteral` operand to a // different type in such cases. // -// TODO: For now, we also treat builtins *returning* `Core.IntLiteral` as being -// compile-time-only. This is mostly done for simplicity, but should probably be -// revisited. -static auto AnyIntLiteralTypes(const File& sem_ir, - llvm::ArrayRef arg_ids, - TypeId return_type_id) -> bool { - if (sem_ir.types().Is(return_type_id)) { +// TODO: For now, we also treat builtins *returning* `Core.IntLiteral` or +// `Core.FloatLiteral` as being compile-time-only. This is mostly done for +// simplicity, but should probably be revisited. +static auto AnyLiteralTypes(const File& sem_ir, llvm::ArrayRef arg_ids, + TypeId return_type_id) -> bool { + if (IsLiteralType(sem_ir, return_type_id)) { return true; } for (auto arg_id : arg_ids) { - if (sem_ir.types().Is( - sem_ir.insts().Get(arg_id).type_id())) { + if (IsLiteralType(sem_ir, sem_ir.insts().Get(arg_id).type_id())) { return true; } } @@ -673,9 +677,20 @@ auto BuiltinFunctionKind::IsCompTimeOnly(const File& sem_ir, case IntLessEq: case IntGreater: case IntGreaterEq: - // Integer operations are compile-time-only if they involve integer - // literal types. See AnyIntLiteralTypes comment for explanation. - return AnyIntLiteralTypes(sem_ir, arg_ids, return_type_id); + case FloatNegate: + case FloatAdd: + case FloatSub: + case FloatMul: + case FloatDiv: + case FloatEq: + case FloatNeq: + case FloatLess: + case FloatLessEq: + case FloatGreater: + case FloatGreaterEq: + // Integer and floating-point operations are compile-time-only if they + // involve literal types. See AnyLiteralTypes comment for explanation. + return AnyLiteralTypes(sem_ir, arg_ids, return_type_id); case TypeAnd: return true; diff --git a/toolchain/sem_ir/expr_info.cpp b/toolchain/sem_ir/expr_info.cpp index 6c360c4c6d86..006ab160d49b 100644 --- a/toolchain/sem_ir/expr_info.cpp +++ b/toolchain/sem_ir/expr_info.cpp @@ -116,6 +116,7 @@ auto GetExprCategory(const File& file, InstId inst_id) -> ExprCategory { case FacetAccessType::Kind: case FacetType::Kind: case FacetValue::Kind: + case FloatLiteralType::Kind: case FloatType::Kind: case FloatValue::Kind: case FunctionType::Kind: @@ -136,7 +137,6 @@ auto GetExprCategory(const File& file, InstId inst_id) -> ExprCategory { case IntType::Kind: case IntValue::Kind: case InterfaceDecl::Kind: - case LegacyFloatType::Kind: case NamespaceType::Kind: case PartialType::Kind: case PatternType::Kind: diff --git a/toolchain/sem_ir/inst_kind.def b/toolchain/sem_ir/inst_kind.def index 4f86b4113474..da4db3354d9d 100644 --- a/toolchain/sem_ir/inst_kind.def +++ b/toolchain/sem_ir/inst_kind.def @@ -65,6 +65,7 @@ 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(FloatLiteralType) CARBON_SEM_IR_INST_KIND(FloatType) CARBON_SEM_IR_INST_KIND(FloatValue) CARBON_SEM_IR_INST_KIND(FunctionDecl) @@ -91,7 +92,6 @@ CARBON_SEM_IR_INST_KIND(IntLiteralType) CARBON_SEM_IR_INST_KIND(IntType) CARBON_SEM_IR_INST_KIND(IntValue) CARBON_SEM_IR_INST_KIND(InterfaceDecl) -CARBON_SEM_IR_INST_KIND(LegacyFloatType) CARBON_SEM_IR_INST_KIND(NameBindingDecl) CARBON_SEM_IR_INST_KIND(NameRef) CARBON_SEM_IR_INST_KIND(Namespace) diff --git a/toolchain/sem_ir/singleton_insts.h b/toolchain/sem_ir/singleton_insts.h index 4bdc00bdee07..d4606a414dbf 100644 --- a/toolchain/sem_ir/singleton_insts.h +++ b/toolchain/sem_ir/singleton_insts.h @@ -13,20 +13,13 @@ namespace Carbon::SemIR { // The canonical list of singleton kinds. The order of `TypeType` is // significant because other singletons use it as a type. static constexpr std::array SingletonInstKinds = { - InstKind::TypeType, - InstKind::AutoType, - InstKind::BoolType, - InstKind::BoundMethodType, - InstKind::CharLiteralType, - InstKind::ErrorInst, - InstKind::ImplWitnessTablePlaceholder, - InstKind::InstType, - InstKind::IntLiteralType, - InstKind::LegacyFloatType, - InstKind::NamespaceType, - InstKind::SpecificFunctionType, - InstKind::StringType, - InstKind::VtableType, + InstKind::TypeType, InstKind::AutoType, + InstKind::BoolType, InstKind::BoundMethodType, + InstKind::CharLiteralType, InstKind::ErrorInst, + InstKind::FloatLiteralType, InstKind::ImplWitnessTablePlaceholder, + InstKind::InstType, InstKind::IntLiteralType, + InstKind::NamespaceType, InstKind::SpecificFunctionType, + InstKind::StringType, InstKind::VtableType, InstKind::WitnessType, }; diff --git a/toolchain/sem_ir/type.cpp b/toolchain/sem_ir/type.cpp index 7c6d48e2649a..8b903a2ab3d6 100644 --- a/toolchain/sem_ir/type.cpp +++ b/toolchain/sem_ir/type.cpp @@ -73,6 +73,26 @@ auto TypeStore::GetObjectRepr(TypeId type_id) const -> TypeId { return class_info.GetObjectRepr(*file_, class_type->specific_id); } +auto TypeStore::GetAdaptedType(TypeId type_id) const -> TypeId { + if (auto class_type = TryGetAs(type_id)) { + return file_->classes() + .Get(class_type->class_id) + .GetAdaptedType(*file_, class_type->specific_id); + } + return TypeId::None; +} + +auto TypeStore::GetTransitiveAdaptedType(TypeId type_id) const -> TypeId { + while (true) { + auto adapted_type_id = GetAdaptedType(type_id); + if (!adapted_type_id.has_value()) { + break; + } + type_id = adapted_type_id; + } + return type_id; +} + auto TypeStore::GetUnqualifiedType(TypeId type_id) const -> TypeId { if (auto const_type = TryGetAs(type_id)) { return file_->types().GetTypeIdForTypeInstId(const_type->inner_id); diff --git a/toolchain/sem_ir/type.h b/toolchain/sem_ir/type.h index 3d30b74bb187..2a15769b3df6 100644 --- a/toolchain/sem_ir/type.h +++ b/toolchain/sem_ir/type.h @@ -147,6 +147,13 @@ class TypeStore : public Yaml::Printable { // cannot be determined because the type is not complete. auto GetObjectRepr(TypeId type_id) const -> TypeId; + // Get the type that the given type adapts, or `None` if the type is not known + // to be an adapter, including the case where the type is an incomplete class. + auto GetAdaptedType(TypeId type_id) const -> TypeId; + + // Returns the non-adapter type that is compatible with the specified type. + auto GetTransitiveAdaptedType(TypeId type_id) const -> TypeId; + // Determines whether the given type is known to be complete. This does not // determine whether the type could be completed, only whether it has been. auto IsComplete(TypeId type_id) const -> bool { diff --git a/toolchain/sem_ir/type_iterator.cpp b/toolchain/sem_ir/type_iterator.cpp index 32c63c36e76e..0165a85294e8 100644 --- a/toolchain/sem_ir/type_iterator.cpp +++ b/toolchain/sem_ir/type_iterator.cpp @@ -81,6 +81,7 @@ auto TypeIterator::Next() -> Step { case SemIR::BoolType::Kind: case SemIR::CharLiteralType::Kind: case SemIR::FacetType::Kind: + case SemIR::FloatLiteralType::Kind: case SemIR::FloatType::Kind: case SemIR::FunctionType::Kind: case SemIR::FunctionTypeWithSelfType::Kind: @@ -88,7 +89,6 @@ auto TypeIterator::Next() -> Step { case SemIR::GenericInterfaceType::Kind: case SemIR::ImplWitnessAccess::Kind: case SemIR::IntLiteralType::Kind: - case SemIR::LegacyFloatType::Kind: case SemIR::NamespaceType::Kind: case SemIR::StringType::Kind: case SemIR::TypeType::Kind: diff --git a/toolchain/sem_ir/typed_insts.h b/toolchain/sem_ir/typed_insts.h index 40188da0c74a..f7b4010feacf 100644 --- a/toolchain/sem_ir/typed_insts.h +++ b/toolchain/sem_ir/typed_insts.h @@ -691,6 +691,21 @@ struct FieldDecl { ElementIndex index; }; +// The float literal type. This is currently represented as f64. +// TODO: Replace this with a rational number type, following the design. +struct FloatLiteralType { + static constexpr auto Kind = + InstKind::FloatLiteralType.Define( + {.ir_name = "Core.FloatLiteral", + .is_type = InstIsType::Always, + .constant_kind = InstConstantKind::Always}); + // This is a singleton instruction. However, it may still evolve into a more + // standard type and be removed. + static constexpr auto TypeInstId = MakeSingletonTypeInstId(); + + TypeId type_id; +}; + // A floating point type. struct FloatType { static constexpr auto Kind = InstKind::FloatType.Define( @@ -1085,22 +1100,6 @@ struct IntValue { IntId int_id; }; -// The float literal type. This is currently represented as f64. -// TODO: Rename this to FloatLiteralType. -// TODO: Replace this with a rational number type, following the design. -struct LegacyFloatType { - static constexpr auto Kind = - InstKind::LegacyFloatType.Define( - {.ir_name = "Core.FloatLiteral", - .is_type = InstIsType::Always, - .constant_kind = InstConstantKind::Always}); - // This is a singleton instruction. However, it may still evolve into a more - // standard type and be removed. - static constexpr auto TypeInstId = MakeSingletonTypeInstId(); - - TypeId type_id; -}; - // A symbolic instruction that takes the place of an `ImplWitness` when the // result is not fully known. When evaluated it does an impl lookup query, based // on the stored query arguments, that a type implements an interface. The query