Avoid GetCR/SetCR in the cr bitwise ops
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1597 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
347fc18542
commit
c4f27aaae1
|
@ -430,75 +430,42 @@ void mtspr(UGeckoInstruction _inst)
|
|||
|
||||
void crand(UGeckoInstruction _inst)
|
||||
{
|
||||
u32 cr = GetCR();
|
||||
u32 a = cr << _inst.CRBA;
|
||||
u32 b = cr << _inst.CRBB;
|
||||
u32 d = ((a & b) & 0x80000000) >> _inst.CRBD;
|
||||
SetCR(d | (cr & ~(0x80000000 >> _inst.CRBD)));
|
||||
SetCRBit(_inst.CRBD, GetCRBit(_inst.CRBA) & GetCRBit(_inst.CRBB));
|
||||
}
|
||||
|
||||
void crandc(UGeckoInstruction _inst)
|
||||
{
|
||||
u32 cr = GetCR();
|
||||
u32 a = cr << _inst.CRBA;
|
||||
u32 b = cr << _inst.CRBB;
|
||||
u32 d = ((a & ~b) & 0x80000000) >> _inst.CRBD;
|
||||
SetCR(d | (cr & ~(0x80000000 >> _inst.CRBD)));
|
||||
SetCRBit(_inst.CRBD, GetCRBit(_inst.CRBA) & (1 ^ GetCRBit(_inst.CRBB)));
|
||||
}
|
||||
|
||||
|
||||
void creqv(UGeckoInstruction _inst)
|
||||
{
|
||||
u32 cr = GetCR();
|
||||
u32 a = cr << _inst.CRBA;
|
||||
u32 b = cr << _inst.CRBB;
|
||||
u32 d = ((~(a ^ b)) & 0x80000000) >> _inst.CRBD;
|
||||
SetCR(d | (cr & ~(0x80000000 >> _inst.CRBD)));
|
||||
SetCRBit(_inst.CRBD, 1 ^ (GetCRBit(_inst.CRBA) ^ GetCRBit(_inst.CRBB)));
|
||||
}
|
||||
|
||||
void crnand(UGeckoInstruction _inst)
|
||||
{
|
||||
u32 cr = GetCR();
|
||||
u32 a = cr << _inst.CRBA;
|
||||
u32 b = cr << _inst.CRBB;
|
||||
u32 d = ((~(a & b)) & 0x80000000) >>_inst.CRBD;
|
||||
SetCR(d | (cr & ~(0x80000000 >> _inst.CRBD)));
|
||||
SetCRBit(_inst.CRBD, 1 ^ (GetCRBit(_inst.CRBA) & GetCRBit(_inst.CRBB)));
|
||||
}
|
||||
|
||||
void crnor(UGeckoInstruction _inst)
|
||||
{
|
||||
u32 cr = GetCR();
|
||||
u32 a = cr << _inst.CRBA;
|
||||
u32 b = cr << _inst.CRBB;
|
||||
u32 d = ((~(a | b)) & 0x80000000) >> _inst.CRBD;
|
||||
SetCR(d | (cr & ~(0x80000000 >> _inst.CRBD)));
|
||||
SetCRBit(_inst.CRBD, 1 ^ (GetCRBit(_inst.CRBA) | GetCRBit(_inst.CRBB)));
|
||||
}
|
||||
|
||||
void cror(UGeckoInstruction _inst)
|
||||
{
|
||||
u32 cr = GetCR();
|
||||
u32 a = cr << _inst.CRBA;
|
||||
u32 b = cr << _inst.CRBB;
|
||||
u32 d = ((a | b) & 0x80000000) >> _inst.CRBD;
|
||||
SetCR(d | (cr & ~(0x80000000 >> _inst.CRBD)));
|
||||
SetCRBit(_inst.CRBD, (GetCRBit(_inst.CRBA) | GetCRBit(_inst.CRBB)));
|
||||
}
|
||||
|
||||
void crorc(UGeckoInstruction _inst)
|
||||
{
|
||||
u32 cr = GetCR();
|
||||
u32 a = cr << _inst.CRBA;
|
||||
u32 b = cr << _inst.CRBB;
|
||||
u32 d = ((a | ~b) & 0x80000000) >> _inst.CRBD;
|
||||
SetCR(d | (cr & ~(0x80000000 >> _inst.CRBD)));
|
||||
SetCRBit(_inst.CRBD, (GetCRBit(_inst.CRBA) | (1 ^ GetCRBit(_inst.CRBB))));
|
||||
}
|
||||
|
||||
void crxor(UGeckoInstruction _inst)
|
||||
{
|
||||
u32 cr = GetCR();
|
||||
u32 a = cr << _inst.CRBA;
|
||||
u32 b = cr << _inst.CRBB;
|
||||
u32 d = ((a ^ b) & 0x80000000) >> _inst.CRBD;
|
||||
SetCR(d | (cr & ~(0x80000000 >> _inst.CRBD)));
|
||||
SetCRBit(_inst.CRBD, (GetCRBit(_inst.CRBA) ^ GetCRBit(_inst.CRBB)));
|
||||
}
|
||||
|
||||
void mcrf(UGeckoInstruction _inst)
|
||||
|
|
|
@ -143,6 +143,13 @@ inline u32 GetCRBit(int bit) {
|
|||
return (PowerPC::ppcState.cr_fast[bit >> 2] >> (3 - (bit & 3))) & 1;
|
||||
}
|
||||
|
||||
inline void SetCRBit(int bit, int value) {
|
||||
if (value & 1)
|
||||
PowerPC::ppcState.cr_fast[bit >> 2] |= 0x8 >> (bit & 3);
|
||||
else
|
||||
PowerPC::ppcState.cr_fast[bit >> 2] &= ~(0x8 >> (bit & 3));
|
||||
}
|
||||
|
||||
// SetCR and GetCR are fairly slow. Should be avoided if possible.
|
||||
inline void SetCR(u32 new_cr) {
|
||||
PowerPC::ppcState.cr = new_cr;
|
||||
|
|
Loading…
Reference in New Issue