mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 16:44:33 +00:00
Add AArch64 to dev backend object generation
This commit is contained in:
parent
e2b0692a36
commit
dbf335a79d
2 changed files with 34 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
||||||
use crate::generic64::{x86_64, Backend64Bit};
|
use crate::generic64::{aarch64, x86_64, Backend64Bit};
|
||||||
use crate::{Backend, Env, Relocation, INLINED_SYMBOLS};
|
use crate::{Backend, Env, Relocation, INLINED_SYMBOLS};
|
||||||
use bumpalo::collections::Vec;
|
use bumpalo::collections::Vec;
|
||||||
use object::write;
|
use object::write;
|
||||||
|
@ -22,7 +22,7 @@ pub fn build_module<'a>(
|
||||||
target: &Triple,
|
target: &Triple,
|
||||||
procedures: MutMap<(symbol::Symbol, Layout<'a>), Proc<'a>>,
|
procedures: MutMap<(symbol::Symbol, Layout<'a>), Proc<'a>>,
|
||||||
) -> Result<Object, String> {
|
) -> Result<Object, String> {
|
||||||
let (mut output, mut backend) = match target {
|
match target {
|
||||||
Triple {
|
Triple {
|
||||||
architecture: TargetArch::X86_64,
|
architecture: TargetArch::X86_64,
|
||||||
binary_format: TargetBF::Elf,
|
binary_format: TargetBF::Elf,
|
||||||
|
@ -33,15 +33,42 @@ pub fn build_module<'a>(
|
||||||
x86_64::X86_64Assembler,
|
x86_64::X86_64Assembler,
|
||||||
x86_64::X86_64SystemV,
|
x86_64::X86_64SystemV,
|
||||||
> = Backend::new(env, target)?;
|
> = Backend::new(env, target)?;
|
||||||
Ok((
|
build_object(
|
||||||
Object::new(BinaryFormat::Elf, Architecture::X86_64, Endianness::Little),
|
env,
|
||||||
|
procedures,
|
||||||
backend,
|
backend,
|
||||||
))
|
Object::new(BinaryFormat::Elf, Architecture::X86_64, Endianness::Little),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Triple {
|
||||||
|
architecture: TargetArch::Aarch64(_),
|
||||||
|
binary_format: TargetBF::Elf,
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
let backend: Backend64Bit<
|
||||||
|
aarch64::AArch64GPReg,
|
||||||
|
aarch64::AArch64Assembler,
|
||||||
|
aarch64::AArch64Call,
|
||||||
|
> = Backend::new(env, target)?;
|
||||||
|
build_object(
|
||||||
|
env,
|
||||||
|
procedures,
|
||||||
|
backend,
|
||||||
|
Object::new(BinaryFormat::Elf, Architecture::Aarch64, Endianness::Little),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
x => Err(format! {
|
x => Err(format! {
|
||||||
"the target, {:?}, is not yet implemented",
|
"the target, {:?}, is not yet implemented",
|
||||||
x}),
|
x}),
|
||||||
}?;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_object<'a, B: Backend<'a>>(
|
||||||
|
env: &'a Env,
|
||||||
|
procedures: MutMap<(symbol::Symbol, Layout<'a>), Proc<'a>>,
|
||||||
|
mut backend: B,
|
||||||
|
mut output: Object,
|
||||||
|
) -> Result<Object, String> {
|
||||||
let text = output.section_id(StandardSection::Text);
|
let text = output.section_id(StandardSection::Text);
|
||||||
let data_section = output.section_id(StandardSection::Data);
|
let data_section = output.section_id(StandardSection::Data);
|
||||||
let comment = output.add_section(vec![], b"comment".to_vec(), SectionKind::OtherString);
|
let comment = output.add_section(vec![], b"comment".to_vec(), SectionKind::OtherString);
|
||||||
|
|
|
@ -9,7 +9,7 @@ extern crate libc;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod helpers;
|
mod helpers;
|
||||||
|
|
||||||
#[cfg(all(test, target_os = "linux", target_arch = "x86_64"))]
|
#[cfg(all(test, target_os = "linux", any(target_arch = "x86_64", target_arch = "aarch64")))]
|
||||||
mod gen_num {
|
mod gen_num {
|
||||||
//use roc_std::RocOrder;
|
//use roc_std::RocOrder;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue