PGXP: Combine a couple of instructions

This commit is contained in:
Connor McLaughlin 2021-02-17 23:45:50 +10:00
parent 09805c1f80
commit efecb44344
3 changed files with 3 additions and 24 deletions

View file

@ -716,7 +716,7 @@ restart_instruction:
const u32 add_value = ReadReg(inst.r.rt);
const u32 new_value = old_value + add_value;
if constexpr (pgxp_mode >= PGXPMode::CPU)
PGXP::CPU_ADDU(inst.bits, new_value, old_value, add_value);
PGXP::CPU_ADD(inst.bits, new_value, old_value, add_value);
else if constexpr (pgxp_mode >= PGXPMode::Memory)
{
if (add_value == 0)
@ -752,7 +752,7 @@ restart_instruction:
{
const u32 new_value = ReadReg(inst.r.rs) - ReadReg(inst.r.rt);
if constexpr (pgxp_mode >= PGXPMode::CPU)
PGXP::CPU_SUBU(inst.bits, new_value, ReadReg(inst.r.rs), ReadReg(inst.r.rt));
PGXP::CPU_SUB(inst.bits, new_value, ReadReg(inst.r.rs), ReadReg(inst.r.rt));
WriteReg(inst.r.rd, new_value);
}
@ -1009,7 +1009,7 @@ restart_instruction:
const u32 new_value = old_value + add_value;
if constexpr (pgxp_mode >= PGXPMode::CPU)
PGXP::CPU_ADDIU(inst.bits, new_value, ReadReg(inst.i.rs));
PGXP::CPU_ADDI(inst.bits, new_value, ReadReg(inst.i.rs));
else if constexpr (pgxp_mode >= PGXPMode::Memory)
{
if (add_value == 0)

View file

@ -920,12 +920,6 @@ void CPU_ADDI(u32 instr, u32 rtVal, u32 rsVal)
CPU_reg[rt(instr)].value = rtVal;
}
void CPU_ADDIU(u32 instr, u32 rtVal, u32 rsVal)
{
// Rt = Rs + Imm (signed) (unsafe?)
CPU_ADDI(instr, rtVal, rsVal);
}
void CPU_ANDI(u32 instr, u32 rtVal, u32 rsVal)
{
// Rt = Rs & Imm
@ -1112,12 +1106,6 @@ void CPU_ADD(u32 instr, u32 rdVal, u32 rsVal, u32 rtVal)
CPU_reg[rd(instr)] = ret;
}
void CPU_ADDU(u32 instr, u32 rdVal, u32 rsVal, u32 rtVal)
{
// Rd = Rs + Rt (signed) (unsafe?)
CPU_ADD(instr, rdVal, rsVal, rtVal);
}
void CPU_SUB(u32 instr, u32 rdVal, u32 rsVal, u32 rtVal)
{
// Rd = Rs - Rt (signed)
@ -1156,12 +1144,6 @@ void CPU_SUB(u32 instr, u32 rdVal, u32 rsVal, u32 rtVal)
CPU_reg[rd(instr)] = ret;
}
void CPU_SUBU(u32 instr, u32 rdVal, u32 rsVal, u32 rtVal)
{
// Rd = Rs - Rt (signed) (unsafe?)
CPU_SUB(instr, rdVal, rsVal, rtVal);
}
void CPU_AND_(u32 instr, u32 rdVal, u32 rsVal, u32 rtVal)
{
// Rd = Rs & Rt

View file

@ -56,7 +56,6 @@ void CPU_MOVE(u32 rd_and_rs, u32 rsVal);
// Arithmetic with immediate value
void CPU_ADDI(u32 instr, u32 rtVal, u32 rsVal);
void CPU_ADDIU(u32 instr, u32 rtVal, u32 rsVal);
void CPU_ANDI(u32 instr, u32 rtVal, u32 rsVal);
void CPU_ORI(u32 instr, u32 rtVal, u32 rsVal);
void CPU_XORI(u32 instr, u32 rtVal, u32 rsVal);
@ -68,9 +67,7 @@ void CPU_LUI(u32 instr, u32 rtVal);
// Register Arithmetic
void CPU_ADD(u32 instr, u32 rdVal, u32 rsVal, u32 rtVal);
void CPU_ADDU(u32 instr, u32 rdVal, u32 rsVal, u32 rtVal);
void CPU_SUB(u32 instr, u32 rdVal, u32 rsVal, u32 rtVal);
void CPU_SUBU(u32 instr, u32 rdVal, u32 rsVal, u32 rtVal);
void CPU_AND_(u32 instr, u32 rdVal, u32 rsVal, u32 rtVal);
void CPU_OR_(u32 instr, u32 rdVal, u32 rsVal, u32 rtVal);
void CPU_XOR_(u32 instr, u32 rdVal, u32 rsVal, u32 rtVal);