made recUpdateFlags more readable while keeping most (all?) of the optimizations from last update.

git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@632 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
cottonvibes 2009-01-25 15:33:20 +00:00 committed by Gregory Hainaut
parent c787b00cc7
commit be57d5384a
1 changed files with 60 additions and 87 deletions

View File

@ -145,13 +145,13 @@ void recUpdateFlags(VURegs * VU, int reg, int info)
static u8 *pjmp, *pjmp2;
static u32 *pjmp32;
static u32 macaddr, stataddr, prevstataddr;
static int x86macflag, x86temp;
static int x86macflag, x86statflag, x86temp;
static int t1reg, t1regBoolean;
static const int flipMask[16] = {0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15};
if( !(info & PROCESS_VU_UPDATEFLAGS) ) return;
//SysPrintf ("recUpdateFlags \n");
//SysPrintf ("recUpdateFlags\n");
macaddr = VU_VI_ADDR(REG_MAC_FLAG, 0);
stataddr = VU_VI_ADDR(REG_STATUS_FLAG, 0); // write address
@ -162,10 +162,10 @@ void recUpdateFlags(VURegs * VU, int reg, int info)
SysPrintf( "VU ALLOCATION WARNING: Using Mac Flag Previous Address!\n" );
macaddr = VU_VI_ADDR(REG_MAC_FLAG, 2);
}
x86macflag = ALLOCTEMPX86(0);
x86temp = ALLOCTEMPX86(0);
x86statflag = ALLOCTEMPX86(0);
if (reg == EEREC_TEMP) {
t1reg = _vuGetTempXMMreg(info);
if (t1reg < 0) {
@ -182,11 +182,14 @@ void recUpdateFlags(VURegs * VU, int reg, int info)
}
SSE_SHUFPS_XMM_to_XMM(reg, reg, 0x1B); // Flip wzyx to xyzw
MOV32MtoR(x86temp, prevstataddr); // Load the previous status in to x86temp
AND16ItoR(x86temp, 0xff0); // Keep Sticky and D/I flags
MOV32MtoR(x86statflag, prevstataddr); // Load the previous status in to x86statflag
AND16ItoR(x86statflag, 0xff0); // Keep Sticky and D/I flags
if (CHECK_VU_EXTRA_FLAGS) {
if (CHECK_VU_EXTRA_FLAGS) { // Checks all flags
x86temp = ALLOCTEMPX86(0);
//-------------------------Check for Overflow flags------------------------------
//SSE_XORPS_XMM_to_XMM(t1reg, t1reg); // Clear t1reg
@ -205,7 +208,7 @@ void recUpdateFlags(VURegs * VU, int reg, int info)
AND16ItoR(x86macflag, _X_Y_Z_W ); // Grab "Has Overflowed" bits from the previous calculation (also make sure we're only grabbing from the XYZW being modified)
pjmp = JZ8(0); // Skip if none are
OR16ItoR(x86temp, 0x208); // OS, O flags
OR16ItoR(x86statflag, 0x208); // OS, O flags
SHL16ItoR(x86macflag, 12);
if (_XYZW_SS) pjmp32 = JMP32(0); // Skip Underflow Check
x86SetJ8(pjmp);
@ -225,7 +228,7 @@ void recUpdateFlags(VURegs * VU, int reg, int info)
AND16ItoR(EAX, _X_Y_Z_W ); // Grab "Has Underflowed" bits from the previous calculation
pjmp = JZ8(0); // Skip if none are
OR16ItoR(x86temp, 0x104); // US, U flags
OR16ItoR(x86statflag, 0x104); // US, U flags
SHL16ItoR(EAX, 8);
OR32RtoR(x86macflag, EAX);
x86SetJ8(pjmp);
@ -240,96 +243,66 @@ void recUpdateFlags(VURegs * VU, int reg, int info)
}
if (_XYZW_SS) x86SetJ32(pjmp32); // If we skipped the Underflow Flag Checking (when we had an Overflow), return here
}
vuFloat2(reg, t1reg, flipMask[_X_Y_Z_W]); // Clamp overflowed vectors that were modified (remember reg's vectors have been flipped, so have to use a flipmask)
vuFloat2(reg, t1reg, flipMask[_X_Y_Z_W]); // Clamp overflowed vectors that were modified (remember reg's vectors have been flipped, so have to use a flipmask)
if (_XYZW_SS) {
//-------------------------Check for Signed flags------------------------------
// The following code makes sure the Signed Bit isn't set with Negative Zero
SSE_XORPS_XMM_to_XMM(t1reg, t1reg); // Clear t1reg
SSE_CMPEQPS_XMM_to_XMM(t1reg, reg); // Set all F's if each vector is zero
if (CHECK_VU_EXTRA_FLAGS) {
SSE_ANDNPS_XMM_to_XMM(t1reg, reg);
SSE_MOVMSKPS_XMM_to_R32(EAX, t1reg); // Move the sign bits of the t1reg
AND16ItoR(EAX, _X_Y_Z_W ); // Grab "Is Signed" bits from the previous calculation
pjmp = JZ8(0); // Skip if none are
OR16ItoR(x86temp, 0x82); // SS, S flags
SHL16ItoR(EAX, 4);
OR32RtoR(x86macflag, EAX);
pjmp2 = JMP8(0); // If negative and not Zero, we can skip the Zero Flag checking
x86SetJ8(pjmp);
}
else {
SSE_MOVMSKPS_XMM_to_R32(EAX, t1reg); // Move the sign bits of the t1reg (for zero flag)
SSE_ANDNPS_XMM_to_XMM(t1reg, reg);
SSE_MOVMSKPS_XMM_to_R32(x86macflag, t1reg); // Move the sign bits of the t1reg
AND16ItoR(x86macflag, _X_Y_Z_W ); // Grab "Is Signed" bits from the previous calculation
pjmp = JZ8(0); // Skip if none are
OR16ItoR(x86temp, 0x82); // SS, S flags
SHL16ItoR(x86macflag, 4);
pjmp2 = JMP8(0); // If negative and not Zero, we can skip the Zero Flag checking
x86SetJ8(pjmp);
}
//-------------------------Check for Zero flags------------------------------
if (CHECK_VU_EXTRA_FLAGS) {
SSE_XORPS_XMM_to_XMM(t1reg, t1reg); // Clear t1reg
SSE_CMPEQPS_XMM_to_XMM(t1reg, reg); // Set all F's if each vector is zero
SSE_MOVMSKPS_XMM_to_R32(EAX, t1reg); // Move the sign bits of the previous calculation
}
AND16ItoR(EAX, _X_Y_Z_W ); // Grab "Is Zero" bits from the previous calculation
pjmp = JZ8(0); // Skip if none are
OR16ItoR(x86temp, 0x41); // ZS, Z flags
OR32RtoR(x86macflag, EAX);
x86SetJ8(pjmp);
}
else {
//-------------------------Check for Zero flags------------------------------
SSE_XORPS_XMM_to_XMM(t1reg, t1reg); // Clear t1reg
SSE_CMPEQPS_XMM_to_XMM(t1reg, reg); // Set all F's if each vector is zero
if (CHECK_VU_EXTRA_FLAGS) {
SSE_MOVMSKPS_XMM_to_R32(EAX, t1reg); // Move the sign bits of the previous calculation
AND16ItoR(EAX, _X_Y_Z_W ); // Grab "Is Zero" bits from the previous calculation
pjmp = JZ8(0); // Skip if none are
OR16ItoR(x86temp, 0x41); // ZS, Z flags
OR32RtoR(x86macflag, EAX);
x86SetJ8(pjmp);
}
else {
SSE_MOVMSKPS_XMM_to_R32(x86macflag, t1reg); // Move the sign bits of the previous calculation
AND16ItoR(x86macflag, _X_Y_Z_W ); // Grab "Is Zero" bits from the previous calculation
pjmp = JZ8(0); // Skip if none are
OR16ItoR(x86temp, 0x41); // ZS, Z flags
x86SetJ8(pjmp);
}
//-------------------------Check for Signed flags------------------------------
// The following code makes sure the Signed Bit isn't set with Negative Zero
SSE_MOVMSKPS_XMM_to_R32(x86temp, t1reg); // Used for Zero Flag Calculation
SSE_ANDNPS_XMM_to_XMM(t1reg, reg);
SSE_MOVMSKPS_XMM_to_R32(EAX, t1reg); // Move the sign bits of the t1reg
AND16ItoR(EAX, _X_Y_Z_W ); // Grab "Is Signed" bits from the previous calculation
pjmp = JZ8(0); // Skip if none are
OR16ItoR(x86temp, 0x82); // SS, S flags
OR16ItoR(x86statflag, 0x82); // SS, S flags
SHL16ItoR(EAX, 4);
OR32RtoR(x86macflag, EAX);
if (_XYZW_SS) pjmp2 = JMP8(0); // If negative and not Zero, we can skip the Zero Flag checking
x86SetJ8(pjmp);
//-------------------------Check for Zero flags------------------------------
AND16ItoR(x86temp, _X_Y_Z_W ); // Grab "Is Zero" bits from the previous calculation
pjmp = JZ8(0); // Skip if none are
OR16ItoR(x86statflag, 0x41); // ZS, Z flags
OR32RtoR(x86macflag, x86temp);
x86SetJ8(pjmp);
_freeX86reg(x86temp);
}
else { // Only Checks for Sign and Zero Flags
vuFloat2(reg, t1reg, flipMask[_X_Y_Z_W]); // Clamp overflowed vectors that were modified (remember reg's vectors have been flipped, so have to use a flipmask)
//-------------------------Check for Signed flags------------------------------
// The following code makes sure the Signed Bit isn't set with Negative Zero
SSE_XORPS_XMM_to_XMM(t1reg, t1reg); // Clear t1reg
SSE_CMPEQPS_XMM_to_XMM(t1reg, reg); // Set all F's if each vector is zero
SSE_MOVMSKPS_XMM_to_R32(EAX, t1reg); // Used for Zero Flag Calculation
SSE_ANDNPS_XMM_to_XMM(t1reg, reg);
SSE_MOVMSKPS_XMM_to_R32(x86macflag, t1reg); // Move the sign bits of the t1reg
AND16ItoR(x86macflag, _X_Y_Z_W ); // Grab "Is Signed" bits from the previous calculation
pjmp = JZ8(0); // Skip if none are
OR16ItoR(x86statflag, 0x82); // SS, S flags
SHL16ItoR(x86macflag, 4);
if (_XYZW_SS) pjmp2 = JMP8(0); // If negative and not Zero, we can skip the Zero Flag checking
x86SetJ8(pjmp);
//-------------------------Check for Zero flags------------------------------
AND16ItoR(EAX, _X_Y_Z_W ); // Grab "Is Zero" bits from the previous calculation
pjmp = JZ8(0); // Skip if none are
OR16ItoR(x86statflag, 0x41); // ZS, Z flags
OR32RtoR(x86macflag, EAX);
x86SetJ8(pjmp);
}
//-------------------------Finally: Send the Flags to the Mac Flag Address------------------------------
if (_XYZW_SS) x86SetJ8(pjmp2); // If we skipped the Zero Flag Checking, return here
@ -339,10 +312,10 @@ void recUpdateFlags(VURegs * VU, int reg, int info)
else _freeXMMreg(t1reg); // Free temp reg
MOV16RtoM(macaddr, x86macflag);
MOV16RtoM(stataddr, x86temp);
MOV16RtoM(stataddr, x86statflag);
_freeX86reg(x86macflag);
_freeX86reg(x86temp);
_freeX86reg(x86statflag);
}
//------------------------------------------------------------------