diff --git a/core/prelude/operators/as.carbon b/core/prelude/operators/as.carbon index 31ad271cc190..2f13b4f133ff 100644 --- a/core/prelude/operators/as.carbon +++ b/core/prelude/operators/as.carbon @@ -5,6 +5,8 @@ package Core library "prelude/operators/as"; import library "prelude/copy"; +import library "prelude/types/int_literal"; +import library "prelude/types/float_literal"; interface UnsafeAs(Dest:! type) { fn Convert[self: Self]() -> Dest; @@ -61,4 +63,14 @@ impl forall [T:! type, U:! type] T* as UnsafeAs(U*) { fn Convert[self: T*]() -> U* = "pointer.unsafe_convert"; } +// Integer literals can be implicitly converted to floating-point literals. +impl IntLiteral() as ImplicitAs(FloatLiteral()) { + fn Convert[self: Self]() -> FloatLiteral() = "int.convert_float_checked"; +} + +// Floating-point literals can be explicitly cast to integer literals. +impl FloatLiteral() as UnsafeAs(IntLiteral()) { + fn Convert[self: Self]() -> IntLiteral() = "float.convert_int"; +} + interface IntFitsIn(Dest:! type) {} diff --git a/core/prelude/types/float.carbon b/core/prelude/types/float.carbon index 96bf640a7236..1d72fb4b7146 100644 --- a/core/prelude/types/float.carbon +++ b/core/prelude/types/float.carbon @@ -9,6 +9,8 @@ import library "prelude/default"; import library "prelude/destroy"; import library "prelude/operators"; import library "prelude/types/float_literal"; +import library "prelude/types/int"; +import library "prelude/types/uint"; import library "prelude/types/int_literal"; private fn MakeFloat(size: IntLiteral()) -> type = "float.make_type"; @@ -25,9 +27,8 @@ impl forall [N:! IntLiteral()] Float(N) as Copy { fn Op[self: Self]() -> Self = "primitive_copy"; } -// Conversions. +// Conversions between floating-point types. // TODO: Support mixed-size conversions. -// TODO: Support int-to-float conversions. impl forall [N:! IntLiteral()] FloatLiteral() as ImplicitAs(Float(N)) { fn Convert[self: Self]() -> Float(N) = "float.convert_checked"; } @@ -37,6 +38,108 @@ impl forall [N:! IntLiteral()] FloatLiteral() as As(Float(N)) { fn Convert[self: Self]() -> Float(N) = "float.convert_checked"; } +// Conversions from floating-point to integer type. Always unsafe: not all +// source values fit in the target type. +final impl forall [From:! IntLiteral(), To:! IntLiteral()] + Float(From) as UnsafeAs(Int(To)) { + fn Convert[self: Self]() -> Int(To) = "float.convert_int"; +} + +final impl forall [From:! IntLiteral(), To:! IntLiteral()] + Float(From) as UnsafeAs(UInt(To)) { + fn Convert[self: Self]() -> UInt(To) = "float.convert_int"; +} + +final impl forall [From:! IntLiteral()] + Float(From) as UnsafeAs(IntLiteral()) { + fn Convert[self: Self]() -> IntLiteral() = "float.convert_int"; +} + +// Conversions from integer to floating-point type. Implicit if all source +// values can be represented exactly in the target type, otherwise explicit. +impl forall [From:! IntLiteral(), To:! IntLiteral()] + Int(From) as As(Float(To)) { + fn Convert[self: Self]() -> Float(To) = "int.convert_float"; +} + +impl forall [From:! IntLiteral(), To:! IntLiteral()] + UInt(From) as As(Float(To)) { + fn Convert[self: Self]() -> Float(To) = "int.convert_float"; +} + +impl forall [To:! IntLiteral()] + IntLiteral() as As(Float(To)) { + fn Convert[self: Self]() -> Float(To) = "int.convert_float"; +} + +// AnyInt, AnyUInt, and IntImplicitAsFloat exist to work around the inability to +// apply constraints to an impl that is only parameterized by integers, and the +// lack of support for `match_first`. +// TODO: Remove these once possible. +private interface AnyInt { + let Width:! IntLiteral(); + fn AsInt[self: Self]() -> Int(Width); +} + +impl forall [N:! IntLiteral()] Int(N) as AnyInt where .Width = N { + fn AsInt[self: Self]() -> Self { return self; } +} + +private interface AnyUInt { + let Width:! IntLiteral(); + fn AsUInt[self: Self]() -> UInt(Width); +} + +impl forall [N:! IntLiteral()] UInt(N) as AnyUInt where .Width = N { + fn AsUInt[self: Self]() -> Self { return self; } +} + +private interface IntImplicitAsFloat(To:! IntLiteral()) { + fn Convert[self: Self]() -> Float(To); +} + +final impl forall [To:! IntLiteral(), From:! AnyInt & IntFitsIn(Float(To))] + From as IntImplicitAsFloat(To) { + fn Convert[self: Self]() -> Float(To) { + fn Impl(src: Int(From.Width)) -> Float(To) = "int.convert_float"; + return Impl(self.AsInt()); + } +} + +impl forall [To:! IntLiteral(), From:! AnyUInt & IntFitsIn(Float(To))] + From as IntImplicitAsFloat(To) { + fn Convert[self: Self]() -> Float(To) { + fn Impl(src: UInt(From.Width)) -> Float(To) = "int.convert_float"; + return Impl(self.AsUInt()); + } +} + +impl forall [To:! IntLiteral(), From:! IntImplicitAsFloat(To)] + From as ImplicitAs(Float(To)) { + fn Convert[self: Self]() -> Float(To) { + return self.Convert(); + } +} + +// Desired workaround-free version of the above: +// +// impl forall [From:! IntLiteral(), To:! IntLiteral() +// where Int(From) impls ImplicitAs(Float(To))] +// Int(From) as ImplicitAs(Float(To)) { +// fn Convert[self: Self]() -> Float(To) = "int.convert_float"; +// } +// +// impl forall [From:! IntLiteral(), To:! IntLiteral() +// where UInt(From) impls ImplicitAs(Float(To))] +// UInt(From) as ImplicitAs(Float(To)) { +// fn Convert[self: Self]() -> Float(To) = "int.convert_float"; +// } + +impl forall [To:! IntLiteral()] + IntLiteral() as ImplicitAs(Float(To)) { + fn Convert[self: Self]() -> Float(To) = "int.convert_float_checked"; +} + // Comparisons. // TODO: Support mixed-type comparisons. final impl forall [N:! IntLiteral()] Float(N) as EqWith(Float(N)) { diff --git a/core/prelude/types/int.carbon b/core/prelude/types/int.carbon index 075ec91fae42..1bfe01e1d977 100644 --- a/core/prelude/types/int.carbon +++ b/core/prelude/types/int.carbon @@ -9,6 +9,7 @@ import library "prelude/default"; import library "prelude/destroy"; import library "prelude/operators"; import library "prelude/types/int_literal"; +import library "prelude/types/float_literal"; private fn MakeInt(size: IntLiteral()) -> type = "int.make_type_signed"; @@ -69,6 +70,12 @@ final impl forall [From:! IntLiteral(), To:! IntLiteral()] Int(From) as As(Int(T fn Convert[self: Self]() -> Int(To) = "int.convert"; } +// Explicit conversion from floating-point literals. +impl forall [To:! IntLiteral()] + FloatLiteral() as UnsafeAs(Int(To)) { + fn Convert[self: Self]() -> Int(To) = "float.convert_int"; +} + // Comparisons. // - Int(N) vs Int(M). diff --git a/core/prelude/types/uint.carbon b/core/prelude/types/uint.carbon index 0d636cb85d00..055fee9033ce 100644 --- a/core/prelude/types/uint.carbon +++ b/core/prelude/types/uint.carbon @@ -10,6 +10,7 @@ import library "prelude/destroy"; import library "prelude/operators"; import library "prelude/types/int"; import library "prelude/types/int_literal"; +import library "prelude/types/float_literal"; private fn MakeUInt(size: IntLiteral()) -> type = "int.make_type_unsigned"; @@ -58,8 +59,8 @@ impl forall [N:! IntLiteral()] UInt(N) as AnyUInt where .Width = N { fn AsUInt[self: Self]() -> Self { return self; } } -// Work around the inability to constrain types other than `.Self` by reversing -// the Self and argument type of `ImplicitAs`. +// Work around the inability to apply constraints to an impl that is only +// parameterized by integers, and the lack of support for `match_first`. // TODO: Remove this once possible. private interface FromUInt(From:! type) { fn Convert(from: From) -> Self; @@ -101,6 +102,12 @@ impl forall [From:! IntLiteral(), To:! IntLiteral()] Int(From) as As(UInt(To)) { fn Convert[self: Self]() -> UInt(To) = "int.convert"; } +// Explicit conversion from floating-point literals. +impl forall [To:! IntLiteral()] + FloatLiteral() as UnsafeAs(UInt(To)) { + fn Convert[self: Self]() -> UInt(To) = "float.convert_int"; +} + // Comparisons. // - UInt(N) vs UInt(M). diff --git a/toolchain/check/custom_witness.cpp b/toolchain/check/custom_witness.cpp index ca7389681bf1..3c8b90c0aef6 100644 --- a/toolchain/check/custom_witness.cpp +++ b/toolchain/check/custom_witness.cpp @@ -4,6 +4,7 @@ #include "toolchain/check/custom_witness.h" +#include "llvm/ADT/APFloat.h" #include "toolchain/base/kind_switch.h" #include "toolchain/check/facet_type.h" #include "toolchain/check/function.h" @@ -673,9 +674,34 @@ static auto MakeIntFitsInWitness( } auto src_info = context.types().TryGetIntTypeInfo(src_type_id); - auto dest_info = context.types().TryGetIntTypeInfo(dest_type_id); + if (!src_info) { + return std::nullopt; + } - if (!src_info || !dest_info) { + auto dest_info = context.types().TryGetIntTypeInfo(dest_type_id); + if (!dest_info) { + if (src_info->bit_width == IntId::None) { + return std::nullopt; + } + // Check if the destination is a floating-point type. + auto dest_object_rep_id = context.types().GetObjectRepr(dest_type_id); + if (auto dest_float_type = + context.types().TryGetAs(dest_object_rep_id)) { + const auto& src_width = context.ints().Get(src_info->bit_width); + unsigned int float_precision = llvm::APFloat::semanticsPrecision( + dest_float_type->float_kind.Semantics()); + // For iN we need one fewer bit. We don't need to worry about the value + // -2^(N-1) needing all N bits, as it can always be represented exactly. + if (src_width.sgt(src_info->is_signed ? float_precision + 1 + : float_precision)) { + return std::nullopt; + } + if (!build_witness) { + return SemIR::InstId::None; + } + return BuildCustomWitness(context, loc_id, query_self_const_id, + query_specific_interface_id, {}); + } return std::nullopt; } diff --git a/toolchain/check/eval.cpp b/toolchain/check/eval.cpp index 92265f83535d..129632c04649 100644 --- a/toolchain/check/eval.cpp +++ b/toolchain/check/eval.cpp @@ -10,6 +10,7 @@ #include #include "common/raw_string_ostream.h" +#include "llvm/ADT/APFloat.h" #include "llvm/Support/ConvertUTF.h" #include "toolchain/base/canonical_value_store.h" #include "toolchain/base/kind_switch.h" @@ -385,6 +386,14 @@ static auto MakeBoolResult(Context& context, SemIR::TypeId bool_type_id, Phase::Concrete); } +// Converts an IntId value into a ConstantId. +static auto MakeIntResult(Context& context, SemIR::TypeId type_id, IntId int_id) + -> SemIR::ConstantId { + return MakeConstantResult( + context, SemIR::IntValue{.type_id = type_id, .int_id = int_id}, + Phase::Concrete); +} + // Converts an APInt value into a ConstantId. static auto MakeIntResult(Context& context, SemIR::TypeId type_id, bool is_signed, llvm::APInt value) @@ -392,9 +401,7 @@ static auto MakeIntResult(Context& context, SemIR::TypeId type_id, CARBON_CHECK(is_signed == context.types().IsSignedInt(type_id)); auto result = is_signed ? context.ints().AddSigned(std::move(value)) : context.ints().AddUnsigned(std::move(value)); - return MakeConstantResult( - context, SemIR::IntValue{.type_id = type_id, .int_id = result}, - Phase::Concrete); + return MakeIntResult(context, type_id, result); } // Converts an APFloat value into a ConstantId. @@ -1141,7 +1148,8 @@ static auto PerformCheckedCharConvert(Context& context, SemIR::LocId loc_id, } llvm::APInt int_val(8, arg.value.index, /*isSigned=*/false); - return MakeIntResult(context, dest_type_id, /*is_signed=*/false, int_val); + return MakeIntResult(context, dest_type_id, /*is_signed=*/false, + std::move(int_val)); } // Forms a constant int type as an evaluation result. Requires that width_id is @@ -1172,6 +1180,15 @@ static auto MakeFloatTypeResult(Context& context, SemIR::LocId loc_id, return MakeConstantResult(context, result, phase); } +// Get an integer at a suitable bit-width: either `bit_width_id` if it has a +// value, or the canonical width from the value store if not. +static auto GetIntAtSuitableWidth(Context& context, IntId int_id, + IntId bit_width_id) -> llvm::APInt { + return bit_width_id.has_value() + ? context.ints().GetAtWidth(int_id, bit_width_id) + : context.ints().Get(int_id); +} + // Performs a conversion between integer types, truncating if the value doesn't // fit in the destination type. static auto PerformIntConvert(Context& context, SemIR::InstId arg_id, @@ -1189,7 +1206,8 @@ static auto PerformIntConvert(Context& context, SemIR::InstId arg_id, arg_val = src_is_signed ? arg_val.sextOrTrunc(width) : arg_val.zextOrTrunc(width); } - return MakeIntResult(context, dest_type_id, dest_is_signed, arg_val); + return MakeIntResult(context, dest_type_id, dest_is_signed, + std::move(arg_val)); } // Performs a conversion between integer types, diagnosing if the value doesn't @@ -1227,9 +1245,40 @@ static auto PerformCheckedIntConvert(Context& context, SemIR::LocId loc_id, dest_type_id); } - return MakeConstantResult( - context, SemIR::IntValue{.type_id = dest_type_id, .int_id = arg.int_id}, - Phase::Concrete); + return MakeIntResult(context, dest_type_id, arg.int_id); +} + +// Convert a real value to an APFloat. +static auto RealToAPFloat(Context& context, RealId real_id, + const llvm::fltSemantics& semantics, + llvm::APFloat::opStatus* status = nullptr) + -> llvm::APFloat { + auto real_value = context.sem_ir().reals().Get(real_id); + + // Convert the real value to a string. + llvm::SmallString<64> str; + real_value.mantissa.toString(str, real_value.is_decimal ? 10 : 16, + /*signed=*/false, /*formatAsCLiteral=*/true); + str += real_value.is_decimal ? "e" : "p"; + real_value.exponent.toStringSigned(str); + + // Convert the string to an APFloat. + // TODO: The implementation of this conversion effectively converts back to + // APInts, but unfortunately the conversion from integer mantissa and + // exponent in IEEEFloat::roundSignificandWithExponent is not part of the + // public API. + llvm::APFloat result(semantics); + auto res_status = + result.convertFromString(str, llvm::APFloat::rmNearestTiesToEven); + if (auto error = res_status.takeError()) { + // The literal we create should always successfully parse. + CARBON_FATAL("Float literal parsing failed: {0}", + toString(std::move(error))); + } + if (status) { + *status = res_status.get(); + } + return result; } // Performs a conversion between floating-point types, diagnosing if the value @@ -1263,29 +1312,11 @@ static auto PerformCheckedFloatConvert(Context& context, SemIR::LocId loc_id, // TODO: Implement Carbon's actual implicit conversion rules for // floating-point constants, as per the design // docs/design/expressions/implicit_conversions.md - auto real_value = context.sem_ir().reals().Get(literal->real_id); - - // Convert the real value to a string. - llvm::SmallString<64> str; - real_value.mantissa.toString(str, real_value.is_decimal ? 10 : 16, - /*signed=*/false, /*formatAsCLiteral=*/true); - str += real_value.is_decimal ? "e" : "p"; - real_value.exponent.toStringSigned(str); - - // Convert the string to an APFloat. - llvm::APFloat result(dest_float_type->float_kind.Semantics()); - // TODO: The implementation of this conversion effectively converts back to - // APInts, but unfortunately the conversion from integer mantissa and - // exponent in IEEEFloat::roundSignificandWithExponent is not part of the - // public API. - auto status = - result.convertFromString(str, llvm::APFloat::rmNearestTiesToEven); - if (auto error = status.takeError()) { - // The literal we create should always successfully parse. - CARBON_FATAL("Float literal parsing failed: {0}", - toString(std::move(error))); - } - if (status.get() & llvm::APFloat::opOverflow) { + llvm::APFloat::opStatus status; + llvm::APFloat result = + RealToAPFloat(context, literal->real_id, + dest_float_type->float_kind.Semantics(), &status); + if (status & llvm::APFloat::opOverflow) { CARBON_DIAGNOSTIC(FloatLiteralTooLargeForType, Error, "value {0} too large for floating-point type {1}", RealId, SemIR::TypeId); @@ -1319,6 +1350,284 @@ static auto PerformCheckedFloatConvert(Context& context, SemIR::LocId loc_id, return MakeFloatResult(context, dest_type_id, std::move(result)); } +// Performs a conversion from integer type to a floating-point type, optionally +// checking for exactness. +static auto PerformIntToFloatConvert(Context& context, SemIR::LocId loc_id, + SemIR::InstId arg_id, + SemIR::TypeId dest_type_id, + bool require_exact) -> SemIR::ConstantId { + auto arg = context.insts().GetAs(arg_id); + auto [src_is_signed, bit_width_id] = + context.sem_ir().types().GetIntTypeInfo(arg.type_id); + llvm::APInt op_val = GetIntAtSuitableWidth(context, arg.int_id, bit_width_id); + + auto dest_type_object_rep_id = context.types().GetObjectRepr(dest_type_id); + CARBON_CHECK(dest_type_object_rep_id.has_value(), + "Conversion to incomplete type"); + auto dest_float_type = + context.types().TryGetAs(dest_type_object_rep_id); + + if (!dest_float_type) { + // Target is Core.FloatLiteral, which is always exact. + llvm::APInt mantissa = op_val; + if (src_is_signed && op_val.isNegative()) { + // FloatLiteral can only represent positive real values. Negative + // literals are parsed as Negate(FloatLiteralValue). + context.TODO(loc_id, "negative float literal conversion"); + return SemIR::ErrorInst::ConstantId; + } + auto real_id = context.reals().Add( + Real{.mantissa = mantissa, + .exponent = llvm::APInt(32, 0, /*isSigned=*/true), + .is_decimal = true}); + return MakeConstantResult( + context, + SemIR::FloatLiteralValue{.type_id = dest_type_id, .real_id = real_id}, + Phase::Concrete); + } + + llvm::APFloat ap_float(dest_float_type->float_kind.Semantics()); + auto status = ap_float.convertFromAPInt(op_val, src_is_signed, + llvm::APFloat::rmNearestTiesToEven); + if (status & llvm::APFloat::opOverflow) { + CARBON_DIAGNOSTIC(IntTooLargeForFloatType, Error, + "integer value {0} too large for floating-point type {1}", + TypedInt, SemIR::TypeId); + context.emitter().Emit(loc_id, IntTooLargeForFloatType, + {.type = arg.type_id, .value = op_val}, + dest_type_id); + return SemIR::ErrorInst::ConstantId; + } + if (require_exact && (status & llvm::APFloat::opInexact)) { + CARBON_DIAGNOSTIC(IntLossyConversionToFloat, Error, + "integer value {0} cannot be represented exactly in " + "floating-point type {1}", + TypedInt, SemIR::TypeId); + context.emitter().Emit(loc_id, IntLossyConversionToFloat, + {.type = arg.type_id, .value = op_val}, + dest_type_id); + return SemIR::ErrorInst::ConstantId; + } + return MakeFloatResult(context, dest_type_id, std::move(ap_float)); +} + +// Diagnoses that the real literal is too large for the destination type. +static auto DiagnoseRealLiteralTooLarge(Context& context, SemIR::LocId loc_id, + RealId real_id, + SemIR::TypeId dest_type_id) + -> SemIR::ConstantId { + CARBON_DIAGNOSTIC(RealLiteralTooLargeForIntType, Error, + "floating-point value {0} too large for integer type {1}", + RealId, SemIR::TypeId); + context.emitter().Emit(loc_id, RealLiteralTooLargeForIntType, real_id, + dest_type_id); + return SemIR::ErrorInst::ConstantId; +} + +namespace { +struct BitWidthBounds { + uint64_t lower_bound; + uint64_t upper_bound; +}; +} // namespace + +// Computes a strict lower bound and upper bound on the bit-width of a real +// literal value when converted to an integer, rounding towards zero. +static auto EstimateRealLiteralBitWidth(const Real& real_val) + -> BitWidthBounds { + const llvm::APInt& mantissa = real_val.mantissa; + const llvm::APInt& exponent = real_val.exponent; + + if (mantissa.isZero() || + (exponent.isNegative() && exponent.abs().getActiveBits() > 64)) { + // If the result is definitely less than one, it rounds to zero. + return {.lower_bound = 0, .upper_bound = 0}; + } + + // Check if the exponent is extremely large, indicating an immediate overflow. + // We return the maximum possible bit width since the mathematically evaluated + // value has at least 2^64 bits. + if (!exponent.isNegative() && exponent.getActiveBits() > 64) { + return {.lower_bound = static_cast(-1), + .upper_bound = static_cast(-1)}; + } + + uint64_t abs_exponent = exponent.abs().getZExtValue(); + uint64_t scale_min = abs_exponent; + uint64_t scale_max = abs_exponent; + if (real_val.is_decimal) { + // 10^4 = 10000 > 8192 = 2^13, so each decimal digit changes the size by + // at least 13/4 bits (safe lower-bound scaling). + scale_min = (abs_exponent * 13) / 4; + // 10^3 = 1000 < 1024 = 2^10, so each decimal digit changes the size by + // less than 10/3 bits (safe upper-bound scaling). + scale_max = (abs_exponent * 10 + 2) / 3; + } + + uint64_t lower_bound = mantissa.getActiveBits(); + uint64_t upper_bound = mantissa.getActiveBits(); + + if (exponent.isNegative()) { + // A negative exponent decreases the result size. + lower_bound = (lower_bound > scale_max) ? (lower_bound - scale_max) : 0; + upper_bound = (upper_bound > scale_min) ? (upper_bound - scale_min) : 0; + } else { + // A positive exponent increases the result size. + lower_bound += scale_min; + upper_bound += scale_max; + } + + return {.lower_bound = lower_bound, .upper_bound = upper_bound}; +} + +// Converts an unsized RealId (floating-point literal) to an integer. +static auto ConvertRealLiteralToInt(Context& context, SemIR::LocId loc_id, + RealId real_id, SemIR::TypeId dest_type_id, + bool dest_is_signed, IntId bit_width_id) + -> SemIR::ConstantId { + const auto& real_val = context.reals().Get(real_id); + const llvm::APInt& mantissa = real_val.mantissa; + const llvm::APInt& exponent = real_val.exponent; + + auto bounds = EstimateRealLiteralBitWidth(real_val); + if (bounds.upper_bound == 0) { + // The result fits in 0 bits, so must be 0. + return MakeIntResult(context, dest_type_id, context.ints().Add(0)); + } + + // Sized bounds check: prevent constructing an APInt with a huge number of + // digits if it's way larger than the destination type. + if (bit_width_id.has_value()) { + if (context.ints().Get(bit_width_id).ult(bounds.lower_bound)) { + return DiagnoseRealLiteralTooLarge(context, loc_id, real_id, + dest_type_id); + } + } else if (bounds.lower_bound > IntStore::MaxIntWidth) { + CARBON_DIAGNOSTIC( + RealLiteralTooLargeForUnsizedInt, Error, + "floating-point value {0} too large to convert: result would be an " + "integer whose width is greater than the maximum supported width of " + "{1}", + RealId, int); + context.emitter().Emit(loc_id, RealLiteralTooLargeForUnsizedInt, real_id, + IntStore::MaxIntWidth); + return SemIR::ErrorInst::ConstantId; + } + + // Compute an upper bound on the bit width of base^exponent. + unsigned abs_exponent = exponent.abs().getZExtValue(); + unsigned exponent_upper_bound = + real_val.is_decimal ? ((abs_exponent * 10 + 2) / 3) : abs_exponent; + + // If the exponent is positive, base^exponent cannot be larger than the result + // size. If it's negative, base^exponent can't be *much* larger than the + // mantissa or we'd have computed a lower bound of 0 bits and bailed out. + CARBON_CHECK( + exponent_upper_bound <= + std::max(mantissa.getActiveBits() * 2, bounds.upper_bound)); + + // Compute a bit-width in which we can safely compute the result. We need + // enough space to store the mantissa, base^exponent, the result and a sign + // bit, and the number 10 (4 bits). + unsigned calc_width = + std::max({mantissa.getActiveBits(), exponent_upper_bound, + static_cast(bounds.upper_bound + 1), 4U}); + + // Compute the integer result. + llvm::APInt integer_val = mantissa.zextOrTrunc(calc_width); + if (!real_val.is_decimal) { + // Binary exponent (mantissa * 2^exponent). + if (!exponent.isNegative()) { + integer_val <<= abs_exponent; + } else { + integer_val.lshrInPlace(abs_exponent); + } + } else { + // Decimal exponent (mantissa * 10^exponent). + llvm::APInt ten(calc_width, 10); + llvm::APInt ten_pow = llvm::APIntOps::pow(ten, abs_exponent); + if (!exponent.isNegative()) { + integer_val *= ten_pow; + } else { + integer_val = integer_val.udiv(ten_pow); + } + } + + // If the target type is sized, check the final value fits in the type. + if (bit_width_id.has_value()) { + unsigned dest_width = context.ints().Get(bit_width_id).getZExtValue(); + if (integer_val.getActiveBits() > dest_width - dest_is_signed) { + return DiagnoseRealLiteralTooLarge(context, loc_id, real_id, + dest_type_id); + } + } + + return MakeIntResult(context, dest_type_id, dest_is_signed, + std::move(integer_val)); +} + +// Converts a sized FloatId to an integer. +static auto ConvertFloatValueToInt(Context& context, SemIR::LocId loc_id, + FloatId float_id, SemIR::TypeId dest_type_id, + bool dest_is_signed, IntId bit_width_id) + -> SemIR::ConstantId { + llvm::APFloat float_val = context.floats().Get(float_id); + + if (float_val.isNaN()) { + CARBON_DIAGNOSTIC(FloatNaNConvertedToInt, Error, + "cannot convert NaN to integer type {0}", SemIR::TypeId); + context.emitter().Emit(loc_id, FloatNaNConvertedToInt, dest_type_id); + return SemIR::ErrorInst::ConstantId; + } + if (float_val.isInfinity()) { + CARBON_DIAGNOSTIC(FloatInfinityConvertedToInt, Error, + "cannot convert infinity to integer type {0}", + SemIR::TypeId); + context.emitter().Emit(loc_id, FloatInfinityConvertedToInt, dest_type_id); + return SemIR::ErrorInst::ConstantId; + } + + int exp = float_val.isZero() ? 0 : llvm::ilogb(float_val); + unsigned target_width = bit_width_id.has_value() + ? context.ints().Get(bit_width_id).getZExtValue() + : std::max(64, exp + 2); + + llvm::APSInt result(target_width, !dest_is_signed); + bool is_exact; + auto status = float_val.convertToInteger(result, llvm::APFloat::rmTowardZero, + &is_exact); + if (status & (llvm::APFloat::opOverflow | llvm::APFloat::opInvalidOp)) { + CARBON_DIAGNOSTIC(FloatTooLargeForIntType, Error, + "floating-point value {0} too large for integer type {1}", + llvm::APFloat, SemIR::TypeId); + context.emitter().Emit(loc_id, FloatTooLargeForIntType, float_val, + dest_type_id); + return SemIR::ErrorInst::ConstantId; + } + + return MakeIntResult(context, dest_type_id, dest_is_signed, + std::move(result)); +} + +// Performs a conversion from a floating-point type to an integer type. +static auto PerformFloatToIntConvert(Context& context, SemIR::LocId loc_id, + SemIR::InstId arg_id, + SemIR::TypeId dest_type_id) + -> SemIR::ConstantId { + auto [dest_is_signed, bit_width_id] = + context.sem_ir().types().GetIntTypeInfo(dest_type_id); + + if (auto literal = + context.insts().TryGetAs(arg_id)) { + return ConvertRealLiteralToInt(context, loc_id, literal->real_id, + dest_type_id, dest_is_signed, bit_width_id); + } + + auto arg = context.insts().GetAs(arg_id); + return ConvertFloatValueToInt(context, loc_id, arg.float_id, dest_type_id, + dest_is_signed, bit_width_id); +} + // Issues a diagnostic for a compile-time division by zero. static auto DiagnoseDivisionByZero(Context& context, SemIR::LocId loc_id) -> void { @@ -1326,15 +1635,6 @@ static auto DiagnoseDivisionByZero(Context& context, SemIR::LocId loc_id) context.emitter().Emit(loc_id, CompileTimeDivisionByZero); } -// Get an integer at a suitable bit-width: either `bit_width_id` if it has a -// value, or the canonical width from the value store if not. -static auto GetIntAtSuitableWidth(Context& context, IntId int_id, - IntId bit_width_id) -> llvm::APInt { - return bit_width_id.has_value() - ? context.ints().GetAtWidth(int_id, bit_width_id) - : context.ints().Get(int_id); -} - // Performs a builtin unary integer -> integer operation. static auto PerformBuiltinUnaryIntOp(Context& context, SemIR::LocId loc_id, SemIR::BuiltinFunctionKind builtin_kind, @@ -1883,12 +2183,8 @@ static auto MakeConstantForBuiltinCall(EvalContext& eval_context, auto char_value = static_cast(string_value[index_val.getZExtValue()]); - - auto int_id = eval_context.ints().Add( - llvm::APSInt(llvm::APInt(32, char_value), /*isUnsigned=*/false)); - return MakeConstantResult( - eval_context.context(), - SemIR::IntValue{.type_id = call.type_id, .int_id = int_id}, phase); + return MakeIntResult(eval_context.context(), call.type_id, + /*is_signed=*/false, llvm::APInt(32, char_value)); } case SemIR::BuiltinFunctionKind::MakeUninitialized: @@ -2022,6 +2318,20 @@ static auto MakeConstantForBuiltinCall(EvalContext& eval_context, return PerformCheckedIntConvert(context, loc_id, arg_ids[0], call.type_id); } + case SemIR::BuiltinFunctionKind::IntConvertFloat: { + if (phase != Phase::Concrete) { + return MakeConstantResult(context, call, phase); + } + return PerformIntToFloatConvert(context, loc_id, arg_ids[0], call.type_id, + /*require_exact=*/false); + } + case SemIR::BuiltinFunctionKind::IntConvertFloatChecked: { + if (phase != Phase::Concrete) { + return MakeConstantResult(context, call, phase); + } + return PerformIntToFloatConvert(context, loc_id, arg_ids[0], call.type_id, + /*require_exact=*/true); + } // Unary integer -> integer operations. case SemIR::BuiltinFunctionKind::IntSNegate: @@ -2087,6 +2397,13 @@ static auto MakeConstantForBuiltinCall(EvalContext& eval_context, return PerformCheckedFloatConvert(context, loc_id, arg_ids[0], call.type_id); } + case SemIR::BuiltinFunctionKind::FloatConvertInt: { + if (phase != Phase::Concrete) { + return MakeConstantResult(context, call, phase); + } + return PerformFloatToIntConvert(context, loc_id, arg_ids[0], + call.type_id); + } // Unary float -> float operations. case SemIR::BuiltinFunctionKind::FloatNegate: { diff --git a/toolchain/check/testdata/builtins/float/convert_int.carbon b/toolchain/check/testdata/builtins/float/convert_int.carbon new file mode 100644 index 000000000000..25595e6ae3dc --- /dev/null +++ b/toolchain/check/testdata/builtins/float/convert_int.carbon @@ -0,0 +1,624 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/primitives.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/float/convert_int.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/float/convert_int.carbon + +// --- float_to_int.carbon +library "[[@TEST_NAME]]"; + +fn ConvertF64ToI32(a: f64) -> i32 = "float.convert_int"; +fn ConvertF64ToU32(a: f64) -> u32 = "float.convert_int"; +fn ConvertFloatLiteralToI32(a: Core.FloatLiteral()) -> i32 = "float.convert_int"; +fn ConvertFloatLiteralToU32(a: Core.FloatLiteral()) -> u32 = "float.convert_int"; +fn ConvertFloatLiteralToIntLiteral(a: Core.FloatLiteral()) -> Core.IntLiteral() = "float.convert_int"; +fn ConvertF64ToIntLiteral(a: f64) -> Core.IntLiteral() = "float.convert_int"; + +fn Negate(a: f64) -> f64 = "float.negate"; +fn Div(a: f64, b: f64) -> f64 = "float.div"; + +class Expect[T:! type](N:! T) {} +fn Test[T:! type](N:! T) -> Expect(N) { return {}; } + +// --- identity.carbon +library "[[@TEST_NAME]]"; +import library "float_to_int"; + +fn F() { + Test(ConvertF64ToI32(0.0)) as Expect(0 as i32); + Test(ConvertF64ToI32(1.0)) as Expect(1 as i32); + Test(ConvertF64ToI32(Negate(1.0))) as Expect(-1 as i32); + Test(ConvertF64ToI32(1.99)) as Expect(1 as i32); + Test(ConvertF64ToI32(Negate(1.99))) as Expect(-1 as i32); + Test(ConvertF64ToI32(2147483647.0)) as Expect(2147483647 as i32); + Test(ConvertF64ToI32(Negate(2147483648.0))) as Expect(-2147483648 as i32); + + Test(ConvertF64ToU32(0.0)) as Expect(0 as u32); + Test(ConvertF64ToU32(1.0)) as Expect(1 as u32); + Test(ConvertF64ToU32(4294967295.0)) as Expect(4294967295 as u32); + + Test(ConvertFloatLiteralToI32(1.0)) as Expect(1 as i32); + Test(ConvertFloatLiteralToI32(0.0)) as Expect(0 as i32); + Test(ConvertFloatLiteralToI32(0.0e1000000000000000000000000000000000)) as Expect(0 as i32); + Test(ConvertFloatLiteralToI32(1.0e-1000000000000000000000000000000000)) as Expect(0 as i32); + + Test(ConvertFloatLiteralToI32(0x1.0p4)) as Expect(16 as i32); + Test(ConvertFloatLiteralToI32(0x3.4p4)) as Expect(52 as i32); + Test(ConvertFloatLiteralToI32(0x1.0p-4)) as Expect(0 as i32); + Test(ConvertFloatLiteralToI32(0x10.0p-2)) as Expect(4 as i32); + + Test(ConvertFloatLiteralToI32(0x1000000000000000000000000.0p-96)) as Expect(1 as i32); + Test(ConvertFloatLiteralToI32(0x1000000000000000000000000.1p-96)) as Expect(1 as i32); + Test(ConvertFloatLiteralToI32(0x0FFFFFFFFFFFFFFFFFFFFFFFF.Fp-96)) as Expect(0 as i32); + + Test(ConvertFloatLiteralToI32(100000000000000000000000000000000000000000000000000.0e-50)) as Expect(1 as i32); + Test(ConvertFloatLiteralToI32(100000000000000000000000000000000000000000000000000.1e-50)) as Expect(1 as i32); + Test(ConvertFloatLiteralToI32(99999999999999999999999999999999999999999999999999.9e-50)) as Expect(0 as i32); + + Test(ConvertFloatLiteralToI32(214748364.7e1)) as Expect(2147483647 as i32); + Test(ConvertFloatLiteralToI32(21474.83647e5)) as Expect(2147483647 as i32); + Test(ConvertFloatLiteralToI32(0x7FFF.FFFFp16)) as Expect(2147483647 as i32); + Test(ConvertFloatLiteralToI32(1.0e9)) as Expect(1000000000 as i32); + Test(ConvertFloatLiteralToI32(0x1.0p30)) as Expect(1073741824 as i32); + + Test(ConvertFloatLiteralToU32(0x8000.0000p16)) as Expect(2147483648 as u32); + Test(ConvertFloatLiteralToU32(4.0e9)) as Expect(4000000000 as u32); + Test(ConvertFloatLiteralToU32(0x1.0p31)) as Expect(2147483648 as u32); + + Test(ConvertFloatLiteralToIntLiteral(1.0)) as Expect(1); + Test(ConvertFloatLiteralToIntLiteral(0.0)) as Expect(0); + Test(ConvertFloatLiteralToIntLiteral(0.0e1000000000000000000000000000000000)) as Expect(0); + Test(ConvertFloatLiteralToIntLiteral(1.0e-1000000000000000000000000000000000)) as Expect(0); + + Test(ConvertFloatLiteralToIntLiteral(0x1.0p8)) as Expect(256); + Test(ConvertFloatLiteralToIntLiteral(0x1.0p-8)) as Expect(0); + + Test(ConvertFloatLiteralToIntLiteral(0x1000000000000000000000000.0p-96)) as Expect(1); + Test(ConvertFloatLiteralToIntLiteral(0x1000000000000000000000000.1p-96)) as Expect(1); + Test(ConvertFloatLiteralToIntLiteral(0x0FFFFFFFFFFFFFFFFFFFFFFFF.Fp-96)) as Expect(0); + + Test(ConvertFloatLiteralToIntLiteral(100000000000000000000000000000000000000000000000000.0e-50)) as Expect(1); + Test(ConvertFloatLiteralToIntLiteral(100000000000000000000000000000000000000000000000000.1e-50)) as Expect(1); + Test(ConvertFloatLiteralToIntLiteral(99999999999999999999999999999999999999999999999999.9e-50)) as Expect(0); + + Test(ConvertF64ToIntLiteral(1.0)) as Expect(1); + Test(ConvertF64ToIntLiteral(Negate(1.0))) as Expect(-1); +} + +// --- fail_overflow.carbon +library "[[@TEST_NAME]]"; +import library "float_to_int"; + +//@dump-sem-ir-begin +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:21: error: floating-point value 2147483648 too large for integer type `i32` [FloatTooLargeForIntType] +// CHECK:STDERR: let overflow: i32 = ConvertF64ToI32(2147483648.0); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let overflow: i32 = ConvertF64ToI32(2147483648.0); + +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:22: error: floating-point value -2147483649 too large for integer type `i32` [FloatTooLargeForIntType] +// CHECK:STDERR: let underflow: i32 = ConvertF64ToI32(Negate(2147483649.0)); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let underflow: i32 = ConvertF64ToI32(Negate(2147483649.0)); + +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:25: error: floating-point value -1 too large for integer type `u32` [FloatTooLargeForIntType] +// CHECK:STDERR: let unsigned_neg: u32 = ConvertF64ToU32(Negate(1.0)); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let unsigned_neg: u32 = ConvertF64ToU32(Negate(1.0)); + +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:29: error: floating-point value 21474836480*10^-1 too large for integer type `i32` [RealLiteralTooLargeForIntType] +// CHECK:STDERR: let literal_overflow: i32 = ConvertFloatLiteralToI32(2147483648.0); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let literal_overflow: i32 = ConvertFloatLiteralToI32(2147483648.0); + +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:35: error: floating-point value 10*10^999999 too large for integer type `i32` [RealLiteralTooLargeForIntType] +// CHECK:STDERR: let giant_literal_overflow: i32 = ConvertFloatLiteralToI32(1.0e1000000); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let giant_literal_overflow: i32 = ConvertFloatLiteralToI32(1.0e1000000); + +// +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:64: error: floating-point value 10*10^9999999 too large to convert: result would be an integer whose width is greater than the maximum supported width of 8388608 [RealLiteralTooLargeForUnsizedInt] +// CHECK:STDERR: let giant_literal_to_int_literal_overflow: Core.IntLiteral() = ConvertFloatLiteralToIntLiteral(1.0e10000000); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let giant_literal_to_int_literal_overflow: Core.IntLiteral() = ConvertFloatLiteralToIntLiteral(1.0e10000000); + +// +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:44: error: floating-point value 10*10^999999999999999999999999999999999 too large for integer type `i32` [RealLiteralTooLargeForIntType] +// CHECK:STDERR: let giant_exponent_literal_overflow: i32 = ConvertFloatLiteralToI32(1.0e1000000000000000000000000000000000); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let giant_exponent_literal_overflow: i32 = ConvertFloatLiteralToI32(1.0e1000000000000000000000000000000000); + +// +// +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:73: error: floating-point value 10*10^999999999999999999999999999999999 too large to convert: result would be an integer whose width is greater than the maximum supported width of 8388608 [RealLiteralTooLargeForUnsizedInt] +// CHECK:STDERR: let giant_exponent_literal_to_int_literal_overflow: Core.IntLiteral() = ConvertFloatLiteralToIntLiteral(1.0e1000000000000000000000000000000000); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let giant_exponent_literal_to_int_literal_overflow: Core.IntLiteral() = ConvertFloatLiteralToIntLiteral(1.0e1000000000000000000000000000000000); + +// +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:44: error: floating-point value 2147483648*10^0 too large for integer type `i32` [RealLiteralTooLargeForIntType] +// CHECK:STDERR: let literal_overflow_large_mantissa: i32 = ConvertFloatLiteralToI32(214748364.8e1); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let literal_overflow_large_mantissa: i32 = ConvertFloatLiteralToI32(214748364.8e1); + +// +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:42: error: floating-point value 2147483648*10^0 too large for integer type `i32` [RealLiteralTooLargeForIntType] +// CHECK:STDERR: let literal_overflow_med_mantissa: i32 = ConvertFloatLiteralToI32(21474.83648e5); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let literal_overflow_med_mantissa: i32 = ConvertFloatLiteralToI32(21474.83648e5); + +// +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:46: error: floating-point value 2147483648*2^0 too large for integer type `i32` [RealLiteralTooLargeForIntType] +// CHECK:STDERR: let literal_overflow_hex_med_mantissa: i32 = ConvertFloatLiteralToI32(0x8000.0000p16); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let literal_overflow_hex_med_mantissa: i32 = ConvertFloatLiteralToI32(0x8000.0000p16); + +// +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:44: error: floating-point value 10*10^9 too large for integer type `i32` [RealLiteralTooLargeForIntType] +// CHECK:STDERR: let literal_overflow_small_mantissa: i32 = ConvertFloatLiteralToI32(1.0e10); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let literal_overflow_small_mantissa: i32 = ConvertFloatLiteralToI32(1.0e10); + +// +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:48: error: floating-point value 16*2^27 too large for integer type `i32` [RealLiteralTooLargeForIntType] +// CHECK:STDERR: let literal_overflow_bin_small_mantissa: i32 = ConvertFloatLiteralToI32(0x1.0p31); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let literal_overflow_bin_small_mantissa: i32 = ConvertFloatLiteralToI32(0x1.0p31); + +// +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:42: error: floating-point value 50*10^8 too large for integer type `u32` [RealLiteralTooLargeForIntType] +// CHECK:STDERR: let literal_overflow_unsigned_neg: u32 = ConvertFloatLiteralToU32(5.0e9); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let literal_overflow_unsigned_neg: u32 = ConvertFloatLiteralToU32(5.0e9); + +// +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:46: error: floating-point value 16*2^28 too large for integer type `u32` [RealLiteralTooLargeForIntType] +// CHECK:STDERR: let literal_overflow_bin_unsigned_neg: u32 = ConvertFloatLiteralToU32(0x1.0p32); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let literal_overflow_bin_unsigned_neg: u32 = ConvertFloatLiteralToU32(0x1.0p32); +//@dump-sem-ir-end + +// --- fail_nan_inf.carbon +library "[[@TEST_NAME]]"; +import library "float_to_int"; + +//@dump-sem-ir-begin +// CHECK:STDERR: fail_nan_inf.carbon:[[@LINE+4]]:20: error: cannot convert NaN to integer type `i32` [FloatNaNConvertedToInt] +// CHECK:STDERR: let nan_val: i32 = ConvertF64ToI32(Div(0.0, 0.0)); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let nan_val: i32 = ConvertF64ToI32(Div(0.0, 0.0)); + +// CHECK:STDERR: fail_nan_inf.carbon:[[@LINE+4]]:20: error: cannot convert infinity to integer type `i32` [FloatInfinityConvertedToInt] +// CHECK:STDERR: let inf_val: i32 = ConvertF64ToI32(Div(1.0, 0.0)); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let inf_val: i32 = ConvertF64ToI32(Div(1.0, 0.0)); +//@dump-sem-ir-end + +// CHECK:STDOUT: --- fail_overflow.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// 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] +// CHECK:STDOUT: %pattern_type.dc0: type = pattern_type Core.IntLiteral [concrete] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] +// CHECK:STDOUT: %pattern_type.104: type = pattern_type %i32 [concrete] +// CHECK:STDOUT: %ConvertF64ToI32.type: type = fn_type @ConvertF64ToI32 [concrete] +// CHECK:STDOUT: %ConvertF64ToI32: %ConvertF64ToI32.type = struct_value () [concrete] +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete] +// CHECK:STDOUT: %f64.8ef: type = class_type @Float, @Float(%int_64) [concrete] +// CHECK:STDOUT: %float.bab60c.1: Core.FloatLiteral = float_literal_value 21474836480e-1 [concrete] +// CHECK:STDOUT: %ImplicitAs.type.754: type = generic_interface_type @ImplicitAs [concrete] +// CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.754 = struct_value () [concrete] +// CHECK:STDOUT: %ImplicitAs.type.047: type = facet_type <@ImplicitAs, @ImplicitAs(%f64.8ef)> [concrete] +// CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.080: type = fn_type @Core.FloatLiteral.as.ImplicitAs.impl.Convert, @Core.FloatLiteral.as.ImplicitAs.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.dc5: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.080 = struct_value () [symbolic] +// CHECK:STDOUT: %ImplicitAs.impl_witness.141: = impl_witness imports.%ImplicitAs.impl_witness_table, @Core.FloatLiteral.as.ImplicitAs.impl(%int_64) [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.828: type = fn_type @Core.FloatLiteral.as.ImplicitAs.impl.Convert, @Core.FloatLiteral.as.ImplicitAs.impl(%int_64) [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.565: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.828 = struct_value () [concrete] +// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.047 = facet_value Core.FloatLiteral, (%ImplicitAs.impl_witness.141) [concrete] +// CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.1e2: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%f64.8ef, %ImplicitAs.facet) [concrete] +// CHECK:STDOUT: %.dfd: type = fn_type_with_self_type %ImplicitAs.WithSelf.Convert.type.1e2, %ImplicitAs.facet [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.43d: = bound_method %float.bab60c.1, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.565 [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.FloatLiteral.as.ImplicitAs.impl.Convert.565, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(%int_64) [concrete] +// CHECK:STDOUT: %bound_method.f0d: = bound_method %float.bab60c.1, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.5f5: %f64.8ef = float_value 2147483648 [concrete] +// CHECK:STDOUT: %Negate.type: type = fn_type @Negate [concrete] +// CHECK:STDOUT: %Negate: %Negate.type = struct_value () [concrete] +// CHECK:STDOUT: %float.449: Core.FloatLiteral = float_literal_value 21474836490e-1 [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.0c7: = bound_method %float.449, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.565 [concrete] +// CHECK:STDOUT: %bound_method.855: = bound_method %float.449, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.f40: %f64.8ef = float_value 2147483649 [concrete] +// CHECK:STDOUT: %float.9be: %f64.8ef = float_value -2147483649 [concrete] +// CHECK:STDOUT: %UInt.type: type = generic_class_type @UInt [concrete] +// CHECK:STDOUT: %UInt.generic: %UInt.type = struct_value () [concrete] +// CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(%int_32) [concrete] +// CHECK:STDOUT: %pattern_type.126: type = pattern_type %u32 [concrete] +// CHECK:STDOUT: %ConvertF64ToU32.type: type = fn_type @ConvertF64ToU32 [concrete] +// CHECK:STDOUT: %ConvertF64ToU32: %ConvertF64ToU32.type = struct_value () [concrete] +// CHECK:STDOUT: %float.6da: Core.FloatLiteral = float_literal_value 10e-1 [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.ffa: = bound_method %float.6da, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.565 [concrete] +// CHECK:STDOUT: %bound_method.9d1: = bound_method %float.6da, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.9b4: %f64.8ef = float_value 1 [concrete] +// CHECK:STDOUT: %float.08a: %f64.8ef = float_value -1 [concrete] +// CHECK:STDOUT: %ConvertFloatLiteralToI32.type: type = fn_type @ConvertFloatLiteralToI32 [concrete] +// CHECK:STDOUT: %ConvertFloatLiteralToI32: %ConvertFloatLiteralToI32.type = struct_value () [concrete] +// CHECK:STDOUT: %float.bab60c.2: Core.FloatLiteral = float_literal_value 21474836480e-1 [concrete] +// CHECK:STDOUT: %float.53d: Core.FloatLiteral = float_literal_value 10e999999 [concrete] +// CHECK:STDOUT: %IntLiteral.type: type = fn_type @IntLiteral [concrete] +// CHECK:STDOUT: %IntLiteral: %IntLiteral.type = struct_value () [concrete] +// CHECK:STDOUT: %ConvertFloatLiteralToIntLiteral.type: type = fn_type @ConvertFloatLiteralToIntLiteral [concrete] +// CHECK:STDOUT: %ConvertFloatLiteralToIntLiteral: %ConvertFloatLiteralToIntLiteral.type = struct_value () [concrete] +// CHECK:STDOUT: %float.ef09: Core.FloatLiteral = float_literal_value 10e9999999 [concrete] +// CHECK:STDOUT: %float.f461ee.1: Core.FloatLiteral = float_literal_value 10e999999999999999999999999999999999 [concrete] +// CHECK:STDOUT: %float.f461ee.2: Core.FloatLiteral = float_literal_value 10e999999999999999999999999999999999 [concrete] +// CHECK:STDOUT: %float.e12922.1: Core.FloatLiteral = float_literal_value 2147483648e0 [concrete] +// CHECK:STDOUT: %float.e12922.2: Core.FloatLiteral = float_literal_value 2147483648e0 [concrete] +// CHECK:STDOUT: %float.ef03: Core.FloatLiteral = float_literal_value 2147483648p0 [concrete] +// CHECK:STDOUT: %float.9d5: Core.FloatLiteral = float_literal_value 10e9 [concrete] +// CHECK:STDOUT: %float.c0c: Core.FloatLiteral = float_literal_value 16p27 [concrete] +// CHECK:STDOUT: %ConvertFloatLiteralToU32.type: type = fn_type @ConvertFloatLiteralToU32 [concrete] +// CHECK:STDOUT: %ConvertFloatLiteralToU32: %ConvertFloatLiteralToU32.type = struct_value () [concrete] +// CHECK:STDOUT: %float.4f4: Core.FloatLiteral = float_literal_value 50e8 [concrete] +// CHECK:STDOUT: %float.97b: Core.FloatLiteral = float_literal_value 16p28 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Main.ConvertF64ToI32: %ConvertF64ToI32.type = import_ref Main//float_to_int, ConvertF64ToI32, loaded [concrete = constants.%ConvertF64ToI32] +// CHECK:STDOUT: %Main.ConvertF64ToU32: %ConvertF64ToU32.type = import_ref Main//float_to_int, ConvertF64ToU32, loaded [concrete = constants.%ConvertF64ToU32] +// CHECK:STDOUT: %Main.ConvertFloatLiteralToI32: %ConvertFloatLiteralToI32.type = import_ref Main//float_to_int, ConvertFloatLiteralToI32, loaded [concrete = constants.%ConvertFloatLiteralToI32] +// CHECK:STDOUT: %Main.ConvertFloatLiteralToU32: %ConvertFloatLiteralToU32.type = import_ref Main//float_to_int, ConvertFloatLiteralToU32, loaded [concrete = constants.%ConvertFloatLiteralToU32] +// CHECK:STDOUT: %Main.ConvertFloatLiteralToIntLiteral: %ConvertFloatLiteralToIntLiteral.type = import_ref Main//float_to_int, ConvertFloatLiteralToIntLiteral, loaded [concrete = constants.%ConvertFloatLiteralToIntLiteral] +// CHECK:STDOUT: %Main.Negate: %Negate.type = import_ref Main//float_to_int, Negate, loaded [concrete = constants.%Negate] +// CHECK:STDOUT: %Core.979: = namespace file.%Core.import, [concrete] { +// CHECK:STDOUT: .Int = %Core.Int +// CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs +// CHECK:STDOUT: .UInt = %Core.UInt +// CHECK:STDOUT: .IntLiteral = %Core.IntLiteral +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/... +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic] +// CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.754 = import_ref Core//prelude/parts/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic] +// CHECK:STDOUT: %Core.import_ref.c01: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.080) = import_ref Core//prelude/parts/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.dc5)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table = impl_witness_table (%Core.import_ref.c01), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.UInt: %UInt.type = import_ref Core//prelude/parts/uint, UInt, loaded [concrete = constants.%UInt.generic] +// CHECK:STDOUT: %Core.IntLiteral: %IntLiteral.type = import_ref Core//prelude/parts/int_literal, IntLiteral, loaded [concrete = constants.%IntLiteral] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %overflow.patt: %pattern_type.104 = value_binding_pattern overflow [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %i32.loc9: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc9_49.1: %i32 = value_of_initializer @__global_init.%ConvertF64ToI32.call.loc9 [concrete = ] +// CHECK:STDOUT: %.loc9_49.2: %i32 = converted @__global_init.%ConvertF64ToI32.call.loc9, %.loc9_49.1 [concrete = ] +// CHECK:STDOUT: %overflow: %i32 = value_binding overflow, %.loc9_49.2 [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %underflow.patt: %pattern_type.104 = value_binding_pattern underflow [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %i32.loc15: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc15_58.1: %i32 = value_of_initializer @__global_init.%ConvertF64ToI32.call.loc15 [concrete = ] +// CHECK:STDOUT: %.loc15_58.2: %i32 = converted @__global_init.%ConvertF64ToI32.call.loc15, %.loc15_58.1 [concrete = ] +// CHECK:STDOUT: %underflow: %i32 = value_binding underflow, %.loc15_58.2 [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %unsigned_neg.patt: %pattern_type.126 = value_binding_pattern unsigned_neg [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %u32.loc21: type = type_literal constants.%u32 [concrete = constants.%u32] +// CHECK:STDOUT: %.loc21_52.1: %u32 = value_of_initializer @__global_init.%ConvertF64ToU32.call [concrete = ] +// CHECK:STDOUT: %.loc21_52.2: %u32 = converted @__global_init.%ConvertF64ToU32.call, %.loc21_52.1 [concrete = ] +// CHECK:STDOUT: %unsigned_neg: %u32 = value_binding unsigned_neg, %.loc21_52.2 [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %literal_overflow.patt: %pattern_type.104 = value_binding_pattern literal_overflow [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %i32.loc27: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc27_66.1: %i32 = value_of_initializer @__global_init.%ConvertFloatLiteralToI32.call.loc27 [concrete = ] +// CHECK:STDOUT: %.loc27_66.2: %i32 = converted @__global_init.%ConvertFloatLiteralToI32.call.loc27, %.loc27_66.1 [concrete = ] +// CHECK:STDOUT: %literal_overflow: %i32 = value_binding literal_overflow, %.loc27_66.2 [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %giant_literal_overflow.patt: %pattern_type.104 = value_binding_pattern giant_literal_overflow [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %i32.loc33: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc33_71.1: %i32 = value_of_initializer @__global_init.%ConvertFloatLiteralToI32.call.loc33 [concrete = ] +// CHECK:STDOUT: %.loc33_71.2: %i32 = converted @__global_init.%ConvertFloatLiteralToI32.call.loc33, %.loc33_71.1 [concrete = ] +// CHECK:STDOUT: %giant_literal_overflow: %i32 = value_binding giant_literal_overflow, %.loc33_71.2 [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %giant_literal_to_int_literal_overflow.patt: %pattern_type.dc0 = value_binding_pattern giant_literal_to_int_literal_overflow [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc40_60.1: type = splice_block %.loc40_60.3 [concrete = Core.IntLiteral] { +// CHECK:STDOUT: %Core.ref.loc40: = name_ref Core, imports.%Core.979 [concrete = imports.%Core.979] +// CHECK:STDOUT: %IntLiteral.ref.loc40: %IntLiteral.type = name_ref IntLiteral, imports.%Core.IntLiteral [concrete = constants.%IntLiteral] +// CHECK:STDOUT: %IntLiteral.call.loc40: init type = call %IntLiteral.ref.loc40() [concrete = Core.IntLiteral] +// CHECK:STDOUT: %.loc40_60.2: type = value_of_initializer %IntLiteral.call.loc40 [concrete = Core.IntLiteral] +// CHECK:STDOUT: %.loc40_60.3: type = converted %IntLiteral.call.loc40, %.loc40_60.2 [concrete = Core.IntLiteral] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc40_108.1: Core.IntLiteral = value_of_initializer @__global_init.%ConvertFloatLiteralToIntLiteral.call.loc40 [concrete = ] +// CHECK:STDOUT: %.loc40_108.2: Core.IntLiteral = converted @__global_init.%ConvertFloatLiteralToIntLiteral.call.loc40, %.loc40_108.1 [concrete = ] +// CHECK:STDOUT: %giant_literal_to_int_literal_overflow: Core.IntLiteral = value_binding giant_literal_to_int_literal_overflow, %.loc40_108.2 [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %giant_exponent_literal_overflow.patt: %pattern_type.104 = value_binding_pattern giant_exponent_literal_overflow [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %i32.loc47: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc47_107.1: %i32 = value_of_initializer @__global_init.%ConvertFloatLiteralToI32.call.loc47 [concrete = ] +// CHECK:STDOUT: %.loc47_107.2: %i32 = converted @__global_init.%ConvertFloatLiteralToI32.call.loc47, %.loc47_107.1 [concrete = ] +// CHECK:STDOUT: %giant_exponent_literal_overflow: %i32 = value_binding giant_exponent_literal_overflow, %.loc47_107.2 [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %giant_exponent_literal_to_int_literal_overflow.patt: %pattern_type.dc0 = value_binding_pattern giant_exponent_literal_to_int_literal_overflow [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc55_69.1: type = splice_block %.loc55_69.3 [concrete = Core.IntLiteral] { +// CHECK:STDOUT: %Core.ref.loc55: = name_ref Core, imports.%Core.979 [concrete = imports.%Core.979] +// CHECK:STDOUT: %IntLiteral.ref.loc55: %IntLiteral.type = name_ref IntLiteral, imports.%Core.IntLiteral [concrete = constants.%IntLiteral] +// CHECK:STDOUT: %IntLiteral.call.loc55: init type = call %IntLiteral.ref.loc55() [concrete = Core.IntLiteral] +// CHECK:STDOUT: %.loc55_69.2: type = value_of_initializer %IntLiteral.call.loc55 [concrete = Core.IntLiteral] +// CHECK:STDOUT: %.loc55_69.3: type = converted %IntLiteral.call.loc55, %.loc55_69.2 [concrete = Core.IntLiteral] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc55_143.1: Core.IntLiteral = value_of_initializer @__global_init.%ConvertFloatLiteralToIntLiteral.call.loc55 [concrete = ] +// CHECK:STDOUT: %.loc55_143.2: Core.IntLiteral = converted @__global_init.%ConvertFloatLiteralToIntLiteral.call.loc55, %.loc55_143.1 [concrete = ] +// CHECK:STDOUT: %giant_exponent_literal_to_int_literal_overflow: Core.IntLiteral = value_binding giant_exponent_literal_to_int_literal_overflow, %.loc55_143.2 [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %literal_overflow_large_mantissa.patt: %pattern_type.104 = value_binding_pattern literal_overflow_large_mantissa [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %i32.loc62: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc62_82.1: %i32 = value_of_initializer @__global_init.%ConvertFloatLiteralToI32.call.loc62 [concrete = ] +// CHECK:STDOUT: %.loc62_82.2: %i32 = converted @__global_init.%ConvertFloatLiteralToI32.call.loc62, %.loc62_82.1 [concrete = ] +// CHECK:STDOUT: %literal_overflow_large_mantissa: %i32 = value_binding literal_overflow_large_mantissa, %.loc62_82.2 [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %literal_overflow_med_mantissa.patt: %pattern_type.104 = value_binding_pattern literal_overflow_med_mantissa [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %i32.loc69: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc69_80.1: %i32 = value_of_initializer @__global_init.%ConvertFloatLiteralToI32.call.loc69 [concrete = ] +// CHECK:STDOUT: %.loc69_80.2: %i32 = converted @__global_init.%ConvertFloatLiteralToI32.call.loc69, %.loc69_80.1 [concrete = ] +// CHECK:STDOUT: %literal_overflow_med_mantissa: %i32 = value_binding literal_overflow_med_mantissa, %.loc69_80.2 [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %literal_overflow_hex_med_mantissa.patt: %pattern_type.104 = value_binding_pattern literal_overflow_hex_med_mantissa [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %i32.loc76: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc76_85.1: %i32 = value_of_initializer @__global_init.%ConvertFloatLiteralToI32.call.loc76 [concrete = ] +// CHECK:STDOUT: %.loc76_85.2: %i32 = converted @__global_init.%ConvertFloatLiteralToI32.call.loc76, %.loc76_85.1 [concrete = ] +// CHECK:STDOUT: %literal_overflow_hex_med_mantissa: %i32 = value_binding literal_overflow_hex_med_mantissa, %.loc76_85.2 [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %literal_overflow_small_mantissa.patt: %pattern_type.104 = value_binding_pattern literal_overflow_small_mantissa [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %i32.loc83: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc83_75.1: %i32 = value_of_initializer @__global_init.%ConvertFloatLiteralToI32.call.loc83 [concrete = ] +// CHECK:STDOUT: %.loc83_75.2: %i32 = converted @__global_init.%ConvertFloatLiteralToI32.call.loc83, %.loc83_75.1 [concrete = ] +// CHECK:STDOUT: %literal_overflow_small_mantissa: %i32 = value_binding literal_overflow_small_mantissa, %.loc83_75.2 [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %literal_overflow_bin_small_mantissa.patt: %pattern_type.104 = value_binding_pattern literal_overflow_bin_small_mantissa [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %i32.loc90: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc90_81.1: %i32 = value_of_initializer @__global_init.%ConvertFloatLiteralToI32.call.loc90 [concrete = ] +// CHECK:STDOUT: %.loc90_81.2: %i32 = converted @__global_init.%ConvertFloatLiteralToI32.call.loc90, %.loc90_81.1 [concrete = ] +// CHECK:STDOUT: %literal_overflow_bin_small_mantissa: %i32 = value_binding literal_overflow_bin_small_mantissa, %.loc90_81.2 [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %literal_overflow_unsigned_neg.patt: %pattern_type.126 = value_binding_pattern literal_overflow_unsigned_neg [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %u32.loc97: type = type_literal constants.%u32 [concrete = constants.%u32] +// CHECK:STDOUT: %.loc97_72.1: %u32 = value_of_initializer @__global_init.%ConvertFloatLiteralToU32.call.loc97 [concrete = ] +// CHECK:STDOUT: %.loc97_72.2: %u32 = converted @__global_init.%ConvertFloatLiteralToU32.call.loc97, %.loc97_72.1 [concrete = ] +// CHECK:STDOUT: %literal_overflow_unsigned_neg: %u32 = value_binding literal_overflow_unsigned_neg, %.loc97_72.2 [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %literal_overflow_bin_unsigned_neg.patt: %pattern_type.126 = value_binding_pattern literal_overflow_bin_unsigned_neg [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %u32.loc104: type = type_literal constants.%u32 [concrete = constants.%u32] +// CHECK:STDOUT: %.loc104_79.1: %u32 = value_of_initializer @__global_init.%ConvertFloatLiteralToU32.call.loc104 [concrete = ] +// CHECK:STDOUT: %.loc104_79.2: %u32 = converted @__global_init.%ConvertFloatLiteralToU32.call.loc104, %.loc104_79.1 [concrete = ] +// CHECK:STDOUT: %literal_overflow_bin_unsigned_neg: %u32 = value_binding literal_overflow_bin_unsigned_neg, %.loc104_79.2 [concrete = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %ConvertF64ToI32.ref.loc9: %ConvertF64ToI32.type = name_ref ConvertF64ToI32, imports.%Main.ConvertF64ToI32 [concrete = constants.%ConvertF64ToI32] +// CHECK:STDOUT: %float.loc9: Core.FloatLiteral = float_literal_value 21474836480e-1 [concrete = constants.%float.bab60c.1] +// CHECK:STDOUT: %impl.elem0.loc9: %.dfd = impl_witness_access constants.%ImplicitAs.impl_witness.141, element0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.565] +// CHECK:STDOUT: %bound_method.loc9_37.1: = bound_method %float.loc9, %impl.elem0.loc9 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.43d] +// CHECK:STDOUT: %specific_fn.loc9: = specific_function %impl.elem0.loc9, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] +// CHECK:STDOUT: %bound_method.loc9_37.2: = bound_method %float.loc9, %specific_fn.loc9 [concrete = constants.%bound_method.f0d] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc9: init %f64.8ef = call %bound_method.loc9_37.2(%float.loc9) [concrete = constants.%float.5f5] +// CHECK:STDOUT: %.loc9_37.1: %f64.8ef = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc9 [concrete = constants.%float.5f5] +// CHECK:STDOUT: %.loc9_37.2: %f64.8ef = converted %float.loc9, %.loc9_37.1 [concrete = constants.%float.5f5] +// CHECK:STDOUT: %ConvertF64ToI32.call.loc9: init %i32 = call %ConvertF64ToI32.ref.loc9(%.loc9_37.2) [concrete = ] +// CHECK:STDOUT: %ConvertF64ToI32.ref.loc15: %ConvertF64ToI32.type = name_ref ConvertF64ToI32, imports.%Main.ConvertF64ToI32 [concrete = constants.%ConvertF64ToI32] +// CHECK:STDOUT: %Negate.ref.loc15: %Negate.type = name_ref Negate, imports.%Main.Negate [concrete = constants.%Negate] +// CHECK:STDOUT: %float.loc15: Core.FloatLiteral = float_literal_value 21474836490e-1 [concrete = constants.%float.449] +// CHECK:STDOUT: %impl.elem0.loc15: %.dfd = impl_witness_access constants.%ImplicitAs.impl_witness.141, element0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.565] +// CHECK:STDOUT: %bound_method.loc15_45.1: = bound_method %float.loc15, %impl.elem0.loc15 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.0c7] +// CHECK:STDOUT: %specific_fn.loc15: = specific_function %impl.elem0.loc15, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] +// CHECK:STDOUT: %bound_method.loc15_45.2: = bound_method %float.loc15, %specific_fn.loc15 [concrete = constants.%bound_method.855] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc15: init %f64.8ef = call %bound_method.loc15_45.2(%float.loc15) [concrete = constants.%float.f40] +// CHECK:STDOUT: %.loc15_45.1: %f64.8ef = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc15 [concrete = constants.%float.f40] +// CHECK:STDOUT: %.loc15_45.2: %f64.8ef = converted %float.loc15, %.loc15_45.1 [concrete = constants.%float.f40] +// CHECK:STDOUT: %Negate.call.loc15: init %f64.8ef = call %Negate.ref.loc15(%.loc15_45.2) [concrete = constants.%float.9be] +// CHECK:STDOUT: %.loc15_57.1: %f64.8ef = value_of_initializer %Negate.call.loc15 [concrete = constants.%float.9be] +// CHECK:STDOUT: %.loc15_57.2: %f64.8ef = converted %Negate.call.loc15, %.loc15_57.1 [concrete = constants.%float.9be] +// CHECK:STDOUT: %ConvertF64ToI32.call.loc15: init %i32 = call %ConvertF64ToI32.ref.loc15(%.loc15_57.2) [concrete = ] +// CHECK:STDOUT: %ConvertF64ToU32.ref: %ConvertF64ToU32.type = name_ref ConvertF64ToU32, imports.%Main.ConvertF64ToU32 [concrete = constants.%ConvertF64ToU32] +// CHECK:STDOUT: %Negate.ref.loc21: %Negate.type = name_ref Negate, imports.%Main.Negate [concrete = constants.%Negate] +// CHECK:STDOUT: %float.loc21: Core.FloatLiteral = float_literal_value 10e-1 [concrete = constants.%float.6da] +// CHECK:STDOUT: %impl.elem0.loc21: %.dfd = impl_witness_access constants.%ImplicitAs.impl_witness.141, element0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.565] +// CHECK:STDOUT: %bound_method.loc21_48.1: = bound_method %float.loc21, %impl.elem0.loc21 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.ffa] +// CHECK:STDOUT: %specific_fn.loc21: = specific_function %impl.elem0.loc21, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] +// CHECK:STDOUT: %bound_method.loc21_48.2: = bound_method %float.loc21, %specific_fn.loc21 [concrete = constants.%bound_method.9d1] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc21: init %f64.8ef = call %bound_method.loc21_48.2(%float.loc21) [concrete = constants.%float.9b4] +// CHECK:STDOUT: %.loc21_48.1: %f64.8ef = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc21 [concrete = constants.%float.9b4] +// CHECK:STDOUT: %.loc21_48.2: %f64.8ef = converted %float.loc21, %.loc21_48.1 [concrete = constants.%float.9b4] +// CHECK:STDOUT: %Negate.call.loc21: init %f64.8ef = call %Negate.ref.loc21(%.loc21_48.2) [concrete = constants.%float.08a] +// CHECK:STDOUT: %.loc21_51.1: %f64.8ef = value_of_initializer %Negate.call.loc21 [concrete = constants.%float.08a] +// CHECK:STDOUT: %.loc21_51.2: %f64.8ef = converted %Negate.call.loc21, %.loc21_51.1 [concrete = constants.%float.08a] +// CHECK:STDOUT: %ConvertF64ToU32.call: init %u32 = call %ConvertF64ToU32.ref(%.loc21_51.2) [concrete = ] +// CHECK:STDOUT: %ConvertFloatLiteralToI32.ref.loc27: %ConvertFloatLiteralToI32.type = name_ref ConvertFloatLiteralToI32, imports.%Main.ConvertFloatLiteralToI32 [concrete = constants.%ConvertFloatLiteralToI32] +// CHECK:STDOUT: %float.loc27: Core.FloatLiteral = float_literal_value 21474836480e-1 [concrete = constants.%float.bab60c.2] +// CHECK:STDOUT: %ConvertFloatLiteralToI32.call.loc27: init %i32 = call %ConvertFloatLiteralToI32.ref.loc27(%float.loc27) [concrete = ] +// CHECK:STDOUT: %ConvertFloatLiteralToI32.ref.loc33: %ConvertFloatLiteralToI32.type = name_ref ConvertFloatLiteralToI32, imports.%Main.ConvertFloatLiteralToI32 [concrete = constants.%ConvertFloatLiteralToI32] +// CHECK:STDOUT: %float.loc33: Core.FloatLiteral = float_literal_value 10e999999 [concrete = constants.%float.53d] +// CHECK:STDOUT: %ConvertFloatLiteralToI32.call.loc33: init %i32 = call %ConvertFloatLiteralToI32.ref.loc33(%float.loc33) [concrete = ] +// CHECK:STDOUT: %ConvertFloatLiteralToIntLiteral.ref.loc40: %ConvertFloatLiteralToIntLiteral.type = name_ref ConvertFloatLiteralToIntLiteral, imports.%Main.ConvertFloatLiteralToIntLiteral [concrete = constants.%ConvertFloatLiteralToIntLiteral] +// CHECK:STDOUT: %float.loc40: Core.FloatLiteral = float_literal_value 10e9999999 [concrete = constants.%float.ef09] +// CHECK:STDOUT: %ConvertFloatLiteralToIntLiteral.call.loc40: init Core.IntLiteral = call %ConvertFloatLiteralToIntLiteral.ref.loc40(%float.loc40) [concrete = ] +// CHECK:STDOUT: %ConvertFloatLiteralToI32.ref.loc47: %ConvertFloatLiteralToI32.type = name_ref ConvertFloatLiteralToI32, imports.%Main.ConvertFloatLiteralToI32 [concrete = constants.%ConvertFloatLiteralToI32] +// CHECK:STDOUT: %float.loc47: Core.FloatLiteral = float_literal_value 10e999999999999999999999999999999999 [concrete = constants.%float.f461ee.1] +// CHECK:STDOUT: %ConvertFloatLiteralToI32.call.loc47: init %i32 = call %ConvertFloatLiteralToI32.ref.loc47(%float.loc47) [concrete = ] +// CHECK:STDOUT: %ConvertFloatLiteralToIntLiteral.ref.loc55: %ConvertFloatLiteralToIntLiteral.type = name_ref ConvertFloatLiteralToIntLiteral, imports.%Main.ConvertFloatLiteralToIntLiteral [concrete = constants.%ConvertFloatLiteralToIntLiteral] +// CHECK:STDOUT: %float.loc55: Core.FloatLiteral = float_literal_value 10e999999999999999999999999999999999 [concrete = constants.%float.f461ee.2] +// CHECK:STDOUT: %ConvertFloatLiteralToIntLiteral.call.loc55: init Core.IntLiteral = call %ConvertFloatLiteralToIntLiteral.ref.loc55(%float.loc55) [concrete = ] +// CHECK:STDOUT: %ConvertFloatLiteralToI32.ref.loc62: %ConvertFloatLiteralToI32.type = name_ref ConvertFloatLiteralToI32, imports.%Main.ConvertFloatLiteralToI32 [concrete = constants.%ConvertFloatLiteralToI32] +// CHECK:STDOUT: %float.loc62: Core.FloatLiteral = float_literal_value 2147483648e0 [concrete = constants.%float.e12922.1] +// CHECK:STDOUT: %ConvertFloatLiteralToI32.call.loc62: init %i32 = call %ConvertFloatLiteralToI32.ref.loc62(%float.loc62) [concrete = ] +// CHECK:STDOUT: %ConvertFloatLiteralToI32.ref.loc69: %ConvertFloatLiteralToI32.type = name_ref ConvertFloatLiteralToI32, imports.%Main.ConvertFloatLiteralToI32 [concrete = constants.%ConvertFloatLiteralToI32] +// CHECK:STDOUT: %float.loc69: Core.FloatLiteral = float_literal_value 2147483648e0 [concrete = constants.%float.e12922.2] +// CHECK:STDOUT: %ConvertFloatLiteralToI32.call.loc69: init %i32 = call %ConvertFloatLiteralToI32.ref.loc69(%float.loc69) [concrete = ] +// CHECK:STDOUT: %ConvertFloatLiteralToI32.ref.loc76: %ConvertFloatLiteralToI32.type = name_ref ConvertFloatLiteralToI32, imports.%Main.ConvertFloatLiteralToI32 [concrete = constants.%ConvertFloatLiteralToI32] +// CHECK:STDOUT: %float.loc76: Core.FloatLiteral = float_literal_value 2147483648p0 [concrete = constants.%float.ef03] +// CHECK:STDOUT: %ConvertFloatLiteralToI32.call.loc76: init %i32 = call %ConvertFloatLiteralToI32.ref.loc76(%float.loc76) [concrete = ] +// CHECK:STDOUT: %ConvertFloatLiteralToI32.ref.loc83: %ConvertFloatLiteralToI32.type = name_ref ConvertFloatLiteralToI32, imports.%Main.ConvertFloatLiteralToI32 [concrete = constants.%ConvertFloatLiteralToI32] +// CHECK:STDOUT: %float.loc83: Core.FloatLiteral = float_literal_value 10e9 [concrete = constants.%float.9d5] +// CHECK:STDOUT: %ConvertFloatLiteralToI32.call.loc83: init %i32 = call %ConvertFloatLiteralToI32.ref.loc83(%float.loc83) [concrete = ] +// CHECK:STDOUT: %ConvertFloatLiteralToI32.ref.loc90: %ConvertFloatLiteralToI32.type = name_ref ConvertFloatLiteralToI32, imports.%Main.ConvertFloatLiteralToI32 [concrete = constants.%ConvertFloatLiteralToI32] +// CHECK:STDOUT: %float.loc90: Core.FloatLiteral = float_literal_value 16p27 [concrete = constants.%float.c0c] +// CHECK:STDOUT: %ConvertFloatLiteralToI32.call.loc90: init %i32 = call %ConvertFloatLiteralToI32.ref.loc90(%float.loc90) [concrete = ] +// CHECK:STDOUT: %ConvertFloatLiteralToU32.ref.loc97: %ConvertFloatLiteralToU32.type = name_ref ConvertFloatLiteralToU32, imports.%Main.ConvertFloatLiteralToU32 [concrete = constants.%ConvertFloatLiteralToU32] +// CHECK:STDOUT: %float.loc97: Core.FloatLiteral = float_literal_value 50e8 [concrete = constants.%float.4f4] +// CHECK:STDOUT: %ConvertFloatLiteralToU32.call.loc97: init %u32 = call %ConvertFloatLiteralToU32.ref.loc97(%float.loc97) [concrete = ] +// CHECK:STDOUT: %ConvertFloatLiteralToU32.ref.loc104: %ConvertFloatLiteralToU32.type = name_ref ConvertFloatLiteralToU32, imports.%Main.ConvertFloatLiteralToU32 [concrete = constants.%ConvertFloatLiteralToU32] +// CHECK:STDOUT: %float.loc104: Core.FloatLiteral = float_literal_value 16p28 [concrete = constants.%float.97b] +// CHECK:STDOUT: %ConvertFloatLiteralToU32.call.loc104: init %u32 = call %ConvertFloatLiteralToU32.ref.loc104(%float.loc104) [concrete = ] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_nan_inf.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] +// CHECK:STDOUT: %pattern_type.104: type = pattern_type %i32 [concrete] +// CHECK:STDOUT: %ConvertF64ToI32.type: type = fn_type @ConvertF64ToI32 [concrete] +// CHECK:STDOUT: %ConvertF64ToI32: %ConvertF64ToI32.type = struct_value () [concrete] +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete] +// CHECK:STDOUT: %f64.8ef: type = class_type @Float, @Float(%int_64) [concrete] +// CHECK:STDOUT: %Div.type: type = fn_type @Div [concrete] +// CHECK:STDOUT: %Div: %Div.type = struct_value () [concrete] +// CHECK:STDOUT: %float.1f75e4.1: Core.FloatLiteral = float_literal_value 0e-1 [concrete] +// CHECK:STDOUT: %float.1f75e4.2: Core.FloatLiteral = float_literal_value 0e-1 [concrete] +// CHECK:STDOUT: %ImplicitAs.type.047: type = facet_type <@ImplicitAs, @ImplicitAs(%f64.8ef)> [concrete] +// CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.080: type = fn_type @Core.FloatLiteral.as.ImplicitAs.impl.Convert, @Core.FloatLiteral.as.ImplicitAs.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.dc5: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.080 = struct_value () [symbolic] +// CHECK:STDOUT: %ImplicitAs.impl_witness.141: = impl_witness imports.%ImplicitAs.impl_witness_table, @Core.FloatLiteral.as.ImplicitAs.impl(%int_64) [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.828: type = fn_type @Core.FloatLiteral.as.ImplicitAs.impl.Convert, @Core.FloatLiteral.as.ImplicitAs.impl(%int_64) [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.565: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.828 = struct_value () [concrete] +// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.047 = facet_value Core.FloatLiteral, (%ImplicitAs.impl_witness.141) [concrete] +// CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.1e2: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%f64.8ef, %ImplicitAs.facet) [concrete] +// CHECK:STDOUT: %.dfd: type = fn_type_with_self_type %ImplicitAs.WithSelf.Convert.type.1e2, %ImplicitAs.facet [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.040aeb.1: = bound_method %float.1f75e4.1, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.565 [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.FloatLiteral.as.ImplicitAs.impl.Convert.565, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(%int_64) [concrete] +// CHECK:STDOUT: %bound_method.155552.1: = bound_method %float.1f75e4.1, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.ff2: %f64.8ef = float_value 0 [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.040aeb.2: = bound_method %float.1f75e4.2, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.565 [concrete] +// CHECK:STDOUT: %bound_method.155552.2: = bound_method %float.1f75e4.2, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.142: %f64.8ef = float_value NaN [concrete] +// CHECK:STDOUT: %float.6da: Core.FloatLiteral = float_literal_value 10e-1 [concrete] +// CHECK:STDOUT: %float.1f75e4.3: Core.FloatLiteral = float_literal_value 0e-1 [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.ffa: = bound_method %float.6da, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.565 [concrete] +// CHECK:STDOUT: %bound_method.9d1: = bound_method %float.6da, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.9b4: %f64.8ef = float_value 1 [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.040aeb.3: = bound_method %float.1f75e4.3, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.565 [concrete] +// CHECK:STDOUT: %bound_method.155552.3: = bound_method %float.1f75e4.3, %Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.ab6: %f64.8ef = float_value +Inf [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Main.ConvertF64ToI32: %ConvertF64ToI32.type = import_ref Main//float_to_int, ConvertF64ToI32, loaded [concrete = constants.%ConvertF64ToI32] +// CHECK:STDOUT: %Main.Div: %Div.type = import_ref Main//float_to_int, Div, loaded [concrete = constants.%Div] +// CHECK:STDOUT: %Core.import_ref.c01: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.080) = import_ref Core//prelude/parts/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.dc5)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table = impl_witness_table (%Core.import_ref.c01), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %nan_val.patt: %pattern_type.104 = value_binding_pattern nan_val [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %i32.loc9: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc9_49.1: %i32 = value_of_initializer @__global_init.%ConvertF64ToI32.call.loc9 [concrete = ] +// CHECK:STDOUT: %.loc9_49.2: %i32 = converted @__global_init.%ConvertF64ToI32.call.loc9, %.loc9_49.1 [concrete = ] +// CHECK:STDOUT: %nan_val: %i32 = value_binding nan_val, %.loc9_49.2 [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %inf_val.patt: %pattern_type.104 = value_binding_pattern inf_val [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %i32.loc15: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc15_49.1: %i32 = value_of_initializer @__global_init.%ConvertF64ToI32.call.loc15 [concrete = ] +// CHECK:STDOUT: %.loc15_49.2: %i32 = converted @__global_init.%ConvertF64ToI32.call.loc15, %.loc15_49.1 [concrete = ] +// CHECK:STDOUT: %inf_val: %i32 = value_binding inf_val, %.loc15_49.2 [concrete = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %ConvertF64ToI32.ref.loc9: %ConvertF64ToI32.type = name_ref ConvertF64ToI32, imports.%Main.ConvertF64ToI32 [concrete = constants.%ConvertF64ToI32] +// CHECK:STDOUT: %Div.ref.loc9: %Div.type = name_ref Div, imports.%Main.Div [concrete = constants.%Div] +// CHECK:STDOUT: %float.loc9_40: Core.FloatLiteral = float_literal_value 0e-1 [concrete = constants.%float.1f75e4.1] +// CHECK:STDOUT: %float.loc9_45: Core.FloatLiteral = float_literal_value 0e-1 [concrete = constants.%float.1f75e4.2] +// CHECK:STDOUT: %impl.elem0.loc9_40: %.dfd = impl_witness_access constants.%ImplicitAs.impl_witness.141, element0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.565] +// CHECK:STDOUT: %bound_method.loc9_40.1: = bound_method %float.loc9_40, %impl.elem0.loc9_40 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.040aeb.1] +// CHECK:STDOUT: %specific_fn.loc9_40: = specific_function %impl.elem0.loc9_40, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] +// CHECK:STDOUT: %bound_method.loc9_40.2: = bound_method %float.loc9_40, %specific_fn.loc9_40 [concrete = constants.%bound_method.155552.1] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc9_40: init %f64.8ef = call %bound_method.loc9_40.2(%float.loc9_40) [concrete = constants.%float.ff2] +// CHECK:STDOUT: %.loc9_40.1: %f64.8ef = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc9_40 [concrete = constants.%float.ff2] +// CHECK:STDOUT: %.loc9_40.2: %f64.8ef = converted %float.loc9_40, %.loc9_40.1 [concrete = constants.%float.ff2] +// CHECK:STDOUT: %impl.elem0.loc9_45: %.dfd = impl_witness_access constants.%ImplicitAs.impl_witness.141, element0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.565] +// CHECK:STDOUT: %bound_method.loc9_45.1: = bound_method %float.loc9_45, %impl.elem0.loc9_45 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.040aeb.2] +// CHECK:STDOUT: %specific_fn.loc9_45: = specific_function %impl.elem0.loc9_45, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] +// CHECK:STDOUT: %bound_method.loc9_45.2: = bound_method %float.loc9_45, %specific_fn.loc9_45 [concrete = constants.%bound_method.155552.2] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc9_45: init %f64.8ef = call %bound_method.loc9_45.2(%float.loc9_45) [concrete = constants.%float.ff2] +// CHECK:STDOUT: %.loc9_45.1: %f64.8ef = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc9_45 [concrete = constants.%float.ff2] +// CHECK:STDOUT: %.loc9_45.2: %f64.8ef = converted %float.loc9_45, %.loc9_45.1 [concrete = constants.%float.ff2] +// CHECK:STDOUT: %Div.call.loc9: init %f64.8ef = call %Div.ref.loc9(%.loc9_40.2, %.loc9_45.2) [concrete = constants.%float.142] +// CHECK:STDOUT: %.loc9_48.1: %f64.8ef = value_of_initializer %Div.call.loc9 [concrete = constants.%float.142] +// CHECK:STDOUT: %.loc9_48.2: %f64.8ef = converted %Div.call.loc9, %.loc9_48.1 [concrete = constants.%float.142] +// CHECK:STDOUT: %ConvertF64ToI32.call.loc9: init %i32 = call %ConvertF64ToI32.ref.loc9(%.loc9_48.2) [concrete = ] +// CHECK:STDOUT: %ConvertF64ToI32.ref.loc15: %ConvertF64ToI32.type = name_ref ConvertF64ToI32, imports.%Main.ConvertF64ToI32 [concrete = constants.%ConvertF64ToI32] +// CHECK:STDOUT: %Div.ref.loc15: %Div.type = name_ref Div, imports.%Main.Div [concrete = constants.%Div] +// CHECK:STDOUT: %float.loc15_40: Core.FloatLiteral = float_literal_value 10e-1 [concrete = constants.%float.6da] +// CHECK:STDOUT: %float.loc15_45: Core.FloatLiteral = float_literal_value 0e-1 [concrete = constants.%float.1f75e4.3] +// CHECK:STDOUT: %impl.elem0.loc15_40: %.dfd = impl_witness_access constants.%ImplicitAs.impl_witness.141, element0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.565] +// CHECK:STDOUT: %bound_method.loc15_40.1: = bound_method %float.loc15_40, %impl.elem0.loc15_40 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.ffa] +// CHECK:STDOUT: %specific_fn.loc15_40: = specific_function %impl.elem0.loc15_40, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] +// CHECK:STDOUT: %bound_method.loc15_40.2: = bound_method %float.loc15_40, %specific_fn.loc15_40 [concrete = constants.%bound_method.9d1] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc15_40: init %f64.8ef = call %bound_method.loc15_40.2(%float.loc15_40) [concrete = constants.%float.9b4] +// CHECK:STDOUT: %.loc15_40.1: %f64.8ef = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc15_40 [concrete = constants.%float.9b4] +// CHECK:STDOUT: %.loc15_40.2: %f64.8ef = converted %float.loc15_40, %.loc15_40.1 [concrete = constants.%float.9b4] +// CHECK:STDOUT: %impl.elem0.loc15_45: %.dfd = impl_witness_access constants.%ImplicitAs.impl_witness.141, element0 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.565] +// CHECK:STDOUT: %bound_method.loc15_45.1: = bound_method %float.loc15_45, %impl.elem0.loc15_45 [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.bound.040aeb.3] +// CHECK:STDOUT: %specific_fn.loc15_45: = specific_function %impl.elem0.loc15_45, @Core.FloatLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.specific_fn] +// CHECK:STDOUT: %bound_method.loc15_45.2: = bound_method %float.loc15_45, %specific_fn.loc15_45 [concrete = constants.%bound_method.155552.3] +// CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc15_45: init %f64.8ef = call %bound_method.loc15_45.2(%float.loc15_45) [concrete = constants.%float.ff2] +// CHECK:STDOUT: %.loc15_45.1: %f64.8ef = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call.loc15_45 [concrete = constants.%float.ff2] +// CHECK:STDOUT: %.loc15_45.2: %f64.8ef = converted %float.loc15_45, %.loc15_45.1 [concrete = constants.%float.ff2] +// CHECK:STDOUT: %Div.call.loc15: init %f64.8ef = call %Div.ref.loc15(%.loc15_40.2, %.loc15_45.2) [concrete = constants.%float.ab6] +// CHECK:STDOUT: %.loc15_48.1: %f64.8ef = value_of_initializer %Div.call.loc15 [concrete = constants.%float.ab6] +// CHECK:STDOUT: %.loc15_48.2: %f64.8ef = converted %Div.call.loc15, %.loc15_48.1 [concrete = constants.%float.ab6] +// CHECK:STDOUT: %ConvertF64ToI32.call.loc15: init %i32 = call %ConvertF64ToI32.ref.loc15(%.loc15_48.2) [concrete = ] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/int/convert_float.carbon b/toolchain/check/testdata/builtins/int/convert_float.carbon new file mode 100644 index 000000000000..801bbc145ad4 --- /dev/null +++ b/toolchain/check/testdata/builtins/int/convert_float.carbon @@ -0,0 +1,173 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/primitives.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/int/convert_float.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/int/convert_float.carbon + +// --- int_to_float.carbon +library "[[@TEST_NAME]]"; + +fn ConvertI32ToF64(a: i32) -> f64 = "int.convert_float"; +fn ConvertU32ToF64(a: u32) -> f64 = "int.convert_float"; +fn ConvertIntLiteralToF64(a: Core.IntLiteral()) -> f64 = "int.convert_float"; +fn ConvertIntLiteralToFloatLiteral(a: Core.IntLiteral()) -> Core.FloatLiteral() = "int.convert_float"; + +fn Negate(a: f64) -> f64 = "float.negate"; + +class Expect[T:! type](N:! T) {} +fn Test[T:! type](N:! T) -> Expect(N) { return {}; } + +// --- identity.carbon +library "[[@TEST_NAME]]"; +import library "int_to_float"; + +fn F() { + Test(ConvertI32ToF64(0)) as Expect(0.0 as f64); + Test(ConvertI32ToF64(1)) as Expect(1.0 as f64); + Test(ConvertI32ToF64(-1)) as Expect(Negate(1.0)); + Test(ConvertI32ToF64(123456789)) as Expect(123456789.0 as f64); + + Test(ConvertU32ToF64(0)) as Expect(0.0 as f64); + Test(ConvertU32ToF64(1)) as Expect(1.0 as f64); + Test(ConvertU32ToF64(4294967295)) as Expect(4294967295.0 as f64); + + Test(ConvertIntLiteralToF64(1)) as Expect(1.0 as f64); + Test(ConvertIntLiteralToF64(-1)) as Expect(Negate(1.0)); + + Test(ConvertIntLiteralToFloatLiteral(1) as f64) as Expect(1.0 as f64); +} + +// --- fail_overflow.carbon +library "[[@TEST_NAME]]"; +import library "int_to_float"; + +//@dump-sem-ir-begin +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:21: error: integer value 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 too large for floating-point type `f64` [IntTooLargeForFloatType] +// CHECK:STDERR: let overflow: f64 = ConvertIntLiteralToF64(1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let overflow: f64 = ConvertIntLiteralToF64(1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000); +//@dump-sem-ir-end + +// --- fail_todo_negative_literal.carbon +library "[[@TEST_NAME]]"; +import library "int_to_float"; + +//@dump-sem-ir-begin +// CHECK:STDERR: fail_todo_negative_literal.carbon:[[@LINE+4]]:20: error: semantics TODO: `negative float literal conversion` [SemanticsTodo] +// CHECK:STDERR: let invalid: f64 = ConvertIntLiteralToFloatLiteral(-1) as f64; +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let invalid: f64 = ConvertIntLiteralToFloatLiteral(-1) as f64; +//@dump-sem-ir-end + +// CHECK:STDOUT: --- fail_overflow.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete] +// CHECK:STDOUT: %f64.b55: type = class_type @Float, @Float(%int_64) [concrete] +// CHECK:STDOUT: %pattern_type.f3c: type = pattern_type %f64.b55 [concrete] +// CHECK:STDOUT: %ConvertIntLiteralToF64.type: type = fn_type @ConvertIntLiteralToF64 [concrete] +// CHECK:STDOUT: %ConvertIntLiteralToF64: %ConvertIntLiteralToF64.type = struct_value () [concrete] +// CHECK:STDOUT: %int_1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000: Core.IntLiteral = int_value 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Main.ConvertIntLiteralToF64: %ConvertIntLiteralToF64.type = import_ref Main//int_to_float, ConvertIntLiteralToF64, loaded [concrete = constants.%ConvertIntLiteralToF64] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %overflow.patt: %pattern_type.f3c = value_binding_pattern overflow [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %f64: type = type_literal constants.%f64.b55 [concrete = constants.%f64.b55] +// CHECK:STDOUT: %.loc9_354.1: %f64.b55 = value_of_initializer @__global_init.%ConvertIntLiteralToF64.call [concrete = ] +// CHECK:STDOUT: %.loc9_354.2: %f64.b55 = converted @__global_init.%ConvertIntLiteralToF64.call, %.loc9_354.1 [concrete = ] +// CHECK:STDOUT: %overflow: %f64.b55 = value_binding overflow, %.loc9_354.2 [concrete = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %ConvertIntLiteralToF64.ref: %ConvertIntLiteralToF64.type = name_ref ConvertIntLiteralToF64, imports.%Main.ConvertIntLiteralToF64 [concrete = constants.%ConvertIntLiteralToF64] +// CHECK:STDOUT: %int_1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000: Core.IntLiteral = int_value 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 [concrete = constants.%int_1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000] +// CHECK:STDOUT: %ConvertIntLiteralToF64.call: init %f64.b55 = call %ConvertIntLiteralToF64.ref(%int_1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) [concrete = ] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_negative_literal.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete] +// CHECK:STDOUT: %f64.b55: type = class_type @Float, @Float(%int_64) [concrete] +// CHECK:STDOUT: %pattern_type.f3c: type = pattern_type %f64.b55 [concrete] +// CHECK:STDOUT: %ConvertIntLiteralToFloatLiteral.type: type = fn_type @ConvertIntLiteralToFloatLiteral [concrete] +// CHECK:STDOUT: %ConvertIntLiteralToFloatLiteral: %ConvertIntLiteralToFloatLiteral.type = struct_value () [concrete] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete] +// CHECK:STDOUT: %Negate.type: type = facet_type <@Negate> [concrete] +// CHECK:STDOUT: %Negate.impl_witness: = impl_witness imports.%Negate.impl_witness_table [concrete] +// CHECK:STDOUT: %Negate.facet: %Negate.type = facet_value Core.IntLiteral, (%Negate.impl_witness) [concrete] +// CHECK:STDOUT: %Negate.WithSelf.Op.type.309: type = fn_type @Negate.WithSelf.Op, @Negate.WithSelf(%Negate.facet) [concrete] +// CHECK:STDOUT: %.f38: type = fn_type_with_self_type %Negate.WithSelf.Op.type.309, %Negate.facet [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.Negate.impl.Op.type: type = fn_type @Core.IntLiteral.as.Negate.impl.Op [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.Negate.impl.Op: %Core.IntLiteral.as.Negate.impl.Op.type = struct_value () [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.Negate.impl.Op.bound: = bound_method %int_1, %Core.IntLiteral.as.Negate.impl.Op [concrete] +// CHECK:STDOUT: %int_-1: Core.IntLiteral = int_value -1 [concrete] +// CHECK:STDOUT: %As.type.e53: type = facet_type <@As, @As(%f64.b55)> [concrete] +// CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.type.bad: type = fn_type @Core.FloatLiteral.as.As.impl.Convert, @Core.FloatLiteral.as.As.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.df8: %Core.FloatLiteral.as.As.impl.Convert.type.bad = struct_value () [symbolic] +// CHECK:STDOUT: %As.impl_witness.cf2: = impl_witness imports.%As.impl_witness_table, @Core.FloatLiteral.as.As.impl(%int_64) [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.type.8de: type = fn_type @Core.FloatLiteral.as.As.impl.Convert, @Core.FloatLiteral.as.As.impl(%int_64) [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.bcc: %Core.FloatLiteral.as.As.impl.Convert.type.8de = struct_value () [concrete] +// CHECK:STDOUT: %As.facet: %As.type.e53 = facet_value Core.FloatLiteral, (%As.impl_witness.cf2) [concrete] +// CHECK:STDOUT: %As.WithSelf.Convert.type.d43: type = fn_type @As.WithSelf.Convert, @As.WithSelf(%f64.b55, %As.facet) [concrete] +// CHECK:STDOUT: %.f88: type = fn_type_with_self_type %As.WithSelf.Convert.type.d43, %As.facet [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.specific_fn: = specific_function %Core.FloatLiteral.as.As.impl.Convert.bcc, @Core.FloatLiteral.as.As.impl.Convert(%int_64) [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Main.ConvertIntLiteralToFloatLiteral: %ConvertIntLiteralToFloatLiteral.type = import_ref Main//int_to_float, ConvertIntLiteralToFloatLiteral, loaded [concrete = constants.%ConvertIntLiteralToFloatLiteral] +// CHECK:STDOUT: %Core.import_ref.abd = import_ref Core//prelude/parts/int_literal, loc{{\d+_\d+}}, unloaded +// CHECK:STDOUT: %Core.import_ref.f63: %Core.IntLiteral.as.Negate.impl.Op.type = import_ref Core//prelude/parts/int_literal, loc{{\d+_\d+}}, loaded [concrete = constants.%Core.IntLiteral.as.Negate.impl.Op] +// CHECK:STDOUT: %Negate.impl_witness_table = impl_witness_table (%Core.import_ref.abd, %Core.import_ref.f63), @Core.IntLiteral.as.Negate.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.81f: @Core.FloatLiteral.as.As.impl.%Core.FloatLiteral.as.As.impl.Convert.type (%Core.FloatLiteral.as.As.impl.Convert.type.bad) = import_ref Core//prelude/parts/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.As.impl.%Core.FloatLiteral.as.As.impl.Convert (constants.%Core.FloatLiteral.as.As.impl.Convert.df8)] +// CHECK:STDOUT: %As.impl_witness_table = impl_witness_table (%Core.import_ref.81f), @Core.FloatLiteral.as.As.impl [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %invalid.patt: %pattern_type.f3c = value_binding_pattern invalid [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %f64: type = type_literal constants.%f64.b55 [concrete = constants.%f64.b55] +// CHECK:STDOUT: %invalid: %f64.b55 = value_binding invalid, @__global_init.%.loc9_56.2 [concrete = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %ConvertIntLiteralToFloatLiteral.ref: %ConvertIntLiteralToFloatLiteral.type = name_ref ConvertIntLiteralToFloatLiteral, imports.%Main.ConvertIntLiteralToFloatLiteral [concrete = constants.%ConvertIntLiteralToFloatLiteral] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] +// CHECK:STDOUT: %impl.elem1: %.f38 = impl_witness_access constants.%Negate.impl_witness, element1 [concrete = constants.%Core.IntLiteral.as.Negate.impl.Op] +// CHECK:STDOUT: %bound_method.loc9_52: = bound_method %int_1, %impl.elem1 [concrete = constants.%Core.IntLiteral.as.Negate.impl.Op.bound] +// CHECK:STDOUT: %Core.IntLiteral.as.Negate.impl.Op.call: init Core.IntLiteral = call %bound_method.loc9_52(%int_1) [concrete = constants.%int_-1] +// CHECK:STDOUT: %.loc9_52.1: Core.IntLiteral = value_of_initializer %Core.IntLiteral.as.Negate.impl.Op.call [concrete = constants.%int_-1] +// CHECK:STDOUT: %.loc9_52.2: Core.IntLiteral = converted %Core.IntLiteral.as.Negate.impl.Op.call, %.loc9_52.1 [concrete = constants.%int_-1] +// CHECK:STDOUT: %ConvertIntLiteralToFloatLiteral.call: init Core.FloatLiteral = call %ConvertIntLiteralToFloatLiteral.ref(%.loc9_52.2) [concrete = ] +// CHECK:STDOUT: %f64: type = type_literal constants.%f64.b55 [concrete = constants.%f64.b55] +// CHECK:STDOUT: %impl.elem0: %.f88 = impl_witness_access constants.%As.impl_witness.cf2, element0 [concrete = constants.%Core.FloatLiteral.as.As.impl.Convert.bcc] +// CHECK:STDOUT: %bound_method.loc9_56.1: = bound_method %ConvertIntLiteralToFloatLiteral.call, %impl.elem0 [concrete = ] +// 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.loc9_56.2: = bound_method %ConvertIntLiteralToFloatLiteral.call, %specific_fn [concrete = ] +// CHECK:STDOUT: %.loc9_54.1: Core.FloatLiteral = value_of_initializer %ConvertIntLiteralToFloatLiteral.call [concrete = ] +// CHECK:STDOUT: %.loc9_54.2: Core.FloatLiteral = converted %ConvertIntLiteralToFloatLiteral.call, %.loc9_54.1 [concrete = ] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.call: init %f64.b55 = call %bound_method.loc9_56.2(%.loc9_54.2) [concrete = ] +// CHECK:STDOUT: %.loc9_56.1: %f64.b55 = value_of_initializer %Core.FloatLiteral.as.As.impl.Convert.call [concrete = ] +// CHECK:STDOUT: %.loc9_56.2: %f64.b55 = converted %ConvertIntLiteralToFloatLiteral.call, %.loc9_56.1 [concrete = ] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/int/convert_float_checked.carbon b/toolchain/check/testdata/builtins/int/convert_float_checked.carbon new file mode 100644 index 000000000000..aaa3da0b9cb7 --- /dev/null +++ b/toolchain/check/testdata/builtins/int/convert_float_checked.carbon @@ -0,0 +1,78 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/primitives.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/int/convert_float_checked.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/int/convert_float_checked.carbon + +// --- int_to_float_checked.carbon +library "[[@TEST_NAME]]"; + +fn ConvertIntLiteralToFloatLiteral(a: Core.IntLiteral()) -> Core.FloatLiteral() = "int.convert_float_checked"; +fn ConvertIntLiteralToF32(a: Core.IntLiteral()) -> f32 = "int.convert_float_checked"; + +class Expect[T:! type](N:! T) {} +fn Test[T:! type](N:! T) -> Expect(N) { return {}; } + +// --- identity.carbon +library "[[@TEST_NAME]]"; +import library "int_to_float_checked"; + +fn F() { + // Exact unsized float literal checked conversion. + Test(ConvertIntLiteralToFloatLiteral(42) as f64) as Expect(42.0 as f64); + + // Direct exact sized float conversions. + Test(ConvertIntLiteralToF32(12345)) as Expect(12345.0 as f32); +} + +// --- fail_lossy.carbon +library "[[@TEST_NAME]]"; +import library "int_to_float_checked"; + +//@dump-sem-ir-begin +// CHECK:STDERR: fail_lossy.carbon:[[@LINE+4]]:18: error: integer value 123456789 cannot be represented exactly in floating-point type `f32` [IntLossyConversionToFloat] +// CHECK:STDERR: let lossy: f32 = ConvertIntLiteralToF32(123456789); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let lossy: f32 = ConvertIntLiteralToF32(123456789); +//@dump-sem-ir-end + +// CHECK:STDOUT: --- fail_lossy.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] +// CHECK:STDOUT: %f32.a26: type = class_type @Float, @Float(%int_32) [concrete] +// CHECK:STDOUT: %pattern_type.f3b: type = pattern_type %f32.a26 [concrete] +// CHECK:STDOUT: %ConvertIntLiteralToF32.type: type = fn_type @ConvertIntLiteralToF32 [concrete] +// CHECK:STDOUT: %ConvertIntLiteralToF32: %ConvertIntLiteralToF32.type = struct_value () [concrete] +// CHECK:STDOUT: %int_123456789: Core.IntLiteral = int_value 123456789 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Main.ConvertIntLiteralToF32: %ConvertIntLiteralToF32.type = import_ref Main//int_to_float_checked, ConvertIntLiteralToF32, loaded [concrete = constants.%ConvertIntLiteralToF32] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %lossy.patt: %pattern_type.f3b = value_binding_pattern lossy [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %f32: type = type_literal constants.%f32.a26 [concrete = constants.%f32.a26] +// CHECK:STDOUT: %.loc9_50.1: %f32.a26 = value_of_initializer @__global_init.%ConvertIntLiteralToF32.call [concrete = ] +// CHECK:STDOUT: %.loc9_50.2: %f32.a26 = converted @__global_init.%ConvertIntLiteralToF32.call, %.loc9_50.1 [concrete = ] +// CHECK:STDOUT: %lossy: %f32.a26 = value_binding lossy, %.loc9_50.2 [concrete = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %ConvertIntLiteralToF32.ref: %ConvertIntLiteralToF32.type = name_ref ConvertIntLiteralToF32, imports.%Main.ConvertIntLiteralToF32 [concrete = constants.%ConvertIntLiteralToF32] +// CHECK:STDOUT: %int_123456789: Core.IntLiteral = int_value 123456789 [concrete = constants.%int_123456789] +// CHECK:STDOUT: %ConvertIntLiteralToF32.call: init %f32.a26 = call %ConvertIntLiteralToF32.ref(%int_123456789) [concrete = ] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/print/int.carbon b/toolchain/check/testdata/builtins/print/int.carbon index b9629edad7b7..7cabb1050273 100644 --- a/toolchain/check/testdata/builtins/print/int.carbon +++ b/toolchain/check/testdata/builtins/print/int.carbon @@ -36,10 +36,10 @@ fn Main() { // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.754 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.type.360: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete] // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%To) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048 = struct_value () [symbolic] -// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.ab1: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.360 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.3d6) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.da5: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i32, %ImplicitAs.facet) [concrete] @@ -67,8 +67,8 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic] // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.754 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic] -// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl.4e8 [concrete] // CHECK:STDOUT: %Core.Print: %Print.type.a10 = import_ref Core//io, Print, loaded [concrete = constants.%Print.2fc] // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/for/actual.carbon b/toolchain/check/testdata/for/actual.carbon index 9b83b9d82739..da09dfc72756 100644 --- a/toolchain/check/testdata/for/actual.carbon +++ b/toolchain/check/testdata/for/actual.carbon @@ -188,10 +188,10 @@ fn Read(y:! Core.IntLiteral()) { // CHECK:STDOUT: %IntRange.Make.specific_fn: = specific_function %IntRange.Make.2b6, @IntRange.Make(%int_32) [concrete] // CHECK:STDOUT: %ImplicitAs.type.360: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete] // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%To) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048 = struct_value () [symbolic] -// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.ab1: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet.840: %ImplicitAs.type.360 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.3d6) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.da5: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i32, %ImplicitAs.facet.840) [concrete] @@ -251,8 +251,8 @@ fn Read(y:! Core.IntLiteral()) { // CHECK:STDOUT: %Core.Inc: type = import_ref Core//prelude/operators/arithmetic, Inc, loaded [concrete = constants.%Inc.type] // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/destroy, Destroy, loaded [concrete = constants.%Destroy.type] // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.754 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic] -// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl.4e8 [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -892,10 +892,10 @@ fn Read(y:! Core.IntLiteral()) { // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.754 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.type.cf3: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete] // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.a20: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.a20: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.09f(%To) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.cd7: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.a20 = struct_value () [symbolic] -// CHECK:STDOUT: %ImplicitAs.impl_witness.e84: = impl_witness imports.%ImplicitAs.impl_witness_table.fca, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.104: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.e84: = impl_witness imports.%ImplicitAs.impl_witness_table.fca, @Core.IntLiteral.as.ImplicitAs.impl.09f(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.104: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.09f(%int_32) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.785: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.104 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.cf3 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.e84) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.b79: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i32, %ImplicitAs.facet) [concrete] @@ -928,8 +928,8 @@ fn Read(y:! Core.IntLiteral()) { // CHECK:STDOUT: %Main.import_ref.acd = import_ref Main//lib, loc23_18, unloaded // CHECK:STDOUT: %Main.import_ref.6b552a.2: Core.IntLiteral = import_ref Main//lib, loc4_17, loaded [symbolic = @IntRange.%N (constants.%N)] // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.754 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic] -// CHECK:STDOUT: %Core.import_ref.4e597: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.a20) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.cd7)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.fca = impl_witness_table (%Core.import_ref.4e597), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.4e597: @Core.IntLiteral.as.ImplicitAs.impl.09f.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.a20) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.09f.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.cd7)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.fca = impl_witness_table (%Core.import_ref.4e597), @Core.IntLiteral.as.ImplicitAs.impl.09f [concrete] // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/destroy, Destroy, loaded [concrete = constants.%Destroy.type] // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/impl_assoc_const_with_prelude.carbon b/toolchain/check/testdata/impl/impl_assoc_const_with_prelude.carbon index 57f04bb49d45..24e30bc81302 100644 --- a/toolchain/check/testdata/impl/impl_assoc_const_with_prelude.carbon +++ b/toolchain/check/testdata/impl/impl_assoc_const_with_prelude.carbon @@ -64,10 +64,10 @@ impl () as I where .X = {.a = true, .b = (1, 2)} and .X = {.a = false, .b = (3, // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.754 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.type.360: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete] // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%To) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048 = struct_value () [symbolic] -// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.ab1: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.360 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.3d6) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.da5: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i32, %ImplicitAs.facet) [concrete] @@ -122,8 +122,8 @@ impl () as I where .X = {.a = true, .b = (1, 2)} and .X = {.a = false, .b = (3, // CHECK:STDOUT: %Core.Bool: %Bool.type = import_ref Core//prelude/types/bool, Bool, loaded [concrete = constants.%Bool] // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic] // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.754 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic] -// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl.4e8 [concrete] // CHECK:STDOUT: %Core.SubWith: %SubWith.type.9de = import_ref Core//prelude/operators/arithmetic, SubWith, loaded [concrete = constants.%SubWith.generic] // CHECK:STDOUT: %Core.import_ref.abd97d.1 = import_ref Core//prelude/operators/arithmetic, loc{{\d+_\d+}}, unloaded // CHECK:STDOUT: %Core.import_ref.f63b02.1: %Core.IntLiteral.as.SubWith.impl.Op.type = import_ref Core//prelude/operators/arithmetic, loc{{\d+_\d+}}, loaded [concrete = constants.%Core.IntLiteral.as.SubWith.impl.Op] @@ -295,10 +295,10 @@ impl () as I where .X = {.a = true, .b = (1, 2)} and .X = {.a = false, .b = (3, // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.754 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.type.360: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete] // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%To) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048 = struct_value () [symbolic] -// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.ab1: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.360 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.3d6) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.da5: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i32, %ImplicitAs.facet) [concrete] @@ -338,8 +338,8 @@ impl () as I where .X = {.a = true, .b = (1, 2)} and .X = {.a = false, .b = (3, // CHECK:STDOUT: %Core.Bool: %Bool.type = import_ref Core//prelude/types/bool, Bool, loaded [concrete = constants.%Bool] // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic] // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.754 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic] -// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl.4e8 [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/interop/cpp/function/import/arithmetic_types_bridged.carbon b/toolchain/check/testdata/interop/cpp/function/import/arithmetic_types_bridged.carbon index 660a22175d4d..490d45813308 100644 --- a/toolchain/check/testdata/interop/cpp/function/import/arithmetic_types_bridged.carbon +++ b/toolchain/check/testdata/interop/cpp/function/import/arithmetic_types_bridged.carbon @@ -688,11 +688,11 @@ fn F() { // CHECK:STDOUT: %i8.builtin: type = int_type signed, %int_8 [concrete] // CHECK:STDOUT: %ImplicitAs.type.046: type = facet_type <@ImplicitAs, @ImplicitAs(%i8)> [concrete] // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%To) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048 = struct_value () [symbolic] // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete] -// CHECK:STDOUT: %ImplicitAs.impl_witness.361: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl(%int_8) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.3d1: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_8) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.361: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_8) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.3d1: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_8) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bcf: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.3d1 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.046 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.361) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.389: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i8, %ImplicitAs.facet) [concrete] @@ -733,8 +733,8 @@ fn F() { // CHECK:STDOUT: } { // CHECK:STDOUT: // CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl.4e8 [concrete] // CHECK:STDOUT: %Core.import_ref.55f: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.2f2) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.a64)] // CHECK:STDOUT: %Copy.impl_witness_table.0ac = impl_witness_table (%Core.import_ref.55f), @Int.as.Copy.impl [concrete] // CHECK:STDOUT: } @@ -792,11 +792,11 @@ fn F() { // CHECK:STDOUT: %u8.builtin: type = int_type unsigned, %int_8 [concrete] // CHECK:STDOUT: %ImplicitAs.type.b41: type = facet_type <@ImplicitAs, @ImplicitAs(%u8)> [concrete] // CHECK:STDOUT: %To.fe9: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.eb6: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To.fe9) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.eb6: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.501(%To.fe9) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.498: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.eb6 = struct_value () [symbolic] // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete] -// CHECK:STDOUT: %ImplicitAs.impl_witness.c41: = impl_witness imports.%ImplicitAs.impl_witness_table.0c6, @Core.IntLiteral.as.ImplicitAs.impl(%int_8) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.17e: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_8) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.c41: = impl_witness imports.%ImplicitAs.impl_witness_table.0c6, @Core.IntLiteral.as.ImplicitAs.impl.501(%int_8) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.17e: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.501(%int_8) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.59a: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.17e = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.b41 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c41) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.dfc: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%u8, %ImplicitAs.facet) [concrete] @@ -834,8 +834,8 @@ fn F() { // CHECK:STDOUT: } { // CHECK:STDOUT: // CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import_ref.e9f: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.eb6) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.498)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0c6 = impl_witness_table (%Core.import_ref.e9f), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.e9f: @Core.IntLiteral.as.ImplicitAs.impl.501.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.eb6) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.501.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.498)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0c6 = impl_witness_table (%Core.import_ref.e9f), @Core.IntLiteral.as.ImplicitAs.impl.501 [concrete] // CHECK:STDOUT: %Core.import_ref.3cf: @UInt.as.Copy.impl.%UInt.as.Copy.impl.Op.type (%UInt.as.Copy.impl.Op.type.743) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @UInt.as.Copy.impl.%UInt.as.Copy.impl.Op (constants.%UInt.as.Copy.impl.Op.521)] // CHECK:STDOUT: %Copy.impl_witness_table.306 = impl_witness_table (%Core.import_ref.3cf), @UInt.as.Copy.impl [concrete] // CHECK:STDOUT: } @@ -991,10 +991,10 @@ fn F() { // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.type.360: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete] // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%To) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048 = struct_value () [symbolic] -// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.ab1: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.360 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.3d6) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.da5: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i32, %ImplicitAs.facet) [concrete] @@ -1016,8 +1016,8 @@ fn F() { // CHECK:STDOUT: } { // CHECK:STDOUT: // CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl.4e8 [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { @@ -1197,11 +1197,11 @@ fn F() { // CHECK:STDOUT: %i16.builtin: type = int_type signed, %int_16 [concrete] // CHECK:STDOUT: %ImplicitAs.type.be3: type = facet_type <@ImplicitAs, @ImplicitAs(%i16)> [concrete] // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%To) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048 = struct_value () [symbolic] // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete] -// CHECK:STDOUT: %ImplicitAs.impl_witness.685: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl(%int_16) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.720: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_16) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.685: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_16) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.720: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_16) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.f75: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.720 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.be3 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.685) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.e56: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i16, %ImplicitAs.facet) [concrete] @@ -1239,8 +1239,8 @@ fn F() { // CHECK:STDOUT: } { // CHECK:STDOUT: // CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl.4e8 [concrete] // CHECK:STDOUT: %Core.import_ref.55f: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.2f2) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.a64)] // CHECK:STDOUT: %Copy.impl_witness_table.0ac = impl_witness_table (%Core.import_ref.55f), @Int.as.Copy.impl [concrete] // CHECK:STDOUT: } @@ -1302,11 +1302,11 @@ fn F() { // CHECK:STDOUT: %i16.builtin: type = int_type signed, %int_16 [concrete] // CHECK:STDOUT: %ImplicitAs.type.be3: type = facet_type <@ImplicitAs, @ImplicitAs(%i16)> [concrete] // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%To) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048 = struct_value () [symbolic] // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete] -// CHECK:STDOUT: %ImplicitAs.impl_witness.685: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl(%int_16) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.720: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_16) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.685: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_16) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.720: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_16) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.f75: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.720 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.be3 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.685) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.e56: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i16, %ImplicitAs.facet) [concrete] @@ -1347,8 +1347,8 @@ fn F() { // CHECK:STDOUT: } { // CHECK:STDOUT: // CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl.4e8 [concrete] // CHECK:STDOUT: %Core.import_ref.55f: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.2f2) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.a64)] // CHECK:STDOUT: %Copy.impl_witness_table.0ac = impl_witness_table (%Core.import_ref.55f), @Int.as.Copy.impl [concrete] // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/interop/cpp/function/import/decayed_param.carbon b/toolchain/check/testdata/interop/cpp/function/import/decayed_param.carbon index 7d0eda404566..7835f9ace154 100644 --- a/toolchain/check/testdata/interop/cpp/function/import/decayed_param.carbon +++ b/toolchain/check/testdata/interop/cpp/function/import/decayed_param.carbon @@ -103,10 +103,10 @@ fn F() { // CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [concrete] // CHECK:STDOUT: %ImplicitAs.type.360: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete] // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%To) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048 = struct_value () [symbolic] -// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.ab1: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet.840: %ImplicitAs.type.360 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.3d6) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.da5: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i32, %ImplicitAs.facet.840) [concrete] @@ -183,8 +183,8 @@ fn F() { // CHECK:STDOUT: %UnformedInit.impl_witness_table.e8d = impl_witness_table (), @array_type.as.UnformedInit.impl [concrete] // CHECK:STDOUT: %UnformedInit.impl_witness_table.d46 = impl_witness_table (), @Int.as.UnformedInit.impl [concrete] // CHECK:STDOUT: %TakesArray.cpp_overload_set.value: %TakesArray.cpp_overload_set.type = cpp_overload_set_value @TakesArray.cpp_overload_set [concrete = constants.%TakesArray.cpp_overload_set.value] -// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl.4e8 [concrete] // CHECK:STDOUT: %Core.import_ref.c1a: type = import_ref Core//prelude/types/optional, loc{{\d+_\d+}}, loaded [symbolic = @ptr.as.OptionalStorage.impl.%MaybeUnformed (constants.%MaybeUnformed.d10)] // CHECK:STDOUT: %Core.import_ref.d20: @ptr.as.OptionalStorage.impl.%ptr.as.OptionalStorage.impl.None.type (%ptr.as.OptionalStorage.impl.None.type.da2) = import_ref Core//prelude/types/optional, loc{{\d+_\d+}}, loaded [symbolic = @ptr.as.OptionalStorage.impl.%ptr.as.OptionalStorage.impl.None (constants.%ptr.as.OptionalStorage.impl.None.41b)] // CHECK:STDOUT: %Core.import_ref.ed3: @ptr.as.OptionalStorage.impl.%ptr.as.OptionalStorage.impl.Some.type (%ptr.as.OptionalStorage.impl.Some.type.7a7) = import_ref Core//prelude/types/optional, loc{{\d+_\d+}}, loaded [symbolic = @ptr.as.OptionalStorage.impl.%ptr.as.OptionalStorage.impl.Some (constants.%ptr.as.OptionalStorage.impl.Some.d46)] @@ -332,10 +332,10 @@ fn F() { // CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [concrete] // CHECK:STDOUT: %ImplicitAs.type.360: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete] // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%To) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048 = struct_value () [symbolic] -// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.ab1: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.360 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.3d6) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.da5: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i32, %ImplicitAs.facet) [concrete] @@ -364,8 +364,8 @@ fn F() { // CHECK:STDOUT: %DefaultOrUnformed.impl_witness_table.8fb = impl_witness_table (%Core.import_ref.876), @T.as_type.as.DefaultOrUnformed.impl.01f [concrete] // CHECK:STDOUT: %UnformedInit.impl_witness_table.e8d = impl_witness_table (), @array_type.as.UnformedInit.impl [concrete] // CHECK:STDOUT: %UnformedInit.impl_witness_table.d46 = impl_witness_table (), @Int.as.UnformedInit.impl [concrete] -// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl.4e8 [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { diff --git a/toolchain/check/testdata/interop/cpp/macros/macros.carbon b/toolchain/check/testdata/interop/cpp/macros/macros.carbon index 5d2bb6afb17a..19aa51f30408 100644 --- a/toolchain/check/testdata/interop/cpp/macros/macros.carbon +++ b/toolchain/check/testdata/interop/cpp/macros/macros.carbon @@ -1112,8 +1112,8 @@ fn F() { // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import_ref.835: @Int.as.ImplicitAs.impl.%Int.as.ImplicitAs.impl.Convert.type (%Int.as.ImplicitAs.impl.Convert.type.f73) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.ImplicitAs.impl.%Int.as.ImplicitAs.impl.Convert (constants.%Int.as.ImplicitAs.impl.Convert.34b)] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.eac = impl_witness_table (%Core.import_ref.835), @Int.as.ImplicitAs.impl [concrete] -// CHECK:STDOUT: %Core.import_ref.63c: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.5e6) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.539)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.234 = impl_witness_table (%Core.import_ref.63c), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.63cb: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.5e6) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.539)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.234 = impl_witness_table (%Core.import_ref.63cb), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] // CHECK:STDOUT: %X: = namespace [concrete] { // CHECK:STDOUT: .n = %n.var // CHECK:STDOUT: import Cpp//... @@ -2051,10 +2051,10 @@ fn F() { // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete] // CHECK:STDOUT: %ImplicitAs.type.360: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete] // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%To) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048 = struct_value () [symbolic] -// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.ab1: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.360 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.3d6) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.da5: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i32, %ImplicitAs.facet) [concrete] @@ -2073,8 +2073,8 @@ fn F() { // CHECK:STDOUT: %v.patt: %pattern_type.104 = ref_binding_pattern v [concrete] // CHECK:STDOUT: %v.var_patt: %pattern_type.104 = var_pattern %v.patt [concrete] // CHECK:STDOUT: %v.var: ref %i32 = var %v.var_patt [concrete] -// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl.4e8 [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { @@ -2108,10 +2108,10 @@ fn F() { // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete] // CHECK:STDOUT: %ImplicitAs.type.360: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete] // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%To) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048 = struct_value () [symbolic] -// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.ab1: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.360 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.3d6) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.da5: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i32, %ImplicitAs.facet) [concrete] @@ -2130,8 +2130,8 @@ fn F() { // CHECK:STDOUT: %a.patt: %pattern_type.aa6 = ref_binding_pattern a [concrete] // CHECK:STDOUT: %a.var_patt: %pattern_type.aa6 = var_pattern %a.patt [concrete] // CHECK:STDOUT: %a.var: ref %A = var %a.var_patt [concrete] -// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl.4e8 [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { diff --git a/toolchain/check/testdata/interop/cpp/operators/operators.carbon b/toolchain/check/testdata/interop/cpp/operators/operators.carbon index 8e08c1ab584f..e7486ee0a564 100644 --- a/toolchain/check/testdata/interop/cpp/operators/operators.carbon +++ b/toolchain/check/testdata/interop/cpp/operators/operators.carbon @@ -1194,10 +1194,10 @@ fn F() { // CHECK:STDOUT: %operator_LessLess__carbon_thunk: %operator_LessLess__carbon_thunk.type = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.type.360: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete] // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%To) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048 = struct_value () [symbolic] -// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.ab1: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.360 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.3d6) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.da5: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i32, %ImplicitAs.facet) [concrete] @@ -1317,8 +1317,8 @@ fn F() { // CHECK:STDOUT: } { // CHECK:STDOUT: // CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl.4e8 [concrete] // CHECK:STDOUT: %operator_GreaterGreater__carbon_thunk.decl: %operator_GreaterGreater__carbon_thunk.type = fn_decl @operator_GreaterGreater__carbon_thunk [concrete = constants.%operator_GreaterGreater__carbon_thunk] { // CHECK:STDOUT: // CHECK:STDOUT: } { diff --git a/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.llp64.carbon b/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.llp64.carbon index df8c3df0ce99..a8a43713fc76 100644 --- a/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.llp64.carbon +++ b/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.llp64.carbon @@ -694,20 +694,20 @@ fn CopyUnsignedLong() { // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete] // CHECK:STDOUT: %ImplicitAs.type.08a: type = facet_type <@ImplicitAs, @ImplicitAs(%i64)> [concrete] // CHECK:STDOUT: %To.fe9: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To.fe9) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert.1, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%To.fe9) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048 = struct_value () [symbolic] // CHECK:STDOUT: %ImplicitAs.type.ace: type = facet_type <@ImplicitAs, @ImplicitAs(Core.IntLiteral)> [concrete] // CHECK:STDOUT: %From.fe9: Core.IntLiteral = symbolic_binding From, 0 [symbolic] // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.type.f73: type = fn_type @Int.as.ImplicitAs.impl.Convert, @Int.as.ImplicitAs.impl(%From.fe9) [symbolic] // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.34b: %Int.as.ImplicitAs.impl.Convert.type.f73 = struct_value () [symbolic] -// CHECK:STDOUT: %ImplicitAs.impl_witness.35c: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl(%int_64) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.fc2: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_64) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.35c: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.fc2: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert.1, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_64) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.fc5: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.fc2 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet.8a1: %ImplicitAs.type.08a = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.35c) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.744: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i64, %ImplicitAs.facet.8a1) [concrete] // CHECK:STDOUT: %.d4c: type = fn_type_with_self_type %ImplicitAs.WithSelf.Convert.type.744, %ImplicitAs.facet.8a1 [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound: = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.fc5 [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.fc5, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.fc5, @Core.IntLiteral.as.ImplicitAs.impl.Convert.1(%int_64) [concrete] // CHECK:STDOUT: %bound_method.072: = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] // CHECK:STDOUT: %int_1.0f3: %i64 = int_value 1 [concrete] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] @@ -763,14 +763,14 @@ fn CopyUnsignedLong() { // CHECK:STDOUT: .long_long = @F.%i64.2 // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl.4e8 [concrete] // CHECK:STDOUT: %Core.import_ref.835: @Int.as.ImplicitAs.impl.%Int.as.ImplicitAs.impl.Convert.type (%Int.as.ImplicitAs.impl.Convert.type.f73) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.ImplicitAs.impl.%Int.as.ImplicitAs.impl.Convert (constants.%Int.as.ImplicitAs.impl.Convert.34b)] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.eac = impl_witness_table (%Core.import_ref.835), @Int.as.ImplicitAs.impl [concrete] // CHECK:STDOUT: %Core.import_ref.fd7: @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.f55) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.44f)] // CHECK:STDOUT: %As.impl_witness_table.2b9 = impl_witness_table (%Core.import_ref.fd7), @Core.IntLiteral.as.As.impl [concrete] -// CHECK:STDOUT: %Core.import_ref.63c: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.5e6) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.539)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.234 = impl_witness_table (%Core.import_ref.63c), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.63cb: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.5e6) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.539)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.234 = impl_witness_table (%Core.import_ref.63cb), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { @@ -786,7 +786,7 @@ fn CopyUnsignedLong() { // CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0.loc8: %.d4c = impl_witness_access constants.%ImplicitAs.impl_witness.35c, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.fc5] // CHECK:STDOUT: %bound_method.loc8_38.1: = bound_method %int_1.loc8, %impl.elem0.loc8 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] -// CHECK:STDOUT: %specific_fn.loc8: = specific_function %impl.elem0.loc8, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] +// CHECK:STDOUT: %specific_fn.loc8: = specific_function %impl.elem0.loc8, @Core.IntLiteral.as.ImplicitAs.impl.Convert.1(constants.%int_64) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc8_38.2: = bound_method %int_1.loc8, %specific_fn.loc8 [concrete = constants.%bound_method.072] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i64 = call %bound_method.loc8_38.2(%int_1.loc8) [concrete = constants.%int_1.0f3] // CHECK:STDOUT: %.loc8_38.1: %i64 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_1.0f3] @@ -867,20 +867,20 @@ fn CopyUnsignedLong() { // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete] // CHECK:STDOUT: %ImplicitAs.type.9b6: type = facet_type <@ImplicitAs, @ImplicitAs(%u64)> [concrete] // CHECK:STDOUT: %To.fe9: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.eb6: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To.fe9) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.eb6: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert.1, @Core.IntLiteral.as.ImplicitAs.impl.501(%To.fe9) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.498: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.eb6 = struct_value () [symbolic] // CHECK:STDOUT: %ImplicitAs.type.ace: type = facet_type <@ImplicitAs, @ImplicitAs(Core.IntLiteral)> [concrete] // CHECK:STDOUT: %From.fe9: Core.IntLiteral = symbolic_binding From, 0 [symbolic] // CHECK:STDOUT: %UInt.as.ImplicitAs.impl.Convert.type.594: type = fn_type @UInt.as.ImplicitAs.impl.Convert.1, @UInt.as.ImplicitAs.impl.791(%From.fe9) [symbolic] // CHECK:STDOUT: %UInt.as.ImplicitAs.impl.Convert.141: %UInt.as.ImplicitAs.impl.Convert.type.594 = struct_value () [symbolic] -// CHECK:STDOUT: %ImplicitAs.impl_witness.248: = impl_witness imports.%ImplicitAs.impl_witness_table.0c6, @Core.IntLiteral.as.ImplicitAs.impl(%int_64) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.dbe: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_64) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.248: = impl_witness imports.%ImplicitAs.impl_witness_table.0c6, @Core.IntLiteral.as.ImplicitAs.impl.501(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.dbe: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert.1, @Core.IntLiteral.as.ImplicitAs.impl.501(%int_64) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.b79: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.dbe = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet.b50: %ImplicitAs.type.9b6 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.248) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.a9d: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%u64, %ImplicitAs.facet.b50) [concrete] // CHECK:STDOUT: %.200: type = fn_type_with_self_type %ImplicitAs.WithSelf.Convert.type.a9d, %ImplicitAs.facet.b50 [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound: = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.b79 [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.b79, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.b79, @Core.IntLiteral.as.ImplicitAs.impl.Convert.1(%int_64) [concrete] // CHECK:STDOUT: %bound_method.231: = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] // CHECK:STDOUT: %int_1.8a8: %u64 = int_value 1 [concrete] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] @@ -936,14 +936,14 @@ fn CopyUnsignedLong() { // CHECK:STDOUT: .unsigned_long_long = @F.%u64.2 // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import_ref.e9f: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.eb6) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.498)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0c6 = impl_witness_table (%Core.import_ref.e9f), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.e9f: @Core.IntLiteral.as.ImplicitAs.impl.501.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.eb6) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.501.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.498)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0c6 = impl_witness_table (%Core.import_ref.e9f), @Core.IntLiteral.as.ImplicitAs.impl.501 [concrete] // CHECK:STDOUT: %Core.import_ref.96b: @UInt.as.ImplicitAs.impl.791.%UInt.as.ImplicitAs.impl.Convert.type (%UInt.as.ImplicitAs.impl.Convert.type.594) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @UInt.as.ImplicitAs.impl.791.%UInt.as.ImplicitAs.impl.Convert (constants.%UInt.as.ImplicitAs.impl.Convert.141)] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.1b2 = impl_witness_table (%Core.import_ref.96b), @UInt.as.ImplicitAs.impl.791 [concrete] // CHECK:STDOUT: %Core.import_ref.8db: @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.150) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.b6a)] // CHECK:STDOUT: %As.impl_witness_table.613 = impl_witness_table (%Core.import_ref.8db), @Core.IntLiteral.as.As.impl [concrete] -// CHECK:STDOUT: %Core.import_ref.63c: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.5e6) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.539)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.234 = impl_witness_table (%Core.import_ref.63c), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.63cb: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.5e6) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.539)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.234 = impl_witness_table (%Core.import_ref.63cb), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { @@ -959,7 +959,7 @@ fn CopyUnsignedLong() { // CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0.loc8: %.200 = impl_witness_access constants.%ImplicitAs.impl_witness.248, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.b79] // CHECK:STDOUT: %bound_method.loc8_56.1: = bound_method %int_1.loc8, %impl.elem0.loc8 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] -// CHECK:STDOUT: %specific_fn.loc8: = specific_function %impl.elem0.loc8, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] +// CHECK:STDOUT: %specific_fn.loc8: = specific_function %impl.elem0.loc8, @Core.IntLiteral.as.ImplicitAs.impl.Convert.1(constants.%int_64) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc8_56.2: = bound_method %int_1.loc8, %specific_fn.loc8 [concrete = constants.%bound_method.231] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %u64 = call %bound_method.loc8_56.2(%int_1.loc8) [concrete = constants.%int_1.8a8] // CHECK:STDOUT: %.loc8_56.1: %u64 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_1.8a8] @@ -1176,8 +1176,8 @@ fn CopyUnsignedLong() { // CHECK:STDOUT: %As.impl_witness_table.737 = impl_witness_table (%Core.import_ref.adef5f.3), @Core.IntLiteral.as.As.impl.846 [concrete] // CHECK:STDOUT: %Core.import_ref.adef5f.4: %Cpp.long.as.ImplicitAs.impl.Convert.type.ae6f4c.2 = import_ref Core//prelude/types/cpp/int, loc{{\d+_\d+}}, loaded [concrete = constants.%Cpp.long.as.ImplicitAs.impl.Convert.3cefb0.2] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.b4e = impl_witness_table (%Core.import_ref.adef5f.4), @Cpp.long.as.ImplicitAs.impl.6b0 [concrete] -// CHECK:STDOUT: %Core.import_ref.63c: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.5e6) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.539)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.234 = impl_witness_table (%Core.import_ref.63c), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.63cb: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.5e6) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.539)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.234 = impl_witness_table (%Core.import_ref.63cb), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/destroy, Destroy, loaded [concrete = constants.%Destroy.type] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -3962,8 +3962,8 @@ fn CopyUnsignedLong() { // CHECK:STDOUT: %As.impl_witness_table.e82 = impl_witness_table (%Core.import_ref.adef5f.2), @Core.IntLiteral.as.As.impl.51f [concrete] // CHECK:STDOUT: %Core.import_ref.adef5f.3: %Cpp.unsigned_long.as.ImplicitAs.impl.Convert.type = import_ref Core//prelude/types/cpp/int, loc{{\d+_\d+}}, loaded [concrete = constants.%Cpp.unsigned_long.as.ImplicitAs.impl.Convert] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.245 = impl_witness_table (%Core.import_ref.adef5f.3), @Cpp.unsigned_long.as.ImplicitAs.impl.b42 [concrete] -// CHECK:STDOUT: %Core.import_ref.63c: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.5e6) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.539)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.234 = impl_witness_table (%Core.import_ref.63c), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.63cb: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.5e6) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.539)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.234 = impl_witness_table (%Core.import_ref.63cb), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/destroy, Destroy, loaded [concrete = constants.%Destroy.type] // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.lp64.carbon b/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.lp64.carbon index d01de5145392..e34790d88d64 100644 --- a/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.lp64.carbon +++ b/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.lp64.carbon @@ -642,20 +642,20 @@ fn CopyUnsignedLongLong() { // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete] // CHECK:STDOUT: %ImplicitAs.type.08a: type = facet_type <@ImplicitAs, @ImplicitAs(%i64)> [concrete] // CHECK:STDOUT: %To.fe9: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To.fe9) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert.1, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%To.fe9) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048 = struct_value () [symbolic] // CHECK:STDOUT: %ImplicitAs.type.ace: type = facet_type <@ImplicitAs, @ImplicitAs(Core.IntLiteral)> [concrete] // CHECK:STDOUT: %From.fe9: Core.IntLiteral = symbolic_binding From, 0 [symbolic] // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.type.f73: type = fn_type @Int.as.ImplicitAs.impl.Convert, @Int.as.ImplicitAs.impl(%From.fe9) [symbolic] // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.34b: %Int.as.ImplicitAs.impl.Convert.type.f73 = struct_value () [symbolic] -// CHECK:STDOUT: %ImplicitAs.impl_witness.35c: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl(%int_64) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.fc2: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_64) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.35c: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.fc2: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert.1, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_64) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.fc5: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.fc2 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet.8a1: %ImplicitAs.type.08a = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.35c) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.744: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i64, %ImplicitAs.facet.8a1) [concrete] // CHECK:STDOUT: %.d4c: type = fn_type_with_self_type %ImplicitAs.WithSelf.Convert.type.744, %ImplicitAs.facet.8a1 [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound: = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.fc5 [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.fc5, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.fc5, @Core.IntLiteral.as.ImplicitAs.impl.Convert.1(%int_64) [concrete] // CHECK:STDOUT: %bound_method.072: = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] // CHECK:STDOUT: %int_1.0f3: %i64 = int_value 1 [concrete] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] @@ -711,14 +711,14 @@ fn CopyUnsignedLongLong() { // CHECK:STDOUT: .long = @F.%i64.2 // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl.4e8 [concrete] // CHECK:STDOUT: %Core.import_ref.835: @Int.as.ImplicitAs.impl.%Int.as.ImplicitAs.impl.Convert.type (%Int.as.ImplicitAs.impl.Convert.type.f73) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.ImplicitAs.impl.%Int.as.ImplicitAs.impl.Convert (constants.%Int.as.ImplicitAs.impl.Convert.34b)] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.eac = impl_witness_table (%Core.import_ref.835), @Int.as.ImplicitAs.impl [concrete] // CHECK:STDOUT: %Core.import_ref.fd7: @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.f55) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.44f)] // CHECK:STDOUT: %As.impl_witness_table.2b9 = impl_witness_table (%Core.import_ref.fd7), @Core.IntLiteral.as.As.impl [concrete] -// CHECK:STDOUT: %Core.import_ref.63c: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.5e6) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.539)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.234 = impl_witness_table (%Core.import_ref.63c), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.63cb: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.5e6) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.539)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.234 = impl_witness_table (%Core.import_ref.63cb), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { @@ -734,7 +734,7 @@ fn CopyUnsignedLongLong() { // CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0.loc8: %.d4c = impl_witness_access constants.%ImplicitAs.impl_witness.35c, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.fc5] // CHECK:STDOUT: %bound_method.loc8_28.1: = bound_method %int_1.loc8, %impl.elem0.loc8 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] -// CHECK:STDOUT: %specific_fn.loc8: = specific_function %impl.elem0.loc8, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] +// CHECK:STDOUT: %specific_fn.loc8: = specific_function %impl.elem0.loc8, @Core.IntLiteral.as.ImplicitAs.impl.Convert.1(constants.%int_64) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc8_28.2: = bound_method %int_1.loc8, %specific_fn.loc8 [concrete = constants.%bound_method.072] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i64 = call %bound_method.loc8_28.2(%int_1.loc8) [concrete = constants.%int_1.0f3] // CHECK:STDOUT: %.loc8_28.1: %i64 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_1.0f3] @@ -815,20 +815,20 @@ fn CopyUnsignedLongLong() { // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete] // CHECK:STDOUT: %ImplicitAs.type.9b6: type = facet_type <@ImplicitAs, @ImplicitAs(%u64)> [concrete] // CHECK:STDOUT: %To.fe9: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.eb6: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To.fe9) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.eb6: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert.1, @Core.IntLiteral.as.ImplicitAs.impl.501(%To.fe9) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.498: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.eb6 = struct_value () [symbolic] // CHECK:STDOUT: %ImplicitAs.type.ace: type = facet_type <@ImplicitAs, @ImplicitAs(Core.IntLiteral)> [concrete] // CHECK:STDOUT: %From.fe9: Core.IntLiteral = symbolic_binding From, 0 [symbolic] // CHECK:STDOUT: %UInt.as.ImplicitAs.impl.Convert.type.594: type = fn_type @UInt.as.ImplicitAs.impl.Convert.1, @UInt.as.ImplicitAs.impl.791(%From.fe9) [symbolic] // CHECK:STDOUT: %UInt.as.ImplicitAs.impl.Convert.141: %UInt.as.ImplicitAs.impl.Convert.type.594 = struct_value () [symbolic] -// CHECK:STDOUT: %ImplicitAs.impl_witness.248: = impl_witness imports.%ImplicitAs.impl_witness_table.0c6, @Core.IntLiteral.as.ImplicitAs.impl(%int_64) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.dbe: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_64) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.248: = impl_witness imports.%ImplicitAs.impl_witness_table.0c6, @Core.IntLiteral.as.ImplicitAs.impl.501(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.dbe: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert.1, @Core.IntLiteral.as.ImplicitAs.impl.501(%int_64) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.b79: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.dbe = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet.b50: %ImplicitAs.type.9b6 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.248) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.a9d: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%u64, %ImplicitAs.facet.b50) [concrete] // CHECK:STDOUT: %.200: type = fn_type_with_self_type %ImplicitAs.WithSelf.Convert.type.a9d, %ImplicitAs.facet.b50 [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound: = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.b79 [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.b79, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.b79, @Core.IntLiteral.as.ImplicitAs.impl.Convert.1(%int_64) [concrete] // CHECK:STDOUT: %bound_method.231: = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] // CHECK:STDOUT: %int_1.8a8: %u64 = int_value 1 [concrete] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] @@ -884,14 +884,14 @@ fn CopyUnsignedLongLong() { // CHECK:STDOUT: .unsigned_long = @F.%u64.2 // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import_ref.e9f: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.eb6) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.498)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0c6 = impl_witness_table (%Core.import_ref.e9f), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.e9f: @Core.IntLiteral.as.ImplicitAs.impl.501.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.eb6) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.501.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.498)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0c6 = impl_witness_table (%Core.import_ref.e9f), @Core.IntLiteral.as.ImplicitAs.impl.501 [concrete] // CHECK:STDOUT: %Core.import_ref.96b: @UInt.as.ImplicitAs.impl.791.%UInt.as.ImplicitAs.impl.Convert.type (%UInt.as.ImplicitAs.impl.Convert.type.594) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @UInt.as.ImplicitAs.impl.791.%UInt.as.ImplicitAs.impl.Convert (constants.%UInt.as.ImplicitAs.impl.Convert.141)] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.1b2 = impl_witness_table (%Core.import_ref.96b), @UInt.as.ImplicitAs.impl.791 [concrete] // CHECK:STDOUT: %Core.import_ref.8db: @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.150) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.b6a)] // CHECK:STDOUT: %As.impl_witness_table.613 = impl_witness_table (%Core.import_ref.8db), @Core.IntLiteral.as.As.impl [concrete] -// CHECK:STDOUT: %Core.import_ref.63c: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.5e6) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.539)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.234 = impl_witness_table (%Core.import_ref.63c), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.63cb: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.5e6) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.539)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.234 = impl_witness_table (%Core.import_ref.63cb), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { @@ -907,7 +907,7 @@ fn CopyUnsignedLongLong() { // CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0.loc8: %.200 = impl_witness_access constants.%ImplicitAs.impl_witness.248, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.b79] // CHECK:STDOUT: %bound_method.loc8_46.1: = bound_method %int_1.loc8, %impl.elem0.loc8 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] -// CHECK:STDOUT: %specific_fn.loc8: = specific_function %impl.elem0.loc8, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_64) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] +// CHECK:STDOUT: %specific_fn.loc8: = specific_function %impl.elem0.loc8, @Core.IntLiteral.as.ImplicitAs.impl.Convert.1(constants.%int_64) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] // CHECK:STDOUT: %bound_method.loc8_46.2: = bound_method %int_1.loc8, %specific_fn.loc8 [concrete = constants.%bound_method.231] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %u64 = call %bound_method.loc8_46.2(%int_1.loc8) [concrete = constants.%int_1.8a8] // CHECK:STDOUT: %.loc8_46.1: %u64 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_1.8a8] @@ -998,9 +998,9 @@ fn CopyUnsignedLongLong() { // CHECK:STDOUT: %ImplicitAs.facet.532: %ImplicitAs.type.fb7 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.59e) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.f1d: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%Cpp.long_long, %ImplicitAs.facet.532) [concrete] // CHECK:STDOUT: %.424: type = fn_type_with_self_type %ImplicitAs.WithSelf.Convert.type.f1d, %ImplicitAs.facet.532 [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type = struct_value () [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound: = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.ae6: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert.1 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.3ce: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.ae6 = struct_value () [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound: = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.3ce [concrete] // CHECK:STDOUT: %int_1.8b4: %Cpp.long_long = int_value 1 [concrete] // CHECK:STDOUT: %LongLongResult: type = class_type @LongLongResult [concrete] // CHECK:STDOUT: %pattern_type.f75: type = pattern_type %LongLongResult [concrete] @@ -1091,7 +1091,7 @@ fn CopyUnsignedLongLong() { // CHECK:STDOUT: } // CHECK:STDOUT: %Core.LongLong64: type = import_ref Core//prelude/types/cpp/int, LongLong64, loaded [concrete = constants.%Cpp.long_long] // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.754 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic] -// CHECK:STDOUT: %Core.import_ref.adef5f.1: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type = import_ref Core//prelude/types/cpp/int, loc{{\d+_\d+}}, loaded [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert] +// CHECK:STDOUT: %Core.import_ref.adef5f.1: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.ae6 = import_ref Core//prelude/types/cpp/int, loc{{\d+_\d+}}, loaded [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.3ce] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.337 = impl_witness_table (%Core.import_ref.adef5f.1), @Core.IntLiteral.as.ImplicitAs.impl.74b [concrete] // CHECK:STDOUT: %LongLongResult.decl: type = class_decl @LongLongResult [concrete = constants.%LongLongResult] {} {} // CHECK:STDOUT: %PassLongLong.cpp_overload_set.value: %PassLongLong.cpp_overload_set.type = cpp_overload_set_value @PassLongLong.cpp_overload_set [concrete = constants.%PassLongLong.cpp_overload_set.value] @@ -1113,8 +1113,8 @@ fn CopyUnsignedLongLong() { // CHECK:STDOUT: %As.impl_witness_table.603 = impl_witness_table (%Core.import_ref.adef5f.2), @Core.IntLiteral.as.As.impl.fab [concrete] // CHECK:STDOUT: %Core.import_ref.adef5f.3: %Cpp.long_long.as.ImplicitAs.impl.Convert.type = import_ref Core//prelude/types/cpp/int, loc{{\d+_\d+}}, loaded [concrete = constants.%Cpp.long_long.as.ImplicitAs.impl.Convert] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.45f = impl_witness_table (%Core.import_ref.adef5f.3), @Cpp.long_long.as.ImplicitAs.impl.e5f [concrete] -// CHECK:STDOUT: %Core.import_ref.63c: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.5e6) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.539)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.234 = impl_witness_table (%Core.import_ref.63c), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.63cb: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.5e6) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.539)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.234 = impl_witness_table (%Core.import_ref.63cb), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/destroy, Destroy, loaded [concrete = constants.%Destroy.type] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -1128,7 +1128,7 @@ fn CopyUnsignedLongLong() { // CHECK:STDOUT: %Cpp.ref.loc15: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] // CHECK:STDOUT: %long_long.ref.loc15: type = name_ref long_long, constants.%Cpp.long_long [concrete = constants.%Cpp.long_long] // CHECK:STDOUT: } -// CHECK:STDOUT: %impl.elem0.loc15: %.424 = impl_witness_access constants.%ImplicitAs.impl_witness.59e, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert] +// CHECK:STDOUT: %impl.elem0.loc15: %.424 = impl_witness_access constants.%ImplicitAs.impl_witness.59e, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.3ce] // CHECK:STDOUT: %bound_method.loc15: = bound_method %int_1.loc15, %impl.elem0.loc15 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %Cpp.long_long = call %bound_method.loc15(%int_1.loc15) [concrete = constants.%int_1.8b4] // CHECK:STDOUT: %.loc15_38.1: %Cpp.long_long = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_1.8b4] @@ -3681,8 +3681,8 @@ fn CopyUnsignedLongLong() { // CHECK:STDOUT: %As.impl_witness_table.846 = impl_witness_table (%Core.import_ref.adef5f.2), @Core.IntLiteral.as.As.impl.0c0 [concrete] // CHECK:STDOUT: %Core.import_ref.adef5f.3: %Cpp.unsigned_long_long.as.ImplicitAs.impl.Convert.type = import_ref Core//prelude/types/cpp/int, loc{{\d+_\d+}}, loaded [concrete = constants.%Cpp.unsigned_long_long.as.ImplicitAs.impl.Convert] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.1a4 = impl_witness_table (%Core.import_ref.adef5f.3), @Cpp.unsigned_long_long.as.ImplicitAs.impl.3d6 [concrete] -// CHECK:STDOUT: %Core.import_ref.63c: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.5e6) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.539)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.234 = impl_witness_table (%Core.import_ref.63c), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.63cb: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.5e6) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.539)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.234 = impl_witness_table (%Core.import_ref.63cb), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/destroy, Destroy, loaded [concrete = constants.%Destroy.type] // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interop/cpp/stdlib/initializer_list.carbon b/toolchain/check/testdata/interop/cpp/stdlib/initializer_list.carbon index cfb5d178808a..0db4c0c21170 100644 --- a/toolchain/check/testdata/interop/cpp/stdlib/initializer_list.carbon +++ b/toolchain/check/testdata/interop/cpp/stdlib/initializer_list.carbon @@ -76,10 +76,10 @@ fn F() { // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete] // CHECK:STDOUT: %ImplicitAs.type.360: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete] // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%To) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048 = struct_value () [symbolic] -// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.3d6: = impl_witness imports.%ImplicitAs.impl_witness_table.0bd, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_32) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.ab1: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0a4 = struct_value () [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.360 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.3d6) [concrete] // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.da5: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i32, %ImplicitAs.facet) [concrete] @@ -131,8 +131,8 @@ fn F() { // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } // CHECK:STDOUT: %initializer_list.template: %initializer_list.type = struct_value () [concrete = constants.%initializer_list.template] -// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.b42: @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.048) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.4e8.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e2c)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.0bd = impl_witness_table (%Core.import_ref.b42), @Core.IntLiteral.as.ImplicitAs.impl.4e8 [concrete] // CHECK:STDOUT: %Consume.cpp_overload_set.value: %Consume.cpp_overload_set.type = cpp_overload_set_value @Consume.cpp_overload_set [concrete = constants.%Consume.cpp_overload_set.value] // CHECK:STDOUT: %Consume__carbon_thunk.decl: %Consume__carbon_thunk.type = fn_decl @Consume__carbon_thunk [concrete = constants.%Consume__carbon_thunk] { // CHECK:STDOUT: diff --git a/toolchain/check/testdata/operators/overloaded/string_indexing.carbon b/toolchain/check/testdata/operators/overloaded/string_indexing.carbon index 63d525af4b55..5f6712dc06d7 100644 --- a/toolchain/check/testdata/operators/overloaded/string_indexing.carbon +++ b/toolchain/check/testdata/operators/overloaded/string_indexing.carbon @@ -120,7 +120,7 @@ fn TestStringIndexing() { // CHECK:STDOUT: %T.61c: %ImplicitAs.type.08a = symbolic_binding T, 0 [symbolic] // CHECK:STDOUT: %str.as.IndexWith.impl.At.type.c1f: type = fn_type @str.as.IndexWith.impl.At, @str.as.IndexWith.impl(%T.61c) [symbolic] // CHECK:STDOUT: %str.as.IndexWith.impl.At.2b4: %str.as.IndexWith.impl.At.type.c1f = struct_value () [symbolic] -// CHECK:STDOUT: %ImplicitAs.impl_witness.fe0: = impl_witness imports.%ImplicitAs.impl_witness_table.bc4, @Core.IntLiteral.as.ImplicitAs.impl(%int_64) [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness.fe0: = impl_witness imports.%ImplicitAs.impl_witness_table.bc4, @Core.IntLiteral.as.ImplicitAs.impl.4e8(%int_64) [concrete] // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.08a = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.fe0) [concrete] // CHECK:STDOUT: %IndexWith.impl_witness.f69: = impl_witness imports.%IndexWith.impl_witness_table, @str.as.IndexWith.impl(%ImplicitAs.facet) [concrete] // CHECK:STDOUT: %str.as.IndexWith.impl.At.type.49d: type = fn_type @str.as.IndexWith.impl.At, @str.as.IndexWith.impl(%ImplicitAs.facet) [concrete] @@ -141,7 +141,7 @@ fn TestStringIndexing() { // CHECK:STDOUT: %Core.import_ref.c67: @str.as.IndexWith.impl.%str.as.IndexWith.impl.At.type (%str.as.IndexWith.impl.At.type.c1f) = import_ref Core//prelude/types/string, loc{{\d+_\d+}}, loaded [symbolic = @str.as.IndexWith.impl.%str.as.IndexWith.impl.At (constants.%str.as.IndexWith.impl.At.2b4)] // CHECK:STDOUT: %IndexWith.impl_witness_table = impl_witness_table (%Core.import_ref.1f3, %Core.import_ref.c67), @str.as.IndexWith.impl [concrete] // CHECK:STDOUT: %Core.import_ref.154 = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, unloaded -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.bc4 = impl_witness_table (%Core.import_ref.154), @Core.IntLiteral.as.ImplicitAs.impl [concrete] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.bc4 = impl_witness_table (%Core.import_ref.154), @Core.IntLiteral.as.ImplicitAs.impl.4e8 [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestStringIndexing() { diff --git a/toolchain/check/testdata/primitives/float_conversions.carbon b/toolchain/check/testdata/primitives/float_conversions.carbon new file mode 100644 index 000000000000..aa9aa0080ff2 --- /dev/null +++ b/toolchain/check/testdata/primitives/float_conversions.carbon @@ -0,0 +1,113 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/full.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/primitives/float_conversions.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/primitives/float_conversions.carbon + +// --- test_helpers.carbon +library "[[@TEST_NAME]]"; + +class Expect[T:! type](N:! T) {} +fn Test[T:! type](N:! T) -> Expect(N) { return {}; } + +// --- literal_conversions.carbon +library "[[@TEST_NAME]]"; + +let _: f32 = 1.25; + +let _: Core.FloatLiteral() = 42; +let _: Core.IntLiteral() = 42.0 unsafe as Core.IntLiteral(); + +// --- int_to_float.carbon +library "[[@TEST_NAME]]"; + +import library "test_helpers"; + +fn F(x: i32, y: u32) { + let _: f64 = x; + let _: f64 = y; + + Test(12345 as f32) as Expect(12345.0 as f32); + Test(-42 as f64) as Expect(-(42.0 as f64)); +} + +// --- int_literal_to_float.carbon +library "[[@TEST_NAME]]"; + +fn F() { + let _: f32 = 42; + let _: f64 = 1234567890123456; +} + +// --- fail_int_literal_to_float_lossy.carbon +library "[[@TEST_NAME]]"; + +// CHECK:STDERR: fail_int_literal_to_float_lossy.carbon:[[@LINE+4]]:14: error: integer value 123456789 cannot be represented exactly in floating-point type `f32` [IntLossyConversionToFloat] +// CHECK:STDERR: let a: f32 = 123456789; +// CHECK:STDERR: ^~~~~~~~~ +// CHECK:STDERR: +let a: f32 = 123456789; + +// CHECK:STDERR: fail_int_literal_to_float_lossy.carbon:[[@LINE+4]]:14: error: integer value 100000001 cannot be represented exactly in floating-point type `f32` [IntLossyConversionToFloat] +// CHECK:STDERR: let b: f32 = 100000001; +// CHECK:STDERR: ^~~~~~~~~ +// CHECK:STDERR: +let b: f32 = 100000001; + +// CHECK:STDERR: fail_int_literal_to_float_lossy.carbon:[[@LINE+4]]:14: error: integer value 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 too large for floating-point type `f32` [IntTooLargeForFloatType] +// CHECK:STDERR: let c: f32 = 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000; +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let c: f32 = 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000; + +// --- float_unsafe_as_int.carbon +library "[[@TEST_NAME]]"; + +import library "test_helpers"; + +fn F() { + // Float literal to Sized Integer explicit conversion via `unsafe as`. + Test(12.34 unsafe as i32) as Expect(12 as i32); + + Test(42.0 unsafe as u32) as Expect(42 as u32); + + // Negative float to signed integer. + // TODO: Also test converting a negative float literal once they are + // supported. + Test(-(1.99 as f64) unsafe as i8) as Expect(-1 as i8); + + // Float literal to int literal. + Test(123.45 unsafe as Core.IntLiteral()) as Expect(123); +} + +// --- fail_float_as_int.carbon +library "[[@TEST_NAME]]"; + +import library "test_helpers"; + +fn F(f: f32) { + // Lossy explicit conversion using `as` not permitted. + // CHECK:STDERR: fail_float_as_int.carbon:[[@LINE+7]]:16: error: cannot convert expression of type `Core.FloatLiteral` to `i32` with `as` [ConversionFailure] + // CHECK:STDERR: let _: i32 = 12.34 as i32; + // CHECK:STDERR: ^~~~~~~~~~~~ + // CHECK:STDERR: fail_float_as_int.carbon:[[@LINE+4]]:16: note: type `Core.FloatLiteral` does not implement interface `Core.As(i32)` [MissingImplInMemberAccessInContext] + // CHECK:STDERR: let _: i32 = 12.34 as i32; + // CHECK:STDERR: ^~~~~~~~~~~~ + // CHECK:STDERR: + let _: i32 = 12.34 as i32; + + // CHECK:STDERR: fail_float_as_int.carbon:[[@LINE+7]]:16: error: cannot convert expression of type `f32` to `i32` with `as` [ConversionFailure] + // CHECK:STDERR: let _: i32 = f as i32; + // CHECK:STDERR: ^~~~~~~~ + // CHECK:STDERR: fail_float_as_int.carbon:[[@LINE+4]]:16: note: type `f32` does not implement interface `Core.As(i32)` [MissingImplInMemberAccessInContext] + // CHECK:STDERR: let _: i32 = f as i32; + // CHECK:STDERR: ^~~~~~~~ + // CHECK:STDERR: + let _: i32 = f as i32; +} diff --git a/toolchain/diagnostics/kind.def b/toolchain/diagnostics/kind.def index ec7f727840ca..247837e9a7d1 100644 --- a/toolchain/diagnostics/kind.def +++ b/toolchain/diagnostics/kind.def @@ -467,6 +467,13 @@ CARBON_DIAGNOSTIC_KIND(IntTooLargeForCppType) CARBON_DIAGNOSTIC_KIND(IntTooLargeForType) CARBON_DIAGNOSTIC_KIND(FloatLiteralTooLargeForType) CARBON_DIAGNOSTIC_KIND(FloatTooLargeForType) +CARBON_DIAGNOSTIC_KIND(IntTooLargeForFloatType) +CARBON_DIAGNOSTIC_KIND(IntLossyConversionToFloat) +CARBON_DIAGNOSTIC_KIND(FloatNaNConvertedToInt) +CARBON_DIAGNOSTIC_KIND(FloatInfinityConvertedToInt) +CARBON_DIAGNOSTIC_KIND(FloatTooLargeForIntType) +CARBON_DIAGNOSTIC_KIND(RealLiteralTooLargeForIntType) +CARBON_DIAGNOSTIC_KIND(RealLiteralTooLargeForUnsizedInt) CARBON_DIAGNOSTIC_KIND(IntWidthNotMultipleOf8) CARBON_DIAGNOSTIC_KIND(IntWidthNotPositive) CARBON_DIAGNOSTIC_KIND(IntWidthTooLarge) diff --git a/toolchain/driver/testdata/compile/optimize/optimize_debug.carbon b/toolchain/driver/testdata/compile/optimize/optimize_debug.carbon index 4492dfc9e4d7..3fb93541df5e 100644 --- a/toolchain/driver/testdata/compile/optimize/optimize_debug.carbon +++ b/toolchain/driver/testdata/compile/optimize/optimize_debug.carbon @@ -119,16 +119,16 @@ fn VectorizedWithOptSpeed(a: array(i32, 65536)*) { // CHECK:STDOUT: !21 = !DILocalVariable(arg: 1, scope: !16, type: !19) // CHECK:STDOUT: !22 = !DILocation(line: 18, column: 9, scope: !16) // CHECK:STDOUT: !23 = !DILocation(line: 19, column: 5, scope: !16) -// CHECK:STDOUT: !24 = !DILocation(line: 299, column: 3, scope: !25, inlinedAt: !32) -// CHECK:STDOUT: !25 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.07875fab836259ed.Core:Int.9452f4c51951679b.Core:AddAssignWith.f8737c9507fb115f.Core.4f441e6d456a6b17", scope: null, file: !26, line: 299, type: !27, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !29) +// CHECK:STDOUT: !24 = !DILocation(line: 306, column: 3, scope: !25, inlinedAt: !32) +// CHECK:STDOUT: !25 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.07875fab836259ed.Core:Int.9452f4c51951679b.Core:AddAssignWith.f8737c9507fb115f.Core.4f441e6d456a6b17", scope: null, file: !26, line: 306, type: !27, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !29) // CHECK:STDOUT: !26 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !27 = !DISubroutineType(types: !28) // CHECK:STDOUT: !28 = !{null, !7, !7} // CHECK:STDOUT: !29 = !{!30, !31} // CHECK:STDOUT: !30 = !DILocalVariable(arg: 1, scope: !25, type: !7) // CHECK:STDOUT: !31 = !DILocalVariable(arg: 2, scope: !25, type: !7) -// CHECK:STDOUT: !32 = distinct !DILocation(line: 365, column: 5, scope: !33, inlinedAt: !38) -// CHECK:STDOUT: !33 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !26, line: 363, type: !34, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36) +// CHECK:STDOUT: !32 = distinct !DILocation(line: 372, column: 5, scope: !33, inlinedAt: !38) +// CHECK:STDOUT: !33 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !26, line: 370, type: !34, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36) // CHECK:STDOUT: !34 = !DISubroutineType(types: !35) // CHECK:STDOUT: !35 = !{null, !7} // CHECK:STDOUT: !36 = !{!37} diff --git a/toolchain/driver/testdata/compile/optimize/optimize_default.carbon b/toolchain/driver/testdata/compile/optimize/optimize_default.carbon index fbcdba8d0edf..696456816c51 100644 --- a/toolchain/driver/testdata/compile/optimize/optimize_default.carbon +++ b/toolchain/driver/testdata/compile/optimize/optimize_default.carbon @@ -119,16 +119,16 @@ fn VectorizedWithOptSpeed(a: array(i32, 65536)*) { // CHECK:STDOUT: !21 = !DILocalVariable(arg: 1, scope: !16, type: !19) // CHECK:STDOUT: !22 = !DILocation(line: 18, column: 9, scope: !16) // CHECK:STDOUT: !23 = !DILocation(line: 19, column: 5, scope: !16) -// CHECK:STDOUT: !24 = !DILocation(line: 299, column: 3, scope: !25, inlinedAt: !32) -// CHECK:STDOUT: !25 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.07875fab836259ed.Core:Int.9452f4c51951679b.Core:AddAssignWith.f8737c9507fb115f.Core.4f441e6d456a6b17", scope: null, file: !26, line: 299, type: !27, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !29) +// CHECK:STDOUT: !24 = !DILocation(line: 306, column: 3, scope: !25, inlinedAt: !32) +// CHECK:STDOUT: !25 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.07875fab836259ed.Core:Int.9452f4c51951679b.Core:AddAssignWith.f8737c9507fb115f.Core.4f441e6d456a6b17", scope: null, file: !26, line: 306, type: !27, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !29) // CHECK:STDOUT: !26 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !27 = !DISubroutineType(types: !28) // CHECK:STDOUT: !28 = !{null, !7, !7} // CHECK:STDOUT: !29 = !{!30, !31} // CHECK:STDOUT: !30 = !DILocalVariable(arg: 1, scope: !25, type: !7) // CHECK:STDOUT: !31 = !DILocalVariable(arg: 2, scope: !25, type: !7) -// CHECK:STDOUT: !32 = distinct !DILocation(line: 365, column: 5, scope: !33, inlinedAt: !38) -// CHECK:STDOUT: !33 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !26, line: 363, type: !34, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36) +// CHECK:STDOUT: !32 = distinct !DILocation(line: 372, column: 5, scope: !33, inlinedAt: !38) +// CHECK:STDOUT: !33 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !26, line: 370, type: !34, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36) // CHECK:STDOUT: !34 = !DISubroutineType(types: !35) // CHECK:STDOUT: !35 = !{null, !7} // CHECK:STDOUT: !36 = !{!37} diff --git a/toolchain/driver/testdata/compile/optimize/optimize_none.carbon b/toolchain/driver/testdata/compile/optimize/optimize_none.carbon index ec3a654ad59b..0f25868b19b1 100644 --- a/toolchain/driver/testdata/compile/optimize/optimize_none.carbon +++ b/toolchain/driver/testdata/compile/optimize/optimize_none.carbon @@ -158,28 +158,28 @@ fn VectorizedWithOptSpeed(a: array(i32, 65536)*) { // CHECK:STDOUT: !31 = !{!32} // CHECK:STDOUT: !32 = !DILocalVariable(arg: 1, scope: !28, type: !7) // CHECK:STDOUT: !33 = !DILocation(line: 17, column: 3, scope: !28) -// CHECK:STDOUT: !34 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !35, line: 363, type: !29, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36) +// CHECK:STDOUT: !34 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !35, line: 370, type: !29, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36) // CHECK:STDOUT: !35 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !36 = !{!37} // CHECK:STDOUT: !37 = !DILocalVariable(arg: 1, scope: !34, type: !7) -// CHECK:STDOUT: !38 = !DILocation(line: 365, column: 5, scope: !34) -// CHECK:STDOUT: !39 = !DILocation(line: 363, column: 3, scope: !34) -// CHECK:STDOUT: !40 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.07875fab836259ed.Core:Int.9452f4c51951679b.Core:AddAssignWith.f8737c9507fb115f.Core.4f441e6d456a6b17", scope: null, file: !35, line: 299, type: !41, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !43) +// CHECK:STDOUT: !38 = !DILocation(line: 372, column: 5, scope: !34) +// CHECK:STDOUT: !39 = !DILocation(line: 370, column: 3, scope: !34) +// CHECK:STDOUT: !40 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.07875fab836259ed.Core:Int.9452f4c51951679b.Core:AddAssignWith.f8737c9507fb115f.Core.4f441e6d456a6b17", scope: null, file: !35, line: 306, type: !41, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !43) // CHECK:STDOUT: !41 = !DISubroutineType(types: !42) // CHECK:STDOUT: !42 = !{null, !7, !7} // CHECK:STDOUT: !43 = !{!44, !45} // CHECK:STDOUT: !44 = !DILocalVariable(arg: 1, scope: !40, type: !7) // CHECK:STDOUT: !45 = !DILocalVariable(arg: 2, scope: !40, type: !7) // CHECK:STDOUT: !46 = !DILocation(line: 4294967295, scope: !40) -// CHECK:STDOUT: !47 = !DILocation(line: 299, column: 3, scope: !40) -// CHECK:STDOUT: !48 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.667d1d3a0ad99849:ImplicitAs.8b551f392b5250ee.Core.4a088ada889550fc", scope: null, file: !35, line: 62, type: !49, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) +// CHECK:STDOUT: !47 = !DILocation(line: 306, column: 3, scope: !40) +// CHECK:STDOUT: !48 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.667d1d3a0ad99849:ImplicitAs.8b551f392b5250ee.Core.4a088ada889550fc", scope: null, file: !35, line: 63, type: !49, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) // CHECK:STDOUT: !49 = !DISubroutineType(types: !50) // CHECK:STDOUT: !50 = !{!7, !7} // CHECK:STDOUT: !51 = !{!52} // CHECK:STDOUT: !52 = !DILocalVariable(arg: 1, scope: !48, type: !7) -// CHECK:STDOUT: !53 = !DILocation(line: 64, column: 17, scope: !48) -// CHECK:STDOUT: !54 = !DILocation(line: 64, column: 5, scope: !48) -// CHECK:STDOUT: !55 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !35, line: 57, type: !49, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !56) +// CHECK:STDOUT: !53 = !DILocation(line: 65, column: 17, scope: !48) +// CHECK:STDOUT: !54 = !DILocation(line: 65, column: 5, scope: !48) +// CHECK:STDOUT: !55 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !35, line: 58, type: !49, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !56) // CHECK:STDOUT: !56 = !{!57} // CHECK:STDOUT: !57 = !DILocalVariable(arg: 1, scope: !55, type: !7) -// CHECK:STDOUT: !58 = !DILocation(line: 57, column: 36, scope: !55) +// CHECK:STDOUT: !58 = !DILocation(line: 58, column: 36, scope: !55) diff --git a/toolchain/driver/testdata/compile/optimize/optimize_size.carbon b/toolchain/driver/testdata/compile/optimize/optimize_size.carbon index 803b155bedd0..035f36ce31d0 100644 --- a/toolchain/driver/testdata/compile/optimize/optimize_size.carbon +++ b/toolchain/driver/testdata/compile/optimize/optimize_size.carbon @@ -158,28 +158,28 @@ fn VectorizedWithOptSpeed(a: array(i32, 65536)*) { // CHECK:STDOUT: !31 = !{!32} // CHECK:STDOUT: !32 = !DILocalVariable(arg: 1, scope: !28, type: !7) // CHECK:STDOUT: !33 = !DILocation(line: 17, column: 3, scope: !28) -// CHECK:STDOUT: !34 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !35, line: 363, type: !29, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36) +// CHECK:STDOUT: !34 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !35, line: 370, type: !29, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36) // CHECK:STDOUT: !35 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !36 = !{!37} // CHECK:STDOUT: !37 = !DILocalVariable(arg: 1, scope: !34, type: !7) -// CHECK:STDOUT: !38 = !DILocation(line: 365, column: 5, scope: !34) -// CHECK:STDOUT: !39 = !DILocation(line: 363, column: 3, scope: !34) -// CHECK:STDOUT: !40 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.07875fab836259ed.Core:Int.9452f4c51951679b.Core:AddAssignWith.f8737c9507fb115f.Core.4f441e6d456a6b17", scope: null, file: !35, line: 299, type: !41, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !43) +// CHECK:STDOUT: !38 = !DILocation(line: 372, column: 5, scope: !34) +// CHECK:STDOUT: !39 = !DILocation(line: 370, column: 3, scope: !34) +// CHECK:STDOUT: !40 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.07875fab836259ed.Core:Int.9452f4c51951679b.Core:AddAssignWith.f8737c9507fb115f.Core.4f441e6d456a6b17", scope: null, file: !35, line: 306, type: !41, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !43) // CHECK:STDOUT: !41 = !DISubroutineType(types: !42) // CHECK:STDOUT: !42 = !{null, !7, !7} // CHECK:STDOUT: !43 = !{!44, !45} // CHECK:STDOUT: !44 = !DILocalVariable(arg: 1, scope: !40, type: !7) // CHECK:STDOUT: !45 = !DILocalVariable(arg: 2, scope: !40, type: !7) // CHECK:STDOUT: !46 = !DILocation(line: 4294967295, scope: !40) -// CHECK:STDOUT: !47 = !DILocation(line: 299, column: 3, scope: !40) -// CHECK:STDOUT: !48 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.667d1d3a0ad99849:ImplicitAs.8b551f392b5250ee.Core.4a088ada889550fc", scope: null, file: !35, line: 62, type: !49, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) +// CHECK:STDOUT: !47 = !DILocation(line: 306, column: 3, scope: !40) +// CHECK:STDOUT: !48 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.667d1d3a0ad99849:ImplicitAs.8b551f392b5250ee.Core.4a088ada889550fc", scope: null, file: !35, line: 63, type: !49, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) // CHECK:STDOUT: !49 = !DISubroutineType(types: !50) // CHECK:STDOUT: !50 = !{!7, !7} // CHECK:STDOUT: !51 = !{!52} // CHECK:STDOUT: !52 = !DILocalVariable(arg: 1, scope: !48, type: !7) -// CHECK:STDOUT: !53 = !DILocation(line: 64, column: 17, scope: !48) -// CHECK:STDOUT: !54 = !DILocation(line: 64, column: 5, scope: !48) -// CHECK:STDOUT: !55 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !35, line: 57, type: !49, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !56) +// CHECK:STDOUT: !53 = !DILocation(line: 65, column: 17, scope: !48) +// CHECK:STDOUT: !54 = !DILocation(line: 65, column: 5, scope: !48) +// CHECK:STDOUT: !55 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !35, line: 58, type: !49, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !56) // CHECK:STDOUT: !56 = !{!57} // CHECK:STDOUT: !57 = !DILocalVariable(arg: 1, scope: !55, type: !7) -// CHECK:STDOUT: !58 = !DILocation(line: 57, column: 36, scope: !55) +// CHECK:STDOUT: !58 = !DILocation(line: 58, column: 36, scope: !55) diff --git a/toolchain/driver/testdata/compile/optimize/optimize_speed.carbon b/toolchain/driver/testdata/compile/optimize/optimize_speed.carbon index 2084f39435e3..b6ed3bafc2aa 100644 --- a/toolchain/driver/testdata/compile/optimize/optimize_speed.carbon +++ b/toolchain/driver/testdata/compile/optimize/optimize_speed.carbon @@ -134,16 +134,16 @@ fn VectorizedWithOptSpeed(a: array(i32, 65536)*) { // CHECK:STDOUT: !20 = !{!21} // CHECK:STDOUT: !21 = !DILocalVariable(arg: 1, scope: !16, type: !19) // CHECK:STDOUT: !22 = !DILocation(line: 18, column: 9, scope: !16) -// CHECK:STDOUT: !23 = !DILocation(line: 299, column: 3, scope: !24, inlinedAt: !31) -// CHECK:STDOUT: !24 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.07875fab836259ed.Core:Int.9452f4c51951679b.Core:AddAssignWith.f8737c9507fb115f.Core.4f441e6d456a6b17", scope: null, file: !25, line: 299, type: !26, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !28) +// CHECK:STDOUT: !23 = !DILocation(line: 306, column: 3, scope: !24, inlinedAt: !31) +// CHECK:STDOUT: !24 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.07875fab836259ed.Core:Int.9452f4c51951679b.Core:AddAssignWith.f8737c9507fb115f.Core.4f441e6d456a6b17", scope: null, file: !25, line: 306, type: !26, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !28) // CHECK:STDOUT: !25 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !26 = !DISubroutineType(types: !27) // CHECK:STDOUT: !27 = !{null, !7, !7} // CHECK:STDOUT: !28 = !{!29, !30} // CHECK:STDOUT: !29 = !DILocalVariable(arg: 1, scope: !24, type: !7) // CHECK:STDOUT: !30 = !DILocalVariable(arg: 2, scope: !24, type: !7) -// CHECK:STDOUT: !31 = distinct !DILocation(line: 365, column: 5, scope: !32, inlinedAt: !37) -// CHECK:STDOUT: !32 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !25, line: 363, type: !33, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !35) +// CHECK:STDOUT: !31 = distinct !DILocation(line: 372, column: 5, scope: !32, inlinedAt: !37) +// CHECK:STDOUT: !32 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !25, line: 370, type: !33, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !35) // CHECK:STDOUT: !33 = !DISubroutineType(types: !34) // CHECK:STDOUT: !34 = !{null, !7} // CHECK:STDOUT: !35 = !{!36} diff --git a/toolchain/lower/handle_call.cpp b/toolchain/lower/handle_call.cpp index 4fffd4cd0c91..f5fd2255cb1a 100644 --- a/toolchain/lower/handle_call.cpp +++ b/toolchain/lower/handle_call.cpp @@ -431,6 +431,26 @@ static auto HandleBuiltinCall(FunctionContext& context, SemIR::InstId inst_id, IsSignedInt(context, arg_ids[0]))); return; } + case SemIR::BuiltinFunctionKind::IntConvertFloat: { + auto* operand = context.GetValue(arg_ids[0]); + auto* dest_type = context.GetTypeOfInst(inst_id); + bool is_signed = IsSignedInt(context, arg_ids[0]); + context.SetLocal( + inst_id, is_signed + ? context.builder().CreateSIToFP(operand, dest_type) + : context.builder().CreateUIToFP(operand, dest_type)); + return; + } + case SemIR::BuiltinFunctionKind::FloatConvertInt: { + auto* operand = context.GetValue(arg_ids[0]); + auto* dest_type = context.GetTypeOfInst(inst_id); + bool is_signed = IsSignedInt(context, inst_id); + context.SetLocal( + inst_id, is_signed + ? context.builder().CreateFPToSI(operand, dest_type) + : context.builder().CreateFPToUI(operand, dest_type)); + return; + } case SemIR::BuiltinFunctionKind::IntSNegate: { // Lower `-x` as `0 - x`. @@ -549,7 +569,8 @@ static auto HandleBuiltinCall(FunctionContext& context, SemIR::InstId inst_id, case SemIR::BuiltinFunctionKind::CharConvertChecked: case SemIR::BuiltinFunctionKind::FloatConvertChecked: - case SemIR::BuiltinFunctionKind::IntConvertChecked: { + case SemIR::BuiltinFunctionKind::IntConvertChecked: + case SemIR::BuiltinFunctionKind::IntConvertFloatChecked: { // TODO: Check this statically. CARBON_CHECK(builtin_kind.IsCompTimeOnly( context.sem_ir(), arg_ids, diff --git a/toolchain/lower/testdata/array/iterate.carbon b/toolchain/lower/testdata/array/iterate.carbon index 5e486bb8a9e1..efd2969eb4a5 100644 --- a/toolchain/lower/testdata/array/iterate.carbon +++ b/toolchain/lower/testdata/array/iterate.carbon @@ -295,12 +295,12 @@ fn F() { // CHECK:STDOUT: !74 = !DILocalVariable(arg: 1, scope: !72, type: !26) // CHECK:STDOUT: !75 = !DILocation(line: 40, column: 12, scope: !72) // CHECK:STDOUT: !76 = !DILocation(line: 40, column: 5, scope: !72) -// CHECK:STDOUT: !77 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !78, line: 363, type: !13, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !79) +// CHECK:STDOUT: !77 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !78, line: 370, type: !13, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !79) // CHECK:STDOUT: !78 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !79 = !{!80} // CHECK:STDOUT: !80 = !DILocalVariable(arg: 1, scope: !77, type: !15) -// CHECK:STDOUT: !81 = !DILocation(line: 365, column: 5, scope: !77) -// CHECK:STDOUT: !82 = !DILocation(line: 363, column: 3, scope: !77) +// CHECK:STDOUT: !81 = !DILocation(line: 372, column: 5, scope: !77) +// CHECK:STDOUT: !82 = !DILocation(line: 370, column: 3, scope: !77) // CHECK:STDOUT: !83 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.Optional.Core.7ad52311c812a115", scope: null, file: !65, line: 33, type: !84, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !86) // CHECK:STDOUT: !84 = !DISubroutineType(types: !85) // CHECK:STDOUT: !85 = !{!26, !15} @@ -323,14 +323,14 @@ fn F() { // CHECK:STDOUT: !102 = !DILocalVariable(arg: 1, scope: !100, type: !26) // CHECK:STDOUT: !103 = !DILocation(line: 145, column: 12, scope: !100) // CHECK:STDOUT: !104 = !DILocation(line: 145, column: 5, scope: !100) -// CHECK:STDOUT: !105 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.07875fab836259ed.Core:Int.9452f4c51951679b.Core:AddAssignWith.f8737c9507fb115f.Core.4f441e6d456a6b17", scope: null, file: !78, line: 299, type: !106, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !108) +// CHECK:STDOUT: !105 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.07875fab836259ed.Core:Int.9452f4c51951679b.Core:AddAssignWith.f8737c9507fb115f.Core.4f441e6d456a6b17", scope: null, file: !78, line: 306, type: !106, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !108) // CHECK:STDOUT: !106 = !DISubroutineType(types: !107) // CHECK:STDOUT: !107 = !{null, !15, !15} // CHECK:STDOUT: !108 = !{!109, !110} // CHECK:STDOUT: !109 = !DILocalVariable(arg: 1, scope: !105, type: !15) // CHECK:STDOUT: !110 = !DILocalVariable(arg: 2, scope: !105, type: !15) // CHECK:STDOUT: !111 = !DILocation(line: 4294967295, scope: !105) -// CHECK:STDOUT: !112 = !DILocation(line: 299, column: 3, scope: !105) +// CHECK:STDOUT: !112 = !DILocation(line: 306, column: 3, scope: !105) // CHECK:STDOUT: !113 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.2d6936f0ed82c0eb:OptionalStorage.Core.3f49c03818d8362d", scope: null, file: !65, line: 131, type: !84, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !114) // CHECK:STDOUT: !114 = !{!115} // CHECK:STDOUT: !115 = !DILocalVariable(arg: 1, scope: !113, type: !15) @@ -340,14 +340,14 @@ fn F() { // CHECK:STDOUT: !119 = distinct !DISubprogram(name: "None", linkageName: "_CNone.2d6936f0ed82c0eb:OptionalStorage.Core.3f49c03818d8362d", scope: null, file: !65, line: 125, type: !91, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !120 = !DILocation(line: 128, column: 5, scope: !119) // CHECK:STDOUT: !121 = !DILocation(line: 129, column: 5, scope: !119) -// CHECK:STDOUT: !122 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.667d1d3a0ad99849:ImplicitAs.8b551f392b5250ee.Core.4a088ada889550fc", scope: null, file: !78, line: 62, type: !123, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !125) +// CHECK:STDOUT: !122 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.667d1d3a0ad99849:ImplicitAs.8b551f392b5250ee.Core.4a088ada889550fc", scope: null, file: !78, line: 63, type: !123, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !125) // CHECK:STDOUT: !123 = !DISubroutineType(types: !124) // CHECK:STDOUT: !124 = !{!15, !15} // CHECK:STDOUT: !125 = !{!126} // CHECK:STDOUT: !126 = !DILocalVariable(arg: 1, scope: !122, type: !15) -// CHECK:STDOUT: !127 = !DILocation(line: 64, column: 17, scope: !122) -// CHECK:STDOUT: !128 = !DILocation(line: 64, column: 5, scope: !122) -// CHECK:STDOUT: !129 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !78, line: 57, type: !123, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !130) +// CHECK:STDOUT: !127 = !DILocation(line: 65, column: 17, scope: !122) +// CHECK:STDOUT: !128 = !DILocation(line: 65, column: 5, scope: !122) +// CHECK:STDOUT: !129 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !78, line: 58, type: !123, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !130) // CHECK:STDOUT: !130 = !{!131} // CHECK:STDOUT: !131 = !DILocalVariable(arg: 1, scope: !129, type: !15) -// CHECK:STDOUT: !132 = !DILocation(line: 57, column: 36, scope: !129) +// CHECK:STDOUT: !132 = !DILocation(line: 58, column: 36, scope: !129) diff --git a/toolchain/lower/testdata/builtins/float_to_int.carbon b/toolchain/lower/testdata/builtins/float_to_int.carbon new file mode 100644 index 000000000000..d049135b9af9 --- /dev/null +++ b/toolchain/lower/testdata/builtins/float_to_int.carbon @@ -0,0 +1,130 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/primitives.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/builtins/float_to_int.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/builtins/float_to_int.carbon + +// --- float_to_int.carbon +library "[[@TEST_NAME]]"; + +fn ConvertF32ToI32(a: f32) -> i32 = "float.convert_int"; +fn TestConvertF32ToI32(a: f32) -> i32 { return ConvertF32ToI32(a); } + +fn ConvertF32ToU32(a: f32) -> u32 = "float.convert_int"; +fn TestConvertF32ToU32(a: f32) -> u32 { return ConvertF32ToU32(a); } + +fn ConvertF64ToI32(a: f64) -> i32 = "float.convert_int"; +fn TestConvertF64ToI32(a: f64) -> i32 { return ConvertF64ToI32(a); } + +fn ConvertF64ToU32(a: f64) -> u32 = "float.convert_int"; +fn TestConvertF64ToU32(a: f64) -> u32 { return ConvertF64ToU32(a); } + +fn ConvertF128ToI64(a: f128) -> i64 = "float.convert_int"; +fn TestConvertF128ToI64(a: f128) -> i64 { return ConvertF128ToI64(a); } + +fn ConvertF128ToU64(a: f128) -> u64 = "float.convert_int"; +fn TestConvertF128ToU64(a: f128) -> u64 { return ConvertF128ToU64(a); } + +// CHECK:STDOUT: ; ModuleID = 'float_to_int.carbon' +// CHECK:STDOUT: source_filename = "float_to_int.carbon" +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define i32 @_CTestConvertF32ToI32.Main(float %a) #0 !dbg !4 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: %ConvertF32ToI32.call = fptosi float %a to i32, !dbg !11 +// CHECK:STDOUT: ret i32 %ConvertF32ToI32.call, !dbg !12 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define i32 @_CTestConvertF32ToU32.Main(float %a) #0 !dbg !13 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: %ConvertF32ToU32.call = fptoui float %a to i32, !dbg !19 +// CHECK:STDOUT: ret i32 %ConvertF32ToU32.call, !dbg !20 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define i32 @_CTestConvertF64ToI32.Main(double %a) #0 !dbg !21 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: %ConvertF64ToI32.call = fptosi double %a to i32, !dbg !24 +// CHECK:STDOUT: ret i32 %ConvertF64ToI32.call, !dbg !25 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define i32 @_CTestConvertF64ToU32.Main(double %a) #0 !dbg !26 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: %ConvertF64ToU32.call = fptoui double %a to i32, !dbg !29 +// CHECK:STDOUT: ret i32 %ConvertF64ToU32.call, !dbg !30 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define i64 @_CTestConvertF128ToI64.Main(fp128 %a) #0 !dbg !31 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: %ConvertF128ToI64.call = fptosi fp128 %a to i64, !dbg !37 +// CHECK:STDOUT: ret i64 %ConvertF128ToI64.call, !dbg !38 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define i64 @_CTestConvertF128ToU64.Main(fp128 %a) #0 !dbg !39 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: %ConvertF128ToU64.call = fptoui fp128 %a to i64, !dbg !45 +// CHECK:STDOUT: ret i64 %ConvertF128ToU64.call, !dbg !46 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: attributes #0 = { nounwind } +// CHECK:STDOUT: +// CHECK:STDOUT: !llvm.module.flags = !{!0, !1} +// CHECK:STDOUT: !llvm.dbg.cu = !{!2} +// CHECK:STDOUT: +// CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5} +// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3} +// CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) +// CHECK:STDOUT: !3 = !DIFile(filename: "float_to_int.carbon", directory: "") +// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "TestConvertF32ToI32", linkageName: "_CTestConvertF32ToI32.Main", scope: null, file: !3, line: 4, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !9) +// CHECK:STDOUT: !5 = !DISubroutineType(types: !6) +// CHECK:STDOUT: !6 = !{!7, !8} +// CHECK:STDOUT: !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +// CHECK:STDOUT: !8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +// CHECK:STDOUT: !9 = !{!10} +// CHECK:STDOUT: !10 = !DILocalVariable(arg: 1, scope: !4, type: !8) +// CHECK:STDOUT: !11 = !DILocation(line: 4, column: 48, scope: !4) +// CHECK:STDOUT: !12 = !DILocation(line: 4, column: 41, scope: !4) +// CHECK:STDOUT: !13 = distinct !DISubprogram(name: "TestConvertF32ToU32", linkageName: "_CTestConvertF32ToU32.Main", scope: null, file: !3, line: 7, type: !14, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !17) +// CHECK:STDOUT: !14 = !DISubroutineType(types: !15) +// CHECK:STDOUT: !15 = !{!16, !8} +// CHECK:STDOUT: !16 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_unsigned) +// CHECK:STDOUT: !17 = !{!18} +// CHECK:STDOUT: !18 = !DILocalVariable(arg: 1, scope: !13, type: !8) +// CHECK:STDOUT: !19 = !DILocation(line: 7, column: 48, scope: !13) +// CHECK:STDOUT: !20 = !DILocation(line: 7, column: 41, scope: !13) +// CHECK:STDOUT: !21 = distinct !DISubprogram(name: "TestConvertF64ToI32", linkageName: "_CTestConvertF64ToI32.Main", scope: null, file: !3, line: 10, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !22) +// CHECK:STDOUT: !22 = !{!23} +// CHECK:STDOUT: !23 = !DILocalVariable(arg: 1, scope: !21, type: !8) +// CHECK:STDOUT: !24 = !DILocation(line: 10, column: 48, scope: !21) +// CHECK:STDOUT: !25 = !DILocation(line: 10, column: 41, scope: !21) +// CHECK:STDOUT: !26 = distinct !DISubprogram(name: "TestConvertF64ToU32", linkageName: "_CTestConvertF64ToU32.Main", scope: null, file: !3, line: 13, type: !14, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !27) +// CHECK:STDOUT: !27 = !{!28} +// CHECK:STDOUT: !28 = !DILocalVariable(arg: 1, scope: !26, type: !8) +// CHECK:STDOUT: !29 = !DILocation(line: 13, column: 48, scope: !26) +// CHECK:STDOUT: !30 = !DILocation(line: 13, column: 41, scope: !26) +// CHECK:STDOUT: !31 = distinct !DISubprogram(name: "TestConvertF128ToI64", linkageName: "_CTestConvertF128ToI64.Main", scope: null, file: !3, line: 16, type: !32, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !35) +// CHECK:STDOUT: !32 = !DISubroutineType(types: !33) +// CHECK:STDOUT: !33 = !{!34, !8} +// CHECK:STDOUT: !34 = !DIBasicType(name: "int", size: 64, encoding: DW_ATE_signed) +// CHECK:STDOUT: !35 = !{!36} +// CHECK:STDOUT: !36 = !DILocalVariable(arg: 1, scope: !31, type: !8) +// CHECK:STDOUT: !37 = !DILocation(line: 16, column: 50, scope: !31) +// CHECK:STDOUT: !38 = !DILocation(line: 16, column: 43, scope: !31) +// CHECK:STDOUT: !39 = distinct !DISubprogram(name: "TestConvertF128ToU64", linkageName: "_CTestConvertF128ToU64.Main", scope: null, file: !3, line: 19, type: !40, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !43) +// CHECK:STDOUT: !40 = !DISubroutineType(types: !41) +// CHECK:STDOUT: !41 = !{!42, !8} +// CHECK:STDOUT: !42 = !DIBasicType(name: "int", size: 64, encoding: DW_ATE_unsigned) +// CHECK:STDOUT: !43 = !{!44} +// CHECK:STDOUT: !44 = !DILocalVariable(arg: 1, scope: !39, type: !8) +// CHECK:STDOUT: !45 = !DILocation(line: 19, column: 50, scope: !39) +// CHECK:STDOUT: !46 = !DILocation(line: 19, column: 43, scope: !39) diff --git a/toolchain/lower/testdata/builtins/int_to_float.carbon b/toolchain/lower/testdata/builtins/int_to_float.carbon new file mode 100644 index 000000000000..bf072239851c --- /dev/null +++ b/toolchain/lower/testdata/builtins/int_to_float.carbon @@ -0,0 +1,130 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/primitives.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/builtins/int_to_float.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/builtins/int_to_float.carbon + +// --- int_to_float.carbon +library "[[@TEST_NAME]]"; + +fn ConvertI32ToF32(a: i32) -> f32 = "int.convert_float"; +fn TestConvertI32ToF32(a: i32) -> f32 { return ConvertI32ToF32(a); } + +fn ConvertU32ToF32(a: u32) -> f32 = "int.convert_float"; +fn TestConvertU32ToF32(a: u32) -> f32 { return ConvertU32ToF32(a); } + +fn ConvertI32ToF64(a: i32) -> f64 = "int.convert_float"; +fn TestConvertI32ToF64(a: i32) -> f64 { return ConvertI32ToF64(a); } + +fn ConvertU32ToF64(a: u32) -> f64 = "int.convert_float"; +fn TestConvertU32ToF64(a: u32) -> f64 { return ConvertU32ToF64(a); } + +fn ConvertI64ToF128(a: i64) -> f128 = "int.convert_float"; +fn TestConvertI64ToF128(a: i64) -> f128 { return ConvertI64ToF128(a); } + +fn ConvertU64ToF128(a: u64) -> f128 = "int.convert_float"; +fn TestConvertU64ToF128(a: u64) -> f128 { return ConvertU64ToF128(a); } + +// CHECK:STDOUT: ; ModuleID = 'int_to_float.carbon' +// CHECK:STDOUT: source_filename = "int_to_float.carbon" +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define float @_CTestConvertI32ToF32.Main(i32 %a) #0 !dbg !4 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: %ConvertI32ToF32.call = sitofp i32 %a to float, !dbg !11 +// CHECK:STDOUT: ret float %ConvertI32ToF32.call, !dbg !12 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define float @_CTestConvertU32ToF32.Main(i32 %a) #0 !dbg !13 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: %ConvertU32ToF32.call = uitofp i32 %a to float, !dbg !19 +// CHECK:STDOUT: ret float %ConvertU32ToF32.call, !dbg !20 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define double @_CTestConvertI32ToF64.Main(i32 %a) #0 !dbg !21 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: %ConvertI32ToF64.call = sitofp i32 %a to double, !dbg !24 +// CHECK:STDOUT: ret double %ConvertI32ToF64.call, !dbg !25 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define double @_CTestConvertU32ToF64.Main(i32 %a) #0 !dbg !26 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: %ConvertU32ToF64.call = uitofp i32 %a to double, !dbg !29 +// CHECK:STDOUT: ret double %ConvertU32ToF64.call, !dbg !30 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define fp128 @_CTestConvertI64ToF128.Main(i64 %a) #0 !dbg !31 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: %ConvertI64ToF128.call = sitofp i64 %a to fp128, !dbg !37 +// CHECK:STDOUT: ret fp128 %ConvertI64ToF128.call, !dbg !38 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define fp128 @_CTestConvertU64ToF128.Main(i64 %a) #0 !dbg !39 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: %ConvertU64ToF128.call = uitofp i64 %a to fp128, !dbg !45 +// CHECK:STDOUT: ret fp128 %ConvertU64ToF128.call, !dbg !46 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: attributes #0 = { nounwind } +// CHECK:STDOUT: +// CHECK:STDOUT: !llvm.module.flags = !{!0, !1} +// CHECK:STDOUT: !llvm.dbg.cu = !{!2} +// CHECK:STDOUT: +// CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5} +// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3} +// CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) +// CHECK:STDOUT: !3 = !DIFile(filename: "int_to_float.carbon", directory: "") +// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "TestConvertI32ToF32", linkageName: "_CTestConvertI32ToF32.Main", scope: null, file: !3, line: 4, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !9) +// CHECK:STDOUT: !5 = !DISubroutineType(types: !6) +// CHECK:STDOUT: !6 = !{!7, !8} +// CHECK:STDOUT: !7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +// CHECK:STDOUT: !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +// CHECK:STDOUT: !9 = !{!10} +// CHECK:STDOUT: !10 = !DILocalVariable(arg: 1, scope: !4, type: !8) +// CHECK:STDOUT: !11 = !DILocation(line: 4, column: 48, scope: !4) +// CHECK:STDOUT: !12 = !DILocation(line: 4, column: 41, scope: !4) +// CHECK:STDOUT: !13 = distinct !DISubprogram(name: "TestConvertU32ToF32", linkageName: "_CTestConvertU32ToF32.Main", scope: null, file: !3, line: 7, type: !14, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !17) +// CHECK:STDOUT: !14 = !DISubroutineType(types: !15) +// CHECK:STDOUT: !15 = !{!7, !16} +// CHECK:STDOUT: !16 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_unsigned) +// CHECK:STDOUT: !17 = !{!18} +// CHECK:STDOUT: !18 = !DILocalVariable(arg: 1, scope: !13, type: !16) +// CHECK:STDOUT: !19 = !DILocation(line: 7, column: 48, scope: !13) +// CHECK:STDOUT: !20 = !DILocation(line: 7, column: 41, scope: !13) +// CHECK:STDOUT: !21 = distinct !DISubprogram(name: "TestConvertI32ToF64", linkageName: "_CTestConvertI32ToF64.Main", scope: null, file: !3, line: 10, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !22) +// CHECK:STDOUT: !22 = !{!23} +// CHECK:STDOUT: !23 = !DILocalVariable(arg: 1, scope: !21, type: !8) +// CHECK:STDOUT: !24 = !DILocation(line: 10, column: 48, scope: !21) +// CHECK:STDOUT: !25 = !DILocation(line: 10, column: 41, scope: !21) +// CHECK:STDOUT: !26 = distinct !DISubprogram(name: "TestConvertU32ToF64", linkageName: "_CTestConvertU32ToF64.Main", scope: null, file: !3, line: 13, type: !14, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !27) +// CHECK:STDOUT: !27 = !{!28} +// CHECK:STDOUT: !28 = !DILocalVariable(arg: 1, scope: !26, type: !16) +// CHECK:STDOUT: !29 = !DILocation(line: 13, column: 48, scope: !26) +// CHECK:STDOUT: !30 = !DILocation(line: 13, column: 41, scope: !26) +// CHECK:STDOUT: !31 = distinct !DISubprogram(name: "TestConvertI64ToF128", linkageName: "_CTestConvertI64ToF128.Main", scope: null, file: !3, line: 16, type: !32, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !35) +// CHECK:STDOUT: !32 = !DISubroutineType(types: !33) +// CHECK:STDOUT: !33 = !{!7, !34} +// CHECK:STDOUT: !34 = !DIBasicType(name: "int", size: 64, encoding: DW_ATE_signed) +// CHECK:STDOUT: !35 = !{!36} +// CHECK:STDOUT: !36 = !DILocalVariable(arg: 1, scope: !31, type: !34) +// CHECK:STDOUT: !37 = !DILocation(line: 16, column: 50, scope: !31) +// CHECK:STDOUT: !38 = !DILocation(line: 16, column: 43, scope: !31) +// CHECK:STDOUT: !39 = distinct !DISubprogram(name: "TestConvertU64ToF128", linkageName: "_CTestConvertU64ToF128.Main", scope: null, file: !3, line: 19, type: !40, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !43) +// CHECK:STDOUT: !40 = !DISubroutineType(types: !41) +// CHECK:STDOUT: !41 = !{!7, !42} +// CHECK:STDOUT: !42 = !DIBasicType(name: "int", size: 64, encoding: DW_ATE_unsigned) +// CHECK:STDOUT: !43 = !{!44} +// CHECK:STDOUT: !44 = !DILocalVariable(arg: 1, scope: !39, type: !42) +// CHECK:STDOUT: !45 = !DILocation(line: 19, column: 50, scope: !39) +// CHECK:STDOUT: !46 = !DILocation(line: 19, column: 43, scope: !39) diff --git a/toolchain/lower/testdata/for/break_continue.carbon b/toolchain/lower/testdata/for/break_continue.carbon index 85abbb3a7432..8a646f557dae 100644 --- a/toolchain/lower/testdata/for/break_continue.carbon +++ b/toolchain/lower/testdata/for/break_continue.carbon @@ -340,12 +340,12 @@ fn For() { // CHECK:STDOUT: !87 = !DILocalVariable(arg: 1, scope: !85, type: !33) // CHECK:STDOUT: !88 = !DILocation(line: 40, column: 12, scope: !85) // CHECK:STDOUT: !89 = !DILocation(line: 40, column: 5, scope: !85) -// CHECK:STDOUT: !90 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !91, line: 363, type: !20, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !92) +// CHECK:STDOUT: !90 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !91, line: 370, type: !20, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !92) // CHECK:STDOUT: !91 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !92 = !{!93} // CHECK:STDOUT: !93 = !DILocalVariable(arg: 1, scope: !90, type: !22) -// CHECK:STDOUT: !94 = !DILocation(line: 365, column: 5, scope: !90) -// CHECK:STDOUT: !95 = !DILocation(line: 363, column: 3, scope: !90) +// CHECK:STDOUT: !94 = !DILocation(line: 372, column: 5, scope: !90) +// CHECK:STDOUT: !95 = !DILocation(line: 370, column: 3, scope: !90) // CHECK:STDOUT: !96 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.Optional.Core.326a4fc85c2e7ec7", scope: null, file: !78, line: 33, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !99) // CHECK:STDOUT: !97 = !DISubroutineType(types: !98) // CHECK:STDOUT: !98 = !{!33, !22} @@ -368,14 +368,14 @@ fn For() { // CHECK:STDOUT: !115 = !DILocalVariable(arg: 1, scope: !113, type: !33) // CHECK:STDOUT: !116 = !DILocation(line: 145, column: 12, scope: !113) // CHECK:STDOUT: !117 = !DILocation(line: 145, column: 5, scope: !113) -// CHECK:STDOUT: !118 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.157a183794b6b3f4.Core:Int.9452f4c51951679b.Core:AddAssignWith.f8737c9507fb115f.Core.4f441e6d456a6b17", scope: null, file: !91, line: 299, type: !119, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !121) +// CHECK:STDOUT: !118 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.157a183794b6b3f4.Core:Int.9452f4c51951679b.Core:AddAssignWith.f8737c9507fb115f.Core.4f441e6d456a6b17", scope: null, file: !91, line: 306, type: !119, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !121) // CHECK:STDOUT: !119 = !DISubroutineType(types: !120) // CHECK:STDOUT: !120 = !{null, !22, !22} // CHECK:STDOUT: !121 = !{!122, !123} // CHECK:STDOUT: !122 = !DILocalVariable(arg: 1, scope: !118, type: !22) // CHECK:STDOUT: !123 = !DILocalVariable(arg: 2, scope: !118, type: !22) // CHECK:STDOUT: !124 = !DILocation(line: 4294967295, scope: !118) -// CHECK:STDOUT: !125 = !DILocation(line: 299, column: 3, scope: !118) +// CHECK:STDOUT: !125 = !DILocation(line: 306, column: 3, scope: !118) // CHECK:STDOUT: !126 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.2d6936f0ed82c0eb:OptionalStorage.Core.7fca67425e2a63fa", scope: null, file: !78, line: 131, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !127) // CHECK:STDOUT: !127 = !{!128} // CHECK:STDOUT: !128 = !DILocalVariable(arg: 1, scope: !126, type: !22) @@ -385,14 +385,14 @@ fn For() { // CHECK:STDOUT: !132 = distinct !DISubprogram(name: "None", linkageName: "_CNone.2d6936f0ed82c0eb:OptionalStorage.Core.7fca67425e2a63fa", scope: null, file: !78, line: 125, type: !104, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !133 = !DILocation(line: 128, column: 5, scope: !132) // CHECK:STDOUT: !134 = !DILocation(line: 129, column: 5, scope: !132) -// CHECK:STDOUT: !135 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.667d1d3a0ad99849:ImplicitAs.8b551f392b5250ee.Core.4a088ada889550fc", scope: null, file: !91, line: 62, type: !136, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !138) +// CHECK:STDOUT: !135 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.667d1d3a0ad99849:ImplicitAs.8b551f392b5250ee.Core.4a088ada889550fc", scope: null, file: !91, line: 63, type: !136, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !138) // CHECK:STDOUT: !136 = !DISubroutineType(types: !137) // CHECK:STDOUT: !137 = !{!22, !22} // CHECK:STDOUT: !138 = !{!139} // CHECK:STDOUT: !139 = !DILocalVariable(arg: 1, scope: !135, type: !22) -// CHECK:STDOUT: !140 = !DILocation(line: 64, column: 17, scope: !135) -// CHECK:STDOUT: !141 = !DILocation(line: 64, column: 5, scope: !135) -// CHECK:STDOUT: !142 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !91, line: 57, type: !136, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !143) +// CHECK:STDOUT: !140 = !DILocation(line: 65, column: 17, scope: !135) +// CHECK:STDOUT: !141 = !DILocation(line: 65, column: 5, scope: !135) +// CHECK:STDOUT: !142 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !91, line: 58, type: !136, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !143) // CHECK:STDOUT: !143 = !{!144} // CHECK:STDOUT: !144 = !DILocalVariable(arg: 1, scope: !142, type: !22) -// CHECK:STDOUT: !145 = !DILocation(line: 57, column: 36, scope: !142) +// CHECK:STDOUT: !145 = !DILocation(line: 58, column: 36, scope: !142) diff --git a/toolchain/lower/testdata/for/for.carbon b/toolchain/lower/testdata/for/for.carbon index 91f9835d8501..85d1778b6c03 100644 --- a/toolchain/lower/testdata/for/for.carbon +++ b/toolchain/lower/testdata/for/for.carbon @@ -324,12 +324,12 @@ fn For() { // CHECK:STDOUT: !83 = !DILocalVariable(arg: 1, scope: !81, type: !29) // CHECK:STDOUT: !84 = !DILocation(line: 40, column: 12, scope: !81) // CHECK:STDOUT: !85 = !DILocation(line: 40, column: 5, scope: !81) -// CHECK:STDOUT: !86 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !87, line: 363, type: !16, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !88) +// CHECK:STDOUT: !86 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !87, line: 370, type: !16, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !88) // CHECK:STDOUT: !87 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !88 = !{!89} // CHECK:STDOUT: !89 = !DILocalVariable(arg: 1, scope: !86, type: !18) -// CHECK:STDOUT: !90 = !DILocation(line: 365, column: 5, scope: !86) -// CHECK:STDOUT: !91 = !DILocation(line: 363, column: 3, scope: !86) +// CHECK:STDOUT: !90 = !DILocation(line: 372, column: 5, scope: !86) +// CHECK:STDOUT: !91 = !DILocation(line: 370, column: 3, scope: !86) // CHECK:STDOUT: !92 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.Optional.Core.326a4fc85c2e7ec7", scope: null, file: !74, line: 33, type: !93, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !95) // CHECK:STDOUT: !93 = !DISubroutineType(types: !94) // CHECK:STDOUT: !94 = !{!29, !18} @@ -352,14 +352,14 @@ fn For() { // CHECK:STDOUT: !111 = !DILocalVariable(arg: 1, scope: !109, type: !29) // CHECK:STDOUT: !112 = !DILocation(line: 145, column: 12, scope: !109) // CHECK:STDOUT: !113 = !DILocation(line: 145, column: 5, scope: !109) -// CHECK:STDOUT: !114 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.157a183794b6b3f4.Core:Int.9452f4c51951679b.Core:AddAssignWith.f8737c9507fb115f.Core.4f441e6d456a6b17", scope: null, file: !87, line: 299, type: !115, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !117) +// CHECK:STDOUT: !114 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.157a183794b6b3f4.Core:Int.9452f4c51951679b.Core:AddAssignWith.f8737c9507fb115f.Core.4f441e6d456a6b17", scope: null, file: !87, line: 306, type: !115, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !117) // CHECK:STDOUT: !115 = !DISubroutineType(types: !116) // CHECK:STDOUT: !116 = !{null, !18, !18} // CHECK:STDOUT: !117 = !{!118, !119} // CHECK:STDOUT: !118 = !DILocalVariable(arg: 1, scope: !114, type: !18) // CHECK:STDOUT: !119 = !DILocalVariable(arg: 2, scope: !114, type: !18) // CHECK:STDOUT: !120 = !DILocation(line: 4294967295, scope: !114) -// CHECK:STDOUT: !121 = !DILocation(line: 299, column: 3, scope: !114) +// CHECK:STDOUT: !121 = !DILocation(line: 306, column: 3, scope: !114) // CHECK:STDOUT: !122 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.2d6936f0ed82c0eb:OptionalStorage.Core.7fca67425e2a63fa", scope: null, file: !74, line: 131, type: !93, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !123) // CHECK:STDOUT: !123 = !{!124} // CHECK:STDOUT: !124 = !DILocalVariable(arg: 1, scope: !122, type: !18) @@ -369,14 +369,14 @@ fn For() { // CHECK:STDOUT: !128 = distinct !DISubprogram(name: "None", linkageName: "_CNone.2d6936f0ed82c0eb:OptionalStorage.Core.7fca67425e2a63fa", scope: null, file: !74, line: 125, type: !100, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !129 = !DILocation(line: 128, column: 5, scope: !128) // CHECK:STDOUT: !130 = !DILocation(line: 129, column: 5, scope: !128) -// CHECK:STDOUT: !131 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.667d1d3a0ad99849:ImplicitAs.8b551f392b5250ee.Core.4a088ada889550fc", scope: null, file: !87, line: 62, type: !132, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !134) +// CHECK:STDOUT: !131 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.667d1d3a0ad99849:ImplicitAs.8b551f392b5250ee.Core.4a088ada889550fc", scope: null, file: !87, line: 63, type: !132, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !134) // CHECK:STDOUT: !132 = !DISubroutineType(types: !133) // CHECK:STDOUT: !133 = !{!18, !18} // CHECK:STDOUT: !134 = !{!135} // CHECK:STDOUT: !135 = !DILocalVariable(arg: 1, scope: !131, type: !18) -// CHECK:STDOUT: !136 = !DILocation(line: 64, column: 17, scope: !131) -// CHECK:STDOUT: !137 = !DILocation(line: 64, column: 5, scope: !131) -// CHECK:STDOUT: !138 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !87, line: 57, type: !132, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !139) +// CHECK:STDOUT: !136 = !DILocation(line: 65, column: 17, scope: !131) +// CHECK:STDOUT: !137 = !DILocation(line: 65, column: 5, scope: !131) +// CHECK:STDOUT: !138 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !87, line: 58, type: !132, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !139) // CHECK:STDOUT: !139 = !{!140} // CHECK:STDOUT: !140 = !DILocalVariable(arg: 1, scope: !138, type: !18) -// CHECK:STDOUT: !141 = !DILocation(line: 57, column: 36, scope: !138) +// CHECK:STDOUT: !141 = !DILocation(line: 58, column: 36, scope: !138) diff --git a/toolchain/lower/testdata/operators/increment.carbon b/toolchain/lower/testdata/operators/increment.carbon index f9910d959c91..eecedd1d723d 100644 --- a/toolchain/lower/testdata/operators/increment.carbon +++ b/toolchain/lower/testdata/operators/increment.carbon @@ -92,28 +92,28 @@ fn IncrSigned() { // CHECK:STDOUT: !14 = !{!15} // CHECK:STDOUT: !15 = !DILocalVariable(arg: 1, scope: !10, type: !13) // CHECK:STDOUT: !16 = !DILocation(line: 5, column: 3, scope: !10) -// CHECK:STDOUT: !17 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !18, line: 363, type: !11, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !19) +// CHECK:STDOUT: !17 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !18, line: 370, type: !11, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !19) // CHECK:STDOUT: !18 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !19 = !{!20} // CHECK:STDOUT: !20 = !DILocalVariable(arg: 1, scope: !17, type: !13) -// CHECK:STDOUT: !21 = !DILocation(line: 365, column: 5, scope: !17) -// CHECK:STDOUT: !22 = !DILocation(line: 363, column: 3, scope: !17) -// CHECK:STDOUT: !23 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.07875fab836259ed.Core:Int.9452f4c51951679b.Core:AddAssignWith.f8737c9507fb115f.Core.4f441e6d456a6b17", scope: null, file: !18, line: 299, type: !24, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !26) +// CHECK:STDOUT: !21 = !DILocation(line: 372, column: 5, scope: !17) +// CHECK:STDOUT: !22 = !DILocation(line: 370, column: 3, scope: !17) +// CHECK:STDOUT: !23 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.07875fab836259ed.Core:Int.9452f4c51951679b.Core:AddAssignWith.f8737c9507fb115f.Core.4f441e6d456a6b17", scope: null, file: !18, line: 306, type: !24, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !26) // CHECK:STDOUT: !24 = !DISubroutineType(types: !25) // CHECK:STDOUT: !25 = !{null, !13, !13} // CHECK:STDOUT: !26 = !{!27, !28} // CHECK:STDOUT: !27 = !DILocalVariable(arg: 1, scope: !23, type: !13) // CHECK:STDOUT: !28 = !DILocalVariable(arg: 2, scope: !23, type: !13) // CHECK:STDOUT: !29 = !DILocation(line: 4294967295, scope: !23) -// CHECK:STDOUT: !30 = !DILocation(line: 299, column: 3, scope: !23) -// CHECK:STDOUT: !31 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.667d1d3a0ad99849:ImplicitAs.8b551f392b5250ee.Core.4a088ada889550fc", scope: null, file: !18, line: 62, type: !32, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !34) +// CHECK:STDOUT: !30 = !DILocation(line: 306, column: 3, scope: !23) +// CHECK:STDOUT: !31 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.667d1d3a0ad99849:ImplicitAs.8b551f392b5250ee.Core.4a088ada889550fc", scope: null, file: !18, line: 63, type: !32, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !34) // CHECK:STDOUT: !32 = !DISubroutineType(types: !33) // CHECK:STDOUT: !33 = !{!13, !13} // CHECK:STDOUT: !34 = !{!35} // CHECK:STDOUT: !35 = !DILocalVariable(arg: 1, scope: !31, type: !13) -// CHECK:STDOUT: !36 = !DILocation(line: 64, column: 17, scope: !31) -// CHECK:STDOUT: !37 = !DILocation(line: 64, column: 5, scope: !31) -// CHECK:STDOUT: !38 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !18, line: 57, type: !32, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !39) +// CHECK:STDOUT: !36 = !DILocation(line: 65, column: 17, scope: !31) +// CHECK:STDOUT: !37 = !DILocation(line: 65, column: 5, scope: !31) +// CHECK:STDOUT: !38 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !18, line: 58, type: !32, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !39) // CHECK:STDOUT: !39 = !{!40} // CHECK:STDOUT: !40 = !DILocalVariable(arg: 1, scope: !38, type: !13) -// CHECK:STDOUT: !41 = !DILocation(line: 57, column: 36, scope: !38) +// CHECK:STDOUT: !41 = !DILocation(line: 58, column: 36, scope: !38) diff --git a/toolchain/lower/testdata/primitives/char.carbon b/toolchain/lower/testdata/primitives/char.carbon index b73c8c7a5600..286bf5e26999 100644 --- a/toolchain/lower/testdata/primitives/char.carbon +++ b/toolchain/lower/testdata/primitives/char.carbon @@ -956,58 +956,58 @@ fn AddSubUInt32(c: char, i: u32) { // CHECK:STDOUT: !396 = !DILocation(line: 116, column: 29, scope: !392) // CHECK:STDOUT: !397 = !DILocation(line: 116, column: 13, scope: !392) // CHECK:STDOUT: !398 = !DILocation(line: 116, column: 5, scope: !392) -// CHECK:STDOUT: !399 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.b0c8f4aca61b1cc8.Core.5fc30b52fc63534e", scope: null, file: !400, line: 86, type: !198, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !401) +// CHECK:STDOUT: !399 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.b0c8f4aca61b1cc8.Core.5fc30b52fc63534e", scope: null, file: !400, line: 87, type: !198, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !401) // CHECK:STDOUT: !400 = !DIFile(filename: "{{.*}}/prelude/types/uint.carbon", directory: "") // CHECK:STDOUT: !401 = !{!402} // CHECK:STDOUT: !402 = !DILocalVariable(arg: 1, scope: !399, type: !7) -// CHECK:STDOUT: !403 = !DILocation(line: 87, column: 12, scope: !399) -// CHECK:STDOUT: !404 = !DILocation(line: 87, column: 5, scope: !399) -// CHECK:STDOUT: !405 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.b0c8f4aca61b1cc8.Core.5f7c4ef1aceb8644", scope: null, file: !400, line: 86, type: !210, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !406) +// CHECK:STDOUT: !403 = !DILocation(line: 88, column: 12, scope: !399) +// CHECK:STDOUT: !404 = !DILocation(line: 88, column: 5, scope: !399) +// CHECK:STDOUT: !405 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.b0c8f4aca61b1cc8.Core.5f7c4ef1aceb8644", scope: null, file: !400, line: 87, type: !210, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !406) // CHECK:STDOUT: !406 = !{!407} // CHECK:STDOUT: !407 = !DILocalVariable(arg: 1, scope: !405, type: !7) -// CHECK:STDOUT: !408 = !DILocation(line: 87, column: 12, scope: !405) -// CHECK:STDOUT: !409 = !DILocation(line: 87, column: 5, scope: !405) -// CHECK:STDOUT: !410 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.b0c8f4aca61b1cc8.Core.8d4760853758c835", scope: null, file: !400, line: 86, type: !222, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !411) +// CHECK:STDOUT: !408 = !DILocation(line: 88, column: 12, scope: !405) +// CHECK:STDOUT: !409 = !DILocation(line: 88, column: 5, scope: !405) +// CHECK:STDOUT: !410 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.b0c8f4aca61b1cc8.Core.8d4760853758c835", scope: null, file: !400, line: 87, type: !222, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !411) // CHECK:STDOUT: !411 = !{!412} // CHECK:STDOUT: !412 = !DILocalVariable(arg: 1, scope: !410, type: !7) -// CHECK:STDOUT: !413 = !DILocation(line: 87, column: 12, scope: !410) -// CHECK:STDOUT: !414 = !DILocation(line: 87, column: 5, scope: !410) -// CHECK:STDOUT: !415 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.b0c8f4aca61b1cc8.Core.3b9ab92f0d7dee42", scope: null, file: !400, line: 86, type: !228, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !416) +// CHECK:STDOUT: !413 = !DILocation(line: 88, column: 12, scope: !410) +// CHECK:STDOUT: !414 = !DILocation(line: 88, column: 5, scope: !410) +// CHECK:STDOUT: !415 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.b0c8f4aca61b1cc8.Core.3b9ab92f0d7dee42", scope: null, file: !400, line: 87, type: !228, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !416) // CHECK:STDOUT: !416 = !{!417} // CHECK:STDOUT: !417 = !DILocalVariable(arg: 1, scope: !415, type: !7) -// CHECK:STDOUT: !418 = !DILocation(line: 87, column: 12, scope: !415) -// CHECK:STDOUT: !419 = !DILocation(line: 87, column: 5, scope: !415) +// CHECK:STDOUT: !418 = !DILocation(line: 88, column: 12, scope: !415) +// CHECK:STDOUT: !419 = !DILocation(line: 88, column: 5, scope: !415) // CHECK:STDOUT: !420 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Char.Core:As.5d7343568c0b5715.Core.9e499631a839b430", scope: null, file: !197, line: 46, type: !228, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !421) // CHECK:STDOUT: !421 = !{!422} // CHECK:STDOUT: !422 = !DILocalVariable(arg: 1, scope: !420, type: !7) // CHECK:STDOUT: !423 = !DILocation(line: 47, column: 5, scope: !420) -// CHECK:STDOUT: !424 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:FromUInt.1fcb3ce533adb4f1.Core.c80d3ca7428a249b", scope: null, file: !400, line: 70, type: !198, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !425) +// CHECK:STDOUT: !424 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:FromUInt.1fcb3ce533adb4f1.Core.c80d3ca7428a249b", scope: null, file: !400, line: 71, type: !198, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !425) // CHECK:STDOUT: !425 = !{!426} // CHECK:STDOUT: !426 = !DILocalVariable(arg: 1, scope: !424, type: !7) -// CHECK:STDOUT: !427 = !DILocation(line: 72, column: 17, scope: !424) -// CHECK:STDOUT: !428 = !DILocation(line: 72, column: 12, scope: !424) -// CHECK:STDOUT: !429 = !DILocation(line: 72, column: 5, scope: !424) -// CHECK:STDOUT: !430 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:FromUInt.1fcb3ce533adb4f1.Core.9502038ec13cc220", scope: null, file: !400, line: 70, type: !210, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !431) +// CHECK:STDOUT: !427 = !DILocation(line: 73, column: 17, scope: !424) +// CHECK:STDOUT: !428 = !DILocation(line: 73, column: 12, scope: !424) +// CHECK:STDOUT: !429 = !DILocation(line: 73, column: 5, scope: !424) +// CHECK:STDOUT: !430 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:FromUInt.1fcb3ce533adb4f1.Core.9502038ec13cc220", scope: null, file: !400, line: 71, type: !210, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !431) // CHECK:STDOUT: !431 = !{!432} // CHECK:STDOUT: !432 = !DILocalVariable(arg: 1, scope: !430, type: !7) -// CHECK:STDOUT: !433 = !DILocation(line: 72, column: 17, scope: !430) -// CHECK:STDOUT: !434 = !DILocation(line: 72, column: 12, scope: !430) -// CHECK:STDOUT: !435 = !DILocation(line: 72, column: 5, scope: !430) -// CHECK:STDOUT: !436 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Int.9452f4c51951679b.Core:FromUInt.319e5feddb0783f6.Core.22cb66a8380dd428", scope: null, file: !400, line: 78, type: !222, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !437) +// CHECK:STDOUT: !433 = !DILocation(line: 73, column: 17, scope: !430) +// CHECK:STDOUT: !434 = !DILocation(line: 73, column: 12, scope: !430) +// CHECK:STDOUT: !435 = !DILocation(line: 73, column: 5, scope: !430) +// CHECK:STDOUT: !436 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Int.9452f4c51951679b.Core:FromUInt.319e5feddb0783f6.Core.22cb66a8380dd428", scope: null, file: !400, line: 79, type: !222, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !437) // CHECK:STDOUT: !437 = !{!438} // CHECK:STDOUT: !438 = !DILocalVariable(arg: 1, scope: !436, type: !7) -// CHECK:STDOUT: !439 = !DILocation(line: 80, column: 17, scope: !436) -// CHECK:STDOUT: !440 = !DILocation(line: 80, column: 12, scope: !436) -// CHECK:STDOUT: !441 = !DILocation(line: 80, column: 5, scope: !436) -// CHECK:STDOUT: !442 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Int.9452f4c51951679b.Core:FromUInt.319e5feddb0783f6.Core.de9dae3cdf77ed49", scope: null, file: !400, line: 78, type: !228, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !443) +// CHECK:STDOUT: !439 = !DILocation(line: 81, column: 17, scope: !436) +// CHECK:STDOUT: !440 = !DILocation(line: 81, column: 12, scope: !436) +// CHECK:STDOUT: !441 = !DILocation(line: 81, column: 5, scope: !436) +// CHECK:STDOUT: !442 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Int.9452f4c51951679b.Core:FromUInt.319e5feddb0783f6.Core.de9dae3cdf77ed49", scope: null, file: !400, line: 79, type: !228, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !443) // CHECK:STDOUT: !443 = !{!444} // CHECK:STDOUT: !444 = !DILocalVariable(arg: 1, scope: !442, type: !7) -// CHECK:STDOUT: !445 = !DILocation(line: 80, column: 17, scope: !442) -// CHECK:STDOUT: !446 = !DILocation(line: 80, column: 12, scope: !442) -// CHECK:STDOUT: !447 = !DILocation(line: 80, column: 5, scope: !442) -// CHECK:STDOUT: !448 = distinct !DISubprogram(name: "AsUInt", linkageName: "_CAsUInt.UInt.9452f4c51951679b.Core:AnyUInt.Core.ca1ac10d3fc7c1a8", scope: null, file: !400, line: 58, type: !449, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !451) +// CHECK:STDOUT: !445 = !DILocation(line: 81, column: 17, scope: !442) +// CHECK:STDOUT: !446 = !DILocation(line: 81, column: 12, scope: !442) +// CHECK:STDOUT: !447 = !DILocation(line: 81, column: 5, scope: !442) +// CHECK:STDOUT: !448 = distinct !DISubprogram(name: "AsUInt", linkageName: "_CAsUInt.UInt.9452f4c51951679b.Core:AnyUInt.Core.ca1ac10d3fc7c1a8", scope: null, file: !400, line: 59, type: !449, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !451) // CHECK:STDOUT: !449 = !DISubroutineType(types: !450) // CHECK:STDOUT: !450 = !{!7, !7} // CHECK:STDOUT: !451 = !{!452} // CHECK:STDOUT: !452 = !DILocalVariable(arg: 1, scope: !448, type: !7) -// CHECK:STDOUT: !453 = !DILocation(line: 58, column: 37, scope: !448) +// CHECK:STDOUT: !453 = !DILocation(line: 59, column: 37, scope: !448) diff --git a/toolchain/lower/testdata/primitives/int_types.carbon b/toolchain/lower/testdata/primitives/int_types.carbon index 0d2c621b67fe..87797f6096da 100644 --- a/toolchain/lower/testdata/primitives/int_types.carbon +++ b/toolchain/lower/testdata/primitives/int_types.carbon @@ -321,74 +321,74 @@ fn ImplicitWidenUnsignedCustom(a: Core.UInt(4)) -> Core.UInt(5) { return a; } // CHECK:STDOUT: !39 = !{!40} // CHECK:STDOUT: !40 = !DILocalVariable(arg: 1, scope: !34, type: !38) // CHECK:STDOUT: !41 = !DILocation(line: 8, column: 67, scope: !34) -// CHECK:STDOUT: !42 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.667d1d3a0ad99849:ImplicitAs.8b551f392b5250ee.Core.ddcb82e6e9ddd8c9", scope: null, file: !43, line: 62, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !44) +// CHECK:STDOUT: !42 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.667d1d3a0ad99849:ImplicitAs.8b551f392b5250ee.Core.ddcb82e6e9ddd8c9", scope: null, file: !43, line: 63, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !44) // CHECK:STDOUT: !43 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !44 = !{!45} // CHECK:STDOUT: !45 = !DILocalVariable(arg: 1, scope: !42, type: !8) -// CHECK:STDOUT: !46 = !DILocation(line: 64, column: 17, scope: !42) -// CHECK:STDOUT: !47 = !DILocation(line: 64, column: 12, scope: !42) -// CHECK:STDOUT: !48 = !DILocation(line: 64, column: 5, scope: !42) -// CHECK:STDOUT: !49 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.b0c8f4aca61b1cc8.Core.5f7c4ef1aceb8644", scope: null, file: !50, line: 86, type: !13, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) +// CHECK:STDOUT: !46 = !DILocation(line: 65, column: 17, scope: !42) +// CHECK:STDOUT: !47 = !DILocation(line: 65, column: 12, scope: !42) +// CHECK:STDOUT: !48 = !DILocation(line: 65, column: 5, scope: !42) +// CHECK:STDOUT: !49 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.b0c8f4aca61b1cc8.Core.5f7c4ef1aceb8644", scope: null, file: !50, line: 87, type: !13, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) // CHECK:STDOUT: !50 = !DIFile(filename: "{{.*}}/prelude/types/uint.carbon", directory: "") // CHECK:STDOUT: !51 = !{!52} // CHECK:STDOUT: !52 = !DILocalVariable(arg: 1, scope: !49, type: !16) -// CHECK:STDOUT: !53 = !DILocation(line: 87, column: 12, scope: !49) -// CHECK:STDOUT: !54 = !DILocation(line: 87, column: 5, scope: !49) -// CHECK:STDOUT: !55 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.b0c8f4aca61b1cc8.Core.3b9ab92f0d7dee42", scope: null, file: !50, line: 86, type: !21, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !56) +// CHECK:STDOUT: !53 = !DILocation(line: 88, column: 12, scope: !49) +// CHECK:STDOUT: !54 = !DILocation(line: 88, column: 5, scope: !49) +// CHECK:STDOUT: !55 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.b0c8f4aca61b1cc8.Core.3b9ab92f0d7dee42", scope: null, file: !50, line: 87, type: !21, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !56) // CHECK:STDOUT: !56 = !{!57} // CHECK:STDOUT: !57 = !DILocalVariable(arg: 1, scope: !55, type: !16) -// CHECK:STDOUT: !58 = !DILocation(line: 87, column: 12, scope: !55) -// CHECK:STDOUT: !59 = !DILocation(line: 87, column: 5, scope: !55) -// CHECK:STDOUT: !60 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.667d1d3a0ad99849:ImplicitAs.8b551f392b5250ee.Core.380b88eae23462db", scope: null, file: !43, line: 62, type: !27, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !61) +// CHECK:STDOUT: !58 = !DILocation(line: 88, column: 12, scope: !55) +// CHECK:STDOUT: !59 = !DILocation(line: 88, column: 5, scope: !55) +// CHECK:STDOUT: !60 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.667d1d3a0ad99849:ImplicitAs.8b551f392b5250ee.Core.380b88eae23462db", scope: null, file: !43, line: 63, type: !27, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !61) // CHECK:STDOUT: !61 = !{!62} // CHECK:STDOUT: !62 = !DILocalVariable(arg: 1, scope: !60, type: !30) -// CHECK:STDOUT: !63 = !DILocation(line: 64, column: 17, scope: !60) -// CHECK:STDOUT: !64 = !DILocation(line: 64, column: 12, scope: !60) -// CHECK:STDOUT: !65 = !DILocation(line: 64, column: 5, scope: !60) -// CHECK:STDOUT: !66 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.b0c8f4aca61b1cc8.Core.983e4a1f66495cbc", scope: null, file: !50, line: 86, type: !35, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !67) +// CHECK:STDOUT: !63 = !DILocation(line: 65, column: 17, scope: !60) +// CHECK:STDOUT: !64 = !DILocation(line: 65, column: 12, scope: !60) +// CHECK:STDOUT: !65 = !DILocation(line: 65, column: 5, scope: !60) +// CHECK:STDOUT: !66 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.b0c8f4aca61b1cc8.Core.983e4a1f66495cbc", scope: null, file: !50, line: 87, type: !35, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !67) // CHECK:STDOUT: !67 = !{!68} // CHECK:STDOUT: !68 = !DILocalVariable(arg: 1, scope: !66, type: !38) -// CHECK:STDOUT: !69 = !DILocation(line: 87, column: 12, scope: !66) -// CHECK:STDOUT: !70 = !DILocation(line: 87, column: 5, scope: !66) -// CHECK:STDOUT: !71 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.ca1ac10d3fc7c1a8", scope: null, file: !43, line: 57, type: !72, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !74) +// CHECK:STDOUT: !69 = !DILocation(line: 88, column: 12, scope: !66) +// CHECK:STDOUT: !70 = !DILocation(line: 88, column: 5, scope: !66) +// CHECK:STDOUT: !71 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.ca1ac10d3fc7c1a8", scope: null, file: !43, line: 58, type: !72, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !74) // CHECK:STDOUT: !72 = !DISubroutineType(types: !73) // CHECK:STDOUT: !73 = !{!8, !8} // CHECK:STDOUT: !74 = !{!75} // CHECK:STDOUT: !75 = !DILocalVariable(arg: 1, scope: !71, type: !8) -// CHECK:STDOUT: !76 = !DILocation(line: 57, column: 36, scope: !71) -// CHECK:STDOUT: !77 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:FromUInt.1fcb3ce533adb4f1.Core.9502038ec13cc220", scope: null, file: !50, line: 70, type: !13, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !78) +// CHECK:STDOUT: !76 = !DILocation(line: 58, column: 36, scope: !71) +// CHECK:STDOUT: !77 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:FromUInt.1fcb3ce533adb4f1.Core.9502038ec13cc220", scope: null, file: !50, line: 71, type: !13, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !78) // CHECK:STDOUT: !78 = !{!79} // CHECK:STDOUT: !79 = !DILocalVariable(arg: 1, scope: !77, type: !16) -// CHECK:STDOUT: !80 = !DILocation(line: 72, column: 17, scope: !77) -// CHECK:STDOUT: !81 = !DILocation(line: 72, column: 12, scope: !77) -// CHECK:STDOUT: !82 = !DILocation(line: 72, column: 5, scope: !77) -// CHECK:STDOUT: !83 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Int.9452f4c51951679b.Core:FromUInt.319e5feddb0783f6.Core.de9dae3cdf77ed49", scope: null, file: !50, line: 78, type: !21, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !84) +// CHECK:STDOUT: !80 = !DILocation(line: 73, column: 17, scope: !77) +// CHECK:STDOUT: !81 = !DILocation(line: 73, column: 12, scope: !77) +// CHECK:STDOUT: !82 = !DILocation(line: 73, column: 5, scope: !77) +// CHECK:STDOUT: !83 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Int.9452f4c51951679b.Core:FromUInt.319e5feddb0783f6.Core.de9dae3cdf77ed49", scope: null, file: !50, line: 79, type: !21, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !84) // CHECK:STDOUT: !84 = !{!85} // CHECK:STDOUT: !85 = !DILocalVariable(arg: 1, scope: !83, type: !16) -// CHECK:STDOUT: !86 = !DILocation(line: 80, column: 17, scope: !83) -// CHECK:STDOUT: !87 = !DILocation(line: 80, column: 12, scope: !83) -// CHECK:STDOUT: !88 = !DILocation(line: 80, column: 5, scope: !83) -// CHECK:STDOUT: !89 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.044c7d430ddd4fd6", scope: null, file: !43, line: 57, type: !90, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !92) +// CHECK:STDOUT: !86 = !DILocation(line: 81, column: 17, scope: !83) +// CHECK:STDOUT: !87 = !DILocation(line: 81, column: 12, scope: !83) +// CHECK:STDOUT: !88 = !DILocation(line: 81, column: 5, scope: !83) +// CHECK:STDOUT: !89 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.044c7d430ddd4fd6", scope: null, file: !43, line: 58, type: !90, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !92) // CHECK:STDOUT: !90 = !DISubroutineType(types: !91) // CHECK:STDOUT: !91 = !{!30, !30} // CHECK:STDOUT: !92 = !{!93} // CHECK:STDOUT: !93 = !DILocalVariable(arg: 1, scope: !89, type: !30) -// CHECK:STDOUT: !94 = !DILocation(line: 57, column: 36, scope: !89) -// CHECK:STDOUT: !95 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:FromUInt.1fcb3ce533adb4f1.Core.53bd1b576efef5e7", scope: null, file: !50, line: 70, type: !35, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !96) +// CHECK:STDOUT: !94 = !DILocation(line: 58, column: 36, scope: !89) +// CHECK:STDOUT: !95 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:FromUInt.1fcb3ce533adb4f1.Core.53bd1b576efef5e7", scope: null, file: !50, line: 71, type: !35, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !96) // CHECK:STDOUT: !96 = !{!97} // CHECK:STDOUT: !97 = !DILocalVariable(arg: 1, scope: !95, type: !38) -// CHECK:STDOUT: !98 = !DILocation(line: 72, column: 17, scope: !95) -// CHECK:STDOUT: !99 = !DILocation(line: 72, column: 12, scope: !95) -// CHECK:STDOUT: !100 = !DILocation(line: 72, column: 5, scope: !95) -// CHECK:STDOUT: !101 = distinct !DISubprogram(name: "AsUInt", linkageName: "_CAsUInt.UInt.9452f4c51951679b.Core:AnyUInt.Core.ca1ac10d3fc7c1a8", scope: null, file: !50, line: 58, type: !102, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !104) +// CHECK:STDOUT: !98 = !DILocation(line: 73, column: 17, scope: !95) +// CHECK:STDOUT: !99 = !DILocation(line: 73, column: 12, scope: !95) +// CHECK:STDOUT: !100 = !DILocation(line: 73, column: 5, scope: !95) +// CHECK:STDOUT: !101 = distinct !DISubprogram(name: "AsUInt", linkageName: "_CAsUInt.UInt.9452f4c51951679b.Core:AnyUInt.Core.ca1ac10d3fc7c1a8", scope: null, file: !50, line: 59, type: !102, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !104) // CHECK:STDOUT: !102 = !DISubroutineType(types: !103) // CHECK:STDOUT: !103 = !{!16, !16} // CHECK:STDOUT: !104 = !{!105} // CHECK:STDOUT: !105 = !DILocalVariable(arg: 1, scope: !101, type: !16) -// CHECK:STDOUT: !106 = !DILocation(line: 58, column: 37, scope: !101) -// CHECK:STDOUT: !107 = distinct !DISubprogram(name: "AsUInt", linkageName: "_CAsUInt.UInt.9452f4c51951679b.Core:AnyUInt.Core.044c7d430ddd4fd6", scope: null, file: !50, line: 58, type: !108, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !110) +// CHECK:STDOUT: !106 = !DILocation(line: 59, column: 37, scope: !101) +// CHECK:STDOUT: !107 = distinct !DISubprogram(name: "AsUInt", linkageName: "_CAsUInt.UInt.9452f4c51951679b.Core:AnyUInt.Core.044c7d430ddd4fd6", scope: null, file: !50, line: 59, type: !108, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !110) // CHECK:STDOUT: !108 = !DISubroutineType(types: !109) // CHECK:STDOUT: !109 = !{!38, !38} // CHECK:STDOUT: !110 = !{!111} // CHECK:STDOUT: !111 = !DILocalVariable(arg: 1, scope: !107, type: !38) -// CHECK:STDOUT: !112 = !DILocation(line: 58, column: 37, scope: !107) +// CHECK:STDOUT: !112 = !DILocation(line: 59, column: 37, scope: !107) diff --git a/toolchain/lower/testdata/primitives/optional.carbon b/toolchain/lower/testdata/primitives/optional.carbon index 31e062465c05..080a7b29dbd8 100644 --- a/toolchain/lower/testdata/primitives/optional.carbon +++ b/toolchain/lower/testdata/primitives/optional.carbon @@ -468,42 +468,42 @@ fn F(c: Core.Optional(C*)) -> Core.Optional(C*) { // CHECK:STDOUT: !105 = !{!14} // CHECK:STDOUT: !106 = !DILocation(line: 31, column: 12, scope: !103) // CHECK:STDOUT: !107 = !DILocation(line: 31, column: 5, scope: !103) -// CHECK:STDOUT: !108 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.8c14fbb190d2c4a2:ImplicitAs.ad22d1bbc0605210.Core.4462757cf1994b1f", scope: null, file: !109, line: 40, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !110) +// CHECK:STDOUT: !108 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.8c14fbb190d2c4a2:ImplicitAs.ad22d1bbc0605210.Core.4462757cf1994b1f", scope: null, file: !109, line: 42, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !110) // CHECK:STDOUT: !109 = !DIFile(filename: "{{.*}}/prelude/operators/as.carbon", directory: "") // CHECK:STDOUT: !110 = !{!111} // CHECK:STDOUT: !111 = !DILocalVariable(arg: 1, scope: !108, type: !7) -// CHECK:STDOUT: !112 = !DILocation(line: 40, column: 45, scope: !108) -// CHECK:STDOUT: !113 = !DILocation(line: 40, column: 38, scope: !108) +// CHECK:STDOUT: !112 = !DILocation(line: 42, column: 45, scope: !108) +// CHECK:STDOUT: !113 = !DILocation(line: 42, column: 38, scope: !108) // CHECK:STDOUT: !114 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.0a82a05610538fbd:ImplicitAs.dfe7f37cd2946174.Core.5301bd2e5265063e", scope: null, file: !86, line: 105, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !115) // CHECK:STDOUT: !115 = !{!116} // CHECK:STDOUT: !116 = !DILocalVariable(arg: 1, scope: !114, type: !7) // CHECK:STDOUT: !117 = !DILocation(line: 106, column: 12, scope: !114) // CHECK:STDOUT: !118 = !DILocation(line: 106, column: 5, scope: !114) -// CHECK:STDOUT: !119 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.8c14fbb190d2c4a2:ImplicitAs.ad22d1bbc0605210.Core.bae947e6cb644eb3", scope: null, file: !109, line: 40, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !120) +// CHECK:STDOUT: !119 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.8c14fbb190d2c4a2:ImplicitAs.ad22d1bbc0605210.Core.bae947e6cb644eb3", scope: null, file: !109, line: 42, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !120) // CHECK:STDOUT: !120 = !{!121} // CHECK:STDOUT: !121 = !DILocalVariable(arg: 1, scope: !119, type: !7) -// CHECK:STDOUT: !122 = !DILocation(line: 40, column: 45, scope: !119) -// CHECK:STDOUT: !123 = !DILocation(line: 40, column: 38, scope: !119) -// CHECK:STDOUT: !124 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.874935b394d32264:ImplicitAs.eb057aa32837c84e.Core.4462757cf1994b1f", scope: null, file: !109, line: 44, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !125) +// CHECK:STDOUT: !122 = !DILocation(line: 42, column: 45, scope: !119) +// CHECK:STDOUT: !123 = !DILocation(line: 42, column: 38, scope: !119) +// CHECK:STDOUT: !124 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.874935b394d32264:ImplicitAs.eb057aa32837c84e.Core.4462757cf1994b1f", scope: null, file: !109, line: 46, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !125) // CHECK:STDOUT: !125 = !{!126} // CHECK:STDOUT: !126 = !DILocalVariable(arg: 1, scope: !124, type: !7) -// CHECK:STDOUT: !127 = !DILocation(line: 44, column: 45, scope: !124) -// CHECK:STDOUT: !128 = !DILocation(line: 44, column: 38, scope: !124) -// CHECK:STDOUT: !129 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.874935b394d32264:ImplicitAs.eb057aa32837c84e.Core.d312635c3eabfce6", scope: null, file: !109, line: 44, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !130) +// CHECK:STDOUT: !127 = !DILocation(line: 46, column: 45, scope: !124) +// CHECK:STDOUT: !128 = !DILocation(line: 46, column: 38, scope: !124) +// CHECK:STDOUT: !129 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.874935b394d32264:ImplicitAs.eb057aa32837c84e.Core.d312635c3eabfce6", scope: null, file: !109, line: 46, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !130) // CHECK:STDOUT: !130 = !{!131} // CHECK:STDOUT: !131 = !DILocalVariable(arg: 1, scope: !129, type: !7) -// CHECK:STDOUT: !132 = !DILocation(line: 44, column: 45, scope: !129) -// CHECK:STDOUT: !133 = !DILocation(line: 44, column: 38, scope: !129) -// CHECK:STDOUT: !134 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.874935b394d32264:ImplicitAs.eb057aa32837c84e.Core.bae947e6cb644eb3", scope: null, file: !109, line: 44, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !135) +// CHECK:STDOUT: !132 = !DILocation(line: 46, column: 45, scope: !129) +// CHECK:STDOUT: !133 = !DILocation(line: 46, column: 38, scope: !129) +// CHECK:STDOUT: !134 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.874935b394d32264:ImplicitAs.eb057aa32837c84e.Core.bae947e6cb644eb3", scope: null, file: !109, line: 46, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !135) // CHECK:STDOUT: !135 = !{!136} // CHECK:STDOUT: !136 = !DILocalVariable(arg: 1, scope: !134, type: !7) -// CHECK:STDOUT: !137 = !DILocation(line: 44, column: 45, scope: !134) -// CHECK:STDOUT: !138 = !DILocation(line: 44, column: 38, scope: !134) -// CHECK:STDOUT: !139 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.874935b394d32264:ImplicitAs.eb057aa32837c84e.Core.4e32707a29fe420f", scope: null, file: !109, line: 44, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !140) +// CHECK:STDOUT: !137 = !DILocation(line: 46, column: 45, scope: !134) +// CHECK:STDOUT: !138 = !DILocation(line: 46, column: 38, scope: !134) +// CHECK:STDOUT: !139 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.874935b394d32264:ImplicitAs.eb057aa32837c84e.Core.4e32707a29fe420f", scope: null, file: !109, line: 46, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !140) // CHECK:STDOUT: !140 = !{!141} // CHECK:STDOUT: !141 = !DILocalVariable(arg: 1, scope: !139, type: !7) -// CHECK:STDOUT: !142 = !DILocation(line: 44, column: 45, scope: !139) -// CHECK:STDOUT: !143 = !DILocation(line: 44, column: 38, scope: !139) +// CHECK:STDOUT: !142 = !DILocation(line: 46, column: 45, scope: !139) +// CHECK:STDOUT: !143 = !DILocation(line: 46, column: 38, scope: !139) // CHECK:STDOUT: !144 = distinct !DISubprogram(name: "Has", linkageName: "_CHas.e8f8f92d3d08d149:OptionalStorage.Core.5e5386123d4b6287", scope: null, file: !86, line: 172, type: !12, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !145) // CHECK:STDOUT: !145 = !{!146} // CHECK:STDOUT: !146 = !DILocalVariable(arg: 1, scope: !144, type: !14) @@ -533,11 +533,11 @@ fn F(c: Core.Optional(C*)) -> Core.Optional(C*) { // CHECK:STDOUT: !170 = !DILocalVariable(arg: 1, scope: !168, type: !7) // CHECK:STDOUT: !171 = !DILocation(line: 34, column: 12, scope: !168) // CHECK:STDOUT: !172 = !DILocation(line: 34, column: 5, scope: !168) -// CHECK:STDOUT: !173 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.8c14fbb190d2c4a2:ImplicitAs.ad22d1bbc0605210.Core.8c6f821d602abaa4", scope: null, file: !109, line: 40, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !174) +// CHECK:STDOUT: !173 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.8c14fbb190d2c4a2:ImplicitAs.ad22d1bbc0605210.Core.8c6f821d602abaa4", scope: null, file: !109, line: 42, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !174) // CHECK:STDOUT: !174 = !{!175} // CHECK:STDOUT: !175 = !DILocalVariable(arg: 1, scope: !173, type: !7) -// CHECK:STDOUT: !176 = !DILocation(line: 40, column: 45, scope: !173) -// CHECK:STDOUT: !177 = !DILocation(line: 40, column: 38, scope: !173) +// CHECK:STDOUT: !176 = !DILocation(line: 42, column: 45, scope: !173) +// CHECK:STDOUT: !177 = !DILocation(line: 42, column: 38, scope: !173) // CHECK:STDOUT: !178 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.Optional.Core.664c9635efe58704", scope: null, file: !86, line: 33, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !179) // CHECK:STDOUT: !179 = !{!180} // CHECK:STDOUT: !180 = !DILocalVariable(arg: 1, scope: !178, type: !7) @@ -549,14 +549,14 @@ fn F(c: Core.Optional(C*)) -> Core.Optional(C*) { // CHECK:STDOUT: !186 = !DILocation(line: 137, column: 5, scope: !183) // CHECK:STDOUT: !187 = !DILocation(line: 138, column: 5, scope: !183) // CHECK:STDOUT: !188 = !DILocation(line: 139, column: 5, scope: !183) -// CHECK:STDOUT: !189 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.667d1d3a0ad99849:ImplicitAs.8b551f392b5250ee.Core.4a088ada889550fc", scope: null, file: !190, line: 62, type: !191, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !193) +// CHECK:STDOUT: !189 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.667d1d3a0ad99849:ImplicitAs.8b551f392b5250ee.Core.4a088ada889550fc", scope: null, file: !190, line: 63, type: !191, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !193) // CHECK:STDOUT: !190 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !191 = !DISubroutineType(types: !192) // CHECK:STDOUT: !192 = !{!7, !7} // CHECK:STDOUT: !193 = !{!194} // CHECK:STDOUT: !194 = !DILocalVariable(arg: 1, scope: !189, type: !7) -// CHECK:STDOUT: !195 = !DILocation(line: 64, column: 17, scope: !189) -// CHECK:STDOUT: !196 = !DILocation(line: 64, column: 5, scope: !189) +// CHECK:STDOUT: !195 = !DILocation(line: 65, column: 17, scope: !189) +// CHECK:STDOUT: !196 = !DILocation(line: 65, column: 5, scope: !189) // CHECK:STDOUT: !197 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.c70f21296ce3b72c:OptionalStorage.Core.66877768e8b2b97c", scope: null, file: !86, line: 131, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !198) // CHECK:STDOUT: !198 = !{!199} // CHECK:STDOUT: !199 = !DILocalVariable(arg: 1, scope: !197, type: !7) @@ -564,10 +564,10 @@ fn F(c: Core.Optional(C*)) -> Core.Optional(C*) { // CHECK:STDOUT: !201 = !DILocation(line: 137, column: 28, scope: !197) // CHECK:STDOUT: !202 = !DILocation(line: 138, column: 5, scope: !197) // CHECK:STDOUT: !203 = !DILocation(line: 139, column: 5, scope: !197) -// CHECK:STDOUT: !204 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !190, line: 57, type: !191, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !205) +// CHECK:STDOUT: !204 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !190, line: 58, type: !191, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !205) // CHECK:STDOUT: !205 = !{!206} // CHECK:STDOUT: !206 = !DILocalVariable(arg: 1, scope: !204, type: !7) -// CHECK:STDOUT: !207 = !DILocation(line: 57, column: 36, scope: !204) +// CHECK:STDOUT: !207 = !DILocation(line: 58, column: 36, scope: !204) // CHECK:STDOUT: !208 = distinct !DISubprogram(name: "Op", linkageName: "_COp.99377c0e95f681c6:Copy.Core.4bee6dcdea6ba756", scope: null, file: !209, line: 19, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !210) // CHECK:STDOUT: !209 = !DIFile(filename: "{{.*}}/prelude/copy.carbon", directory: "") // CHECK:STDOUT: !210 = !{!211} diff --git a/toolchain/sem_ir/builtin_function_kind.cpp b/toolchain/sem_ir/builtin_function_kind.cpp index aa42e2370b4a..e641b8213b6c 100644 --- a/toolchain/sem_ir/builtin_function_kind.cpp +++ b/toolchain/sem_ir/builtin_function_kind.cpp @@ -478,6 +478,15 @@ constexpr BuiltinInfo IntConvert = {"int.convert", constexpr BuiltinInfo IntConvertChecked = { "int.convert_checked", ValidateSignatureAnyInt>}; +// Converts an integer type to a floating-point type. +constexpr BuiltinInfo IntConvertFloat = { + "int.convert_float", ValidateSignatureAnyFloat>}; + +// Converts an integer type to a floating-point type, checking for loss of +// precision. +constexpr BuiltinInfo IntConvertFloatChecked = { + "int.convert_float_checked", ValidateSignatureAnyFloat>}; + // "int.snegate": integer negation. constexpr BuiltinInfo IntSNegate = {"int.snegate", ValidateSignatureIntT>}; @@ -698,6 +707,10 @@ constexpr BuiltinInfo FloatDivAssign = { constexpr BuiltinInfo FloatConvertChecked = { "float.convert_checked", ValidateSignatureFloatU>}; +// Converts a floating-point type to an integer type. +constexpr BuiltinInfo FloatConvertInt = { + "float.convert_int", ValidateSignatureAnyInt>}; + // "float.eq": float equality comparison. constexpr BuiltinInfo FloatEq = { "float.eq", ValidateSignatureBool>}; @@ -842,11 +855,14 @@ auto BuiltinFunctionKind::IsCompTimeOnly(const File& sem_ir, case CharConvertChecked: case FloatConvertChecked: case IntConvertChecked: + case IntConvertFloatChecked: // Checked conversions are compile-time only. return true; + case FloatConvertInt: case IntConvert: case IntConvertChar: + case IntConvertFloat: case IntSNegate: case IntComplement: case IntSAdd: diff --git a/toolchain/sem_ir/builtin_function_kind.def b/toolchain/sem_ir/builtin_function_kind.def index 711b9d971b84..01dfc0487e37 100644 --- a/toolchain/sem_ir/builtin_function_kind.def +++ b/toolchain/sem_ir/builtin_function_kind.def @@ -53,6 +53,8 @@ CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(CharConvertChecked) CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntConvert) CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntConvertChar) CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntConvertChecked) +CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntConvertFloat) +CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntConvertFloatChecked) // Integer arithmetic. CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntSNegate) @@ -116,6 +118,7 @@ CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatDivAssign) // Float conversion. CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatConvertChecked) +CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatConvertInt) // Float comparison. CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatEq)