mirror of
				https://github.com/hedge-dev/XenonRecomp.git
				synced 2025-11-04 06:47:09 +00:00 
			
		
		
		
	Remove MSVC macros & implement weak linking properly for clang.
This commit is contained in:
		@@ -1964,11 +1964,11 @@ bool Recompiler::Recompile(const Function& fn)
 | 
			
		||||
    auto symbol = image.symbols.find(fn.base);
 | 
			
		||||
    if (symbol != image.symbols.end())
 | 
			
		||||
    {
 | 
			
		||||
        println("PPC_FUNC({}) {{", symbol->name);
 | 
			
		||||
        println("PPC_WEAK_FUNC({}) {{", symbol->name);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        println("PPC_FUNC(sub_{}) {{", fn.base);
 | 
			
		||||
        println("PPC_WEAK_FUNC(sub_{}) {{", fn.base);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    println("\tPPC_FUNC_PROLOGUE();");
 | 
			
		||||
@@ -2120,7 +2120,7 @@ void Recompiler::Recompile(const char* directoryPath)
 | 
			
		||||
        println("#include <ppc_context.h>\n");
 | 
			
		||||
 | 
			
		||||
        for (auto& symbol : image.symbols)
 | 
			
		||||
            println("PPC_FUNC({});", symbol.name);
 | 
			
		||||
            println("PPC_EXTERN_FUNC({});", symbol.name);
 | 
			
		||||
 | 
			
		||||
        SaveCurrentOutData(directoryPath, "ppc_recomp_shared.h");
 | 
			
		||||
    }
 | 
			
		||||
@@ -2128,7 +2128,7 @@ void Recompiler::Recompile(const char* directoryPath)
 | 
			
		||||
    {
 | 
			
		||||
        println("#include \"ppc_recomp_shared.h\"\n");
 | 
			
		||||
 | 
			
		||||
        println("extern \"C\" PPCFuncMapping PPCFuncMappings[] = {{");
 | 
			
		||||
        println("PPCFuncMapping PPCFuncMappings[] = {{");
 | 
			
		||||
        for (auto& symbol : image.symbols)
 | 
			
		||||
            println("\t{{ 0x{:X}, {} }},", symbol.address, symbol.name);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,10 @@
 | 
			
		||||
project("PowerSample")
 | 
			
		||||
 | 
			
		||||
add_compile_options(
 | 
			
		||||
    "/D_HAS_EXCEPTIONS=0"
 | 
			
		||||
    "/fp:strict"
 | 
			
		||||
    "/GS-"
 | 
			
		||||
    "/EHa-"
 | 
			
		||||
    "-march=haswell"
 | 
			
		||||
    "-fno-strict-aliasing")
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,28 +4,18 @@
 | 
			
		||||
#error "ppc_config.h must be included before ppc_context.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <cmath>
 | 
			
		||||
#include <csetjmp>
 | 
			
		||||
#include <cstdint>
 | 
			
		||||
#include <cstdlib>
 | 
			
		||||
#include <cstring>
 | 
			
		||||
#include <cmath>
 | 
			
		||||
#include <csetjmp>
 | 
			
		||||
 | 
			
		||||
#include <intrin.h>
 | 
			
		||||
 | 
			
		||||
#ifdef __clang__
 | 
			
		||||
#include <x86intrin.h>
 | 
			
		||||
#define PPC_NOINLINE __attribute__((noinline))
 | 
			
		||||
#else
 | 
			
		||||
#define __restrict__ __restrict 
 | 
			
		||||
#define __builtin_bswap16 _byteswap_ushort 
 | 
			
		||||
#define __builtin_bswap32 _byteswap_ulong 
 | 
			
		||||
#define __builtin_bswap64 _byteswap_uint64 
 | 
			
		||||
#define __builtin_isnan isnan
 | 
			
		||||
#define __builtin_assume __assume
 | 
			
		||||
#define __builtin_unreachable() __assume(0)
 | 
			
		||||
#define PPC_NOINLINE __declspec(noinline)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define PPC_FUNC(x) extern "C" PPC_NOINLINE void x(PPCContext& __restrict__ ctx, uint8_t* base)
 | 
			
		||||
#define PPC_FUNC(x) void x(PPCContext& __restrict ctx, uint8_t* base)
 | 
			
		||||
#define PPC_EXTERN_FUNC(x) extern PPC_FUNC(x)
 | 
			
		||||
#define PPC_WEAK_FUNC(x) __attribute__((weak,noinline)) PPC_FUNC(x)
 | 
			
		||||
 | 
			
		||||
#define PPC_FUNC_PROLOGUE() __builtin_assume(((size_t)base & 0xFFFFFFFF) == 0)
 | 
			
		||||
 | 
			
		||||
@@ -50,7 +40,7 @@ struct PPCFuncMapping
 | 
			
		||||
    PPCFunc* host;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
extern "C" PPCFuncMapping PPCFuncMappings[];
 | 
			
		||||
extern PPCFuncMapping PPCFuncMappings[];
 | 
			
		||||
 | 
			
		||||
struct PPCRegister
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user