Support for float <-> float conversions. (#7279)

Implement support for floating-point <-> floating-point type conversions
as described in https://github.com/carbon-language/carbon-lang/pull/820
and https://github.com/carbon-language/carbon-lang/pull/845.
Value-preserving conversions are implicit; narrowing conversions require
explicit `as`.

Assisted-by: Gemini via Antigravity
This commit is contained in:
Richard Smith
2026-06-04 00:33:33 +00:00
committed by GitHub
parent 7fe3e35aec
commit 88c191146d
15 changed files with 976 additions and 11 deletions
+7
View File
@@ -441,6 +441,13 @@ static auto HandleBuiltinCall(FunctionContext& context, SemIR::InstId inst_id,
: context.builder().CreateUIToFP(operand, dest_type));
return;
}
case SemIR::BuiltinFunctionKind::FloatConvert: {
auto* operand = context.GetValue(arg_ids[0]);
auto* dest_type = context.GetTypeOfInst(inst_id);
context.SetLocal(inst_id,
context.builder().CreateFPCast(operand, dest_type));
return;
}
case SemIR::BuiltinFunctionKind::FloatConvertInt: {
auto* operand = context.GetValue(arg_ids[0]);
auto* dest_type = context.GetTypeOfInst(inst_id);