mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
enable loading aligned referenced primitives
This commit is contained in:
parent
907050ceaa
commit
2bcbb19f07
1 changed files with 47 additions and 8 deletions
|
@ -294,6 +294,17 @@ impl<
|
||||||
);
|
);
|
||||||
reg
|
reg
|
||||||
}
|
}
|
||||||
|
Stack(ReferencedPrimitive { base_offset, size })
|
||||||
|
if base_offset % 8 == 0 && size == 8 =>
|
||||||
|
{
|
||||||
|
// The primitive is aligned and the data is exactly 8 bytes, treat it like regular stack.
|
||||||
|
let reg = self.get_general_reg(buf);
|
||||||
|
ASM::mov_reg64_base32(buf, reg, base_offset);
|
||||||
|
self.general_used_regs.push((reg, *sym));
|
||||||
|
self.symbol_storage_map.insert(*sym, Reg(General(reg)));
|
||||||
|
self.free_reference(sym);
|
||||||
|
reg
|
||||||
|
}
|
||||||
Stack(ReferencedPrimitive { .. }) => {
|
Stack(ReferencedPrimitive { .. }) => {
|
||||||
todo!("loading referenced primitives")
|
todo!("loading referenced primitives")
|
||||||
}
|
}
|
||||||
|
@ -349,6 +360,17 @@ impl<
|
||||||
);
|
);
|
||||||
reg
|
reg
|
||||||
}
|
}
|
||||||
|
Stack(ReferencedPrimitive { base_offset, size })
|
||||||
|
if base_offset % 8 == 0 && size == 8 =>
|
||||||
|
{
|
||||||
|
// The primitive is aligned and the data is exactly 8 bytes, treat it like regular stack.
|
||||||
|
let reg = self.get_float_reg(buf);
|
||||||
|
ASM::mov_freg64_base32(buf, reg, base_offset);
|
||||||
|
self.float_used_regs.push((reg, *sym));
|
||||||
|
self.symbol_storage_map.insert(*sym, Reg(Float(reg)));
|
||||||
|
self.free_reference(sym);
|
||||||
|
reg
|
||||||
|
}
|
||||||
Stack(ReferencedPrimitive { .. }) => {
|
Stack(ReferencedPrimitive { .. }) => {
|
||||||
todo!("loading referenced primitives")
|
todo!("loading referenced primitives")
|
||||||
}
|
}
|
||||||
|
@ -402,6 +424,12 @@ impl<
|
||||||
debug_assert_eq!(base_offset % 8, 0);
|
debug_assert_eq!(base_offset % 8, 0);
|
||||||
ASM::mov_reg64_base32(buf, reg, *base_offset);
|
ASM::mov_reg64_base32(buf, reg, *base_offset);
|
||||||
}
|
}
|
||||||
|
Stack(ReferencedPrimitive { base_offset, size })
|
||||||
|
if base_offset % 8 == 0 && *size == 8 =>
|
||||||
|
{
|
||||||
|
// The primitive is aligned and the data is exactly 8 bytes, treat it like regular stack.
|
||||||
|
ASM::mov_reg64_base32(buf, reg, *base_offset);
|
||||||
|
}
|
||||||
Stack(ReferencedPrimitive { .. }) => {
|
Stack(ReferencedPrimitive { .. }) => {
|
||||||
todo!("loading referenced primitives")
|
todo!("loading referenced primitives")
|
||||||
}
|
}
|
||||||
|
@ -450,6 +478,12 @@ impl<
|
||||||
debug_assert_eq!(base_offset % 8, 0);
|
debug_assert_eq!(base_offset % 8, 0);
|
||||||
ASM::mov_freg64_base32(buf, reg, *base_offset);
|
ASM::mov_freg64_base32(buf, reg, *base_offset);
|
||||||
}
|
}
|
||||||
|
Stack(ReferencedPrimitive { base_offset, size })
|
||||||
|
if base_offset % 8 == 0 && *size == 8 =>
|
||||||
|
{
|
||||||
|
// The primitive is aligned and the data is exactly 8 bytes, treat it like regular stack.
|
||||||
|
ASM::mov_freg64_base32(buf, reg, *base_offset);
|
||||||
|
}
|
||||||
Stack(ReferencedPrimitive { .. }) => {
|
Stack(ReferencedPrimitive { .. }) => {
|
||||||
todo!("loading referenced primitives")
|
todo!("loading referenced primitives")
|
||||||
}
|
}
|
||||||
|
@ -766,14 +800,7 @@ impl<
|
||||||
self.free_stack_chunk(base_offset, 8);
|
self.free_stack_chunk(base_offset, 8);
|
||||||
}
|
}
|
||||||
Stack(Complex { .. } | ReferencedPrimitive { .. }) => {
|
Stack(Complex { .. } | ReferencedPrimitive { .. }) => {
|
||||||
let owned_data = if let Some(owned_data) = self.allocation_map.remove(sym) {
|
self.free_reference(sym);
|
||||||
owned_data
|
|
||||||
} else {
|
|
||||||
internal_error!("Unknown symbol: {}", sym);
|
|
||||||
};
|
|
||||||
if Rc::strong_count(&owned_data) == 1 {
|
|
||||||
self.free_stack_chunk(owned_data.0, owned_data.1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
@ -795,6 +822,18 @@ impl<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Frees an reference and release an allocation if it is no longer used.
|
||||||
|
fn free_reference(&mut self, sym: &Symbol) {
|
||||||
|
let owned_data = if let Some(owned_data) = self.allocation_map.remove(sym) {
|
||||||
|
owned_data
|
||||||
|
} else {
|
||||||
|
internal_error!("Unknown symbol: {}", sym);
|
||||||
|
};
|
||||||
|
if Rc::strong_count(&owned_data) == 1 {
|
||||||
|
self.free_stack_chunk(owned_data.0, owned_data.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn free_stack_chunk(&mut self, base_offset: i32, size: u32) {
|
fn free_stack_chunk(&mut self, base_offset: i32, size: u32) {
|
||||||
let loc = (base_offset, size);
|
let loc = (base_offset, size);
|
||||||
// Note: this position current points to the offset following the specified location.
|
// Note: this position current points to the offset following the specified location.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue