mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
final phase
This commit is contained in:
parent
0ed259a80d
commit
c663a35e16
27 changed files with 222 additions and 183 deletions
|
@ -7,12 +7,13 @@ use roc_module::symbol::{Interns, Symbol};
|
|||
use roc_mono::code_gen_help::CodeGenHelp;
|
||||
use roc_mono::ir::{BranchInfo, JoinPointId, Literal, Param, ProcLayout, SelfRecursive, Stmt};
|
||||
use roc_mono::layout::{Builtin, Layout};
|
||||
use roc_target::TargetInfo;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
pub mod aarch64;
|
||||
pub mod x86_64;
|
||||
|
||||
const PTR_SIZE: u32 = 8;
|
||||
const TARGET_INFO: TargetInfo = TargetInfo::default_x86_64();
|
||||
|
||||
pub trait CallConv<GeneralReg: RegTrait, FloatReg: RegTrait> {
|
||||
const BASE_PTR_REG: GeneralReg;
|
||||
|
@ -308,7 +309,7 @@ pub fn new_backend_64bit<
|
|||
phantom_cc: PhantomData,
|
||||
env,
|
||||
interns,
|
||||
helper_proc_gen: CodeGenHelp::new(env.arena, IntWidth::I64, env.module_id),
|
||||
helper_proc_gen: CodeGenHelp::new(env.arena, TARGET_INFO, env.module_id),
|
||||
helper_proc_symbols: bumpalo::vec![in env.arena],
|
||||
proc_name: None,
|
||||
is_self_recursive: None,
|
||||
|
@ -974,7 +975,7 @@ impl<
|
|||
}
|
||||
|
||||
fn create_struct(&mut self, sym: &Symbol, layout: &Layout<'a>, fields: &'a [Symbol]) {
|
||||
let struct_size = layout.stack_size(PTR_SIZE);
|
||||
let struct_size = layout.stack_size(TARGET_INFO);
|
||||
|
||||
if let Layout::Struct(field_layouts) = layout {
|
||||
if struct_size > 0 {
|
||||
|
@ -991,7 +992,7 @@ impl<
|
|||
let mut current_offset = offset;
|
||||
for (field, field_layout) in fields.iter().zip(field_layouts.iter()) {
|
||||
self.copy_symbol_to_stack_offset(current_offset, field, field_layout);
|
||||
let field_size = field_layout.stack_size(PTR_SIZE);
|
||||
let field_size = field_layout.stack_size(TARGET_INFO);
|
||||
current_offset += field_size as i32;
|
||||
}
|
||||
} else {
|
||||
|
@ -1029,14 +1030,14 @@ impl<
|
|||
if let Some(SymbolStorage::Base { offset, .. }) = self.symbol_storage_map.get(structure) {
|
||||
let mut data_offset = *offset;
|
||||
for i in 0..index {
|
||||
let field_size = field_layouts[i as usize].stack_size(PTR_SIZE);
|
||||
let field_size = field_layouts[i as usize].stack_size(TARGET_INFO);
|
||||
data_offset += field_size as i32;
|
||||
}
|
||||
self.symbol_storage_map.insert(
|
||||
*sym,
|
||||
SymbolStorage::Base {
|
||||
offset: data_offset,
|
||||
size: field_layouts[index as usize].stack_size(PTR_SIZE),
|
||||
size: field_layouts[index as usize].stack_size(TARGET_INFO),
|
||||
owned: false,
|
||||
},
|
||||
);
|
||||
|
@ -1569,10 +1570,10 @@ impl<
|
|||
{
|
||||
debug_assert_eq!(
|
||||
*size,
|
||||
layout.stack_size(PTR_SIZE),
|
||||
layout.stack_size(TARGET_INFO),
|
||||
"expected struct to have same size as data being stored in it"
|
||||
);
|
||||
for i in 0..layout.stack_size(PTR_SIZE) as i32 {
|
||||
for i in 0..layout.stack_size(TARGET_INFO) as i32 {
|
||||
ASM::mov_reg64_base32(&mut self.buf, tmp_reg, from_offset + i);
|
||||
ASM::mov_base32_reg64(&mut self.buf, to_offset + i, tmp_reg);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue