Add "jitblacklist" prefs item so that opcodes ranges could be excluded for

translation. This should help debugging of (badly) translated code.

Usage: jitblacklist xxxx(-yyyy)?(;xxxx(-yyyy)?)*
where xxxx/yyyy are hexadecimal numbers
This commit is contained in:
gbeauche 2003-10-14 10:29:19 +00:00
parent 75df809ff7
commit 309c2f0bd5
2 changed files with 75 additions and 10 deletions

View File

@ -62,6 +62,7 @@ prefs_desc common_prefs_items[] = {
{"jitdebug", TYPE_BOOLEAN, false, "enable JIT debugger (requires mon builtin)"},
{"jitcachesize", TYPE_INT32, false, "translation cache size in KB"},
{"jitlazyflush", TYPE_BOOLEAN, false, "enable lazy invalidation of translation cache"},
{"jitblacklist", TYPE_STRING, false, "blacklist opcodes from translation"},
{"keyboardtype", TYPE_INT32, false, "hardware keyboard type"},
{NULL, TYPE_END, false, NULL} // End of list
};

View File

@ -6011,13 +6011,74 @@ static void prepare_block(blockinfo* bi)
//bi->env=empty_ss;
}
static bool avoid_opcode(uae_u32 opcode)
// OPCODE is in big endian format, use cft_map() beforehand, if needed.
static inline void reset_compop(int opcode)
{
#if JIT_DEBUG
struct instr *dp = &table68k[opcode];
// filter opcodes per type, integral value, or whatever
#endif
return false;
compfunctbl[opcode] = NULL;
nfcompfunctbl[opcode] = NULL;
}
static int read_opcode(const char *p)
{
int opcode = 0;
for (int i = 0; i < 4; i++) {
int op = p[i];
switch (op) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
opcode = (opcode << 4) | (op - '0');
break;
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
opcode = (opcode << 4) | ((op - 'a') + 10);
break;
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
opcode = (opcode << 4) | ((op - 'A') + 10);
break;
default:
return -1;
}
}
return opcode;
}
static bool merge_blacklist()
{
const char *blacklist = PrefsFindString("jitblacklist");
if (blacklist) {
const char *p = blacklist;
for (;;) {
if (*p == 0)
return true;
int opcode1 = read_opcode(p);
if (opcode1 < 0)
return false;
p += 4;
int opcode2 = opcode1;
if (*p == '-') {
p++;
opcode2 = read_opcode(p);
if (opcode2 < 0)
return false;
p += 4;
}
if (*p == 0 || *p == ';') {
write_log("<JIT compiler> : blacklist opcodes : %04x-%04x\n", opcode1, opcode2);
for (int opcode = opcode1; opcode <= opcode2; opcode++)
reset_compop(cft_map(opcode));
if (*p++ == ';')
continue;
return true;
}
return false;
}
}
return true;
}
void build_comp(void)
@ -6049,9 +6110,8 @@ void build_comp(void)
write_log ("<JIT compiler> : building compiler function tables\n");
for (opcode = 0; opcode < 65536; opcode++) {
reset_compop(opcode);
nfcpufunctbl[opcode] = op_illg_1;
compfunctbl[opcode] = NULL;
nfcompfunctbl[opcode] = NULL;
prop[opcode].use_flags = 0x1f;
prop[opcode].set_flags = 0x1f;
prop[opcode].cflow = fl_trap; // ILLEGAL instructions do trap
@ -6066,7 +6126,7 @@ void build_comp(void)
prop[cft_map(tbl[i].opcode)].cflow = cflow;
int uses_fpu = tbl[i].specific & 32;
if ((uses_fpu && avoid_fpu) || avoid_opcode(tbl[i].opcode))
if (uses_fpu && avoid_fpu)
compfunctbl[cft_map(tbl[i].opcode)] = NULL;
else
compfunctbl[cft_map(tbl[i].opcode)] = tbl[i].handler;
@ -6074,7 +6134,7 @@ void build_comp(void)
for (i = 0; nftbl[i].opcode < 65536; i++) {
int uses_fpu = tbl[i].specific & 32;
if ((uses_fpu && avoid_fpu) || avoid_opcode(nftbl[i].opcode))
if (uses_fpu && avoid_fpu)
nfcompfunctbl[cft_map(nftbl[i].opcode)] = NULL;
else
nfcompfunctbl[cft_map(nftbl[i].opcode)] = nftbl[i].handler;
@ -6117,6 +6177,10 @@ void build_comp(void)
nfcpufunctbl[cft_map(tbl[i].opcode)] = nfctbl[i].handler;
}
/* Merge in blacklist */
if (!merge_blacklist())
write_log("<JIT compiler> : blacklist merge failure!\n");
count=0;
for (opcode = 0; opcode < 65536; opcode++) {
if (compfunctbl[cft_map(opcode)])