From cdb13775e21cc67e20e291a51257428d18ceac7d Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 6 Oct 2013 10:25:41 -0700 Subject: [PATCH] Alignment option in xmm read/write. --- src/xenia/cpu/x64/x64_emitter.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/xenia/cpu/x64/x64_emitter.cc b/src/xenia/cpu/x64/x64_emitter.cc index b93e35acf..f172963f6 100644 --- a/src/xenia/cpu/x64/x64_emitter.cc +++ b/src/xenia/cpu/x64/x64_emitter.cc @@ -1877,8 +1877,10 @@ XmmVar X64Emitter::ReadMemoryXmm( // Align memory address. GpVar aligned_addr(c.newGpVar()); c.mov(aligned_addr, addr); + bool aligned = false; switch (alignment) { case 4: + aligned = true; c.and_(aligned_addr, imm(~0xF)); break; default: @@ -1890,7 +1892,11 @@ XmmVar X64Emitter::ReadMemoryXmm( GpVar real_address = TouchMemoryAddress(cia, aligned_addr); XmmVar value(c.newXmmVar()); - c.movaps(value, xmmword_ptr(real_address)); + if (aligned) { + c.movaps(value, xmmword_ptr(real_address)); + } else { + c.movups(value, xmmword_ptr(real_address)); + } // Byte swap. GpVar byte_swap_addr(c.newGpVar()); @@ -1952,9 +1958,11 @@ void X64Emitter::WriteMemoryXmm( // Align memory address. GpVar aligned_addr(c.newGpVar()); c.mov(aligned_addr, addr); + bool aligned = false; switch (alignment) { case 4: c.and_(aligned_addr, imm(~0xF)); + aligned = true; break; default: XEASSERTALWAYS(); @@ -1970,7 +1978,11 @@ void X64Emitter::WriteMemoryXmm( c.mov(byte_swap_addr, imm((sysint_t)&__xmm_byte_swap)); c.pshufb(value, xmmword_ptr(byte_swap_addr)); - c.movaps(xmmword_ptr(real_address), value); + if (aligned) { + c.movaps(xmmword_ptr(real_address), value); + } else { + c.movups(xmmword_ptr(real_address), value); + } } GpVar X64Emitter::get_uint64(uint64_t value) {