mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
add empty array expr to gen_dev
This commit is contained in:
parent
472e95f3e3
commit
cfe1d3d893
3 changed files with 21 additions and 0 deletions
|
@ -1075,6 +1075,10 @@ impl<
|
|||
ASM::add_reg64_reg64_imm32(&mut self.buf, dst_reg, CC::BASE_PTR_REG, offset);
|
||||
}
|
||||
|
||||
fn create_empty_array(&mut self, sym: &Symbol) {
|
||||
self.storage_manager.create_empty_array(&mut self.buf, sym);
|
||||
}
|
||||
|
||||
fn create_struct(&mut self, sym: &Symbol, layout: &Layout<'a>, fields: &'a [Symbol]) {
|
||||
self.storage_manager
|
||||
.create_struct(&mut self.buf, sym, layout, fields);
|
||||
|
|
|
@ -627,6 +627,17 @@ impl<
|
|||
);
|
||||
}
|
||||
|
||||
pub fn create_empty_array(&mut self, buf: &mut Vec<'a, u8>, sym: &Symbol) {
|
||||
let base_offset = self.claim_stack_area(sym, 24);
|
||||
// TODO: This can be optimized. We just need to add the ability to set a stack value to zero or load an immediate to the stack.
|
||||
self.with_tmp_general_reg(buf, |_storage_manager, buf, reg| {
|
||||
ASM::mov_reg64_imm64(buf, reg, 0);
|
||||
ASM::mov_reg64_base32(buf, reg, base_offset);
|
||||
ASM::mov_reg64_base32(buf, reg, base_offset + 8);
|
||||
ASM::mov_reg64_base32(buf, reg, base_offset + 16);
|
||||
});
|
||||
}
|
||||
|
||||
/// Creates a struct on the stack, moving the data in fields into the struct.
|
||||
pub fn create_struct(
|
||||
&mut self,
|
||||
|
|
|
@ -310,6 +310,9 @@ trait Backend<'a> {
|
|||
x => todo!("the call type, {:?}", x),
|
||||
}
|
||||
}
|
||||
Expr::EmptyArray => {
|
||||
self.create_empty_array(sym);
|
||||
}
|
||||
Expr::Struct(fields) => {
|
||||
self.load_literal_symbols(fields);
|
||||
self.create_struct(sym, layout, fields);
|
||||
|
@ -772,6 +775,9 @@ trait Backend<'a> {
|
|||
/// load_literal sets a symbol to be equal to a literal.
|
||||
fn load_literal(&mut self, sym: &Symbol, layout: &Layout<'a>, lit: &Literal<'a>);
|
||||
|
||||
/// create_empyt_array creates an empyt array with nullptr, zero length, and zero capacity.
|
||||
fn create_empty_array(&mut self, sym: &Symbol);
|
||||
|
||||
/// create_struct creates a struct with the elements specified loaded into it as data.
|
||||
fn create_struct(&mut self, sym: &Symbol, layout: &Layout<'a>, fields: &'a [Symbol]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue