Skip to content

Commit

Permalink
improv(compiler) Added emit_relaxed_ldr64 utility (65 tests passes now)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed Jan 14, 2022
1 parent ae1925e commit 67e5f9c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
13 changes: 13 additions & 0 deletions lib/compiler-singlepass/src/emitter_arm64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,19 @@ impl EmitterARM64 for Assembler {
let disp = disp as u32;
dynasm!(self ; ldrb W(reg), [X(addr), disp]);
}
(Size::S64, Location::GPR(reg), Location::Memory2(addr, r2, mult, offs)) => {
let reg = reg.into_index() as u32;
let addr = addr.into_index() as u32;
let r2 = r2.into_index() as u32;
if offs != 0 {
unreachable!();
}
let mult = mult as u32;
if mult == 0 {
unreachable!();
}
dynasm!(self ; ldr X(reg), [X(addr), X(r2), LSL mult]);
}
(Size::S64, Location::SIMD(reg), Location::Memory(addr, disp)) => {
let reg = reg.into_index() as u32;
let addr = addr.into_index() as u32;
Expand Down
28 changes: 24 additions & 4 deletions lib/compiler-singlepass/src/machine_arm64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,28 @@ impl MachineARM64 {
self.release_gpr(r);
}
}
fn emit_relaxed_ldr64(&mut self, dst: Location, src: Location) {
match src {
Location::Memory(addr, offset) => {
if offset & 0x7 == 0 {
self.assembler.emit_ldr(Size::S64, dst, src);
} else if offset > -256 && offset < 256 {
self.assembler.emit_ldur(Size::S64, dst, addr, offset);
} else {
let tmp = self.acquire_temp_gpr().unwrap();
self.assembler
.emit_mov_imm(Location::GPR(tmp), offset as u64);
self.assembler.emit_ldr(
Size::S64,
Location::GPR(tmp),
Location::Memory2(addr, tmp, Multiplier::One, 0),
);
self.release_gpr(tmp);
}
}
_ => unreachable!(),
}
}
/// I32 binary operation with both operands popped from the virtual stack.
/*fn emit_binop_i32(
&mut self,
Expand Down Expand Up @@ -245,13 +267,11 @@ impl MachineARM64 {
let tmp_bound = self.acquire_temp_gpr().unwrap();

// Load base into temporary register.
self.assembler
.emit_ldr(Size::S64, Location::GPR(tmp_base), base_loc);
self.emit_relaxed_ldr64(Location::GPR(tmp_base), base_loc);

// Load bound into temporary register, if needed.
if need_check {
self.assembler
.emit_ldr(Size::S64, Location::GPR(tmp_bound), bound_loc);
self.emit_relaxed_ldr64(Location::GPR(tmp_bound), bound_loc);

// Wasm -> Effective.
// Assuming we never underflow - should always be true on Linux/macOS and Windows >=8,
Expand Down

0 comments on commit 67e5f9c

Please sign in to comment.