[JIT]: Constant propagation doesn't need 2 layers + fix JUMP
This commit is contained in:
@@ -10,8 +10,7 @@ using namespace Xbyak::util;
|
||||
void JIT::lui(const u32 instr) {
|
||||
u64 val = static_cast<s64>(static_cast<s16>(instr));
|
||||
val <<= 16;
|
||||
regs.gpr[RT(instr)] = val;
|
||||
regs.gprIsConstant[RT(instr)] = true;
|
||||
regs.Write<s64>(RT(instr), val, true);
|
||||
}
|
||||
|
||||
void JIT::add(const u32 instr) {
|
||||
@@ -835,10 +834,9 @@ void JIT::dsubu(u32 instr) {
|
||||
|
||||
void JIT::j(const u32 instr) {
|
||||
const s32 target = (instr & 0x3ffffff) << 2;
|
||||
code.mov(code.rax, REG(qword, oldPC));
|
||||
code.and_(code.rax, ~0xfffffff);
|
||||
code.or_(code.rax, target);
|
||||
branch_abs(target, mp);
|
||||
const s64 oldPC = branchPC - 8;
|
||||
const s64 address = (oldPC & ~0xfffffff) | target;
|
||||
branch_abs_constant(true, address);
|
||||
}
|
||||
|
||||
void JIT::jr(const u32 instr) {
|
||||
|
||||
@@ -126,11 +126,9 @@ void Registers::Write<bool>(size_t idx, bool v, bool isConstant) {
|
||||
if (idx == 0)
|
||||
return;
|
||||
|
||||
bool oldIsConstant = gprIsConstant[idx];
|
||||
gprIsConstant[idx] = isConstant;
|
||||
|
||||
if (jit) {
|
||||
if (oldIsConstant) {
|
||||
gprIsConstant[idx] = isConstant;
|
||||
if (isConstant) {
|
||||
gpr[idx] = v;
|
||||
return;
|
||||
}
|
||||
@@ -153,11 +151,9 @@ void Registers::Write<u64>(size_t idx, u64 v, bool isConstant) {
|
||||
if (idx == 0)
|
||||
return;
|
||||
|
||||
bool oldIsConstant = gprIsConstant[idx];
|
||||
gprIsConstant[idx] = isConstant;
|
||||
|
||||
if (jit) {
|
||||
if (oldIsConstant) {
|
||||
gprIsConstant[idx] = isConstant;
|
||||
if (isConstant) {
|
||||
gpr[idx] = v;
|
||||
return;
|
||||
}
|
||||
@@ -185,11 +181,9 @@ void Registers::Write<u32>(size_t idx, u32 v, bool isConstant) {
|
||||
if (idx == 0)
|
||||
return;
|
||||
|
||||
bool oldIsConstant = gprIsConstant[idx];
|
||||
gprIsConstant[idx] = isConstant;
|
||||
|
||||
if (jit) {
|
||||
if (oldIsConstant) {
|
||||
gprIsConstant[idx] = isConstant;
|
||||
if (isConstant) {
|
||||
gpr[idx] = v;
|
||||
return;
|
||||
}
|
||||
@@ -213,11 +207,9 @@ void Registers::Write<s32>(size_t idx, s32 v, bool isConstant) {
|
||||
if (idx == 0)
|
||||
return;
|
||||
|
||||
bool oldIsConstant = gprIsConstant[idx];
|
||||
gprIsConstant[idx] = isConstant;
|
||||
|
||||
if (jit) {
|
||||
if (oldIsConstant) {
|
||||
gprIsConstant[idx] = isConstant;
|
||||
if (isConstant) {
|
||||
gpr[idx] = v;
|
||||
return;
|
||||
}
|
||||
@@ -240,11 +232,9 @@ void Registers::Write<u16>(size_t idx, u16 v, bool isConstant) {
|
||||
if (idx == 0)
|
||||
return;
|
||||
|
||||
bool oldIsConstant = gprIsConstant[idx];
|
||||
gprIsConstant[idx] = isConstant;
|
||||
|
||||
if (jit) {
|
||||
if (oldIsConstant) {
|
||||
gprIsConstant[idx] = isConstant;
|
||||
if (isConstant) {
|
||||
gpr[idx] = v;
|
||||
return;
|
||||
}
|
||||
@@ -268,11 +258,9 @@ void Registers::Write<s16>(size_t idx, s16 v, bool isConstant) {
|
||||
if (idx == 0)
|
||||
return;
|
||||
|
||||
bool oldIsConstant = gprIsConstant[idx];
|
||||
gprIsConstant[idx] = isConstant;
|
||||
|
||||
if (jit) {
|
||||
if (oldIsConstant) {
|
||||
gprIsConstant[idx] = isConstant;
|
||||
if (isConstant) {
|
||||
gpr[idx] = v;
|
||||
return;
|
||||
}
|
||||
@@ -295,11 +283,9 @@ void Registers::Write<u8>(size_t idx, u8 v, bool isConstant) {
|
||||
if (idx == 0)
|
||||
return;
|
||||
|
||||
bool oldIsConstant = gprIsConstant[idx];
|
||||
gprIsConstant[idx] = isConstant;
|
||||
|
||||
if (jit) {
|
||||
if (oldIsConstant) {
|
||||
gprIsConstant[idx] = isConstant;
|
||||
if (isConstant) {
|
||||
gpr[idx] = v;
|
||||
return;
|
||||
}
|
||||
@@ -323,11 +309,9 @@ void Registers::Write<s8>(size_t idx, s8 v, bool isConstant) {
|
||||
if (idx == 0)
|
||||
return;
|
||||
|
||||
bool oldIsConstant = gprIsConstant[idx];
|
||||
gprIsConstant[idx] = isConstant;
|
||||
|
||||
if (jit) {
|
||||
if (oldIsConstant) {
|
||||
gprIsConstant[idx] = isConstant;
|
||||
if (isConstant) {
|
||||
gpr[idx] = v;
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user