Fix LEA simulation on aarch64.

This commit is contained in:
losfair 2019-10-17 23:00:50 +08:00
parent d325635629
commit 00242cdd7f

View File

@ -566,16 +566,16 @@ impl Emitter for Assembler {
match (sz, src, dst) { match (sz, src, dst) {
(Size::S32, Location::Memory(src, disp), Location::GPR(dst)) => { (Size::S32, Location::Memory(src, disp), Location::GPR(dst)) => {
if disp >= 0 { if disp >= 0 {
dynasm!(self ; add W(map_gpr(dst).x()), W(map_gpr(src).x()), disp as u32); dynasm!(self ; b >after ; disp: ; .dword disp ; after: ; ldr w_tmp3, <disp ; add W(map_gpr(dst).x()), W(map_gpr(src).x()), w_tmp3);
} else { } else {
dynasm!(self ; sub W(map_gpr(dst).x()), W(map_gpr(src).x()), (-disp) as u32); dynasm!(self ; b >after ; disp: ; .dword -disp ; after: ; ldr w_tmp3, <disp ; sub W(map_gpr(dst).x()), W(map_gpr(src).x()), w_tmp3);
} }
} }
(Size::S64, Location::Memory(src, disp), Location::GPR(dst)) => { (Size::S64, Location::Memory(src, disp), Location::GPR(dst)) => {
if disp >= 0 { if disp >= 0 {
dynasm!(self ; add X(map_gpr(dst).x()), X(map_gpr(src).x()), disp as u32); dynasm!(self ; b >after ; disp: ; .dword disp ; after: ; ldr w_tmp3, <disp ; add X(map_gpr(dst).x()), X(map_gpr(src).x()), x_tmp3);
} else { } else {
dynasm!(self ; sub X(map_gpr(dst).x()), X(map_gpr(src).x()), (-disp) as u32); dynasm!(self ; b >after ; disp: ; .dword -disp ; after: ; ldr w_tmp3, <disp ; sub X(map_gpr(dst).x()), X(map_gpr(src).x()), x_tmp3);
} }
} }
_ => unreachable!(), _ => unreachable!(),