mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Fix a number of bugs in the ppc disassembler, causing valid instructions to show up as (ill). Also fix some broken indentation. Plus a panicalert for illegal instructions in ppctables. Remove some deprecated compiler flags.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1528 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
6
Externals/Bochs_disasm/Bochs_disasm.vcproj
vendored
6
Externals/Bochs_disasm/Bochs_disasm.vcproj
vendored
@ -51,7 +51,6 @@
|
||||
UsePrecompiledHeader="2"
|
||||
WarningLevel="3"
|
||||
WarnAsError="false"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
ForcedIncludeFiles="stdafx.h"
|
||||
/>
|
||||
@ -116,7 +115,6 @@
|
||||
UsePrecompiledHeader="2"
|
||||
WarningLevel="3"
|
||||
WarnAsError="false"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
ForcedIncludeFiles="stdafx.h"
|
||||
/>
|
||||
@ -179,7 +177,6 @@
|
||||
UsePrecompiledHeader="2"
|
||||
WarningLevel="3"
|
||||
WarnAsError="false"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
ForcedIncludeFiles="stdafx.h"
|
||||
/>
|
||||
@ -245,7 +242,6 @@
|
||||
UsePrecompiledHeader="2"
|
||||
WarningLevel="3"
|
||||
WarnAsError="false"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
ForcedIncludeFiles="stdafx.h"
|
||||
/>
|
||||
@ -308,7 +304,6 @@
|
||||
UsePrecompiledHeader="2"
|
||||
WarningLevel="3"
|
||||
WarnAsError="false"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
ForcedIncludeFiles="stdafx.h"
|
||||
/>
|
||||
@ -374,7 +369,6 @@
|
||||
UsePrecompiledHeader="2"
|
||||
WarningLevel="3"
|
||||
WarnAsError="false"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
ForcedIncludeFiles="stdafx.h"
|
||||
/>
|
||||
|
77
Externals/Bochs_disasm/PowerPCDisasm.cpp
vendored
77
Externals/Bochs_disasm/PowerPCDisasm.cpp
vendored
@ -42,21 +42,21 @@
|
||||
namespace PPCDisasm
|
||||
{
|
||||
|
||||
/* version/revision */
|
||||
/* version/revision */
|
||||
#define PPCDISASM_VER 1
|
||||
#define PPCDISASM_REV 1
|
||||
|
||||
|
||||
/* typedefs */
|
||||
typedef unsigned int ppc_word;
|
||||
/* typedefs */
|
||||
typedef unsigned int ppc_word;
|
||||
|
||||
#undef BIGENDIAN
|
||||
#undef LITTTLEENDIAN
|
||||
/* endianess */
|
||||
/* endianess */
|
||||
#define LITTLEENDIAN 0
|
||||
|
||||
|
||||
/* general defines */
|
||||
/* general defines */
|
||||
#define PPCIDXMASK 0xfc000000
|
||||
#define PPCIDX2MASK 0x000007fe
|
||||
#define PPCDMASK 0x03e00000
|
||||
@ -176,7 +176,7 @@ namespace PPCDisasm
|
||||
{
|
||||
static char def[8];
|
||||
|
||||
switch(i)
|
||||
switch (i)
|
||||
{
|
||||
case 1: return "XER";
|
||||
case 8: return "LR";
|
||||
@ -315,7 +315,7 @@ namespace PPCDisasm
|
||||
sprintf(dp->operands,"%s, %s, %d",regnames[(int)PPCGETD(in)],regnames[(int)PPCGETA(in)],i);
|
||||
break;
|
||||
case 1:
|
||||
if(hex)
|
||||
if (hex)
|
||||
sprintf(dp->operands,"%s, %s, 0x%.4X",regnames[(int)PPCGETA(in)],regnames[(int)PPCGETD(in)],i);
|
||||
else
|
||||
sprintf(dp->operands,"%s, %s, %d",regnames[(int)PPCGETA(in)],regnames[(int)PPCGETD(in)],i);
|
||||
@ -324,7 +324,7 @@ namespace PPCDisasm
|
||||
sprintf(dp->operands,"%s, %d",regnames[(int)PPCGETA(in)],i);
|
||||
break;
|
||||
case 3:
|
||||
if(hex)
|
||||
if (hex)
|
||||
sprintf(dp->operands,"%s, 0x%.4X",regnames[(int)PPCGETD(in)],i);
|
||||
else
|
||||
sprintf(dp->operands,"%s, %d",regnames[(int)PPCGETD(in)],i);
|
||||
@ -421,7 +421,7 @@ namespace PPCDisasm
|
||||
{
|
||||
if ((in&0x08000000) && !PPCGETA(in)) {
|
||||
sprintf(dp->opcode,"l%s",ext); /* li, lis */
|
||||
if(!strcmp(ext, "i"))
|
||||
if (!strcmp(ext, "i"))
|
||||
imm(dp,in,0,3,0);
|
||||
else
|
||||
imm(dp,in,1,3,1);
|
||||
@ -486,7 +486,7 @@ namespace PPCDisasm
|
||||
int offs;
|
||||
char *oper = dp->operands;
|
||||
|
||||
if(d & 0x8000) d |= 0xffff0000;
|
||||
if (d & 0x8000) d |= 0xffff0000;
|
||||
|
||||
if (offs = branch(dp,in,"",(in&2)?1:0,d)) {
|
||||
oper += offs;
|
||||
@ -505,7 +505,7 @@ namespace PPCDisasm
|
||||
{
|
||||
unsigned int d = (unsigned int)(in & 0x3fffffc);
|
||||
|
||||
if(d & 0x02000000) d |= 0xfc000000;
|
||||
if (d & 0x02000000) d |= 0xfc000000;
|
||||
|
||||
sprintf(dp->opcode,"b%s",b_ext[in&3]);
|
||||
if (in & 2) /* AA ? */
|
||||
@ -582,9 +582,6 @@ namespace PPCDisasm
|
||||
int bsh = (int)PPCGETB(in);
|
||||
int mb = (int)PPCGETC(in);
|
||||
int me = (int)PPCGETM(in);
|
||||
|
||||
|
||||
|
||||
sprintf(dp->opcode,"rlw%s%c",name,in&1?'.':'\0');
|
||||
sprintf(dp->operands,"%s, %s, %s%d, %d, %d (%08x)",regnames[a],regnames[s],regsel[i],bsh,mb,me,Helper_Mask(mb, me));
|
||||
}
|
||||
@ -819,13 +816,13 @@ namespace PPCDisasm
|
||||
{
|
||||
static char buf[8];
|
||||
|
||||
if(val == 0)
|
||||
if (val == 0)
|
||||
{
|
||||
return "0";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(val & 0x8000)
|
||||
if (val & 0x8000)
|
||||
{
|
||||
sprintf(buf, "-0x%.4X", ((~val) & 0xffff) + 1);
|
||||
}
|
||||
@ -852,7 +849,7 @@ namespace PPCDisasm
|
||||
// d -= 0x10000;
|
||||
dp->displacement = (ppc_word)d;
|
||||
strcpy(dp->opcode,name);
|
||||
if(reg == 'r')
|
||||
if (reg == 'r')
|
||||
{
|
||||
sprintf(dp->operands,"%s, %s (%s)", regnames[s], ldst_offs(d), regnames[a]);
|
||||
}
|
||||
@ -978,6 +975,7 @@ namespace PPCDisasm
|
||||
#define SPR ((inst >> 11) & 0x3ff)
|
||||
#define TBR ((inst >> 11) & 0x3ff)
|
||||
#define CRM ((inst >> 12) & 0xff)
|
||||
|
||||
inline int SEX12(unsigned int x)
|
||||
{
|
||||
return x & 0x800 ? (x|0xFFFFF000) : x;
|
||||
@ -988,7 +986,7 @@ namespace PPCDisasm
|
||||
ppc_word pc = *dp->iaddr;
|
||||
char *op = dp->opcode;
|
||||
char *pr = dp->operands;
|
||||
switch((inst>>1)&0x1F)
|
||||
switch ((inst>>1)&0x1F)
|
||||
{
|
||||
case 6:
|
||||
strcpy(op, "ps_lux");
|
||||
@ -1067,7 +1065,7 @@ namespace PPCDisasm
|
||||
return;
|
||||
}
|
||||
|
||||
switch((inst>>1)&0x3FF)
|
||||
switch ((inst>>1)&0x3FF)
|
||||
{
|
||||
//10-bit suckers (?)
|
||||
case 40: //nmadd
|
||||
@ -1135,7 +1133,7 @@ namespace PPCDisasm
|
||||
ppc_word pc = *dp->iaddr;
|
||||
char *op = dp->opcode;
|
||||
char *pr = dp->operands;
|
||||
switch(PPCGETIDX(inst))
|
||||
switch (PPCGETIDX(inst))
|
||||
{
|
||||
case 56:
|
||||
strcpy(op,"psq_l");
|
||||
@ -1162,20 +1160,31 @@ namespace PPCDisasm
|
||||
/* instruction, or NULL if an error occured. */
|
||||
{
|
||||
ppc_word in = *(dp->instr);
|
||||
if (!dp->opcode || !dp->operands)
|
||||
return NULL; /* no buffers */
|
||||
|
||||
if (dp->opcode==NULL || dp->operands==NULL)
|
||||
return (NULL); /* no buffers */
|
||||
|
||||
#if LITTLEENDIAN
|
||||
#if LITTLEENDIAN
|
||||
in = (in & 0xff)<<24 | (in & 0xff00)<<8 | (in & 0xff0000)>>8 |
|
||||
(in & 0xff000000)>>24;
|
||||
#endif
|
||||
#endif
|
||||
dp->type = PPCINSTR_OTHER;
|
||||
dp->flags = 0;
|
||||
*(dp->operands) = 0;
|
||||
|
||||
switch (PPCGETIDX(in))
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
int block = in & 0x3FFFFFF;
|
||||
if (block) {
|
||||
sprintf(dp->opcode, "JITblock");
|
||||
sprintf(dp->operands, "%i", block);
|
||||
} else {
|
||||
strcpy(dp->opcode, "");
|
||||
strcpy(dp->operands, "---");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
sprintf(dp->opcode,"HLE");
|
||||
//HLE call
|
||||
@ -1990,15 +1999,15 @@ namespace PPCDisasm
|
||||
case 59:
|
||||
switch (in & 0x3e) {
|
||||
case 36:
|
||||
fdabc(dp,in,"divs",6,0);
|
||||
fdabc(dp,in,"divs",5,0);
|
||||
break;
|
||||
|
||||
case 40:
|
||||
fdabc(dp,in,"subs",6,0);
|
||||
fdabc(dp,in,"subs",5,0);
|
||||
break;
|
||||
|
||||
case 42:
|
||||
fdabc(dp,in,"adds",6,0);
|
||||
fdabc(dp,in,"adds",5,0);
|
||||
break;
|
||||
|
||||
case 44:
|
||||
@ -2010,7 +2019,7 @@ namespace PPCDisasm
|
||||
break;
|
||||
|
||||
case 50:
|
||||
fdabc(dp,in,"muls",5,0);
|
||||
fdabc(dp,in,"muls",6,0);
|
||||
break;
|
||||
|
||||
case 56:
|
||||
@ -2077,7 +2086,7 @@ namespace PPCDisasm
|
||||
break;
|
||||
|
||||
case 20:
|
||||
fdabc(dp,in,"rsqrte",2,0);
|
||||
fdabc(dp,in,"rsqrte",3,0);
|
||||
break;
|
||||
|
||||
case 24:
|
||||
@ -2096,12 +2105,15 @@ namespace PPCDisasm
|
||||
fdabc(dp,in,"nmadd",7,0);
|
||||
break;
|
||||
|
||||
case 52:
|
||||
sprintf(dp->opcode, "XXX dp 52");
|
||||
break;
|
||||
|
||||
default:
|
||||
ill(dp,in);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
switch (PPCGETIDX2(in)) {
|
||||
case 0:
|
||||
@ -2204,7 +2216,8 @@ namespace PPCDisasm
|
||||
}
|
||||
return (dp->instr + 1);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// What were MS thinking?
|
||||
#ifdef _WIN32
|
||||
|
@ -645,20 +645,28 @@ void PPCTables::InitTables()
|
||||
}
|
||||
}
|
||||
|
||||
// #define OPLOG
|
||||
|
||||
#ifdef OPLOG
|
||||
namespace {
|
||||
std::vector<u32> rsplocations;
|
||||
}
|
||||
#endif
|
||||
|
||||
void PPCTables::CompileInstruction(UGeckoInstruction _inst)
|
||||
{
|
||||
dynaOpTable[_inst.OPCD](_inst);
|
||||
GekkoOPInfo *info = GetOpInfo(_inst);
|
||||
if (info) {
|
||||
#ifdef OPLOG
|
||||
if (!strcmp(info->opname, "mcrfs")) {
|
||||
rsplocations.push_back(Jit64::js.compilerPC);
|
||||
}
|
||||
#endif
|
||||
info->compileCount++;
|
||||
info->lastUse = Jit64::js.compilerPC;
|
||||
} else {
|
||||
PanicAlert("Tried to compile illegal (or unknown) instruction %08x, at %08x", _inst.hex, Jit64::js.compilerPC);
|
||||
}
|
||||
}
|
||||
|
||||
@ -688,7 +696,6 @@ struct inf
|
||||
void PPCTables::PrintInstructionRunCounts()
|
||||
{
|
||||
std::vector<inf> temp;
|
||||
|
||||
for (int i = 0; i < m_numInstructions; i++)
|
||||
{
|
||||
inf x;
|
||||
@ -697,7 +704,6 @@ void PPCTables::PrintInstructionRunCounts()
|
||||
temp.push_back(x);
|
||||
}
|
||||
std::sort(temp.begin(), temp.end());
|
||||
|
||||
for (int i = 0; i < m_numInstructions; i++)
|
||||
{
|
||||
LOG(GEKKO, "%s : %i", temp[i].name,temp[i].count);
|
||||
@ -724,10 +730,12 @@ void PPCTables::LogCompiledInstructions()
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
#ifdef OPLOG
|
||||
f = fopen(StringFromFormat(FULL_LOGS_DIR "mcrfs_at.txt", time).c_str(), "w");
|
||||
for (size_t i = 0; i < rsplocations.size(); i++) {
|
||||
fprintf(f, "mcrfs: %08x\n", rsplocations[i]);
|
||||
}
|
||||
fclose(f);
|
||||
#endif
|
||||
time++;
|
||||
}
|
||||
|
@ -55,7 +55,6 @@
|
||||
AssemblerListingLocation="$(IntDir)\"
|
||||
WarningLevel="3"
|
||||
WarnAsError="false"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
ForcedIncludeFiles="stdafx.h"
|
||||
/>
|
||||
@ -140,7 +139,6 @@
|
||||
AssemblerListingLocation="$(IntDir)\"
|
||||
WarningLevel="3"
|
||||
WarnAsError="false"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
ForcedIncludeFiles="stdafx.h"
|
||||
/>
|
||||
@ -228,7 +226,6 @@
|
||||
AssemblerListingLocation="$(IntDir)\"
|
||||
WarningLevel="3"
|
||||
WarnAsError="false"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
ForcedIncludeFiles="stdafx.h"
|
||||
/>
|
||||
@ -405,7 +402,6 @@
|
||||
AssemblerListingLocation="$(IntDir)\"
|
||||
WarningLevel="3"
|
||||
WarnAsError="false"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
ForcedIncludeFiles="stdafx.h"
|
||||
/>
|
||||
@ -494,7 +490,6 @@
|
||||
AssemblerListingLocation="$(IntDir)\"
|
||||
WarningLevel="3"
|
||||
WarnAsError="false"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
ForcedIncludeFiles="stdafx.h"
|
||||
/>
|
||||
|
Reference in New Issue
Block a user