[x64] Change the parameters to host_to_guest_thunk
Shuffle some code around in x64_backend.cc Add GetNativeParam to avoid hardcoding parameters
This commit is contained in:
@@ -285,8 +285,8 @@ struct LOAD_CONTEXT_I8
|
||||
auto addr = ComputeContextAddress(e, i.src1);
|
||||
e.mov(i.dest, e.byte[addr]);
|
||||
if (IsTracingData()) {
|
||||
e.mov(e.r8, e.byte[addr]);
|
||||
e.mov(e.rdx, i.src1.value);
|
||||
e.mov(e.GetNativeParam(0), i.src1.value);
|
||||
e.mov(e.GetNativeParam(1), e.byte[addr]);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceContextLoadI8));
|
||||
}
|
||||
}
|
||||
@@ -297,8 +297,8 @@ struct LOAD_CONTEXT_I16
|
||||
auto addr = ComputeContextAddress(e, i.src1);
|
||||
e.mov(i.dest, e.word[addr]);
|
||||
if (IsTracingData()) {
|
||||
e.mov(e.r8, e.word[addr]);
|
||||
e.mov(e.rdx, i.src1.value);
|
||||
e.mov(e.GetNativeParam(1), e.word[addr]);
|
||||
e.mov(e.GetNativeParam(0), i.src1.value);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceContextLoadI16));
|
||||
}
|
||||
}
|
||||
@@ -309,8 +309,8 @@ struct LOAD_CONTEXT_I32
|
||||
auto addr = ComputeContextAddress(e, i.src1);
|
||||
e.mov(i.dest, e.dword[addr]);
|
||||
if (IsTracingData()) {
|
||||
e.mov(e.r8, e.dword[addr]);
|
||||
e.mov(e.rdx, i.src1.value);
|
||||
e.mov(e.GetNativeParam(1), e.dword[addr]);
|
||||
e.mov(e.GetNativeParam(0), i.src1.value);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceContextLoadI32));
|
||||
}
|
||||
}
|
||||
@@ -321,8 +321,8 @@ struct LOAD_CONTEXT_I64
|
||||
auto addr = ComputeContextAddress(e, i.src1);
|
||||
e.mov(i.dest, e.qword[addr]);
|
||||
if (IsTracingData()) {
|
||||
e.mov(e.r8, e.qword[addr]);
|
||||
e.mov(e.rdx, i.src1.value);
|
||||
e.mov(e.GetNativeParam(1), e.qword[addr]);
|
||||
e.mov(e.GetNativeParam(0), i.src1.value);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceContextLoadI64));
|
||||
}
|
||||
}
|
||||
@@ -333,8 +333,8 @@ struct LOAD_CONTEXT_F32
|
||||
auto addr = ComputeContextAddress(e, i.src1);
|
||||
e.vmovss(i.dest, e.dword[addr]);
|
||||
if (IsTracingData()) {
|
||||
e.lea(e.r8, e.dword[addr]);
|
||||
e.mov(e.rdx, i.src1.value);
|
||||
e.lea(e.GetNativeParam(1), e.dword[addr]);
|
||||
e.mov(e.GetNativeParam(0), i.src1.value);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceContextLoadF32));
|
||||
}
|
||||
}
|
||||
@@ -345,8 +345,8 @@ struct LOAD_CONTEXT_F64
|
||||
auto addr = ComputeContextAddress(e, i.src1);
|
||||
e.vmovsd(i.dest, e.qword[addr]);
|
||||
if (IsTracingData()) {
|
||||
e.lea(e.r8, e.qword[addr]);
|
||||
e.mov(e.rdx, i.src1.value);
|
||||
e.lea(e.GetNativeParam(1), e.qword[addr]);
|
||||
e.mov(e.GetNativeParam(0), i.src1.value);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceContextLoadF64));
|
||||
}
|
||||
}
|
||||
@@ -357,8 +357,8 @@ struct LOAD_CONTEXT_V128
|
||||
auto addr = ComputeContextAddress(e, i.src1);
|
||||
e.vmovaps(i.dest, e.ptr[addr]);
|
||||
if (IsTracingData()) {
|
||||
e.lea(e.r8, e.ptr[addr]);
|
||||
e.mov(e.rdx, i.src1.value);
|
||||
e.lea(e.GetNativeParam(1), e.ptr[addr]);
|
||||
e.mov(e.GetNativeParam(0), i.src1.value);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceContextLoadV128));
|
||||
}
|
||||
}
|
||||
@@ -382,8 +382,8 @@ struct STORE_CONTEXT_I8
|
||||
e.mov(e.byte[addr], i.src2);
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
e.mov(e.r8, e.byte[addr]);
|
||||
e.mov(e.rdx, i.src1.value);
|
||||
e.mov(e.GetNativeParam(1), e.byte[addr]);
|
||||
e.mov(e.GetNativeParam(0), i.src1.value);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceContextStoreI8));
|
||||
}
|
||||
}
|
||||
@@ -399,8 +399,8 @@ struct STORE_CONTEXT_I16
|
||||
e.mov(e.word[addr], i.src2);
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
e.mov(e.r8, e.word[addr]);
|
||||
e.mov(e.rdx, i.src1.value);
|
||||
e.mov(e.GetNativeParam(1), e.word[addr]);
|
||||
e.mov(e.GetNativeParam(0), i.src1.value);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceContextStoreI16));
|
||||
}
|
||||
}
|
||||
@@ -416,8 +416,8 @@ struct STORE_CONTEXT_I32
|
||||
e.mov(e.dword[addr], i.src2);
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
e.mov(e.r8, e.dword[addr]);
|
||||
e.mov(e.rdx, i.src1.value);
|
||||
e.mov(e.GetNativeParam(1), e.dword[addr]);
|
||||
e.mov(e.GetNativeParam(0), i.src1.value);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceContextStoreI32));
|
||||
}
|
||||
}
|
||||
@@ -433,8 +433,8 @@ struct STORE_CONTEXT_I64
|
||||
e.mov(e.qword[addr], i.src2);
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
e.mov(e.r8, e.qword[addr]);
|
||||
e.mov(e.rdx, i.src1.value);
|
||||
e.mov(e.GetNativeParam(1), e.qword[addr]);
|
||||
e.mov(e.GetNativeParam(0), i.src1.value);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceContextStoreI64));
|
||||
}
|
||||
}
|
||||
@@ -450,8 +450,8 @@ struct STORE_CONTEXT_F32
|
||||
e.vmovss(e.dword[addr], i.src2);
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
e.lea(e.r8, e.dword[addr]);
|
||||
e.mov(e.rdx, i.src1.value);
|
||||
e.lea(e.GetNativeParam(1), e.dword[addr]);
|
||||
e.mov(e.GetNativeParam(0), i.src1.value);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceContextStoreF32));
|
||||
}
|
||||
}
|
||||
@@ -467,8 +467,8 @@ struct STORE_CONTEXT_F64
|
||||
e.vmovsd(e.qword[addr], i.src2);
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
e.lea(e.r8, e.qword[addr]);
|
||||
e.mov(e.rdx, i.src1.value);
|
||||
e.lea(e.GetNativeParam(1), e.qword[addr]);
|
||||
e.mov(e.GetNativeParam(0), i.src1.value);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceContextStoreF64));
|
||||
}
|
||||
}
|
||||
@@ -485,8 +485,8 @@ struct STORE_CONTEXT_V128
|
||||
e.vmovaps(e.ptr[addr], i.src2);
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
e.lea(e.r8, e.ptr[addr]);
|
||||
e.mov(e.rdx, i.src1.value);
|
||||
e.lea(e.GetNativeParam(1), e.ptr[addr]);
|
||||
e.mov(e.GetNativeParam(0), i.src1.value);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceContextStoreV128));
|
||||
}
|
||||
}
|
||||
@@ -505,13 +505,13 @@ struct LOAD_MMIO_I32
|
||||
// uint64_t (context, addr)
|
||||
auto mmio_range = reinterpret_cast<MMIORange*>(i.src1.value);
|
||||
auto read_address = uint32_t(i.src2.value);
|
||||
e.mov(e.r8, uint64_t(mmio_range->callback_context));
|
||||
e.mov(e.r9d, read_address);
|
||||
e.mov(e.GetNativeParam(0), uint64_t(mmio_range->callback_context));
|
||||
e.mov(e.GetNativeParam(1).cvt32(), read_address);
|
||||
e.CallNativeSafe(reinterpret_cast<void*>(mmio_range->read));
|
||||
e.bswap(e.eax);
|
||||
e.mov(i.dest, e.eax);
|
||||
if (IsTracingData()) {
|
||||
e.mov(e.r8, i.dest);
|
||||
e.mov(e.GetNativeParam(0), i.dest);
|
||||
e.mov(e.edx, read_address);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceContextLoadI32));
|
||||
}
|
||||
@@ -530,20 +530,20 @@ struct STORE_MMIO_I32
|
||||
// void (context, addr, value)
|
||||
auto mmio_range = reinterpret_cast<MMIORange*>(i.src1.value);
|
||||
auto write_address = uint32_t(i.src2.value);
|
||||
e.mov(e.r8, uint64_t(mmio_range->callback_context));
|
||||
e.mov(e.r9d, write_address);
|
||||
e.mov(e.GetNativeParam(0), uint64_t(mmio_range->callback_context));
|
||||
e.mov(e.GetNativeParam(1).cvt32(), write_address);
|
||||
if (i.src3.is_constant) {
|
||||
e.mov(e.r10d, xe::byte_swap(i.src3.constant()));
|
||||
e.mov(e.GetNativeParam(2).cvt32(), xe::byte_swap(i.src3.constant()));
|
||||
} else {
|
||||
e.mov(e.r10d, i.src3);
|
||||
e.bswap(e.r10d);
|
||||
e.mov(e.GetNativeParam(2).cvt32(), i.src3);
|
||||
e.bswap(e.GetNativeParam(2).cvt32());
|
||||
}
|
||||
e.CallNativeSafe(reinterpret_cast<void*>(mmio_range->write));
|
||||
if (IsTracingData()) {
|
||||
if (i.src3.is_constant) {
|
||||
e.mov(e.r8d, i.src3.constant());
|
||||
e.mov(e.GetNativeParam(0).cvt32(), i.src3.constant());
|
||||
} else {
|
||||
e.mov(e.r8d, i.src3);
|
||||
e.mov(e.GetNativeParam(0).cvt32(), i.src3);
|
||||
}
|
||||
e.mov(e.edx, write_address);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceContextStoreI32));
|
||||
@@ -708,8 +708,8 @@ struct LOAD_I8 : Sequence<LOAD_I8, I<OPCODE_LOAD, I8Op, I64Op>> {
|
||||
auto addr = ComputeMemoryAddress(e, i.src1);
|
||||
e.mov(i.dest, e.byte[addr]);
|
||||
if (IsTracingData()) {
|
||||
e.mov(e.r8b, i.dest);
|
||||
e.lea(e.rdx, e.ptr[addr]);
|
||||
e.mov(e.GetNativeParam(1).cvt8(), i.dest);
|
||||
e.lea(e.GetNativeParam(0), e.ptr[addr]);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceMemoryLoadI8));
|
||||
}
|
||||
}
|
||||
@@ -728,8 +728,8 @@ struct LOAD_I16 : Sequence<LOAD_I16, I<OPCODE_LOAD, I16Op, I64Op>> {
|
||||
e.mov(i.dest, e.word[addr]);
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
e.mov(e.r8w, i.dest);
|
||||
e.lea(e.rdx, e.ptr[addr]);
|
||||
e.mov(e.GetNativeParam(1).cvt16(), i.dest);
|
||||
e.lea(e.GetNativeParam(0), e.ptr[addr]);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceMemoryLoadI16));
|
||||
}
|
||||
}
|
||||
@@ -748,8 +748,8 @@ struct LOAD_I32 : Sequence<LOAD_I32, I<OPCODE_LOAD, I32Op, I64Op>> {
|
||||
e.mov(i.dest, e.dword[addr]);
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
e.mov(e.r8d, i.dest);
|
||||
e.lea(e.rdx, e.ptr[addr]);
|
||||
e.mov(e.GetNativeParam(1).cvt32(), i.dest);
|
||||
e.lea(e.GetNativeParam(0), e.ptr[addr]);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceMemoryLoadI32));
|
||||
}
|
||||
}
|
||||
@@ -768,8 +768,8 @@ struct LOAD_I64 : Sequence<LOAD_I64, I<OPCODE_LOAD, I64Op, I64Op>> {
|
||||
e.mov(i.dest, e.qword[addr]);
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
e.mov(e.r8, i.dest);
|
||||
e.lea(e.rdx, e.ptr[addr]);
|
||||
e.mov(e.GetNativeParam(1), i.dest);
|
||||
e.lea(e.GetNativeParam(0), e.ptr[addr]);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceMemoryLoadI64));
|
||||
}
|
||||
}
|
||||
@@ -782,8 +782,8 @@ struct LOAD_F32 : Sequence<LOAD_F32, I<OPCODE_LOAD, F32Op, I64Op>> {
|
||||
assert_always("not implemented yet");
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
e.lea(e.r8, e.dword[addr]);
|
||||
e.lea(e.rdx, e.ptr[addr]);
|
||||
e.lea(e.GetNativeParam(1), e.dword[addr]);
|
||||
e.lea(e.GetNativeParam(0), e.ptr[addr]);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceMemoryLoadF32));
|
||||
}
|
||||
}
|
||||
@@ -796,8 +796,8 @@ struct LOAD_F64 : Sequence<LOAD_F64, I<OPCODE_LOAD, F64Op, I64Op>> {
|
||||
assert_always("not implemented yet");
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
e.lea(e.r8, e.qword[addr]);
|
||||
e.lea(e.rdx, e.ptr[addr]);
|
||||
e.lea(e.GetNativeParam(1), e.qword[addr]);
|
||||
e.lea(e.GetNativeParam(0), e.ptr[addr]);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceMemoryLoadF64));
|
||||
}
|
||||
}
|
||||
@@ -812,8 +812,8 @@ struct LOAD_V128 : Sequence<LOAD_V128, I<OPCODE_LOAD, V128Op, I64Op>> {
|
||||
e.vpshufb(i.dest, i.dest, e.GetXmmConstPtr(XMMByteSwapMask));
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
e.lea(e.r8, e.ptr[addr]);
|
||||
e.lea(e.rdx, e.ptr[addr]);
|
||||
e.lea(e.GetNativeParam(1), e.ptr[addr]);
|
||||
e.lea(e.GetNativeParam(0), e.ptr[addr]);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceMemoryLoadV128));
|
||||
}
|
||||
}
|
||||
@@ -835,8 +835,8 @@ struct STORE_I8 : Sequence<STORE_I8, I<OPCODE_STORE, VoidOp, I64Op, I8Op>> {
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
addr = ComputeMemoryAddress(e, i.src1);
|
||||
e.mov(e.r8b, e.byte[addr]);
|
||||
e.lea(e.rdx, e.ptr[addr]);
|
||||
e.mov(e.GetNativeParam(1).cvt8(), e.byte[addr]);
|
||||
e.lea(e.GetNativeParam(0), e.ptr[addr]);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreI8));
|
||||
}
|
||||
}
|
||||
@@ -860,8 +860,8 @@ struct STORE_I16 : Sequence<STORE_I16, I<OPCODE_STORE, VoidOp, I64Op, I16Op>> {
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
addr = ComputeMemoryAddress(e, i.src1);
|
||||
e.mov(e.r8w, e.word[addr]);
|
||||
e.lea(e.rdx, e.ptr[addr]);
|
||||
e.mov(e.GetNativeParam(1).cvt16(), e.word[addr]);
|
||||
e.lea(e.GetNativeParam(0), e.ptr[addr]);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreI16));
|
||||
}
|
||||
}
|
||||
@@ -885,8 +885,8 @@ struct STORE_I32 : Sequence<STORE_I32, I<OPCODE_STORE, VoidOp, I64Op, I32Op>> {
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
addr = ComputeMemoryAddress(e, i.src1);
|
||||
e.mov(e.r8d, e.dword[addr]);
|
||||
e.lea(e.rdx, e.ptr[addr]);
|
||||
e.mov(e.GetNativeParam(1).cvt32(), e.dword[addr]);
|
||||
e.lea(e.GetNativeParam(0), e.ptr[addr]);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreI32));
|
||||
}
|
||||
}
|
||||
@@ -910,8 +910,8 @@ struct STORE_I64 : Sequence<STORE_I64, I<OPCODE_STORE, VoidOp, I64Op, I64Op>> {
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
addr = ComputeMemoryAddress(e, i.src1);
|
||||
e.mov(e.r8, e.qword[addr]);
|
||||
e.lea(e.rdx, e.ptr[addr]);
|
||||
e.mov(e.GetNativeParam(1), e.qword[addr]);
|
||||
e.lea(e.GetNativeParam(0), e.ptr[addr]);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreI64));
|
||||
}
|
||||
}
|
||||
@@ -931,8 +931,8 @@ struct STORE_F32 : Sequence<STORE_F32, I<OPCODE_STORE, VoidOp, I64Op, F32Op>> {
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
addr = ComputeMemoryAddress(e, i.src1);
|
||||
e.lea(e.r8, e.ptr[addr]);
|
||||
e.lea(e.rdx, e.ptr[addr]);
|
||||
e.lea(e.GetNativeParam(1), e.ptr[addr]);
|
||||
e.lea(e.GetNativeParam(0), e.ptr[addr]);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreF32));
|
||||
}
|
||||
}
|
||||
@@ -952,8 +952,8 @@ struct STORE_F64 : Sequence<STORE_F64, I<OPCODE_STORE, VoidOp, I64Op, F64Op>> {
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
addr = ComputeMemoryAddress(e, i.src1);
|
||||
e.lea(e.r8, e.ptr[addr]);
|
||||
e.lea(e.rdx, e.ptr[addr]);
|
||||
e.lea(e.GetNativeParam(1), e.ptr[addr]);
|
||||
e.lea(e.GetNativeParam(0), e.ptr[addr]);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreF64));
|
||||
}
|
||||
}
|
||||
@@ -976,8 +976,8 @@ struct STORE_V128
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
addr = ComputeMemoryAddress(e, i.src1);
|
||||
e.lea(e.r8, e.ptr[addr]);
|
||||
e.lea(e.rdx, e.ptr[addr]);
|
||||
e.lea(e.GetNativeParam(1), e.ptr[addr]);
|
||||
e.lea(e.GetNativeParam(0), e.ptr[addr]);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreV128));
|
||||
}
|
||||
}
|
||||
@@ -1038,9 +1038,9 @@ struct MEMSET_I64_I8_I64
|
||||
}
|
||||
if (IsTracingData()) {
|
||||
addr = ComputeMemoryAddress(e, i.src1);
|
||||
e.mov(e.r9, i.src3.constant());
|
||||
e.mov(e.r8, i.src2.constant());
|
||||
e.lea(e.rdx, e.ptr[addr]);
|
||||
e.mov(e.GetNativeParam(2), i.src3.constant());
|
||||
e.mov(e.GetNativeParam(1), i.src2.constant());
|
||||
e.lea(e.GetNativeParam(0), e.ptr[addr]);
|
||||
e.CallNative(reinterpret_cast<void*>(TraceMemset));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user