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:
hrydgard 2008-12-19 22:46:28 +00:00
parent 347fc18542
commit c4f27aaae1
2 changed files with 15 additions and 41 deletions

View File

@ -430,75 +430,42 @@ void mtspr(UGeckoInstruction _inst)
void crand(UGeckoInstruction _inst) void crand(UGeckoInstruction _inst)
{ {
u32 cr = GetCR(); SetCRBit(_inst.CRBD, GetCRBit(_inst.CRBA) & GetCRBit(_inst.CRBB));
u32 a = cr << _inst.CRBA;
u32 b = cr << _inst.CRBB;
u32 d = ((a & b) & 0x80000000) >> _inst.CRBD;
SetCR(d | (cr & ~(0x80000000 >> _inst.CRBD)));
} }
void crandc(UGeckoInstruction _inst) void crandc(UGeckoInstruction _inst)
{ {
u32 cr = GetCR(); SetCRBit(_inst.CRBD, GetCRBit(_inst.CRBA) & (1 ^ GetCRBit(_inst.CRBB)));
u32 a = cr << _inst.CRBA;
u32 b = cr << _inst.CRBB;
u32 d = ((a & ~b) & 0x80000000) >> _inst.CRBD;
SetCR(d | (cr & ~(0x80000000 >> _inst.CRBD)));
} }
void creqv(UGeckoInstruction _inst) void creqv(UGeckoInstruction _inst)
{ {
u32 cr = GetCR(); SetCRBit(_inst.CRBD, 1 ^ (GetCRBit(_inst.CRBA) ^ GetCRBit(_inst.CRBB)));
u32 a = cr << _inst.CRBA;
u32 b = cr << _inst.CRBB;
u32 d = ((~(a ^ b)) & 0x80000000) >> _inst.CRBD;
SetCR(d | (cr & ~(0x80000000 >> _inst.CRBD)));
} }
void crnand(UGeckoInstruction _inst) void crnand(UGeckoInstruction _inst)
{ {
u32 cr = GetCR(); SetCRBit(_inst.CRBD, 1 ^ (GetCRBit(_inst.CRBA) & GetCRBit(_inst.CRBB)));
u32 a = cr << _inst.CRBA;
u32 b = cr << _inst.CRBB;
u32 d = ((~(a & b)) & 0x80000000) >>_inst.CRBD;
SetCR(d | (cr & ~(0x80000000 >> _inst.CRBD)));
} }
void crnor(UGeckoInstruction _inst) void crnor(UGeckoInstruction _inst)
{ {
u32 cr = GetCR(); SetCRBit(_inst.CRBD, 1 ^ (GetCRBit(_inst.CRBA) | GetCRBit(_inst.CRBB)));
u32 a = cr << _inst.CRBA;
u32 b = cr << _inst.CRBB;
u32 d = ((~(a | b)) & 0x80000000) >> _inst.CRBD;
SetCR(d | (cr & ~(0x80000000 >> _inst.CRBD)));
} }
void cror(UGeckoInstruction _inst) void cror(UGeckoInstruction _inst)
{ {
u32 cr = GetCR(); SetCRBit(_inst.CRBD, (GetCRBit(_inst.CRBA) | GetCRBit(_inst.CRBB)));
u32 a = cr << _inst.CRBA;
u32 b = cr << _inst.CRBB;
u32 d = ((a | b) & 0x80000000) >> _inst.CRBD;
SetCR(d | (cr & ~(0x80000000 >> _inst.CRBD)));
} }
void crorc(UGeckoInstruction _inst) void crorc(UGeckoInstruction _inst)
{ {
u32 cr = GetCR(); SetCRBit(_inst.CRBD, (GetCRBit(_inst.CRBA) | (1 ^ GetCRBit(_inst.CRBB))));
u32 a = cr << _inst.CRBA;
u32 b = cr << _inst.CRBB;
u32 d = ((a | ~b) & 0x80000000) >> _inst.CRBD;
SetCR(d | (cr & ~(0x80000000 >> _inst.CRBD)));
} }
void crxor(UGeckoInstruction _inst) void crxor(UGeckoInstruction _inst)
{ {
u32 cr = GetCR(); SetCRBit(_inst.CRBD, (GetCRBit(_inst.CRBA) ^ GetCRBit(_inst.CRBB)));
u32 a = cr << _inst.CRBA;
u32 b = cr << _inst.CRBB;
u32 d = ((a ^ b) & 0x80000000) >> _inst.CRBD;
SetCR(d | (cr & ~(0x80000000 >> _inst.CRBD)));
} }
void mcrf(UGeckoInstruction _inst) void mcrf(UGeckoInstruction _inst)

View File

@ -143,6 +143,13 @@ inline u32 GetCRBit(int bit) {
return (PowerPC::ppcState.cr_fast[bit >> 2] >> (3 - (bit & 3))) & 1; 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. // SetCR and GetCR are fairly slow. Should be avoided if possible.
inline void SetCR(u32 new_cr) { inline void SetCR(u32 new_cr) {
PowerPC::ppcState.cr = new_cr; PowerPC::ppcState.cr = new_cr;