Split some parts of UpdateBoundingBox into multiple lines. Also,

fix issues causing failure on Lint.
This commit is contained in:
Rohit Nirmal 2014-09-06 01:24:03 -05:00
parent 1ecb318bcc
commit 629ceaf2b1
4 changed files with 131 additions and 46 deletions

View File

@ -694,8 +694,7 @@ void XEmitter::UD2()
void XEmitter::PREFETCH(PrefetchLevel level, OpArg arg)
{
if (arg.IsImm())
_assert_msg_(DYNA_REC, 0, "PREFETCH - Imm argument");
_assert_msg_(DYNA_REC, !arg.IsImm(), "PREFETCH - Imm argument");
arg.operandReg = (u8)level;
arg.WriteRex(this, 0, 0);
Write8(0x0F);
@ -705,8 +704,7 @@ void XEmitter::PREFETCH(PrefetchLevel level, OpArg arg)
void XEmitter::SETcc(CCFlags flag, OpArg dest)
{
if (dest.IsImm())
_assert_msg_(DYNA_REC, 0, "SETcc - Imm argument");
_assert_msg_(DYNA_REC, !dest.IsImm(), "SETcc - Imm argument");
dest.operandReg = 0;
dest.WriteRex(this, 0, 8);
Write8(0x0F);
@ -716,10 +714,8 @@ void XEmitter::SETcc(CCFlags flag, OpArg dest)
void XEmitter::CMOVcc(int bits, X64Reg dest, OpArg src, CCFlags flag)
{
if (src.IsImm())
_assert_msg_(DYNA_REC, 0, "CMOVcc - Imm argument");
if (bits == 8)
_assert_msg_(DYNA_REC, 0, "CMOVcc - 8 bits unsupported");
_assert_msg_(DYNA_REC, !src.IsImm(), "CMOVcc - Imm argument");
_assert_msg_(DYNA_REC, bits != 8, "CMOVcc - 8 bits unsupported");
if (bits == 16)
Write8(0x66);
src.operandReg = dest;
@ -731,8 +727,7 @@ void XEmitter::CMOVcc(int bits, X64Reg dest, OpArg src, CCFlags flag)
void XEmitter::WriteMulDivType(int bits, OpArg src, int ext)
{
if (src.IsImm())
_assert_msg_(DYNA_REC, 0, "WriteMulDivType - Imm argument");
_assert_msg_(DYNA_REC, !src.IsImm(), "WriteMulDivType - Imm argument");
src.operandReg = ext;
if (bits == 16)
Write8(0x66);
@ -757,8 +752,7 @@ void XEmitter::NOT(int bits, OpArg src) {WriteMulDivType(bits, src, 2);}
void XEmitter::WriteBitSearchType(int bits, X64Reg dest, OpArg src, u8 byte2)
{
if (src.IsImm())
_assert_msg_(DYNA_REC, 0, "WriteBitSearchType - Imm argument");
_assert_msg_(DYNA_REC, !src.IsImm(), "WriteBitSearchType - Imm argument");
src.operandReg = (u8)dest;
if (bits == 16)
Write8(0x66);
@ -780,8 +774,7 @@ void XEmitter::BSR(int bits, X64Reg dest, OpArg src) {WriteBitSearchType(bits,de
void XEmitter::MOVSX(int dbits, int sbits, X64Reg dest, OpArg src)
{
if (src.IsImm())
_assert_msg_(DYNA_REC, 0, "MOVSX - Imm argument");
_assert_msg_(DYNA_REC, !src.IsImm(), "MOVSX - Imm argument");
if (dbits == sbits)
{
MOV(dbits, R(dest), src);
@ -814,8 +807,7 @@ void XEmitter::MOVSX(int dbits, int sbits, X64Reg dest, OpArg src)
void XEmitter::MOVZX(int dbits, int sbits, X64Reg dest, OpArg src)
{
if (src.IsImm())
_assert_msg_(DYNA_REC, 0, "MOVZX - Imm argument");
_assert_msg_(DYNA_REC, !src.IsImm(), "MOVZX - Imm argument");
if (dbits == sbits)
{
MOV(dbits, R(dest), src);
@ -882,8 +874,7 @@ void XEmitter::MOVBE(int bits, const OpArg& dest, const OpArg& src)
void XEmitter::LEA(int bits, X64Reg dest, OpArg src)
{
if (src.IsImm())
_assert_msg_(DYNA_REC, 0, "LEA - Imm argument");
_assert_msg_(DYNA_REC, !src.IsImm(), "LEA - Imm argument");
src.operandReg = (u8)dest;
if (bits == 16)
Write8(0x66); //TODO: performance warning

View File

@ -180,9 +180,10 @@ static void gdb_bp_remove(u32 type, u32 addr, u32 len)
{
gdb_bp_t *p;
do {
do
{
p = gdb_bp_find(type, addr, len);
if (p != nullptr)
if (p != nullptr)
{
DEBUG_LOG(GDB_STUB, "gdb: removed a breakpoint: %08x bytes at %08x\n", len, addr);
p->active = 0;
@ -659,7 +660,7 @@ static void _gdb_add_bp()
u32 i, addr = 0, len = 0;
type = hex2char(cmd_bfr[1]);
switch (type)
switch (type)
{
case 0:
case 1:

View File

@ -12,15 +12,15 @@
namespace PowerPC
{
const u32 plru_mask[8] = {11,11,19,19,37,37,69,69};
const u32 plru_value[8] = {11,3,17,1,36,4,64,0};
const u32 plru_mask[8] = {11, 11, 19, 19, 37, 37, 69, 69};
const u32 plru_value[8] = {11, 3, 17, 1, 36, 4, 64, 0};
InstructionCache::InstructionCache()
{
for (u32 m = 0; m < 0xff; m++)
{
u32 w = 0;
while (m & (1<<w))
while (m & (1 << w))
w++;
way_from_valid[m] = w;
}
@ -29,7 +29,7 @@ namespace PowerPC
{
u32 b[7];
for (int i = 0; i < 7; i++)
b[i] = m & (1<<i);
b[i] = m & (1 << i);
u32 w;
if (b[0])
if (b[2])
@ -84,7 +84,7 @@ namespace PowerPC
// invalidates the whole set
u32 set = (addr >> 5) & 0x7f;
for (int i = 0; i < 8; i++)
if (valid[set] & (1<<i))
if (valid[set] & (1 << i))
{
if (tags[set][i] & (ICACHE_VMEM_BIT >> 12))
lookup_table_vmem[((tags[set][i] << 7) | set) & 0xfffff] = 0xff;
@ -107,15 +107,15 @@ namespace PowerPC
u32 t;
if (addr & ICACHE_VMEM_BIT)
{
t = lookup_table_vmem[(addr>>5) & 0xfffff];
t = lookup_table_vmem[(addr >> 5) & 0xfffff];
}
else if (addr & ICACHE_EXRAM_BIT)
{
t = lookup_table_ex[(addr>>5) & 0x1fffff];
t = lookup_table_ex[(addr >> 5) & 0x1fffff];
}
else
{
t = lookup_table[(addr>>5) & 0xfffff];
t = lookup_table[(addr >> 5) & 0xfffff];
}
if (t == 0xff) // load to the cache
@ -130,7 +130,7 @@ namespace PowerPC
// load
u8 *p = Memory::GetPointer(addr & ~0x1f);
memcpy(data[set][t], p, 32);
if (valid[set] & (1<<t))
if (valid[set] & (1 << t))
{
if (tags[set][t] & (ICACHE_VMEM_BIT >> 12))
lookup_table_vmem[((tags[set][t] << 7) | set) & 0xfffff] = 0xff;
@ -141,17 +141,17 @@ namespace PowerPC
}
if (addr & ICACHE_VMEM_BIT)
lookup_table_vmem[(addr>>5) & 0xfffff] = t;
lookup_table_vmem[(addr >> 5) & 0xfffff] = t;
else if (addr & ICACHE_EXRAM_BIT)
lookup_table_ex[(addr>>5) & 0x1fffff] = t;
lookup_table_ex[(addr >> 5) & 0x1fffff] = t;
else
lookup_table[(addr>>5) & 0xfffff] = t;
tags[set][t] = tag;
valid[set] |= 1<<t;
valid[set] |= (1 << t);
}
// update plru
plru[set] = (plru[set] & ~plru_mask[t]) | plru_value[t];
u32 res = Common::swap32(data[set][t][(addr>>2)&7]);
u32 res = Common::swap32(data[set][t][(addr >> 2) & 7]);
return res;
}

View File

@ -374,10 +374,41 @@ static void LOADERDECL UpdateBoundingBox()
{
m = (p1.x - p0.x) ? ((p1.y - p0.y) / (p1.x - p0.x)) : highNum;
c = p0.y - (m * p0.x);
if (i0 & 1) { s = (s32)(c + roundUp); if (s >= 0 && s <= 479) left = 0; top = std::min(s, top); bottom = std::max(s, bottom); }
if (i0 & 2) { s = (s32)((-c / m) + roundUp); if (s >= 0 && s <= 607) top = 0; left = std::min(s, left); right = std::max(s, right); }
if (i0 & 4) { s = (s32)((m * 607) + c + roundUp); if (s >= 0 && s <= 479) right = 607; top = std::min(s, top); bottom = std::max(s, bottom); }
if (i0 & 8) { s = (s32)(((479 - c) / m) + roundUp); if (s >= 0 && s <= 607) bottom = 479; left = std::min(s, left); right = std::max(s, right); }
if (i0 & 1)
{
s = (s32)(c + roundUp);
if (s >= 0 && s <= 479)
left = 0;
top = std::min(s, top);
bottom = std::max(s, bottom);
}
if (i0 & 2)
{
s = (s32)((-c / m) + roundUp);
if (s >= 0 && s <= 607)
top = 0;
left = std::min(s, left);
right = std::max(s, right);
}
if (i0 & 4)
{
s = (s32)((m * 607) + c + roundUp);
if (s >= 0 && s <= 479)
right = 607;
top = std::min(s, top);
bottom = std::max(s, bottom);
}
if (i0 & 8)
{
s = (s32)(((479 - c) / m) + roundUp);
if (s >= 0 && s <= 607)
bottom = 479;
left = std::min(s, left);
right = std::max(s, right);
}
}
// Only check other lines if we are dealing with a triangle
@ -388,10 +419,41 @@ static void LOADERDECL UpdateBoundingBox()
{
m = (p2.x - p1.x) ? ((p2.y - p1.y) / (p2.x - p1.x)) : highNum;
c = p1.y - (m * p1.x);
if (i1 & 1) { s = (s32)(c + roundUp); if (s >= 0 && s <= 479) left = 0; top = std::min(s, top); bottom = std::max(s, bottom); }
if (i1 & 2) { s = (s32)((-c / m) + roundUp); if (s >= 0 && s <= 607) top = 0; left = std::min(s, left); right = std::max(s, right); }
if (i1 & 4) { s = (s32)((m * 607) + c + roundUp); if (s >= 0 && s <= 479) right = 607; top = std::min(s, top); bottom = std::max(s, bottom); }
if (i1 & 8) { s = (s32)(((479 - c) / m) + roundUp); if (s >= 0 && s <= 607) bottom = 479; left = std::min(s, left); right = std::max(s, right); }
if (i1 & 1)
{
s = (s32)(c + roundUp);
if (s >= 0 && s <= 479)
left = 0;
top = std::min(s, top);
bottom = std::max(s, bottom);
}
if (i1 & 2)
{
s = (s32)((-c / m) + roundUp);
if (s >= 0 && s <= 607)
top = 0;
left = std::min(s, left);
right = std::max(s, right);
}
if (i1 & 4)
{
s = (s32)((m * 607) + c + roundUp);
if (s >= 0 && s <= 479)
right = 607;
top = std::min(s, top);
bottom = std::max(s, bottom);
}
if (i1 & 8)
{
s = (s32)(((479 - c) / m) + roundUp);
if (s >= 0 && s <= 607)
bottom = 479;
left = std::min(s, left);
right = std::max(s, right);
}
}
// Third line intersects
@ -399,10 +461,41 @@ static void LOADERDECL UpdateBoundingBox()
{
m = (p2.x - p0.x) ? ((p2.y - p0.y) / (p2.x - p0.x)) : highNum;
c = p0.y - (m * p0.x);
if (i2 & 1) { s = (s32)(c + roundUp); if (s >= 0 && s <= 479) left = 0; top = std::min(s, top); bottom = std::max(s, bottom); }
if (i2 & 2) { s = (s32)((-c / m) + roundUp); if (s >= 0 && s <= 607) top = 0; left = std::min(s, left); right = std::max(s, right); }
if (i2 & 4) { s = (s32)((m * 607) + c + roundUp); if (s >= 0 && s <= 479) right = 607; top = std::min(s, top); bottom = std::max(s, bottom); }
if (i2 & 8) { s = (s32)(((479 - c) / m) + roundUp); if (s >= 0 && s <= 607) bottom = 479; left = std::min(s, left); right = std::max(s, right); }
if (i2 & 1)
{
s = (s32)(c + roundUp);
if (s >= 0 && s <= 479)
left = 0;
top = std::min(s, top);
bottom = std::max(s, bottom);
}
if (i2 & 2)
{
s = (s32)((-c / m) + roundUp);
if (s >= 0 && s <= 607)
top = 0;
left = std::min(s, left);
right = std::max(s, right);
}
if (i2 & 4)
{
s = (s32)((m * 607) + c + roundUp);
if (s >= 0 && s <= 479)
right = 607;
top = std::min(s, top);
bottom = std::max(s, bottom);
}
if (i2 & 8)
{
s = (s32)(((479 - c) / m) + roundUp);
if (s >= 0 && s <= 607)
bottom = 479;
left = std::min(s, left);
right = std::max(s, right);
}
}
}