mirror of
https://github.com/hedge-dev/XenonRecomp.git
synced 2025-07-22 21:17:14 +00:00
Linux support. (#3)
* Compiling and running on Linux. * Fix xpointer constructor. * Convert dependencies to submodules. * Fix wchar_t usage for Linux.
This commit is contained in:
@@ -2,20 +2,29 @@ cmake_minimum_required (VERSION 3.8)
|
||||
|
||||
project("PowerRecomp")
|
||||
|
||||
BIN2H(SOURCE_FILE ${POWERUTILS_ROOT}/ppc_context.h HEADER_FILE "generated/ppc_context.gen.h" ARRAY_TYPE "char" VARIABLE_NAME "g_PPCContextText")
|
||||
BIN2H(SOURCE_FILE
|
||||
${POWERUTILS_ROOT}/ppc_context.h
|
||||
HEADER_FILE "generated/ppc_context.gen.h"
|
||||
ARRAY_TYPE "char"
|
||||
VARIABLE_NAME "g_PPCContextText")
|
||||
|
||||
add_executable(PowerRecomp
|
||||
"main.cpp"
|
||||
"recompiler.cpp"
|
||||
"test_recompiler.cpp"
|
||||
"recompiler_config.cpp")
|
||||
|
||||
add_executable(PowerRecomp "main.cpp" "pch.h" "recompiler.cpp" "recompiler.h" "test_recompiler.cpp" "test_recompiler.h" "recompiler_config.h" "recompiler_config.cpp")
|
||||
target_precompile_headers(PowerRecomp PUBLIC "pch.h")
|
||||
|
||||
find_package(fmt CONFIG REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(tomlplusplus REQUIRED IMPORTED_TARGET tomlplusplus)
|
||||
find_package(xxHash CONFIG REQUIRED)
|
||||
|
||||
target_link_libraries(PowerRecomp PRIVATE LibPowerAnalyse fmt::fmt PkgConfig::tomlplusplus xxHash::xxhash)
|
||||
target_link_libraries(PowerRecomp PRIVATE
|
||||
LibPowerAnalyse
|
||||
PowerUtils
|
||||
fmt::fmt
|
||||
tomlplusplus::tomlplusplus
|
||||
xxHash::xxhash)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
target_compile_options(PowerRecomp PRIVATE -Wno-switch -Wno-unused-variable)
|
||||
target_compile_options(PowerRecomp PRIVATE -Wno-switch -Wno-unused-variable -Wno-null-arithmetic)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(PowerRecomp PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||
|
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <charconv>
|
||||
#include <disasm.h>
|
||||
#include <file.h>
|
||||
@@ -14,4 +16,5 @@
|
||||
#include <xbox.h>
|
||||
#include <xxhash.h>
|
||||
#include <fmt/core.h>
|
||||
#include <xmmintrin.h>
|
||||
#include "generated/ppc_context.gen.h"
|
||||
|
@@ -607,7 +607,7 @@ bool Recompiler::Recompile(
|
||||
break;
|
||||
|
||||
case PPC_INST_BLRL:
|
||||
println("__debugbreak();");
|
||||
println("__builtin_debugtrap();");
|
||||
break;
|
||||
|
||||
case PPC_INST_BLT:
|
||||
@@ -688,7 +688,7 @@ bool Recompiler::Recompile(
|
||||
break;
|
||||
|
||||
case PPC_INST_CNTLZW:
|
||||
println("\t{}.u64 = __lzcnt({}.u32);", r(insn.operands[0]), r(insn.operands[1]));
|
||||
println("\t{}.u64 = __lzcnt32({}.u32);", r(insn.operands[0]), r(insn.operands[1]));
|
||||
break;
|
||||
|
||||
case PPC_INST_DB16CYC:
|
||||
@@ -1263,43 +1263,43 @@ bool Recompiler::Recompile(
|
||||
break;
|
||||
|
||||
case PPC_INST_RLDICL:
|
||||
println("\t{}.u64 = _rotl64({}.u64, {}) & 0x{:X};", r(insn.operands[0]), r(insn.operands[1]), insn.operands[2], ComputeMask(insn.operands[3], 63));
|
||||
println("\t{}.u64 = __builtin_rotateleft64({}.u64, {}) & 0x{:X};", r(insn.operands[0]), r(insn.operands[1]), insn.operands[2], ComputeMask(insn.operands[3], 63));
|
||||
break;
|
||||
|
||||
case PPC_INST_RLDICR:
|
||||
println("\t{}.u64 = _rotl64({}.u64, {}) & 0x{:X};", r(insn.operands[0]), r(insn.operands[1]), insn.operands[2], ComputeMask(0, insn.operands[3]));
|
||||
println("\t{}.u64 = __builtin_rotateleft64({}.u64, {}) & 0x{:X};", r(insn.operands[0]), r(insn.operands[1]), insn.operands[2], ComputeMask(0, insn.operands[3]));
|
||||
break;
|
||||
|
||||
case PPC_INST_RLDIMI:
|
||||
{
|
||||
const uint64_t mask = ComputeMask(insn.operands[3], ~insn.operands[2]);
|
||||
println("\t{}.u64 = (_rotl64({}.u64, {}) & 0x{:X}) | ({}.u64 & 0x{:X});", r(insn.operands[0]), r(insn.operands[1]), insn.operands[2], mask, r(insn.operands[0]), ~mask);
|
||||
println("\t{}.u64 = (__builtin_rotateleft64({}.u64, {}) & 0x{:X}) | ({}.u64 & 0x{:X});", r(insn.operands[0]), r(insn.operands[1]), insn.operands[2], mask, r(insn.operands[0]), ~mask);
|
||||
break;
|
||||
}
|
||||
|
||||
case PPC_INST_RLWIMI:
|
||||
{
|
||||
const uint64_t mask = ComputeMask(insn.operands[3] + 32, insn.operands[4] + 32);
|
||||
println("\t{}.u64 = (_rotl({}.u32, {}) & 0x{:X}) | ({}.u64 & 0x{:X});", r(insn.operands[0]), r(insn.operands[1]), insn.operands[2], mask, r(insn.operands[0]), ~mask);
|
||||
println("\t{}.u64 = (__builtin_rotateleft32({}.u32, {}) & 0x{:X}) | ({}.u64 & 0x{:X});", r(insn.operands[0]), r(insn.operands[1]), insn.operands[2], mask, r(insn.operands[0]), ~mask);
|
||||
break;
|
||||
}
|
||||
|
||||
case PPC_INST_RLWINM:
|
||||
println("\t{}.u64 = _rotl64({}.u32 | ({}.u64 << 32), {}) & 0x{:X};", r(insn.operands[0]), r(insn.operands[1]), r(insn.operands[1]), insn.operands[2], ComputeMask(insn.operands[3] + 32, insn.operands[4] + 32));
|
||||
println("\t{}.u64 = __builtin_rotateleft64({}.u32 | ({}.u64 << 32), {}) & 0x{:X};", r(insn.operands[0]), r(insn.operands[1]), r(insn.operands[1]), insn.operands[2], ComputeMask(insn.operands[3] + 32, insn.operands[4] + 32));
|
||||
if (strchr(insn.opcode->name, '.'))
|
||||
println("\t{}.compare<int32_t>({}.s32, 0, {});", cr(0), r(insn.operands[0]), xer());
|
||||
break;
|
||||
|
||||
case PPC_INST_ROTLDI:
|
||||
println("\t{}.u64 = _rotl64({}.u64, {});", r(insn.operands[0]), r(insn.operands[1]), insn.operands[2]);
|
||||
println("\t{}.u64 = __builtin_rotateleft64({}.u64, {});", r(insn.operands[0]), r(insn.operands[1]), insn.operands[2]);
|
||||
break;
|
||||
|
||||
case PPC_INST_ROTLW:
|
||||
println("\t{}.u64 = _rotl({}.u32, {}.u8 & 0x1F);", r(insn.operands[0]), r(insn.operands[1]), r(insn.operands[2]));
|
||||
println("\t{}.u64 = __builtin_rotateleft32({}.u32, {}.u8 & 0x1F);", r(insn.operands[0]), r(insn.operands[1]), r(insn.operands[2]));
|
||||
break;
|
||||
|
||||
case PPC_INST_ROTLWI:
|
||||
println("\t{}.u64 = _rotl({}.u32, {});", r(insn.operands[0]), r(insn.operands[1]), insn.operands[2]);
|
||||
println("\t{}.u64 = __builtin_rotateleft32({}.u32, {});", r(insn.operands[0]), r(insn.operands[1]), insn.operands[2]);
|
||||
if (strchr(insn.opcode->name, '.'))
|
||||
println("\t{}.compare<int32_t>({}.s32, 0, {});", cr(0), r(insn.operands[0]), xer());
|
||||
break;
|
||||
@@ -1398,10 +1398,10 @@ bool Recompiler::Recompile(
|
||||
case PPC_INST_STDCX:
|
||||
println("\t{}.lt = 0;", cr(0));
|
||||
println("\t{}.gt = 0;", cr(0));
|
||||
print("\t{}.eq = _InterlockedCompareExchange64(reinterpret_cast<__int64*>(base + ", cr(0));
|
||||
print("\t{}.eq = __sync_bool_compare_and_swap(reinterpret_cast<uint64_t*>(base + ", cr(0));
|
||||
if (insn.operands[1] != 0)
|
||||
print("{}.u32 + ", r(insn.operands[1]));
|
||||
println("{}.u32), __builtin_bswap64({}.s64), {}.s64) == {}.s64;", r(insn.operands[2]), r(insn.operands[0]), reserved(), reserved());
|
||||
println("{}.u32), {}.s64, __builtin_bswap64({}.s64));", r(insn.operands[2]), reserved(), r(insn.operands[0]));
|
||||
println("\t{}.so = {}.so;", cr(0), xer());
|
||||
break;
|
||||
|
||||
@@ -1553,10 +1553,10 @@ bool Recompiler::Recompile(
|
||||
case PPC_INST_STWCX:
|
||||
println("\t{}.lt = 0;", cr(0));
|
||||
println("\t{}.gt = 0;", cr(0));
|
||||
print("\t{}.eq = _InterlockedCompareExchange(reinterpret_cast<long*>(base + ", cr(0));
|
||||
print("\t{}.eq = __sync_bool_compare_and_swap(reinterpret_cast<uint32_t*>(base + ", cr(0));
|
||||
if (insn.operands[1] != 0)
|
||||
print("{}.u32 + ", r(insn.operands[1]));
|
||||
println("{}.u32), __builtin_bswap32({}.s32), {}.s32) == {}.s32;", r(insn.operands[2]), r(insn.operands[0]), reserved(), reserved());
|
||||
println("{}.u32), {}.s32, __builtin_bswap32({}.s32));", r(insn.operands[2]), reserved(), r(insn.operands[0]));
|
||||
println("\t{}.so = {}.so;", cr(0), xer());
|
||||
break;
|
||||
|
||||
@@ -1726,7 +1726,7 @@ bool Recompiler::Recompile(
|
||||
|
||||
case PPC_INST_VCMPBFP:
|
||||
case PPC_INST_VCMPBFP128:
|
||||
println("\t__debugbreak();");
|
||||
println("\t__builtin_debugtrap();");
|
||||
break;
|
||||
|
||||
case PPC_INST_VCMPEQFP:
|
||||
@@ -1910,7 +1910,7 @@ bool Recompiler::Recompile(
|
||||
break;
|
||||
|
||||
default:
|
||||
println("\t__debugbreak();");
|
||||
println("\t__builtin_debugtrap();");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -2086,7 +2086,7 @@ bool Recompiler::Recompile(
|
||||
break;
|
||||
|
||||
default:
|
||||
println("\t__debugbreak();");
|
||||
println("\t__builtin_debugtrap();");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
Reference in New Issue
Block a user