mirror of
https://github.com/hedge-dev/XenonRecomp.git
synced 2025-04-19 10:51:18 +00:00
Implement a better way to combat Clang's unsafe code reordering.
This commit is contained in:
parent
a7c970d324
commit
d8676283fd
@ -2265,9 +2265,6 @@ bool Recompiler::Recompile(const Function& fn)
|
||||
{
|
||||
println("loc_{:X}:", base);
|
||||
|
||||
// With a read barrier we prevent the compiler from doing unsafe code reordering. I wonder if we could do this better...
|
||||
println("\t_ReadBarrier();");
|
||||
|
||||
// Anyone could jump to this label so we wouldn't know what the CSR state would be.
|
||||
csrState = CSRState::Unknown;
|
||||
}
|
||||
|
@ -24,15 +24,15 @@
|
||||
|
||||
#define PPC_FUNC_PROLOGUE() __builtin_assume(((size_t)base & 0xFFFFFFFF) == 0)
|
||||
|
||||
#define PPC_LOAD_U8(x) *(uint8_t*)(base + (x))
|
||||
#define PPC_LOAD_U16(x) __builtin_bswap16(*(uint16_t*)(base + (x)))
|
||||
#define PPC_LOAD_U32(x) __builtin_bswap32(*(uint32_t*)(base + (x)))
|
||||
#define PPC_LOAD_U64(x) __builtin_bswap64(*(uint64_t*)(base + (x)))
|
||||
#define PPC_LOAD_U8(x) *(volatile uint8_t*)(base + (x))
|
||||
#define PPC_LOAD_U16(x) __builtin_bswap16(*(volatile uint16_t*)(base + (x)))
|
||||
#define PPC_LOAD_U32(x) __builtin_bswap32(*(volatile uint32_t*)(base + (x)))
|
||||
#define PPC_LOAD_U64(x) __builtin_bswap64(*(volatile uint64_t*)(base + (x)))
|
||||
|
||||
#define PPC_STORE_U8(x, y) *(uint8_t*)(base + (x)) = (y)
|
||||
#define PPC_STORE_U16(x, y) *(uint16_t*)(base + (x)) = __builtin_bswap16(y)
|
||||
#define PPC_STORE_U32(x, y) *(uint32_t*)(base + (x)) = __builtin_bswap32(y)
|
||||
#define PPC_STORE_U64(x, y) *(uint64_t*)(base + (x)) = __builtin_bswap64(y)
|
||||
#define PPC_STORE_U8(x, y) *(volatile uint8_t*)(base + (x)) = (y)
|
||||
#define PPC_STORE_U16(x, y) *(volatile uint16_t*)(base + (x)) = __builtin_bswap16(y)
|
||||
#define PPC_STORE_U32(x, y) *(volatile uint32_t*)(base + (x)) = __builtin_bswap32(y)
|
||||
#define PPC_STORE_U64(x, y) *(volatile uint64_t*)(base + (x)) = __builtin_bswap64(y)
|
||||
|
||||
#define PPC_CALL_FUNC(x) x(ctx, base)
|
||||
#define PPC_CALL_INDIRECT_FUNC(x) (*(PPCFunc**)(ctx.fn + uint64_t(x) * 2))(ctx, base)
|
||||
|
Loading…
x
Reference in New Issue
Block a user