an attempt at passing bigger values

This commit is contained in:
Folkert 2023-09-18 18:51:17 +02:00
parent 529703d449
commit 3a8d4b853b
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
3 changed files with 60 additions and 15 deletions

View file

@ -752,9 +752,33 @@ impl AArch64CallLoadArgs {
storage_manager.no_data(&sym); storage_manager.no_data(&sym);
} }
_ if stack_size > 16 => { _ if stack_size > 16 => {
// TODO: Double check this. match AArch64Call::GENERAL_PARAM_REGS.get(self.general_i) {
storage_manager.complex_stack_arg(&sym, self.argument_offset, stack_size); Some(ptr_reg) => {
self.argument_offset += stack_size as i32; // if there is a general purpose register available, use it to store a pointer to the value
let base_offset = storage_manager.claim_stack_area_layout(
layout_interner,
sym,
in_layout,
);
let tmp_reg = AArch64Call::GENERAL_RETURN_REGS[0];
super::x86_64::copy_to_base_offset::<_, _, AArch64Assembler>(
buf,
base_offset,
stack_size,
*ptr_reg,
tmp_reg,
0,
);
self.general_i += 1;
}
None => {
// else, pass the value implicitly by copying to the stack (of the new frame)
storage_manager.complex_stack_arg(&sym, self.argument_offset, stack_size);
self.argument_offset += stack_size as i32;
}
}
} }
LayoutRepr::LambdaSet(lambda_set) => self.load_arg( LayoutRepr::LambdaSet(lambda_set) => self.load_arg(
buf, buf,
@ -897,19 +921,30 @@ impl AArch64CallStoreArgs {
} }
_ if layout_interner.stack_size(in_layout) == 0 => {} _ if layout_interner.stack_size(in_layout) == 0 => {}
_ if layout_interner.stack_size(in_layout) > 16 => { _ if layout_interner.stack_size(in_layout) > 16 => {
// TODO: Double check this. match Self::GENERAL_PARAM_REGS.get(self.general_i) {
// Just copy onto the stack. Some(reg) => {
let stack_offset = self.tmp_stack_offset; // if there is a general purpose register available, use it to store a pointer to the value
let (base_offset, _size) = storage_manager.stack_offset_and_size(&sym);
let size = copy_symbol_to_stack_offset::<CC>( ASM::add_reg64_reg64_imm32(buf, *reg, AArch64GeneralReg::FP, base_offset);
buf,
storage_manager,
sym,
tmp_reg,
stack_offset,
);
self.tmp_stack_offset += size as i32; self.general_i += 1;
}
None => {
// else, pass the value implicitly by copying to the stack (of the new frame)
let stack_offset = self.tmp_stack_offset;
let size = copy_symbol_to_stack_offset::<CC>(
buf,
storage_manager,
sym,
tmp_reg,
stack_offset,
);
self.tmp_stack_offset += size as i32;
}
}
} }
LayoutRepr::LambdaSet(lambda_set) => self.store_arg( LayoutRepr::LambdaSet(lambda_set) => self.store_arg(
buf, buf,

View file

@ -601,7 +601,7 @@ where
size size
} }
fn copy_to_base_offset<GeneralReg, FloatReg, ASM>( pub(crate) fn copy_to_base_offset<GeneralReg, FloatReg, ASM>(
buf: &mut Vec<'_, u8>, buf: &mut Vec<'_, u8>,
dst_base_offset: i32, dst_base_offset: i32,
stack_size: u32, stack_size: u32,

View file

@ -3332,6 +3332,16 @@ fn box_num() {
assert_evals_to!("Box.box 123u64", RocBox::new(123), RocBox<u64>) assert_evals_to!("Box.box 123u64", RocBox::new(123), RocBox<u64>)
} }
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn box_record() {
assert_evals_to!(
"Box.box { x: 1u64, y: 2u64 }",
RocBox::new((1u64, 2u64)),
RocBox<(u64, u64)>
);
}
#[test] #[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn box_str() { fn box_str() {