mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
be more precise with zig return types
This commit is contained in:
parent
ec80161824
commit
bb4ff34aaa
3 changed files with 68 additions and 14 deletions
|
@ -33,7 +33,9 @@ use crate::llvm::{
|
|||
pass_update_mode,
|
||||
},
|
||||
compare::{generic_eq, generic_neq},
|
||||
convert::{self, basic_type_from_layout},
|
||||
convert::{
|
||||
self, basic_type_from_layout, zig_num_parse_result_type, zig_to_int_checked_result_type,
|
||||
},
|
||||
intrinsics::{
|
||||
LLVM_ADD_SATURATED, LLVM_ADD_WITH_OVERFLOW, LLVM_CEILING, LLVM_COS, LLVM_FABS, LLVM_FLOOR,
|
||||
LLVM_LOG, LLVM_MUL_WITH_OVERFLOW, LLVM_POW, LLVM_ROUND, LLVM_SIN, LLVM_SQRT,
|
||||
|
@ -257,7 +259,31 @@ pub(crate) fn run_low_level<'a, 'ctx, 'env>(
|
|||
}
|
||||
}
|
||||
PtrWidth::Bytes8 => {
|
||||
call_bitcode_fn_fixing_for_convention(env, &[string], layout, intrinsic)
|
||||
let cc_return_by_pointer = match number_layout {
|
||||
Layout::Builtin(Builtin::Int(int_width)) => {
|
||||
(int_width.stack_size() as usize > env.target_info.ptr_size())
|
||||
.then_some(int_width.type_name())
|
||||
}
|
||||
Layout::Builtin(Builtin::Decimal) => {
|
||||
// zig picks 128 for dec.RocDec
|
||||
Some("i128")
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
|
||||
if let Some(type_name) = cc_return_by_pointer {
|
||||
let bitcode_return_type = zig_num_parse_result_type(env, type_name);
|
||||
|
||||
call_bitcode_fn_fixing_for_convention(
|
||||
env,
|
||||
bitcode_return_type,
|
||||
&[string],
|
||||
layout,
|
||||
intrinsic,
|
||||
)
|
||||
} else {
|
||||
call_bitcode_fn(env, &[string], intrinsic)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1973,14 +1999,20 @@ fn build_int_unary_op<'a, 'ctx, 'env>(
|
|||
}
|
||||
}
|
||||
PtrWidth::Bytes8 => {
|
||||
// call_bitcode_fn_fixing_for_convention(env, &[string], layout, intrinsic)
|
||||
if target_int_width.stack_size() as usize > env.target_info.ptr_size() {
|
||||
let bitcode_return_type =
|
||||
zig_to_int_checked_result_type(env, target_int_width.type_name());
|
||||
|
||||
call_bitcode_fn_fixing_for_convention(
|
||||
env,
|
||||
&[arg.into()],
|
||||
return_layout,
|
||||
intrinsic,
|
||||
)
|
||||
call_bitcode_fn_fixing_for_convention(
|
||||
env,
|
||||
bitcode_return_type,
|
||||
&[arg.into()],
|
||||
return_layout,
|
||||
intrinsic,
|
||||
)
|
||||
} else {
|
||||
call_bitcode_fn(env, &[arg.into()], intrinsic)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue