Route IdentIds to refcount proc generator in dev backend

This commit is contained in:
Brian Carroll 2021-12-02 09:58:34 +00:00
parent b193483756
commit d0ef1e5b36
5 changed files with 77 additions and 28 deletions

View file

@ -8,7 +8,7 @@ use object::{
SymbolFlags, SymbolKind, SymbolScope,
};
use roc_collections::all::MutMap;
use roc_module::symbol;
use roc_module::symbol::{self, IdentIds};
use roc_mono::ir::{Proc, ProcLayout};
use roc_mono::layout::LayoutIds;
use roc_reporting::internal_error;
@ -22,6 +22,7 @@ use target_lexicon::{Architecture as TargetArch, BinaryFormat as TargetBF, Tripl
/// It takes the request to build a module and output the object file for the module.
pub fn build_module<'a>(
env: &'a Env,
ident_ids: &'a mut IdentIds,
target: &Triple,
procedures: MutMap<(symbol::Symbol, ProcLayout<'a>), Proc<'a>>,
) -> Object {
@ -39,6 +40,7 @@ pub fn build_module<'a>(
> = Backend::new(env);
build_object(
env,
ident_ids,
procedures,
backend,
Object::new(BinaryFormat::Elf, Architecture::X86_64, Endianness::Little),
@ -57,6 +59,7 @@ pub fn build_module<'a>(
> = Backend::new(env);
build_object(
env,
ident_ids,
procedures,
backend,
Object::new(
@ -79,6 +82,7 @@ pub fn build_module<'a>(
> = Backend::new(env);
build_object(
env,
ident_ids,
procedures,
backend,
Object::new(BinaryFormat::Elf, Architecture::Aarch64, Endianness::Little),
@ -97,6 +101,7 @@ pub fn build_module<'a>(
> = Backend::new(env);
build_object(
env,
ident_ids,
procedures,
backend,
Object::new(
@ -165,6 +170,7 @@ fn generate_wrapper<'a, B: Backend<'a>>(
fn build_object<'a, B: Backend<'a>>(
env: &'a Env,
ident_ids: &'a mut IdentIds,
procedures: MutMap<(symbol::Symbol, ProcLayout<'a>), Proc<'a>>,
mut backend: B,
mut output: Object,
@ -231,6 +237,7 @@ fn build_object<'a, B: Backend<'a>>(
&mut output,
&mut backend,
&mut relocations,
ident_ids,
data_section,
fn_name,
section_id,
@ -296,6 +303,7 @@ fn build_proc<'a, B: Backend<'a>>(
output: &mut Object,
backend: &mut B,
relocations: &mut Vec<'a, (SectionId, object::write::Relocation)>,
ident_ids: &mut IdentIds,
data_section: SectionId,
fn_name: String,
section_id: SectionId,
@ -303,7 +311,7 @@ fn build_proc<'a, B: Backend<'a>>(
proc: Proc<'a>,
) {
let mut local_data_index = 0;
let (proc_data, relocs) = backend.build_proc(proc);
let (proc_data, relocs) = backend.build_proc(ident_ids, proc);
let proc_offset = output.add_symbol_data(proc_id, section_id, proc_data, 16);
for reloc in relocs {
let elfreloc = match reloc {