From a7da54516a27171d27a6c4b8bad6f4621a5f3e2e Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 12 Oct 2020 17:59:19 -0400 Subject: [PATCH] Cast i64 to f64 instead of using builtin bitcode --- compiler/builtins/bitcode/src/lib.rs | 4 ++-- compiler/gen/src/llvm/build.rs | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/compiler/builtins/bitcode/src/lib.rs b/compiler/builtins/bitcode/src/lib.rs index 57dfd48ba8..b64bbf6580 100644 --- a/compiler/builtins/bitcode/src/lib.rs +++ b/compiler/builtins/bitcode/src/lib.rs @@ -6,8 +6,8 @@ mod libm; -/// TODO replace this with a normal Inkwell build_cast call - this was just -/// used as a proof of concept for getting bitcode importing working! +/// TODO this is no longer used. Feel free to delete it the next time +/// we need to rebuild builtins.bc! #[no_mangle] pub fn i64_to_f64_(num: i64) -> f64 { num as f64 diff --git a/compiler/gen/src/llvm/build.rs b/compiler/gen/src/llvm/build.rs index 2d422b8f79..8404ddb0a3 100644 --- a/compiler/gen/src/llvm/build.rs +++ b/compiler/gen/src/llvm/build.rs @@ -2619,8 +2619,13 @@ fn build_int_unary_op<'a, 'ctx, 'env>( )) } NumToFloat => { - // TODO specialize this to be not just for i64! - call_bitcode_fn(NumToFloat, env, &[arg.into()], "i64_to_f64_") + // This is an Int, so we need to convert it. + bd.build_cast( + InstructionOpcode::SIToFP, + arg, + env.context.f64_type(), + "i64_to_f64", + ) } _ => { unreachable!("Unrecognized int unary operation: {:?}", op);