mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
Route IdentIds to refcount proc generator in dev backend
This commit is contained in:
parent
b193483756
commit
d0ef1e5b36
5 changed files with 77 additions and 28 deletions
|
@ -2,7 +2,8 @@ use crate::{Backend, Env, Relocation};
|
|||
use bumpalo::collections::Vec;
|
||||
use roc_builtins::bitcode::{FloatWidth, IntWidth};
|
||||
use roc_collections::all::{MutMap, MutSet};
|
||||
use roc_module::symbol::Symbol;
|
||||
use roc_module::symbol::{IdentIds, Symbol};
|
||||
use roc_mono::gen_refcount::RefcountProcGenerator;
|
||||
use roc_mono::ir::{BranchInfo, JoinPointId, Literal, Param, SelfRecursive, Stmt};
|
||||
use roc_mono::layout::{Builtin, Layout};
|
||||
use roc_reporting::internal_error;
|
||||
|
@ -226,6 +227,7 @@ pub struct Backend64Bit<
|
|||
phantom_asm: PhantomData<ASM>,
|
||||
phantom_cc: PhantomData<CC>,
|
||||
env: &'a Env<'a>,
|
||||
refcount_proc_gen: RefcountProcGenerator<'a>,
|
||||
buf: Vec<'a, u8>,
|
||||
relocs: Vec<'a, Relocation>,
|
||||
proc_name: Option<String>,
|
||||
|
@ -273,6 +275,7 @@ impl<
|
|||
phantom_asm: PhantomData,
|
||||
phantom_cc: PhantomData,
|
||||
env,
|
||||
refcount_proc_gen: RefcountProcGenerator::new(env.arena, IntWidth::I64, env.module_id),
|
||||
proc_name: None,
|
||||
is_self_recursive: None,
|
||||
buf: bumpalo::vec![in env.arena],
|
||||
|
@ -298,6 +301,9 @@ impl<
|
|||
fn env(&self) -> &'a Env<'a> {
|
||||
self.env
|
||||
}
|
||||
fn refcount_proc_gen_mut(&mut self) -> &mut RefcountProcGenerator<'a> {
|
||||
&mut self.refcount_proc_gen
|
||||
}
|
||||
|
||||
fn reset(&mut self, name: String, is_self_recursive: SelfRecursive) {
|
||||
self.proc_name = Some(name);
|
||||
|
@ -532,6 +538,7 @@ impl<
|
|||
|
||||
fn build_switch(
|
||||
&mut self,
|
||||
ident_ids: &mut IdentIds,
|
||||
cond_symbol: &Symbol,
|
||||
_cond_layout: &Layout<'a>, // cond_layout must be a integer due to potential jump table optimizations.
|
||||
branches: &'a [(u64, BranchInfo<'a>, Stmt<'a>)],
|
||||
|
@ -554,7 +561,7 @@ impl<
|
|||
let start_offset = ASM::jne_reg64_imm64_imm32(&mut self.buf, cond_reg, *val, 0);
|
||||
|
||||
// Build all statements in this branch.
|
||||
self.build_stmt(stmt, ret_layout);
|
||||
self.build_stmt(ident_ids, stmt, ret_layout);
|
||||
|
||||
// Build unconditional jump to the end of this switch.
|
||||
// Since we don't know the offset yet, set it to 0 and overwrite later.
|
||||
|
@ -578,7 +585,7 @@ impl<
|
|||
}
|
||||
let (branch_info, stmt) = default_branch;
|
||||
if let BranchInfo::None = branch_info {
|
||||
self.build_stmt(stmt, ret_layout);
|
||||
self.build_stmt(ident_ids, stmt, ret_layout);
|
||||
|
||||
// Update all return jumps to jump past the default case.
|
||||
let ret_offset = self.buf.len();
|
||||
|
@ -600,6 +607,7 @@ impl<
|
|||
|
||||
fn build_join(
|
||||
&mut self,
|
||||
ident_ids: &mut IdentIds,
|
||||
id: &JoinPointId,
|
||||
parameters: &'a [Param<'a>],
|
||||
body: &'a Stmt<'a>,
|
||||
|
@ -638,7 +646,7 @@ impl<
|
|||
sub_backend.load_args(args.into_bump_slice(), ret_layout);
|
||||
|
||||
// Build all statements in body.
|
||||
sub_backend.build_stmt(body, ret_layout);
|
||||
sub_backend.build_stmt(ident_ids, body, ret_layout);
|
||||
|
||||
// Merge the "sub function" into the main function.
|
||||
let sub_func_offset = self.buf.len() as u64;
|
||||
|
@ -682,7 +690,7 @@ impl<
|
|||
);
|
||||
|
||||
// Build remainder of function.
|
||||
self.build_stmt(remainder, ret_layout)
|
||||
self.build_stmt(ident_ids, remainder, ret_layout)
|
||||
}
|
||||
|
||||
fn build_jump(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue