Fix some formatting (new lines on collapsed single-line conditionals,

new lines for opening braces).
This commit is contained in:
Rohit Nirmal 2014-09-06 01:23:05 -05:00
parent b7f19ca740
commit 1ecb318bcc
4 changed files with 82 additions and 41 deletions

View File

@ -582,14 +582,16 @@ void XEmitter::SFENCE() {Write8(0x0F); Write8(0xAE); Write8(0xF8);}
void XEmitter::WriteSimple1Byte(int bits, u8 byte, X64Reg reg)
{
if (bits == 16) {Write8(0x66);}
if (bits == 16)
Write8(0x66);
Rex(bits == 64, 0, 0, (int)reg >> 3);
Write8(byte + ((int)reg & 7));
}
void XEmitter::WriteSimple2Byte(int bits, u8 byte1, u8 byte2, X64Reg reg)
{
if (bits == 16) {Write8(0x66);}
if (bits == 16)
Write8(0x66);
Rex(bits==64, 0, 0, (int)reg >> 3);
Write8(byte1);
Write8(byte2 + ((int)reg & 7));
@ -597,14 +599,16 @@ void XEmitter::WriteSimple2Byte(int bits, u8 byte1, u8 byte2, X64Reg reg)
void XEmitter::CWD(int bits)
{
if (bits == 16) {Write8(0x66);}
if (bits == 16)
Write8(0x66);
Rex(bits == 64, 0, 0, 0);
Write8(0x99);
}
void XEmitter::CBW(int bits)
{
if (bits == 8) {Write8(0x66);}
if (bits == 8)
Write8(0x66);
Rex(bits == 32, 0, 0, 0);
Write8(0x98);
}
@ -690,7 +694,8 @@ void XEmitter::UD2()
void XEmitter::PREFETCH(PrefetchLevel level, OpArg arg)
{
if (arg.IsImm()) _assert_msg_(DYNA_REC, 0, "PREFETCH - Imm argument");;
if (arg.IsImm())
_assert_msg_(DYNA_REC, 0, "PREFETCH - Imm argument");
arg.operandReg = (u8)level;
arg.WriteRex(this, 0, 0);
Write8(0x0F);
@ -700,7 +705,8 @@ 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");
if (dest.IsImm())
_assert_msg_(DYNA_REC, 0, "SETcc - Imm argument");
dest.operandReg = 0;
dest.WriteRex(this, 0, 8);
Write8(0x0F);
@ -710,9 +716,12 @@ 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");
if (bits == 16) Write8(0x66);
if (src.IsImm())
_assert_msg_(DYNA_REC, 0, "CMOVcc - Imm argument");
if (bits == 8)
_assert_msg_(DYNA_REC, 0, "CMOVcc - 8 bits unsupported");
if (bits == 16)
Write8(0x66);
src.operandReg = dest;
src.WriteRex(this, bits, bits);
Write8(0x0F);
@ -722,9 +731,11 @@ 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");
if (src.IsImm())
_assert_msg_(DYNA_REC, 0, "WriteMulDivType - Imm argument");
src.operandReg = ext;
if (bits == 16) Write8(0x66);
if (bits == 16)
Write8(0x66);
src.WriteRex(this, bits, bits, 0);
if (bits == 8)
{
@ -746,9 +757,11 @@ 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");
if (src.IsImm())
_assert_msg_(DYNA_REC, 0, "WriteBitSearchType - Imm argument");
src.operandReg = (u8)dest;
if (bits == 16) Write8(0x66);
if (bits == 16)
Write8(0x66);
src.WriteRex(this, bits, bits);
Write8(0x0F);
Write8(byte2);
@ -757,7 +770,8 @@ void XEmitter::WriteBitSearchType(int bits, X64Reg dest, OpArg src, u8 byte2)
void XEmitter::MOVNTI(int bits, OpArg dest, X64Reg src)
{
if (bits <= 16) _assert_msg_(DYNA_REC, 0, "MOVNTI - bits<=16");
if (bits <= 16)
_assert_msg_(DYNA_REC, 0, "MOVNTI - bits<=16");
WriteBitSearchType(bits, src, dest, 0xC3);
}
@ -766,14 +780,16 @@ 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");
if (src.IsImm())
_assert_msg_(DYNA_REC, 0, "MOVSX - Imm argument");
if (dbits == sbits)
{
MOV(dbits, R(dest), src);
return;
}
src.operandReg = (u8)dest;
if (dbits == 16) Write8(0x66);
if (dbits == 16)
Write8(0x66);
src.WriteRex(this, dbits, sbits);
if (sbits == 8)
{
@ -798,14 +814,16 @@ 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");
if (src.IsImm())
_assert_msg_(DYNA_REC, 0, "MOVZX - Imm argument");
if (dbits == sbits)
{
MOV(dbits, R(dest), src);
return;
}
src.operandReg = (u8)dest;
if (dbits == 16) Write8(0x66);
if (dbits == 16)
Write8(0x66);
//the 32bit result is automatically zero extended to 64bit
src.WriteRex(this, dbits == 64 ? 32 : dbits, sbits);
if (sbits == 8)
@ -864,9 +882,11 @@ 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");
if (src.IsImm())
_assert_msg_(DYNA_REC, 0, "LEA - Imm argument");
src.operandReg = (u8)dest;
if (bits == 16) Write8(0x66); //TODO: performance warning
if (bits == 16)
Write8(0x66); //TODO: performance warning
src.WriteRex(this, bits, bits);
Write8(0x8D);
src.WriteRest(this, 0, INVALID_REG, bits == 64);
@ -885,7 +905,8 @@ void XEmitter::WriteShift(int bits, OpArg dest, OpArg &shift, int ext)
_assert_msg_(DYNA_REC, 0, "WriteShift - illegal argument");
}
dest.operandReg = ext;
if (bits == 16) Write8(0x66);
if (bits == 16)
Write8(0x66);
dest.WriteRex(this, bits, bits, 0);
if (shift.GetImmBits() == 8)
{
@ -931,7 +952,8 @@ void XEmitter::WriteBitTest(int bits, OpArg &dest, OpArg &index, int ext)
{
_assert_msg_(DYNA_REC, 0, "WriteBitTest - illegal argument");
}
if (bits == 16) Write8(0x66);
if (bits == 16)
Write8(0x66);
if (index.IsImm())
{
dest.WriteRex(this, bits, bits);
@ -968,7 +990,8 @@ void XEmitter::SHRD(int bits, OpArg dest, OpArg src, OpArg shift)
{
_assert_msg_(DYNA_REC, 0, "SHRD - illegal shift");
}
if (bits == 16) Write8(0x66);
if (bits == 16)
Write8(0x66);
X64Reg operand = src.GetSimpleReg();
dest.WriteRex(this, bits, bits, operand);
if (shift.GetImmBits() == 8)
@ -998,7 +1021,8 @@ void XEmitter::SHLD(int bits, OpArg dest, OpArg src, OpArg shift)
{
_assert_msg_(DYNA_REC, 0, "SHLD - illegal shift");
}
if (bits == 16) Write8(0x66);
if (bits == 16)
Write8(0x66);
X64Reg operand = src.GetSimpleReg();
dest.WriteRex(this, bits, bits, operand);
if (shift.GetImmBits() == 8)

View File

@ -54,14 +54,16 @@ void sigsegv_handler(int signal, siginfo_t *info, void *raw_context)
void *fault_memory_ptr = (void*)ctx->arm_r10;
u8 *fault_instruction_ptr = (u8 *)ctx->arm_pc;
if (!JitInterface::IsInCodeSpace(fault_instruction_ptr)) {
if (!JitInterface::IsInCodeSpace(fault_instruction_ptr))
{
// Let's not prevent debugging.
return;
}
u64 bad_address = (u64)fault_memory_ptr;
u64 memspace_bottom = (u64)Memory::base;
if (bad_address < memspace_bottom) {
if (bad_address < memspace_bottom)
{
PanicAlertT("Exception handler - access below memory space. %08llx%08llx",
bad_address >> 32, bad_address);
}
@ -69,7 +71,8 @@ void sigsegv_handler(int signal, siginfo_t *info, void *raw_context)
u32 em_address = (u32)(bad_address - memspace_bottom);
const u8 *new_rip = jit->BackPatch(fault_instruction_ptr, em_address, ctx);
if (new_rip) {
if (new_rip)
{
ctx->arm_pc = (u32) new_rip;
}
}

View File

@ -147,7 +147,8 @@ static gdb_bp_t *gdb_bp_empty_slot(u32 type)
if (p == nullptr)
return nullptr;
for (i = 0; i < GDB_MAX_BP; i++) {
for (i = 0; i < GDB_MAX_BP; i++)
{
if (p[i].active == 0)
return &p[i];
}
@ -164,7 +165,8 @@ static gdb_bp_t *gdb_bp_find(u32 type, u32 addr, u32 len)
if (p == nullptr)
return nullptr;
for (i = 0; i < GDB_MAX_BP; i++) {
for (i = 0; i < GDB_MAX_BP; i++)
{
if (p[i].active == 1 &&
p[i].addr == addr &&
p[i].len == len)
@ -180,7 +182,8 @@ static void gdb_bp_remove(u32 type, u32 addr, u32 len)
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;
memset(p, 0, sizeof(gdb_bp_t));
@ -197,7 +200,8 @@ static int gdb_bp_check(u32 addr, u32 type)
if (p == nullptr)
return 0;
for (i = 0; i < GDB_MAX_BP; i++) {
for (i = 0; i < GDB_MAX_BP; i++)
{
if (p[i].active == 1 &&
(addr >= p[i].addr && addr < p[i].addr + p[i].len))
return 1;
@ -246,12 +250,14 @@ static void gdb_read_command()
gdb_signal(SIGTRAP);
return;
}
else if (c != GDB_STUB_START) {
else if (c != GDB_STUB_START)
{
DEBUG_LOG(GDB_STUB, "gdb: read invalid byte %02x\n", c);
return;
}
while ((c = gdb_read_byte()) != GDB_STUB_END) {
while ((c = gdb_read_byte()) != GDB_STUB_END)
{
cmd_bfr[cmd_len++] = c;
if (cmd_len == sizeof cmd_bfr)
{
@ -266,7 +272,8 @@ static void gdb_read_command()
chk_calc = gdb_calc_chksum();
if (chk_calc != chk_read) {
if (chk_calc != chk_read)
{
ERROR_LOG(GDB_STUB, "gdb: invalid checksum: calculated %02x and read %02x for $%s# (length: %d)\n", chk_calc, chk_read, cmd_bfr, cmd_len);
cmd_len = 0;
@ -469,13 +476,15 @@ static void gdb_read_registers()
memset(bfr, 0, sizeof bfr);
for (i = 0; i < 32; i++) {
for (i = 0; i < 32; i++)
{
wbe32hex(bufptr + i*8, GPR(i));
}
bufptr += 32 * 8;
/*
for (i = 0; i < 32; i++) {
for (i = 0; i < 32; i++)
{
wbe32hex(bufptr + i*8, riPS0(i));
}
bufptr += 32 * 8;
@ -500,7 +509,8 @@ static void gdb_write_registers()
u32 i;
u8 * bufptr = cmd_bfr;
for (i = 0; i < 32; i++) {
for (i = 0; i < 32; i++)
{
GPR(i) = re32hex(bufptr + i*8);
}
bufptr += 32 * 8;
@ -649,7 +659,8 @@ static void _gdb_add_bp()
u32 i, addr = 0, len = 0;
type = hex2char(cmd_bfr[1]);
switch (type) {
switch (type)
{
case 0:
case 1:
type = GDB_BP_TYPE_X;
@ -869,7 +880,8 @@ int gdb_signal(u32 s)
sig = s;
if (send_signal) {
if (send_signal)
{
gdb_handle_signal();
send_signal = 0;
}

View File

@ -20,14 +20,16 @@ namespace PowerPC
for (u32 m = 0; m < 0xff; m++)
{
u32 w = 0;
while (m & (1<<w)) w++;
while (m & (1<<w))
w++;
way_from_valid[m] = w;
}
for (u32 m = 0; m < 128; m++)
{
u32 b[7];
for (int i = 0; i < 7; i++) b[i] = m & (1<<i);
for (int i = 0; i < 7; i++)
b[i] = m & (1<<i);
u32 w;
if (b[0])
if (b[2])