Linux tweaks.
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "xenia/cpu/backend/x64/x64_assembler.h"
|
||||
|
||||
#include <climits>
|
||||
|
||||
#include "third_party/capstone/include/capstone.h"
|
||||
#include "third_party/capstone/include/x86.h"
|
||||
#include "xenia/base/reset_scope.h"
|
||||
|
||||
@@ -61,10 +61,10 @@ bool X64Backend::Initialize() {
|
||||
machine_info_.supports_extended_load_store = false;
|
||||
}
|
||||
|
||||
machine_info_.register_sets[0] = {
|
||||
machine_info_.register_sets[0] = (MachineInfo::RegisterSet){
|
||||
0, "gpr", MachineInfo::RegisterSet::INT_TYPES, X64Emitter::GPR_COUNT,
|
||||
};
|
||||
machine_info_.register_sets[1] = {
|
||||
machine_info_.register_sets[1] = (MachineInfo::RegisterSet){
|
||||
1, "xmm", MachineInfo::RegisterSet::FLOAT_TYPES |
|
||||
MachineInfo::RegisterSet::VEC_TYPES,
|
||||
X64Emitter::XMM_COUNT,
|
||||
|
||||
@@ -2019,7 +2019,7 @@ struct LOAD_MMIO_I32
|
||||
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.CallNativeSafe(mmio_range->read);
|
||||
e.CallNativeSafe(reinterpret_cast<void*>(mmio_range->read));
|
||||
e.bswap(e.eax);
|
||||
e.mov(i.dest, e.eax);
|
||||
if (IsTracingData()) {
|
||||
@@ -2050,7 +2050,7 @@ struct STORE_MMIO_I32
|
||||
e.mov(e.r10d, i.src3);
|
||||
e.bswap(e.r10d);
|
||||
}
|
||||
e.CallNativeSafe(mmio_range->write);
|
||||
e.CallNativeSafe(reinterpret_cast<void*>(mmio_range->write));
|
||||
if (IsTracingData()) {
|
||||
if (i.src3.is_constant) {
|
||||
e.mov(e.r8d, i.src3.constant());
|
||||
@@ -6461,7 +6461,7 @@ struct PACK : Sequence<PACK, I<OPCODE_PACK, V128Op, V128Op, V128Op>> {
|
||||
e.vpshufb(i.dest, i.dest, e.GetXmmConstPtr(XMMPackFLOAT16_2));
|
||||
} else {
|
||||
e.lea(e.r8, e.StashXmm(0, i.src1));
|
||||
e.CallNativeSafe(EmulateFLOAT16_2);
|
||||
e.CallNativeSafe(reinterpret_cast<void*>(EmulateFLOAT16_2));
|
||||
e.vmovaps(i.dest, e.xmm0);
|
||||
}
|
||||
}
|
||||
@@ -6488,7 +6488,7 @@ struct PACK : Sequence<PACK, I<OPCODE_PACK, V128Op, V128Op, V128Op>> {
|
||||
e.vpshufb(i.dest, i.dest, e.GetXmmConstPtr(XMMPackFLOAT16_4));
|
||||
} else {
|
||||
e.lea(e.r8, e.StashXmm(0, i.src1));
|
||||
e.CallNativeSafe(EmulateFLOAT16_4);
|
||||
e.CallNativeSafe(reinterpret_cast<void*>(EmulateFLOAT16_4));
|
||||
e.vmovaps(i.dest, e.xmm0);
|
||||
}
|
||||
}
|
||||
@@ -6787,7 +6787,7 @@ struct UNPACK : Sequence<UNPACK, I<OPCODE_UNPACK, V128Op, V128Op>> {
|
||||
e.vpor(i.dest, e.GetXmmConstPtr(XMM0001));
|
||||
} else {
|
||||
e.lea(e.r8, e.StashXmm(0, i.src1));
|
||||
e.CallNativeSafe(EmulateFLOAT16_2);
|
||||
e.CallNativeSafe(reinterpret_cast<void*>(EmulateFLOAT16_2));
|
||||
e.vmovaps(i.dest, e.xmm0);
|
||||
}
|
||||
}
|
||||
@@ -6821,7 +6821,7 @@ struct UNPACK : Sequence<UNPACK, I<OPCODE_UNPACK, V128Op, V128Op>> {
|
||||
e.vcvtph2ps(i.dest, i.dest);
|
||||
} else {
|
||||
e.lea(e.r8, e.StashXmm(0, i.src1));
|
||||
e.CallNativeSafe(EmulateFLOAT16_4);
|
||||
e.CallNativeSafe(reinterpret_cast<void*>(EmulateFLOAT16_4));
|
||||
e.vmovaps(i.dest, e.xmm0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "xenia/cpu/backend/x64/x64_tracers.h"
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#include "xenia/base/vec128.h"
|
||||
#include "xenia/cpu/backend/x64/x64_emitter.h"
|
||||
#include "xenia/cpu/processor.h"
|
||||
@@ -61,35 +63,36 @@ void TraceString(void* raw_context, const char* str) {
|
||||
|
||||
void TraceContextLoadI8(void* raw_context, uint64_t offset, uint8_t value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
DPRINT("%d (%X) = ctx i8 +%llu\n", (int8_t)value, value, offset);
|
||||
DPRINT("%d (%X) = ctx i8 +%" PRIu64 "\n", (int8_t)value, value, offset);
|
||||
}
|
||||
void TraceContextLoadI16(void* raw_context, uint64_t offset, uint16_t value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
DPRINT("%d (%X) = ctx i16 +%llu\n", (int16_t)value, value, offset);
|
||||
DPRINT("%d (%X) = ctx i16 +%" PRIu64 "\n", (int16_t)value, value, offset);
|
||||
}
|
||||
void TraceContextLoadI32(void* raw_context, uint64_t offset, uint32_t value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
DPRINT("%d (%X) = ctx i32 +%llu\n", (int32_t)value, value, offset);
|
||||
DPRINT("%d (%X) = ctx i32 +%" PRIu64 "\n", (int32_t)value, value, offset);
|
||||
}
|
||||
void TraceContextLoadI64(void* raw_context, uint64_t offset, uint64_t value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
DPRINT("%lld (%llX) = ctx i64 +%llu\n", (int64_t)value, value, offset);
|
||||
DPRINT("%" PRId64 " (%" PRIX64 ") = ctx i64 +%" PRIu64 "\n", (int64_t)value,
|
||||
value, offset);
|
||||
}
|
||||
void TraceContextLoadF32(void* raw_context, uint64_t offset, __m128 value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
DPRINT("%e (%X) = ctx f32 +%llu\n", xe::m128_f32<0>(value),
|
||||
DPRINT("%e (%X) = ctx f32 +%" PRIu64 "\n", xe::m128_f32<0>(value),
|
||||
xe::m128_i32<0>(value), offset);
|
||||
}
|
||||
void TraceContextLoadF64(void* raw_context, uint64_t offset,
|
||||
const double* value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
auto v = _mm_loadu_pd(value);
|
||||
DPRINT("%le (%llX) = ctx f64 +%llu\n", xe::m128_f64<0>(v), xe::m128_i64<0>(v),
|
||||
offset);
|
||||
DPRINT("%le (%" PRIX64 ") = ctx f64 +%" PRIu64 "\n", xe::m128_f64<0>(v),
|
||||
xe::m128_i64<0>(v), offset);
|
||||
}
|
||||
void TraceContextLoadV128(void* raw_context, uint64_t offset, __m128 value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
DPRINT("[%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X] = ctx v128 +%llu\n",
|
||||
DPRINT("[%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X] = ctx v128 +%" PRIu64 "\n",
|
||||
xe::m128_f32<0>(value), xe::m128_f32<1>(value), xe::m128_f32<2>(value),
|
||||
xe::m128_f32<3>(value), xe::m128_i32<0>(value), xe::m128_i32<1>(value),
|
||||
xe::m128_i32<2>(value), xe::m128_i32<3>(value), offset);
|
||||
@@ -97,38 +100,40 @@ void TraceContextLoadV128(void* raw_context, uint64_t offset, __m128 value) {
|
||||
|
||||
void TraceContextStoreI8(void* raw_context, uint64_t offset, uint8_t value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
DPRINT("ctx i8 +%llu = %d (%X)\n", offset, (int8_t)value, value);
|
||||
DPRINT("ctx i8 +%" PRIu64 " = %d (%X)\n", offset, (int8_t)value, value);
|
||||
}
|
||||
void TraceContextStoreI16(void* raw_context, uint64_t offset, uint16_t value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
DPRINT("ctx i16 +%llu = %d (%X)\n", offset, (int16_t)value, value);
|
||||
DPRINT("ctx i16 +%" PRIu64 " = %d (%X)\n", offset, (int16_t)value, value);
|
||||
}
|
||||
void TraceContextStoreI32(void* raw_context, uint64_t offset, uint32_t value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
DPRINT("ctx i32 +%llu = %d (%X)\n", offset, (int32_t)value, value);
|
||||
DPRINT("ctx i32 +%" PRIu64 " = %d (%X)\n", offset, (int32_t)value, value);
|
||||
}
|
||||
void TraceContextStoreI64(void* raw_context, uint64_t offset, uint64_t value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
DPRINT("ctx i64 +%llu = %lld (%llX)\n", offset, (int64_t)value, value);
|
||||
DPRINT("ctx i64 +%" PRIu64 " = %" PRId64 " (%" PRIX64 ")\n", offset,
|
||||
(int64_t)value, value);
|
||||
}
|
||||
void TraceContextStoreF32(void* raw_context, uint64_t offset, __m128 value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
DPRINT("ctx f32 +%llu = %e (%X)\n", offset, xe::m128_f32<0>(value),
|
||||
DPRINT("ctx f32 +%" PRIu64 " = %e (%X)\n", offset, xe::m128_f32<0>(value),
|
||||
xe::m128_i32<0>(value));
|
||||
}
|
||||
void TraceContextStoreF64(void* raw_context, uint64_t offset,
|
||||
const double* value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
auto v = _mm_loadu_pd(value);
|
||||
DPRINT("ctx f64 +%llu = %le (%llX)\n", offset, xe::m128_f64<0>(v),
|
||||
xe::m128_i64<0>(v));
|
||||
DPRINT("ctx f64 +%" PRIu64 " = %le (%" PRIX64 ")\n", offset,
|
||||
xe::m128_f64<0>(v), xe::m128_i64<0>(v));
|
||||
}
|
||||
void TraceContextStoreV128(void* raw_context, uint64_t offset, __m128 value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
DPRINT("ctx v128 +%llu = [%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X]\n", offset,
|
||||
xe::m128_f32<0>(value), xe::m128_f32<1>(value), xe::m128_f32<2>(value),
|
||||
xe::m128_f32<3>(value), xe::m128_i32<0>(value), xe::m128_i32<1>(value),
|
||||
xe::m128_i32<2>(value), xe::m128_i32<3>(value));
|
||||
DPRINT("ctx v128 +%" PRIu64 " = [%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X]\n",
|
||||
offset, xe::m128_f32<0>(value), xe::m128_f32<1>(value),
|
||||
xe::m128_f32<2>(value), xe::m128_f32<3>(value), xe::m128_i32<0>(value),
|
||||
xe::m128_i32<1>(value), xe::m128_i32<2>(value),
|
||||
xe::m128_i32<3>(value));
|
||||
}
|
||||
|
||||
void TraceMemoryLoadI8(void* raw_context, uint32_t address, uint8_t value) {
|
||||
@@ -145,7 +150,8 @@ void TraceMemoryLoadI32(void* raw_context, uint32_t address, uint32_t value) {
|
||||
}
|
||||
void TraceMemoryLoadI64(void* raw_context, uint32_t address, uint64_t value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
DPRINT("%lld (%llX) = load.i64 %.8X\n", (int64_t)value, value, address);
|
||||
DPRINT("%" PRId64 " (%" PRIX64 ") = load.i64 %.8X\n", (int64_t)value, value,
|
||||
address);
|
||||
}
|
||||
void TraceMemoryLoadF32(void* raw_context, uint32_t address, __m128 value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
@@ -154,7 +160,7 @@ void TraceMemoryLoadF32(void* raw_context, uint32_t address, __m128 value) {
|
||||
}
|
||||
void TraceMemoryLoadF64(void* raw_context, uint32_t address, __m128 value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
DPRINT("%le (%llX) = load.f64 %.8X\n", xe::m128_f64<0>(value),
|
||||
DPRINT("%le (%" PRIX64 ") = load.f64 %.8X\n", xe::m128_f64<0>(value),
|
||||
xe::m128_i64<0>(value), address);
|
||||
}
|
||||
void TraceMemoryLoadV128(void* raw_context, uint32_t address, __m128 value) {
|
||||
@@ -179,7 +185,8 @@ void TraceMemoryStoreI32(void* raw_context, uint32_t address, uint32_t value) {
|
||||
}
|
||||
void TraceMemoryStoreI64(void* raw_context, uint32_t address, uint64_t value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
DPRINT("store.i64 %.8X = %lld (%llX)\n", address, (int64_t)value, value);
|
||||
DPRINT("store.i64 %.8X = %" PRId64 " (%" PRIX64 ")\n", address,
|
||||
(int64_t)value, value);
|
||||
}
|
||||
void TraceMemoryStoreF32(void* raw_context, uint32_t address, __m128 value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
@@ -188,8 +195,8 @@ void TraceMemoryStoreF32(void* raw_context, uint32_t address, __m128 value) {
|
||||
}
|
||||
void TraceMemoryStoreF64(void* raw_context, uint32_t address, __m128 value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
DPRINT("store.f64 %.8X = %le (%llX)\n", address, xe::m128_f64<0>(value),
|
||||
xe::m128_i64<0>(value));
|
||||
DPRINT("store.f64 %.8X = %le (%" PRIX64 ")\n", address,
|
||||
xe::m128_f64<0>(value), xe::m128_i64<0>(value));
|
||||
}
|
||||
void TraceMemoryStoreV128(void* raw_context, uint32_t address, __m128 value) {
|
||||
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
|
||||
|
||||
@@ -79,7 +79,7 @@ bool ElfModule::Load(const std::string& name, const std::string& path,
|
||||
XELOGE(
|
||||
"ELF: Could not load ELF because target machine is not PPC! (target: "
|
||||
"%d)",
|
||||
hdr->e_machine);
|
||||
uint32_t(hdr->e_machine));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -108,8 +108,8 @@ bool ElfModule::Load(const std::string& name, const std::string& path,
|
||||
// Allocate and copy into memory.
|
||||
// Base address @ 0x80000000
|
||||
uint32_t virtual_addr = phdr[i].p_vaddr < 0x80000000
|
||||
? phdr[i].p_vaddr + 0x80000000
|
||||
: phdr[i].p_vaddr;
|
||||
? uint32_t(phdr[i].p_vaddr) + 0x80000000
|
||||
: uint32_t(phdr[i].p_vaddr);
|
||||
if (!memory()
|
||||
->LookupHeap(virtual_addr)
|
||||
->AllocFixed(
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "xenia/cpu/frontend/ppc_context.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cstdlib>
|
||||
|
||||
namespace xe {
|
||||
@@ -64,7 +65,7 @@ bool PPCContext::CompareRegWithString(const char* name, const char* value,
|
||||
if (sscanf(name, "r%d", &n) == 1) {
|
||||
uint64_t expected = ParseInt64(value);
|
||||
if (this->r[n] != expected) {
|
||||
snprintf(out_value, out_value_size, "%016llX", this->r[n]);
|
||||
snprintf(out_value, out_value_size, "%016" PRIX64, this->r[n]);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "xenia/cpu/frontend/ppc_instr.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
@@ -98,9 +99,9 @@ void InstrOperand::Dump(std::string& out_str) {
|
||||
break;
|
||||
case 8:
|
||||
if (imm.is_signed) {
|
||||
snprintf(buffer, max_count, "%lld", (int64_t)imm.value);
|
||||
snprintf(buffer, max_count, "%" PRId64, (int64_t)imm.value);
|
||||
} else {
|
||||
snprintf(buffer, max_count, "0x%.16llX", imm.value);
|
||||
snprintf(buffer, max_count, "0x%.16" PRIX64, imm.value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "xenia/cpu/hir/hir_builder.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cstdarg>
|
||||
#include <cstring>
|
||||
|
||||
@@ -118,7 +119,7 @@ void HIRBuilder::DumpValue(StringBuffer* str, Value* value) {
|
||||
str->AppendFormat("%X", value->constant.i32);
|
||||
break;
|
||||
case INT64_TYPE:
|
||||
str->AppendFormat("%llX", value->constant.i64);
|
||||
str->AppendFormat("%" PRIX64, value->constant.i64);
|
||||
break;
|
||||
case FLOAT32_TYPE:
|
||||
str->AppendFormat("%F", value->constant.f32);
|
||||
|
||||
@@ -322,11 +322,23 @@ void Value::MulHi(Value* other, bool is_unsigned) {
|
||||
}
|
||||
break;
|
||||
case INT64_TYPE:
|
||||
#if XE_COMPILER_MSVC
|
||||
if (is_unsigned) {
|
||||
constant.i64 = __umulh(constant.i64, other->constant.i64);
|
||||
} else {
|
||||
constant.i64 = __mulh(constant.i64, other->constant.i64);
|
||||
}
|
||||
#else
|
||||
if (is_unsigned) {
|
||||
constant.i64 = static_cast<uint64_t>(
|
||||
static_cast<unsigned __int128>(constant.i64) *
|
||||
static_cast<unsigned __int128>(other->constant.i64));
|
||||
} else {
|
||||
constant.i64 =
|
||||
static_cast<uint64_t>(static_cast<__int128>(constant.i64) *
|
||||
static_cast<__int128>(other->constant.i64));
|
||||
}
|
||||
#endif // XE_COMPILER_MSVC
|
||||
break;
|
||||
default:
|
||||
assert_unhandled_case(type);
|
||||
@@ -440,7 +452,7 @@ void Value::Abs() {
|
||||
break;
|
||||
case VEC128_TYPE:
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
constant.v128.f32[i] = std::fabsf(constant.v128.f32[i]);
|
||||
constant.v128.f32[i] = std::abs(constant.v128.f32[i]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -452,7 +464,7 @@ void Value::Abs() {
|
||||
void Value::Sqrt() {
|
||||
switch (type) {
|
||||
case FLOAT32_TYPE:
|
||||
constant.f32 = 1.0f / std::sqrtf(constant.f32);
|
||||
constant.f32 = 1.0f / std::sqrt(constant.f32);
|
||||
break;
|
||||
case FLOAT64_TYPE:
|
||||
constant.f64 = 1.0 / std::sqrt(constant.f64);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "xenia/cpu/thread_state.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "xenia/base/assert.h"
|
||||
@@ -85,7 +86,7 @@ ThreadState::ThreadState(Processor* processor, uint32_t thread_id,
|
||||
|
||||
// Allocate with 64b alignment.
|
||||
context_ =
|
||||
reinterpret_cast<PPCContext*>(_aligned_malloc(sizeof(PPCContext), 64));
|
||||
reinterpret_cast<PPCContext*>(aligned_alloc(64, sizeof(PPCContext)));
|
||||
assert_true(((uint64_t)context_ & 0x3F) == 0);
|
||||
std::memset(context_, 0, sizeof(PPCContext));
|
||||
|
||||
@@ -110,7 +111,7 @@ ThreadState::~ThreadState() {
|
||||
thread_state_ = nullptr;
|
||||
}
|
||||
|
||||
_aligned_free(context_);
|
||||
free(context_);
|
||||
if (stack_allocated_) {
|
||||
memory()->LookupHeap(stack_address_)->Decommit(stack_address_, stack_size_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user