jit: fix linux
This commit is contained in:
parent
24aff49ae4
commit
0ff79ea2ad
|
@ -154,13 +154,13 @@ void Compiler::A_Comp_Arith()
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
case 0x0: // AND
|
case 0x0: // AND
|
||||||
Comp_ArithTriOp(AND, rd, rn, op2, carryUsed, opSymmetric|sFlag);
|
Comp_ArithTriOp(&Compiler::AND, rd, rn, op2, carryUsed, opSymmetric|sFlag);
|
||||||
break;
|
break;
|
||||||
case 0x1: // EOR
|
case 0x1: // EOR
|
||||||
Comp_ArithTriOp(XOR, rd, rn, op2, carryUsed, opSymmetric|sFlag);
|
Comp_ArithTriOp(&Compiler::XOR, rd, rn, op2, carryUsed, opSymmetric|sFlag);
|
||||||
break;
|
break;
|
||||||
case 0x2: // SUB
|
case 0x2: // SUB
|
||||||
Comp_ArithTriOp(SUB, rd, rn, op2, carryUsed, sFlag|opRetriveCV|opInvertCarry);
|
Comp_ArithTriOp(&Compiler::SUB, rd, rn, op2, carryUsed, sFlag|opRetriveCV|opInvertCarry);
|
||||||
break;
|
break;
|
||||||
case 0x3: // RSB
|
case 0x3: // RSB
|
||||||
if (op2.IsZero())
|
if (op2.IsZero())
|
||||||
|
@ -172,25 +172,25 @@ void Compiler::A_Comp_Arith()
|
||||||
Comp_RetriveFlags(true, true, false);
|
Comp_RetriveFlags(true, true, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Comp_ArithTriOpReverse(SUB, rd, rn, op2, carryUsed, sFlag|opRetriveCV|opInvertCarry);
|
Comp_ArithTriOpReverse(&Compiler::SUB, rd, rn, op2, carryUsed, sFlag|opRetriveCV|opInvertCarry);
|
||||||
break;
|
break;
|
||||||
case 0x4: // ADD
|
case 0x4: // ADD
|
||||||
Comp_ArithTriOp(ADD, rd, rn, op2, carryUsed, opSymmetric|sFlag|opRetriveCV);
|
Comp_ArithTriOp(&Compiler::ADD, rd, rn, op2, carryUsed, opSymmetric|sFlag|opRetriveCV);
|
||||||
break;
|
break;
|
||||||
case 0x5: // ADC
|
case 0x5: // ADC
|
||||||
Comp_ArithTriOp(ADC, rd, rn, op2, carryUsed, opSymmetric|sFlag|opRetriveCV|opSyncCarry);
|
Comp_ArithTriOp(&Compiler::ADC, rd, rn, op2, carryUsed, opSymmetric|sFlag|opRetriveCV|opSyncCarry);
|
||||||
break;
|
break;
|
||||||
case 0x6: // SBC
|
case 0x6: // SBC
|
||||||
Comp_ArithTriOp(SBB, rd, rn, op2, carryUsed, opSymmetric|sFlag|opRetriveCV|opSyncCarry|opInvertCarry);
|
Comp_ArithTriOp(&Compiler::SBB, rd, rn, op2, carryUsed, opSymmetric|sFlag|opRetriveCV|opSyncCarry|opInvertCarry);
|
||||||
break;
|
break;
|
||||||
case 0x7: // RSC
|
case 0x7: // RSC
|
||||||
Comp_ArithTriOpReverse(SBB, rd, rn, op2, carryUsed, sFlag|opRetriveCV|opInvertCarry|opSyncCarry);
|
Comp_ArithTriOpReverse(&Compiler::SBB, rd, rn, op2, carryUsed, sFlag|opRetriveCV|opInvertCarry|opSyncCarry);
|
||||||
break;
|
break;
|
||||||
case 0xC: // ORR
|
case 0xC: // ORR
|
||||||
Comp_ArithTriOp(OR, rd, rn, op2, carryUsed, opSymmetric|sFlag);
|
Comp_ArithTriOp(&Compiler::OR, rd, rn, op2, carryUsed, opSymmetric|sFlag);
|
||||||
break;
|
break;
|
||||||
case 0xE: // BIC
|
case 0xE: // BIC
|
||||||
Comp_ArithTriOp(AND, rd, rn, op2, carryUsed, sFlag|opSymmetric|opInvertOp2);
|
Comp_ArithTriOp(&Compiler::AND, rd, rn, op2, carryUsed, sFlag|opSymmetric|opInvertOp2);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert("unimplemented");
|
assert("unimplemented");
|
||||||
|
@ -392,11 +392,11 @@ OpArg Compiler::Comp_RegShiftReg(int op, Gen::OpArg rs, Gen::OpArg rm, bool S, b
|
||||||
{
|
{
|
||||||
void (Compiler::*shiftOp)(int, const OpArg&, const OpArg&) = NULL;
|
void (Compiler::*shiftOp)(int, const OpArg&, const OpArg&) = NULL;
|
||||||
if (op == 0)
|
if (op == 0)
|
||||||
shiftOp = SHL;
|
shiftOp = &Compiler::SHL;
|
||||||
else if (op == 1)
|
else if (op == 1)
|
||||||
shiftOp = SHR;
|
shiftOp = &Compiler::SHR;
|
||||||
else if (op == 2)
|
else if (op == 2)
|
||||||
shiftOp = SAR;
|
shiftOp = &Compiler::SAR;
|
||||||
|
|
||||||
CMP(32, R(ECX), Imm8(32));
|
CMP(32, R(ECX), Imm8(32));
|
||||||
FixupBranch lt32 = J_CC(CC_L);
|
FixupBranch lt32 = J_CC(CC_L);
|
||||||
|
@ -539,9 +539,9 @@ void Compiler::T_Comp_AddSub_()
|
||||||
Comp_AddCycles_C();
|
Comp_AddCycles_C();
|
||||||
|
|
||||||
if (op & 1)
|
if (op & 1)
|
||||||
Comp_ArithTriOp(SUB, rd, rs, rn, false, opSetsFlags|opInvertCarry|opRetriveCV);
|
Comp_ArithTriOp(&Compiler::SUB, rd, rs, rn, false, opSetsFlags|opInvertCarry|opRetriveCV);
|
||||||
else
|
else
|
||||||
Comp_ArithTriOp(ADD, rd, rs, rn, false, opSetsFlags|opSymmetric|opRetriveCV);
|
Comp_ArithTriOp(&Compiler::ADD, rd, rs, rn, false, opSetsFlags|opSymmetric|opRetriveCV);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Compiler::T_Comp_ALU_Imm8()
|
void Compiler::T_Comp_ALU_Imm8()
|
||||||
|
@ -564,10 +564,10 @@ void Compiler::T_Comp_ALU_Imm8()
|
||||||
Comp_CmpOp(2, rd, imm, false);
|
Comp_CmpOp(2, rd, imm, false);
|
||||||
return;
|
return;
|
||||||
case 0x2:
|
case 0x2:
|
||||||
Comp_ArithTriOp(ADD, rd, rd, imm, false, opSetsFlags|opSymmetric|opRetriveCV);
|
Comp_ArithTriOp(&Compiler::ADD, rd, rd, imm, false, opSetsFlags|opSymmetric|opRetriveCV);
|
||||||
return;
|
return;
|
||||||
case 0x3:
|
case 0x3:
|
||||||
Comp_ArithTriOp(SUB, rd, rd, imm, false, opSetsFlags|opInvertCarry|opRetriveCV);
|
Comp_ArithTriOp(&Compiler::SUB, rd, rd, imm, false, opSetsFlags|opInvertCarry|opRetriveCV);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -594,10 +594,10 @@ void Compiler::T_Comp_ALU()
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
case 0x0: // AND
|
case 0x0: // AND
|
||||||
Comp_ArithTriOp(AND, rd, rd, rs, false, opSetsFlags|opSymmetric);
|
Comp_ArithTriOp(&Compiler::AND, rd, rd, rs, false, opSetsFlags|opSymmetric);
|
||||||
return;
|
return;
|
||||||
case 0x1: // EOR
|
case 0x1: // EOR
|
||||||
Comp_ArithTriOp(XOR, rd, rd, rs, false, opSetsFlags|opSymmetric);
|
Comp_ArithTriOp(&Compiler::XOR, rd, rd, rs, false, opSetsFlags|opSymmetric);
|
||||||
return;
|
return;
|
||||||
case 0x2:
|
case 0x2:
|
||||||
case 0x3:
|
case 0x3:
|
||||||
|
@ -613,10 +613,10 @@ void Compiler::T_Comp_ALU()
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case 0x5: // ADC
|
case 0x5: // ADC
|
||||||
Comp_ArithTriOp(ADC, rd, rd, rs, false, opSetsFlags|opSymmetric|opSyncCarry|opRetriveCV);
|
Comp_ArithTriOp(&Compiler::ADC, rd, rd, rs, false, opSetsFlags|opSymmetric|opSyncCarry|opRetriveCV);
|
||||||
return;
|
return;
|
||||||
case 0x6: // SBC
|
case 0x6: // SBC
|
||||||
Comp_ArithTriOp(SBB, rd, rd, rs, false, opSetsFlags|opSyncCarry|opInvertCarry|opRetriveCV);
|
Comp_ArithTriOp(&Compiler::SBB, rd, rd, rs, false, opSetsFlags|opSyncCarry|opInvertCarry|opRetriveCV);
|
||||||
return;
|
return;
|
||||||
case 0x8: // TST
|
case 0x8: // TST
|
||||||
Comp_CmpOp(0, rd, rs, false);
|
Comp_CmpOp(0, rd, rs, false);
|
||||||
|
@ -634,10 +634,10 @@ void Compiler::T_Comp_ALU()
|
||||||
Comp_CmpOp(3, rd, rs, false);
|
Comp_CmpOp(3, rd, rs, false);
|
||||||
return;
|
return;
|
||||||
case 0xC: // ORR
|
case 0xC: // ORR
|
||||||
Comp_ArithTriOp(OR, rd, rd, rs, false, opSetsFlags|opSymmetric);
|
Comp_ArithTriOp(&Compiler::OR, rd, rd, rs, false, opSetsFlags|opSymmetric);
|
||||||
return;
|
return;
|
||||||
case 0xE: // BIC
|
case 0xE: // BIC
|
||||||
Comp_ArithTriOp(AND, rd, rd, rs, false, opSetsFlags|opSymmetric|opInvertOp2);
|
Comp_ArithTriOp(&Compiler::AND, rd, rd, rs, false, opSetsFlags|opSymmetric|opInvertOp2);
|
||||||
return;
|
return;
|
||||||
case 0xF: // MVN
|
case 0xF: // MVN
|
||||||
if (rd != rs)
|
if (rd != rs)
|
||||||
|
@ -663,7 +663,7 @@ void Compiler::T_Comp_ALU_HiReg()
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
case 0x0: // ADD
|
case 0x0: // ADD
|
||||||
Comp_ArithTriOp(ADD, rdMapped, rdMapped, rs, false, opSymmetric|opRetriveCV);
|
Comp_ArithTriOp(&Compiler::ADD, rdMapped, rdMapped, rs, false, opSymmetric|opRetriveCV);
|
||||||
break;
|
break;
|
||||||
case 0x1: // CMP
|
case 0x1: // CMP
|
||||||
Comp_CmpOp(2, rdMapped, rs, false);
|
Comp_CmpOp(2, rdMapped, rs, false);
|
||||||
|
|
|
@ -118,7 +118,7 @@ void Compiler::Comp_JumpTo(u32 addr, bool forceNonConstantCycles)
|
||||||
|
|
||||||
if (setupRegion)
|
if (setupRegion)
|
||||||
{
|
{
|
||||||
MOV(32, R(ABI_PARAM1), R(RCPU));
|
MOV(64, R(ABI_PARAM1), R(RCPU));
|
||||||
MOV(32, R(ABI_PARAM2), Imm32(newPC));
|
MOV(32, R(ABI_PARAM2), Imm32(newPC));
|
||||||
CALL((void*)&ARMv5::SetupCodeMem);
|
CALL((void*)&ARMv5::SetupCodeMem);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,12 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#else
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace Gen;
|
using namespace Gen;
|
||||||
|
|
||||||
namespace ARMJIT
|
namespace ARMJIT
|
||||||
|
@ -28,9 +34,34 @@ const int RegisterCache<Compiler, X64Reg>::NativeRegsAvailable =
|
||||||
|
|
||||||
int instructionPopularityARM[ARMInstrInfo::ak_Count];
|
int instructionPopularityARM[ARMInstrInfo::ak_Count];
|
||||||
|
|
||||||
|
/*
|
||||||
|
We'll repurpose this .bss memory
|
||||||
|
|
||||||
|
*/
|
||||||
|
u8 CodeMemory[1024 * 1024 * 32];
|
||||||
|
|
||||||
Compiler::Compiler()
|
Compiler::Compiler()
|
||||||
{
|
{
|
||||||
AllocCodeSpace(1024 * 1024 * 16);
|
#ifdef _WIN32
|
||||||
|
#else
|
||||||
|
u64 pagesize = sysconf(_SC_PAGE_SIZE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
u8* pageAligned = (u8*)(((u64)CodeMemory & ~(pagesize - 1)) + pagesize);
|
||||||
|
u64 alignedSize = (((u64)CodeMemory + sizeof(CodeMemory)) & ~(pagesize - 1)) - (u64)pageAligned;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#else
|
||||||
|
mprotect(pageAligned, alignedSize, PROT_EXEC | PROT_READ | PROT_WRITE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
region = pageAligned;
|
||||||
|
region_size = alignedSize;
|
||||||
|
total_region_size = region_size;
|
||||||
|
|
||||||
|
ClearCodeSpace();
|
||||||
|
|
||||||
|
SetCodePtr(pageAligned);
|
||||||
|
|
||||||
memset(instructionPopularityARM, 0, sizeof(instructionPopularityARM));
|
memset(instructionPopularityARM, 0, sizeof(instructionPopularityARM));
|
||||||
|
|
||||||
|
@ -187,6 +218,124 @@ Gen::FixupBranch Compiler::CheckCondition(u32 cond)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define F(x) &Compiler::x
|
||||||
|
const Compiler::CompileFunc A_Comp[ARMInstrInfo::ak_Count] =
|
||||||
|
{
|
||||||
|
// AND
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
// EOR
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
// SUB
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
// RSB
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
// ADD
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
// ADC
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
// SBC
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
// RSC
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
// ORR
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
// MOV
|
||||||
|
F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp),
|
||||||
|
F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp),
|
||||||
|
// BIC
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith), F(A_Comp_Arith),
|
||||||
|
// MVN
|
||||||
|
F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp),
|
||||||
|
F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp), F(A_Comp_MovOp),
|
||||||
|
// TST
|
||||||
|
F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp),
|
||||||
|
// TEQ
|
||||||
|
F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp),
|
||||||
|
// CMP
|
||||||
|
F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp),
|
||||||
|
// CMN
|
||||||
|
F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp),
|
||||||
|
// Mul
|
||||||
|
F(A_Comp_MUL_MLA), F(A_Comp_MUL_MLA), NULL, NULL, NULL, F(A_Comp_SMULL_SMLAL), NULL, NULL, NULL, NULL, NULL,
|
||||||
|
// ARMv5 stuff
|
||||||
|
F(A_Comp_CLZ), NULL, NULL, NULL, NULL,
|
||||||
|
// STR
|
||||||
|
F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB),
|
||||||
|
// STRB
|
||||||
|
F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB),
|
||||||
|
// LDR
|
||||||
|
F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB),
|
||||||
|
// LDRB
|
||||||
|
F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB), F(A_Comp_MemWB),
|
||||||
|
// STRH
|
||||||
|
F(A_Comp_MemHalf), F(A_Comp_MemHalf), F(A_Comp_MemHalf), F(A_Comp_MemHalf),
|
||||||
|
// LDRD, STRD never used by anything so they stay interpreted (by anything I mean the 5 games I checked)
|
||||||
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||||
|
// LDRH
|
||||||
|
F(A_Comp_MemHalf), F(A_Comp_MemHalf), F(A_Comp_MemHalf), F(A_Comp_MemHalf),
|
||||||
|
// LDRSB
|
||||||
|
F(A_Comp_MemHalf), F(A_Comp_MemHalf), F(A_Comp_MemHalf), F(A_Comp_MemHalf),
|
||||||
|
// LDRSH
|
||||||
|
F(A_Comp_MemHalf), F(A_Comp_MemHalf), F(A_Comp_MemHalf), F(A_Comp_MemHalf),
|
||||||
|
// swap
|
||||||
|
NULL, NULL,
|
||||||
|
// LDM/STM
|
||||||
|
F(A_Comp_LDM_STM), F(A_Comp_LDM_STM),
|
||||||
|
// Branch
|
||||||
|
F(A_Comp_BranchImm), F(A_Comp_BranchImm), F(A_Comp_BranchImm), F(A_Comp_BranchXchangeReg), F(A_Comp_BranchXchangeReg),
|
||||||
|
// system stuff
|
||||||
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
const Compiler::CompileFunc T_Comp[ARMInstrInfo::tk_Count] = {
|
||||||
|
// Shift imm
|
||||||
|
F(T_Comp_ShiftImm), F(T_Comp_ShiftImm), F(T_Comp_ShiftImm),
|
||||||
|
// Three operand ADD/SUB
|
||||||
|
F(T_Comp_AddSub_), F(T_Comp_AddSub_), F(T_Comp_AddSub_), F(T_Comp_AddSub_),
|
||||||
|
// 8 bit imm
|
||||||
|
F(T_Comp_ALU_Imm8), F(T_Comp_ALU_Imm8), F(T_Comp_ALU_Imm8), F(T_Comp_ALU_Imm8),
|
||||||
|
// general ALU
|
||||||
|
F(T_Comp_ALU), F(T_Comp_ALU), F(T_Comp_ALU), F(T_Comp_ALU),
|
||||||
|
F(T_Comp_ALU), F(T_Comp_ALU), F(T_Comp_ALU), F(T_Comp_ALU),
|
||||||
|
F(T_Comp_ALU), F(T_Comp_ALU), F(T_Comp_ALU), F(T_Comp_ALU),
|
||||||
|
F(T_Comp_ALU), F(T_Comp_MUL), F(T_Comp_ALU), F(T_Comp_ALU),
|
||||||
|
// hi reg
|
||||||
|
F(T_Comp_ALU_HiReg), F(T_Comp_ALU_HiReg), F(T_Comp_ALU_HiReg),
|
||||||
|
// pc/sp relative
|
||||||
|
F(T_Comp_RelAddr), F(T_Comp_RelAddr), F(T_Comp_AddSP),
|
||||||
|
// LDR pcrel
|
||||||
|
F(T_Comp_LoadPCRel),
|
||||||
|
// LDR/STR reg offset
|
||||||
|
F(T_Comp_MemReg), F(T_Comp_MemReg), F(T_Comp_MemReg), F(T_Comp_MemReg),
|
||||||
|
// LDR/STR sign extended, half
|
||||||
|
F(T_Comp_MemRegHalf), F(T_Comp_MemRegHalf), F(T_Comp_MemRegHalf), F(T_Comp_MemRegHalf),
|
||||||
|
// LDR/STR imm offset
|
||||||
|
F(T_Comp_MemImm), F(T_Comp_MemImm), F(T_Comp_MemImm), F(T_Comp_MemImm),
|
||||||
|
// LDR/STR half imm offset
|
||||||
|
F(T_Comp_MemImmHalf), F(T_Comp_MemImmHalf),
|
||||||
|
// LDR/STR sp rel
|
||||||
|
F(T_Comp_MemSPRel), F(T_Comp_MemSPRel),
|
||||||
|
// PUSH/POP
|
||||||
|
F(T_Comp_PUSH_POP), F(T_Comp_PUSH_POP),
|
||||||
|
// LDMIA, STMIA
|
||||||
|
F(T_Comp_LDMIA_STMIA), F(T_Comp_LDMIA_STMIA),
|
||||||
|
// Branch
|
||||||
|
F(T_Comp_BCOND), F(T_Comp_BranchXchangeReg), F(T_Comp_BranchXchangeReg), F(T_Comp_B), F(T_Comp_BL_LONG_1), F(T_Comp_BL_LONG_2),
|
||||||
|
// Unk, SVC
|
||||||
|
NULL, NULL
|
||||||
|
};
|
||||||
|
#undef F
|
||||||
|
|
||||||
CompiledBlock Compiler::CompileBlock(ARM* cpu, FetchedInstr instrs[], int instrsCount)
|
CompiledBlock Compiler::CompileBlock(ARM* cpu, FetchedInstr instrs[], int instrsCount)
|
||||||
{
|
{
|
||||||
if (IsAlmostFull())
|
if (IsAlmostFull())
|
||||||
|
@ -206,7 +355,7 @@ CompiledBlock Compiler::CompileBlock(ARM* cpu, FetchedInstr instrs[], int instrs
|
||||||
|
|
||||||
bool mergedThumbBL = false;
|
bool mergedThumbBL = false;
|
||||||
|
|
||||||
ABI_PushRegistersAndAdjustStack({ABI_ALL_CALLEE_SAVED & ABI_ALL_GPRS}, 8, 16);
|
ABI_PushRegistersAndAdjustStack(BitSet32(ABI_ALL_CALLEE_SAVED & ABI_ALL_GPRS & ~RSP), 8);
|
||||||
|
|
||||||
MOV(64, R(RCPU), ImmPtr(cpu));
|
MOV(64, R(RCPU), ImmPtr(cpu));
|
||||||
|
|
||||||
|
@ -220,7 +369,9 @@ CompiledBlock Compiler::CompileBlock(ARM* cpu, FetchedInstr instrs[], int instrs
|
||||||
R15 += Thumb ? 2 : 4;
|
R15 += Thumb ? 2 : 4;
|
||||||
CurInstr = instrs[i];
|
CurInstr = instrs[i];
|
||||||
|
|
||||||
CompileFunc comp = GetCompFunc(CurInstr.Info.Kind);
|
CompileFunc comp = Thumb
|
||||||
|
? T_Comp[CurInstr.Info.Kind]
|
||||||
|
: A_Comp[CurInstr.Info.Kind];
|
||||||
|
|
||||||
if (!Thumb)
|
if (!Thumb)
|
||||||
instructionPopularityARM[CurInstr.Info.Kind] += comp == NULL;
|
instructionPopularityARM[CurInstr.Info.Kind] += comp == NULL;
|
||||||
|
@ -318,139 +469,12 @@ CompiledBlock Compiler::CompileBlock(ARM* cpu, FetchedInstr instrs[], int instrs
|
||||||
|
|
||||||
MOV(32, R(RAX), Imm32(ConstantCycles));
|
MOV(32, R(RAX), Imm32(ConstantCycles));
|
||||||
|
|
||||||
ABI_PopRegistersAndAdjustStack({ABI_ALL_CALLEE_SAVED & ABI_ALL_GPRS}, 8, 16);
|
ABI_PopRegistersAndAdjustStack(BitSet32(ABI_ALL_CALLEE_SAVED & ABI_ALL_GPRS & ~RSP), 8);
|
||||||
RET();
|
RET();
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
CompileFunc Compiler::GetCompFunc(int kind)
|
|
||||||
{
|
|
||||||
// this might look like waste of space, so many repeatitions, but it's invaluable for debugging.
|
|
||||||
// see ARMInstrInfo.h for the order
|
|
||||||
CompileFunc const A_Comp[ARMInstrInfo::ak_Count] =
|
|
||||||
{
|
|
||||||
// AND
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
// EOR
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
// SUB
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
// RSB
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
// ADD
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
// ADC
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
// SBC
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
// RSC
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
// ORR
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
// MOV
|
|
||||||
A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp,
|
|
||||||
A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp,
|
|
||||||
// BIC
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith, A_Comp_Arith,
|
|
||||||
// MVN
|
|
||||||
A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp,
|
|
||||||
A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp, A_Comp_MovOp,
|
|
||||||
// TST
|
|
||||||
A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp,
|
|
||||||
// TEQ
|
|
||||||
A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp,
|
|
||||||
// CMP
|
|
||||||
A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp,
|
|
||||||
// CMN
|
|
||||||
A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp, A_Comp_CmpOp,
|
|
||||||
// Mul
|
|
||||||
A_Comp_MUL_MLA, A_Comp_MUL_MLA, NULL, NULL, NULL, A_Comp_SMULL_SMLAL, NULL, NULL, NULL, NULL, NULL,
|
|
||||||
// ARMv5 stuff
|
|
||||||
A_Comp_CLZ, NULL, NULL, NULL, NULL,
|
|
||||||
// STR
|
|
||||||
A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB,
|
|
||||||
//NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
||||||
// STRB
|
|
||||||
//NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
||||||
A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB,
|
|
||||||
// LDR
|
|
||||||
//NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
||||||
A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB,
|
|
||||||
// LDRB
|
|
||||||
//NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
||||||
A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB, A_Comp_MemWB,
|
|
||||||
// STRH
|
|
||||||
A_Comp_MemHalf, A_Comp_MemHalf, A_Comp_MemHalf, A_Comp_MemHalf,
|
|
||||||
// LDRD, STRD never used by anything so they stay interpreted (by anything I mean the 5 games I checked)
|
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
||||||
// LDRH
|
|
||||||
A_Comp_MemHalf, A_Comp_MemHalf, A_Comp_MemHalf, A_Comp_MemHalf,
|
|
||||||
// LDRSB
|
|
||||||
A_Comp_MemHalf, A_Comp_MemHalf, A_Comp_MemHalf, A_Comp_MemHalf,
|
|
||||||
// LDRSH
|
|
||||||
A_Comp_MemHalf, A_Comp_MemHalf, A_Comp_MemHalf, A_Comp_MemHalf,
|
|
||||||
// swap
|
|
||||||
NULL, NULL,
|
|
||||||
// LDM/STM
|
|
||||||
A_Comp_LDM_STM, A_Comp_LDM_STM,
|
|
||||||
// Branch
|
|
||||||
A_Comp_BranchImm, A_Comp_BranchImm, A_Comp_BranchImm, A_Comp_BranchXchangeReg, A_Comp_BranchXchangeReg,
|
|
||||||
// system stuff
|
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
||||||
};
|
|
||||||
|
|
||||||
CompileFunc const T_Comp[ARMInstrInfo::tk_Count] = {
|
|
||||||
// Shift imm
|
|
||||||
T_Comp_ShiftImm, T_Comp_ShiftImm, T_Comp_ShiftImm,
|
|
||||||
// Three operand ADD/SUB
|
|
||||||
T_Comp_AddSub_, T_Comp_AddSub_, T_Comp_AddSub_, T_Comp_AddSub_,
|
|
||||||
// 8 bit imm
|
|
||||||
T_Comp_ALU_Imm8, T_Comp_ALU_Imm8, T_Comp_ALU_Imm8, T_Comp_ALU_Imm8,
|
|
||||||
// general ALU
|
|
||||||
T_Comp_ALU, T_Comp_ALU, T_Comp_ALU, T_Comp_ALU,
|
|
||||||
T_Comp_ALU, T_Comp_ALU, T_Comp_ALU, T_Comp_ALU,
|
|
||||||
T_Comp_ALU, T_Comp_ALU, T_Comp_ALU, T_Comp_ALU,
|
|
||||||
T_Comp_ALU, T_Comp_MUL, T_Comp_ALU, T_Comp_ALU,
|
|
||||||
// hi reg
|
|
||||||
T_Comp_ALU_HiReg, T_Comp_ALU_HiReg, T_Comp_ALU_HiReg,
|
|
||||||
// pc/sp relative
|
|
||||||
T_Comp_RelAddr, T_Comp_RelAddr, T_Comp_AddSP,
|
|
||||||
// LDR pcrel
|
|
||||||
T_Comp_LoadPCRel,
|
|
||||||
// LDR/STR reg offset
|
|
||||||
T_Comp_MemReg, T_Comp_MemReg, T_Comp_MemReg, T_Comp_MemReg,
|
|
||||||
// LDR/STR sign extended, half
|
|
||||||
T_Comp_MemRegHalf, T_Comp_MemRegHalf, T_Comp_MemRegHalf, T_Comp_MemRegHalf,
|
|
||||||
// LDR/STR imm offset
|
|
||||||
T_Comp_MemImm, T_Comp_MemImm, T_Comp_MemImm, T_Comp_MemImm,
|
|
||||||
// LDR/STR half imm offset
|
|
||||||
T_Comp_MemImmHalf, T_Comp_MemImmHalf,
|
|
||||||
// LDR/STR sp rel
|
|
||||||
T_Comp_MemSPRel, T_Comp_MemSPRel,
|
|
||||||
// PUSH/POP
|
|
||||||
T_Comp_PUSH_POP, T_Comp_PUSH_POP,
|
|
||||||
// LDMIA, STMIA
|
|
||||||
T_Comp_LDMIA_STMIA, T_Comp_LDMIA_STMIA,
|
|
||||||
// Branch
|
|
||||||
T_Comp_BCOND, T_Comp_BranchXchangeReg, T_Comp_BranchXchangeReg, T_Comp_B, T_Comp_BL_LONG_1, T_Comp_BL_LONG_2,
|
|
||||||
// Unk, SVC
|
|
||||||
NULL, NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
return Thumb ? T_Comp[kind] : A_Comp[kind];
|
|
||||||
}
|
|
||||||
|
|
||||||
void Compiler::Comp_AddCycles_C(bool forceNonConstant)
|
void Compiler::Comp_AddCycles_C(bool forceNonConstant)
|
||||||
{
|
{
|
||||||
s32 cycles = Num ?
|
s32 cycles = Num ?
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
#include "../ARMJIT.h"
|
#include "../ARMJIT.h"
|
||||||
#include "../ARMJIT_RegisterCache.h"
|
#include "../ARMJIT_RegisterCache.h"
|
||||||
|
|
||||||
#include <tuple>
|
|
||||||
|
|
||||||
namespace ARMJIT
|
namespace ARMJIT
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -18,9 +16,6 @@ const Gen::X64Reg RSCRATCH = Gen::EAX;
|
||||||
const Gen::X64Reg RSCRATCH2 = Gen::EDX;
|
const Gen::X64Reg RSCRATCH2 = Gen::EDX;
|
||||||
const Gen::X64Reg RSCRATCH3 = Gen::ECX;
|
const Gen::X64Reg RSCRATCH3 = Gen::ECX;
|
||||||
|
|
||||||
class Compiler;
|
|
||||||
|
|
||||||
typedef void (Compiler::*CompileFunc)();
|
|
||||||
|
|
||||||
class Compiler : public Gen::X64CodeBlock
|
class Compiler : public Gen::X64CodeBlock
|
||||||
{
|
{
|
||||||
|
@ -32,8 +27,7 @@ public:
|
||||||
void LoadReg(int reg, Gen::X64Reg nativeReg);
|
void LoadReg(int reg, Gen::X64Reg nativeReg);
|
||||||
void SaveReg(int reg, Gen::X64Reg nativeReg);
|
void SaveReg(int reg, Gen::X64Reg nativeReg);
|
||||||
|
|
||||||
private:
|
typedef void (Compiler::*CompileFunc)();
|
||||||
CompileFunc GetCompFunc(int kind);
|
|
||||||
|
|
||||||
void Comp_JumpTo(Gen::X64Reg addr, bool restoreCPSR = false);
|
void Comp_JumpTo(Gen::X64Reg addr, bool restoreCPSR = false);
|
||||||
void Comp_JumpTo(u32 addr, bool forceNonConstantCycles = false);
|
void Comp_JumpTo(u32 addr, bool forceNonConstantCycles = false);
|
||||||
|
|
|
@ -464,9 +464,6 @@ void printStuff2(u32 a, u32 b)
|
||||||
|
|
||||||
s32 Compiler::Comp_MemAccessBlock(int rn, BitSet16 regs, bool store, bool preinc, bool decrement, bool usermode)
|
s32 Compiler::Comp_MemAccessBlock(int rn, BitSet16 regs, bool store, bool preinc, bool decrement, bool usermode)
|
||||||
{
|
{
|
||||||
FILE* f;
|
|
||||||
const u8* start = GetCodePtr();
|
|
||||||
|
|
||||||
int regsCount = regs.Count();
|
int regsCount = regs.Count();
|
||||||
|
|
||||||
if (decrement)
|
if (decrement)
|
||||||
|
@ -482,11 +479,12 @@ s32 Compiler::Comp_MemAccessBlock(int rn, BitSet16 regs, bool store, bool preinc
|
||||||
u32 cycles = Num
|
u32 cycles = Num
|
||||||
? NDS::ARM7MemTimings[CurInstr.CodeCycles][Thumb ? 0 : 2]
|
? NDS::ARM7MemTimings[CurInstr.CodeCycles][Thumb ? 0 : 2]
|
||||||
: (R15 & 0x2 ? 0 : CurInstr.CodeCycles);
|
: (R15 & 0x2 ? 0 : CurInstr.CodeCycles);
|
||||||
|
|
||||||
MOV(32, R(ABI_PARAM4), Imm32(cycles));
|
MOV(32, R(ABI_PARAM4), Imm32(cycles));
|
||||||
if (!store)
|
if (!store)
|
||||||
{
|
{
|
||||||
MOV(32, R(ABI_PARAM3), Imm32(regsCount));
|
MOV(32, R(ABI_PARAM3), Imm32(regsCount));
|
||||||
SUB(32, R(RSP), regsCount < 16 ? Imm8(regsCount * 8) : Imm32(regsCount * 8));
|
SUB(64, R(RSP), regsCount < 16 ? Imm8(regsCount * 8) : Imm32(regsCount * 8));
|
||||||
MOV(64, R(ABI_PARAM2), R(RSP));
|
MOV(64, R(ABI_PARAM2), R(RSP));
|
||||||
|
|
||||||
CALL(Num == 0
|
CALL(Num == 0
|
||||||
|
@ -581,14 +579,7 @@ s32 Compiler::Comp_MemAccessBlock(int rn, BitSet16 regs, bool store, bool preinc
|
||||||
? MemoryFuncsSeq9[1][preinc]
|
? MemoryFuncsSeq9[1][preinc]
|
||||||
: MemoryFuncsSeq7[1][preinc][CodeRegion == 0x02]);
|
: MemoryFuncsSeq7[1][preinc][CodeRegion == 0x02]);
|
||||||
|
|
||||||
ADD(32, R(RSP), regsCount < 16 ? Imm8(regsCount * 8) : Imm32(regsCount * 8));
|
ADD(64, R(RSP), regsCount < 16 ? Imm8(regsCount * 8) : Imm32(regsCount * 8));
|
||||||
}
|
|
||||||
|
|
||||||
if (usermode && !store)
|
|
||||||
{
|
|
||||||
f= fopen("ldm", "a");
|
|
||||||
fwrite(start, GetCodePtr() - start, 1, f);
|
|
||||||
fclose(f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return offset;
|
return offset;
|
||||||
|
|
|
@ -4,12 +4,13 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#define PanicAlert(msg) \
|
#define PanicAlert(fmt, ...) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
printf("%s\n", msg); \
|
printf(fmt "\n", ## __VA_ARGS__); \
|
||||||
Crash(); \
|
abort(); \
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
|
|
||||||
#define DYNA_REC 0
|
#define DYNA_REC 0
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,9 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#define PanicAlert(fmt, ...) \
|
|
||||||
do \
|
|
||||||
{ \
|
|
||||||
printf(fmt "\n", ## __VA_ARGS__); \
|
|
||||||
abort(); \
|
|
||||||
} while (false)
|
|
||||||
|
|
||||||
#include "../types.h"
|
#include "../types.h"
|
||||||
#include "CommonFuncs.h"
|
#include "CommonFuncs.h"
|
||||||
|
#include "Log.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -39,8 +33,6 @@ namespace Common
|
||||||
|
|
||||||
void* AllocateExecutableMemory(size_t size)
|
void* AllocateExecutableMemory(size_t size)
|
||||||
{
|
{
|
||||||
printf("c\n");
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
void* ptr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
void* ptr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||||
#else
|
#else
|
||||||
|
@ -50,13 +42,10 @@ void* AllocateExecutableMemory(size_t size)
|
||||||
if (ptr == MAP_FAILED)
|
if (ptr == MAP_FAILED)
|
||||||
ptr = nullptr;
|
ptr = nullptr;
|
||||||
#endif
|
#endif
|
||||||
printf("a\n");
|
|
||||||
|
|
||||||
if (ptr == nullptr)
|
if (ptr == nullptr)
|
||||||
PanicAlert("Failed to allocate executable memory");
|
PanicAlert("Failed to allocate executable memory");
|
||||||
|
|
||||||
printf("b\n");
|
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue