GPFifo: Use a pointer instead of an index

This simplifies code generated by the jits.
x86_64 jit now emits PIC.
This commit is contained in:
MerryMage 2017-04-13 23:31:29 +01:00
commit c45028a708
5 changed files with 62 additions and 83 deletions

View file

@ -28,10 +28,12 @@ void CommonAsmRoutines::GenFifoWrite(int size)
const void* start = GetCodePtr();
// Assume value in RSCRATCH
MOV(32, R(RSCRATCH2), M(&GPFifo::m_gatherPipeCount));
SwapAndStore(size, MDisp(RSCRATCH2, PtrOffset(GPFifo::m_gatherPipe)), RSCRATCH);
ADD(32, R(RSCRATCH2), Imm8(size >> 3));
MOV(32, M(&GPFifo::m_gatherPipeCount), R(RSCRATCH2));
MOV(64, R(RSCRATCH2), ImmPtr(&GPFifo::g_gather_pipe_ptr));
MOV(64, R(RSCRATCH2), MatR(RSCRATCH2));
SwapAndStore(size, MatR(RSCRATCH2), RSCRATCH);
MOV(64, R(RSCRATCH), ImmPtr(&GPFifo::g_gather_pipe_ptr));
ADD(64, R(RSCRATCH2), Imm8(size >> 3));
MOV(64, MatR(RSCRATCH), R(RSCRATCH2));
RET();
JitRegister::Register(start, GetCodePtr(), "JIT_FifoWrite_%i", size);

View file

@ -141,7 +141,7 @@ void JitArm64::SafeLoadToReg(u32 dest, s32 addr, s32 offsetReg, u32 flags, s32 o
void JitArm64::SafeStoreFromReg(s32 dest, u32 value, s32 regOffset, u32 flags, s32 offset)
{
// We want to make sure to not get LR as a temp register
gpr.Lock(W0, W1, W30);
gpr.Lock(W0, W1);
ARM64Reg RS = gpr.R(value);
@ -242,41 +242,23 @@ void JitArm64::SafeStoreFromReg(s32 dest, u32 value, s32 regOffset, u32 flags, s
if (accessSize != 8)
WA = gpr.GetReg();
u64 base_ptr = std::min((u64)&GPFifo::m_gatherPipeCount, (u64)&GPFifo::m_gatherPipe);
u32 count_off = (u64)&GPFifo::m_gatherPipeCount - base_ptr;
u32 pipe_off = (u64)&GPFifo::m_gatherPipe - base_ptr;
MOVI2R(X30, base_ptr);
if (pipe_off)
ADD(X1, X30, pipe_off);
LDR(INDEX_UNSIGNED, W0, X30, count_off);
MOVP2R(X1, &GPFifo::g_gather_pipe_ptr);
LDR(INDEX_UNSIGNED, X0, X1, 0);
if (accessSize == 32)
{
REV32(WA, RS);
if (pipe_off)
STR(WA, X1, ArithOption(X0));
else
STR(WA, X30, ArithOption(X0));
STR(INDEX_POST, WA, X0, 4);
}
else if (accessSize == 16)
{
REV16(WA, RS);
if (pipe_off)
STRH(WA, X1, ArithOption(X0));
else
STRH(WA, X30, ArithOption(X0));
STRH(INDEX_POST, WA, X0, 2);
}
else
{
if (pipe_off)
STRB(RS, X1, ArithOption(X0));
else
STRB(RS, X30, ArithOption(X0));
STRB(INDEX_POST, WA, X0, 1);
}
ADD(W0, W0, accessSize >> 3);
STR(INDEX_UNSIGNED, W0, X30, count_off);
STR(INDEX_UNSIGNED, X0, X1, 0);
js.fifoBytesSinceCheck += accessSize >> 3;
if (accessSize != 8)
@ -300,7 +282,7 @@ void JitArm64::SafeStoreFromReg(s32 dest, u32 value, s32 regOffset, u32 flags, s
EmitBackpatchRoutine(flags, jo.fastmem, jo.fastmem, RS, XA, regs_in_use, fprs_in_use);
}
gpr.Unlock(W0, W1, W30);
gpr.Unlock(W0, W1);
}
void JitArm64::lXX(UGeckoInstruction inst)

View file

@ -241,7 +241,7 @@ void JitArm64::stfXX(UGeckoInstruction inst)
u32 imm_addr = 0;
bool is_immediate = false;
gpr.Lock(W0, W1, W30);
gpr.Lock(W0, W1);
fpr.Lock(Q0);
bool single = (flags & BackPatchInfo::FLAG_SIZE_F32) && fpr.IsSingle(inst.FS, true);
@ -357,16 +357,8 @@ void JitArm64::stfXX(UGeckoInstruction inst)
else
accessSize = 32;
u64 base_ptr = std::min((u64)&GPFifo::m_gatherPipeCount, (u64)&GPFifo::m_gatherPipe);
u32 count_off = (u64)&GPFifo::m_gatherPipeCount - base_ptr;
u32 pipe_off = (u64)&GPFifo::m_gatherPipe - base_ptr;
MOVI2R(X30, base_ptr);
if (pipe_off)
ADD(X1, X30, pipe_off);
LDR(INDEX_UNSIGNED, W0, X30, count_off);
MOVP2R(X1, &GPFifo::g_gather_pipe_ptr);
LDR(INDEX_UNSIGNED, X0, X1, 0);
if (flags & BackPatchInfo::FLAG_SIZE_F64)
{
m_float_emit.REV64(8, Q0, V0);
@ -381,17 +373,9 @@ void JitArm64::stfXX(UGeckoInstruction inst)
m_float_emit.REV32(8, D0, V0);
}
if (pipe_off)
{
m_float_emit.STR(accessSize, accessSize == 64 ? Q0 : D0, X1, ArithOption(X0));
}
else
{
m_float_emit.STR(accessSize, accessSize == 64 ? Q0 : D0, X30, ArithOption(X0));
}
m_float_emit.STR(accessSize, INDEX_POST, accessSize == 64 ? Q0 : D0, X0, accessSize >> 3);
ADD(W0, W0, accessSize >> 3);
STR(INDEX_UNSIGNED, W0, X30, count_off);
STR(INDEX_UNSIGNED, X0, X1, 0);
js.fifoBytesSinceCheck += accessSize >> 3;
if (update)
@ -414,6 +398,6 @@ void JitArm64::stfXX(UGeckoInstruction inst)
{
EmitBackpatchRoutine(flags, jo.fastmem, jo.fastmem, V0, XA, regs_in_use, fprs_in_use);
}
gpr.Unlock(W0, W1, W30);
gpr.Unlock(W0, W1);
fpr.Unlock(Q0);
}