working happy path

This commit is contained in:
Folkert 2023-07-26 17:37:06 +02:00
parent d3ac7d616d
commit 644def72f1
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
7 changed files with 103 additions and 59 deletions

View file

@ -463,6 +463,10 @@ impl CallConv<AArch64GeneralReg, AArch64FloatReg, AArch64Assembler> for AArch64C
fn longjmp(buf: &mut Vec<'_, u8>, relocs: &mut Vec<'_, Relocation>) {
todo!()
}
fn roc_panic(buf: &mut Vec<'_, u8>, relocs: &mut Vec<'_, Relocation>) {
todo!()
}
}
impl Assembler<AArch64GeneralReg, AArch64FloatReg> for AArch64Assembler {

View file

@ -137,6 +137,7 @@ pub trait CallConv<GeneralReg: RegTrait, FloatReg: RegTrait, ASM: Assembler<Gene
fn setjmp(buf: &mut Vec<'_, u8>, relocs: &mut Vec<'_, Relocation>);
fn longjmp(buf: &mut Vec<'_, u8>, relocs: &mut Vec<'_, Relocation>);
fn roc_panic(buf: &mut Vec<'_, u8>, relocs: &mut Vec<'_, Relocation>);
}
pub enum CompareOperation {
@ -913,6 +914,16 @@ impl<
out.into_bump_slice()
}
fn build_roc_panic(&mut self) -> &'a [u8] {
let mut out = bumpalo::vec![in self.env.arena];
CC::roc_panic(&mut out, &mut self.relocs);
dbg!(&self.relocs);
out.into_bump_slice()
}
fn build_fn_pointer(&mut self, dst: &Symbol, fn_name: String) {
let reg = self.storage_manager.claim_general_reg(&mut self.buf, dst);
@ -922,7 +933,11 @@ impl<
fn build_data_pointer(&mut self, dst: &Symbol, data_name: String) {
let reg = self.storage_manager.claim_general_reg(&mut self.buf, dst);
ASM::data_pointer(&mut self.buf, &mut self.relocs, data_name, reg)
// now, this gives a pointer to the value
ASM::data_pointer(&mut self.buf, &mut self.relocs, data_name, reg);
// dereference
ASM::mov_reg64_mem64_offset32(&mut self.buf, reg, reg, 0);
}
fn build_fn_call(

View file

@ -266,7 +266,6 @@ impl CallConv<X86_64GeneralReg, X86_64FloatReg, X86_64Assembler> for X86_64Syste
args: &'a [(InLayout<'a>, Symbol)],
ret_layout: &InLayout<'a>,
) {
dbg!(layout_interner.dbg(*ret_layout));
let returns_via_pointer =
X86_64SystemV::returns_via_arg_pointer(layout_interner, ret_layout);
@ -277,7 +276,7 @@ impl CallConv<X86_64GeneralReg, X86_64FloatReg, X86_64Assembler> for X86_64Syste
argument_offset: X86_64SystemV::SHADOW_SPACE_SIZE as i32 + 16,
};
if dbg!(returns_via_pointer) {
if returns_via_pointer {
storage_manager.ret_pointer_arg(X86_64SystemV::GENERAL_PARAM_REGS[0]);
}
@ -380,7 +379,6 @@ impl CallConv<X86_64GeneralReg, X86_64FloatReg, X86_64Assembler> for X86_64Syste
}
_ => {
// This is a large type returned via the arg pointer.
dbg!(sym);
storage_manager.copy_symbol_to_arg_pointer(buf, sym, layout);
// Also set the return reg to the arg pointer.
storage_manager.load_to_specified_general_reg(
@ -522,6 +520,17 @@ impl CallConv<X86_64GeneralReg, X86_64FloatReg, X86_64Assembler> for X86_64Syste
jmp_reg64_offset8(buf, RDI, offset as i8)
}
fn roc_panic(buf: &mut Vec<'_, u8>, relocs: &mut Vec<'_, Relocation>) {
use X86_64GeneralReg::*;
type ASM = X86_64Assembler;
ASM::data_pointer(buf, relocs, String::from("setlongjmp_buffer"), RDI);
ASM::mov_reg64_imm64(buf, RSI, 42);
// Call function and generate reloc.
ASM::call(buf, relocs, String::from("roc_longjmp"));
}
}
struct X64_64SystemVStoreArgs {
@ -1117,6 +1126,10 @@ impl CallConv<X86_64GeneralReg, X86_64FloatReg, X86_64Assembler> for X86_64Windo
fn longjmp(buf: &mut Vec<'_, u8>, relocs: &mut Vec<'_, Relocation>) {
todo!()
}
fn roc_panic(buf: &mut Vec<'_, u8>, relocs: &mut Vec<'_, Relocation>) {
todo!()
}
}
impl X86_64WindowsFastcall {