Merge branch 'master' of https://github.com/xenia-project/xenia into canary_experimental

This commit is contained in:
Gliniak
2022-07-17 21:27:52 +02:00
169 changed files with 39917 additions and 37685 deletions

View File

@@ -15,6 +15,7 @@
#include "third_party/capstone/include/capstone/x86.h"
#include "xenia/base/profiling.h"
#include "xenia/base/reset_scope.h"
#include "xenia/base/string.h"
#include "xenia/cpu/backend/x64/x64_backend.h"
#include "xenia/cpu/backend/x64/x64_code_cache.h"
#include "xenia/cpu/backend/x64/x64_emitter.h"
@@ -86,7 +87,7 @@ bool X64Assembler::Assemble(GuestFunction* function, HIRBuilder* builder,
if (debug_info_flags & DebugInfoFlags::kDebugInfoDisasmMachineCode) {
DumpMachineCode(machine_code, code_size, function->source_map(),
&string_buffer_);
debug_info->set_machine_code_disasm(strdup(string_buffer_.buffer()));
debug_info->set_machine_code_disasm(xe_strdup(string_buffer_.buffer()));
string_buffer_.Reset();
}

View File

@@ -25,12 +25,12 @@
#include "xenia/cpu/backend/x64/x64_sequences.h"
#include <algorithm>
#include <cstring>
#include <unordered_map>
#include "xenia/base/assert.h"
#include "xenia/base/clock.h"
#include "xenia/base/logging.h"
#include "xenia/base/string.h"
#include "xenia/base/threading.h"
#include "xenia/cpu/backend/x64/x64_emitter.h"
#include "xenia/cpu/backend/x64/x64_op.h"
@@ -70,7 +70,7 @@ struct COMMENT : Sequence<COMMENT, I<OPCODE_COMMENT, VoidOp, OffsetOp>> {
auto str = reinterpret_cast<const char*>(i.src1.value);
// TODO(benvanik): pass through.
// TODO(benvanik): don't just leak this memory.
auto str_copy = strdup(str);
auto str_copy = xe_strdup(str);
e.mov(e.rdx, reinterpret_cast<uint64_t>(str_copy));
e.CallNative(reinterpret_cast<void*>(TraceString));
}

View File

@@ -19,6 +19,7 @@
#include "xenia/base/logging.h"
#include "xenia/base/memory.h"
#include "xenia/base/profiling.h"
#include "xenia/base/string.h"
#include "xenia/cpu/cpu_flags.h"
#include "xenia/cpu/hir/label.h"
#include "xenia/cpu/ppc/ppc_context.h"
@@ -215,25 +216,25 @@ void PPCHIRBuilder::MaybeBreakOnInstruction(uint32_t address) {
auto op = cvars::break_condition_op.c_str();
// TODO(rick): table?
if (strcasecmp(op, "eq") == 0) {
if (xe_strcasecmp(op, "eq") == 0) {
TrapTrue(CompareEQ(left, right));
} else if (strcasecmp(op, "ne") == 0) {
} else if (xe_strcasecmp(op, "ne") == 0) {
TrapTrue(CompareNE(left, right));
} else if (strcasecmp(op, "slt") == 0) {
} else if (xe_strcasecmp(op, "slt") == 0) {
TrapTrue(CompareSLT(left, right));
} else if (strcasecmp(op, "sle") == 0) {
} else if (xe_strcasecmp(op, "sle") == 0) {
TrapTrue(CompareSLE(left, right));
} else if (strcasecmp(op, "sgt") == 0) {
} else if (xe_strcasecmp(op, "sgt") == 0) {
TrapTrue(CompareSGT(left, right));
} else if (strcasecmp(op, "sge") == 0) {
} else if (xe_strcasecmp(op, "sge") == 0) {
TrapTrue(CompareSGE(left, right));
} else if (strcasecmp(op, "ult") == 0) {
} else if (xe_strcasecmp(op, "ult") == 0) {
TrapTrue(CompareULT(left, right));
} else if (strcasecmp(op, "ule") == 0) {
} else if (xe_strcasecmp(op, "ule") == 0) {
TrapTrue(CompareULE(left, right));
} else if (strcasecmp(op, "ugt") == 0) {
} else if (xe_strcasecmp(op, "ugt") == 0) {
TrapTrue(CompareUGT(left, right));
} else if (strcasecmp(op, "uge") == 0) {
} else if (xe_strcasecmp(op, "uge") == 0) {
TrapTrue(CompareUGE(left, right));
} else {
assert_always();

View File

@@ -14,6 +14,7 @@
#include "xenia/base/memory.h"
#include "xenia/base/profiling.h"
#include "xenia/base/reset_scope.h"
#include "xenia/base/string.h"
#include "xenia/cpu/compiler/compiler_passes.h"
#include "xenia/cpu/cpu_flags.h"
#include "xenia/cpu/ppc/ppc_frontend.h"
@@ -155,7 +156,7 @@ bool PPCTranslator::Translate(GuestFunction* function,
// Stash source.
if (debug_info_flags & DebugInfoFlags::kDebugInfoDisasmSource) {
DumpSource(function, &string_buffer_);
debug_info->set_source_disasm(strdup(string_buffer_.buffer()));
debug_info->set_source_disasm(xe_strdup(string_buffer_.buffer()));
string_buffer_.Reset();
}
@@ -171,7 +172,7 @@ bool PPCTranslator::Translate(GuestFunction* function,
// Stash raw HIR.
if (debug_info_flags & DebugInfoFlags::kDebugInfoDisasmRawHir) {
builder_->Dump(&string_buffer_);
debug_info->set_raw_hir_disasm(strdup(string_buffer_.buffer()));
debug_info->set_raw_hir_disasm(xe_strdup(string_buffer_.buffer()));
string_buffer_.Reset();
}
@@ -183,7 +184,7 @@ bool PPCTranslator::Translate(GuestFunction* function,
// Stash optimized HIR.
if (debug_info_flags & DebugInfoFlags::kDebugInfoDisasmHir) {
builder_->Dump(&string_buffer_);
debug_info->set_hir_disasm(strdup(string_buffer_.buffer()));
debug_info->set_hir_disasm(xe_strdup(string_buffer_.buffer()));
string_buffer_.Reset();
}

View File

@@ -425,7 +425,9 @@ bool RunTests(const std::string_view test_name) {
int failed_count = 0;
int passed_count = 0;
#if XE_ARCH_AMD64
XELOGI("Instruction feature mask {}.", cvars::x64_extension_mask);
#endif // XE_ARCH_AMD64
auto test_path_root = cvars::test_path;
std::vector<std::filesystem::path> test_files;

View File

@@ -8,10 +8,17 @@ test_suite("xenia-cpu-tests", project_root, ".", {
"xenia-base",
"xenia-core",
"xenia-cpu",
"xenia-cpu-backend-x64",
-- TODO(benvanik): cut these dependencies?
"xenia-kernel",
"xenia-ui", -- needed by xenia-base
},
filtered_links = {
{
filter = 'architecture:x86_64',
links = {
"xenia-cpu-backend-x64",
},
}
},
})

View File

@@ -12,6 +12,7 @@
#include <vector>
#include "xenia/base/platform.h"
#include "xenia/cpu/backend/x64/x64_backend.h"
#include "xenia/cpu/hir/hir_builder.h"
#include "xenia/cpu/ppc/ppc_context.h"
@@ -21,8 +22,6 @@
#include "third_party/catch/include/catch.hpp"
#define XENIA_TEST_X64 1
namespace xe {
namespace cpu {
namespace testing {
@@ -36,14 +35,17 @@ class TestFunction {
memory.reset(new Memory());
memory->Initialize();
#if XENIA_TEST_X64
{
auto backend = std::make_unique<xe::cpu::backend::x64::X64Backend>();
auto processor = std::make_unique<Processor>(memory.get(), nullptr);
processor->Setup(std::move(backend));
processors.emplace_back(std::move(processor));
std::unique_ptr<xe::cpu::backend::Backend> backend;
#if XE_ARCH_AMD64
backend.reset(new xe::cpu::backend::x64::X64Backend());
#endif // XE_ARCH
if (backend) {
auto processor = std::make_unique<Processor>(memory.get(), nullptr);
processor->Setup(std::move(backend));
processors.emplace_back(std::move(processor));
}
}
#endif // XENIA_TEST_X64
for (auto& processor : processors) {
auto module = std::make_unique<xe::cpu::TestModule>(