mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
fix windows function pointer return
This commit is contained in:
parent
04ff184466
commit
e76c63f448
2 changed files with 36 additions and 11 deletions
|
@ -61,6 +61,13 @@ impl FloatWidth {
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const fn type_name(&self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
Self::F32 => "f32",
|
||||||
|
Self::F64 => "f64",
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
|
|
|
@ -20,7 +20,7 @@ use roc_mono::{
|
||||||
},
|
},
|
||||||
list_element_layout,
|
list_element_layout,
|
||||||
};
|
};
|
||||||
use roc_target::PtrWidth;
|
use roc_target::{OperatingSystem, PtrWidth};
|
||||||
|
|
||||||
use crate::llvm::{
|
use crate::llvm::{
|
||||||
bitcode::{
|
bitcode::{
|
||||||
|
@ -287,19 +287,37 @@ pub(crate) fn run_low_level<'a, 'ctx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PtrWidth::Bytes8 => {
|
PtrWidth::Bytes8 => {
|
||||||
let cc_return_by_pointer = match layout_interner.get_repr(number_layout) {
|
let (type_name, width) = {
|
||||||
LayoutRepr::Builtin(Builtin::Int(int_width)) => {
|
match layout_interner.get_repr(number_layout) {
|
||||||
(int_width.stack_size() as usize > env.target_info.ptr_size())
|
LayoutRepr::Builtin(Builtin::Int(int_width)) => {
|
||||||
.then_some(int_width.type_name())
|
(int_width.type_name(), int_width.stack_size())
|
||||||
|
}
|
||||||
|
LayoutRepr::Builtin(Builtin::Decimal) => {
|
||||||
|
// zig picks 128 for dec.RocDec
|
||||||
|
("i128", 16)
|
||||||
|
}
|
||||||
|
LayoutRepr::Builtin(Builtin::Float(float_width)) => {
|
||||||
|
(float_width.type_name(), float_width.stack_size())
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
unreachable!("other layout types are non-numeric")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LayoutRepr::Builtin(Builtin::Decimal) => {
|
|
||||||
// zig picks 128 for dec.RocDec
|
|
||||||
Some("i128")
|
|
||||||
}
|
|
||||||
_ => None,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(type_name) = cc_return_by_pointer {
|
use roc_target::OperatingSystem::*;
|
||||||
|
let cc_return_by_pointer = match env.target_info.operating_system {
|
||||||
|
Windows => {
|
||||||
|
// there is just one return register on Windows
|
||||||
|
(width + 1) as usize > env.target_info.ptr_size()
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
// on other systems we have two return registers
|
||||||
|
(width + 1) as usize > 2 * env.target_info.ptr_size()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if cc_return_by_pointer {
|
||||||
let bitcode_return_type = zig_num_parse_result_type(env, type_name);
|
let bitcode_return_type = zig_num_parse_result_type(env, type_name);
|
||||||
|
|
||||||
call_bitcode_fn_fixing_for_convention(
|
call_bitcode_fn_fixing_for_convention(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue