Skip to content

Commit

Permalink
Add input register shuffling to test calling convention
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter committed May 19, 2024
1 parent 3deb8d1 commit f96e9c2
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fidget/src/jit/aarch64/float_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ impl Assembler for FloatSliceAssembler {
fn init(mmap: Mmap, slot_count: usize) -> Self {
let mut out = AssemblerData::new(mmap);
out.prepare_stack(slot_count, STACK_SIZE as usize);

#[cfg(test)]
out.input_register_shenanigans();

dynasm!(out.ops
// Preserve frame and link register, and set up the frame pointer
; stp x29, x30, [sp, 0x0]
Expand Down
4 changes: 4 additions & 0 deletions fidget/src/jit/aarch64/grad_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ impl Assembler for GradSliceAssembler {
fn init(mmap: Mmap, slot_count: usize) -> Self {
let mut out = AssemblerData::new(mmap);
out.prepare_stack(slot_count, STACK_SIZE as usize);

#[cfg(test)]
out.input_register_shenanigans();

dynasm!(out.ops
// Preserve frame and link register, and set up the frame pointer
; stp x29, x30, [sp, 0x0]
Expand Down
4 changes: 4 additions & 0 deletions fidget/src/jit/aarch64/interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ impl Assembler for IntervalAssembler {
fn init(mmap: Mmap, slot_count: usize) -> Self {
let mut out = AssemblerData::new(mmap);
out.prepare_stack(slot_count, STACK_SIZE as usize);

#[cfg(test)]
out.input_register_shenanigans();

dynasm!(out.ops
// Preserve frame and link register, and set up the frame pointer
; stp x29, x30, [sp, 0x0]
Expand Down
4 changes: 4 additions & 0 deletions fidget/src/jit/aarch64/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ impl Assembler for PointAssembler {
fn init(mmap: Mmap, slot_count: usize) -> Self {
let mut out = AssemblerData::new(mmap);
out.prepare_stack(slot_count, STACK_SIZE as usize);

#[cfg(test)]
out.input_register_shenanigans();

dynasm!(out.ops
// Preserve frame and link register, and set up the frame pointer
; stp x29, x30, [sp, 0x0]
Expand Down
21 changes: 21 additions & 0 deletions fidget/src/jit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,27 @@ impl<T> AssemblerData<T> {
self.push_stack();
}

#[cfg(all(target_arch = "aarch64", test))]
fn input_register_shenanigans(&mut self) {
dynasm!(self.ops
; mov x3, 0xABCD
; lsl x4, x3, 16
; orr x3, x3, x4
);
}

#[cfg(all(target_arch = "x86_64", test))]
fn input_register_shenanigans(&mut self) {
dynasm!(self.ops
; mov rcx, 0xABCDABCDu32 as i32
; mov r8, 0xABCDABCDu32 as i32
; mov r9, 0xABCDABCDu32 as i32
);
for i in 4..=7 {
dynasm!(self.ops ; mov X(i), x3);
}
}

#[cfg(target_arch = "aarch64")]
fn push_stack(&mut self) {
assert!(self.mem_offset < 4096);
Expand Down
4 changes: 4 additions & 0 deletions fidget/src/jit/x86_64/float_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ impl Assembler for FloatSliceAssembler {
; mov rbp, rsp
);
out.prepare_stack(slot_count, STACK_SIZE_UPPER + STACK_SIZE_LOWER);

#[cfg(test)]
out.input_register_shenanigans();

dynasm!(out.ops
// TODO should there be a `vzeroupper` in here?

Expand Down
4 changes: 4 additions & 0 deletions fidget/src/jit/x86_64/grad_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ impl Assembler for GradSliceAssembler {
; mov rbp, rsp
);
out.prepare_stack(slot_count, STACK_SIZE_UPPER + STACK_SIZE_LOWER);

#[cfg(test)]
out.input_register_shenanigans();

dynasm!(out.ops
; xor rcx, rcx // set the array offset (rcx) to 0

Expand Down
4 changes: 4 additions & 0 deletions fidget/src/jit/x86_64/interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ impl Assembler for IntervalAssembler {
; mov rbp, rsp
);
out.prepare_stack(slot_count, STACK_SIZE_UPPER + STACK_SIZE_LOWER);

#[cfg(test)]
out.input_register_shenanigans();

dynasm!(out.ops
; vzeroupper
);
Expand Down
4 changes: 4 additions & 0 deletions fidget/src/jit/x86_64/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ impl Assembler for PointAssembler {
; mov rbp, rsp
);
out.prepare_stack(slot_count, STACK_SIZE_UPPER + STACK_SIZE_LOWER);

#[cfg(test)]
out.input_register_shenanigans();

dynasm!(out.ops
; vzeroupper
);
Expand Down

0 comments on commit f96e9c2

Please sign in to comment.