mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 05:40:01 -06:00
DSPLLE: Opcode LUT Cleanup
ABI: Far Call --> Call (thanks to correct vcproj settings) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5250 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -46,4 +46,9 @@ inline u16 dsp_peek_code()
|
||||
return dsp_imem_read(g_dsp.pc);
|
||||
}
|
||||
|
||||
inline void dsp_skip_inst()
|
||||
{
|
||||
g_dsp.pc += opTable[dsp_peek_code()]->size;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -39,7 +39,7 @@ const DSPOPCTemplate opcodes[] =
|
||||
{"SUBARN", 0x000c, 0xfffc, DSPInterpreter::subarn, nop, 1, 1, {{P_REG, 1, 0, 0, 0x0003}}, false, false},
|
||||
{"ADDARN", 0x0010, 0xfff0, DSPInterpreter::addarn, nop, 1, 2, {{P_REG, 1, 0, 0, 0x0003}, {P_REG04, 1, 0, 2, 0x000c}}, false, false},
|
||||
|
||||
{"HALT", 0x0021, 0xffff, DSPInterpreter::halt, nop, 1, 0, {}, false, false},
|
||||
{"HALT", 0x0021, 0xffff, DSPInterpreter::halt, nop, 1, 0, {}, false, true},
|
||||
|
||||
{"RETGE", 0x02d0, 0xffff, DSPInterpreter::ret, nop, 1, 0, {}, false, true},
|
||||
{"RETL", 0x02d1, 0xffff, DSPInterpreter::ret, nop, 1, 0, {}, false, true},
|
||||
@ -485,10 +485,8 @@ const pdlabel_t regnames[] =
|
||||
{0x23, "AX1", "Extra Accu 1",},
|
||||
};
|
||||
|
||||
u8 opSize[OPTABLE_SIZE];
|
||||
dspInstFunc opTable[OPTABLE_SIZE];
|
||||
dspInstFunc extOpTable[EXT_OPTABLE_SIZE];
|
||||
bool opTableUseExt[OPTABLE_SIZE];
|
||||
const DSPOPCTemplate *opTable[OPTABLE_SIZE];
|
||||
const DSPOPCTemplate *extOpTable[EXT_OPTABLE_SIZE];
|
||||
u16 writeBackLog[WRITEBACKLOGSIZE];
|
||||
int writeBackLogIdx[WRITEBACKLOGSIZE];
|
||||
|
||||
@ -518,13 +516,7 @@ const char *pdregnamelong(int val)
|
||||
|
||||
const DSPOPCTemplate *GetOpTemplate(const UDSPInstruction &inst)
|
||||
{
|
||||
for (int i = 0; i < opcodes_size; i++)
|
||||
{
|
||||
u16 mask = opcodes[i].opcode_mask;
|
||||
if ((mask & inst) == opcodes[i].opcode)
|
||||
return &opcodes[i];
|
||||
}
|
||||
return NULL;
|
||||
return opTable[inst];
|
||||
}
|
||||
|
||||
|
||||
@ -534,7 +526,7 @@ void InitInstructionTable()
|
||||
{
|
||||
// ext op table
|
||||
for (int i = 0; i < EXT_OPTABLE_SIZE; i++)
|
||||
extOpTable[i] = DSPInterpreter::unknown;
|
||||
extOpTable[i] = &cw;
|
||||
|
||||
for (int i = 0; i < EXT_OPTABLE_SIZE; i++)
|
||||
{
|
||||
@ -543,8 +535,8 @@ void InitInstructionTable()
|
||||
u16 mask = opcodes_ext[j].opcode_mask;
|
||||
if ((mask & i) == opcodes_ext[j].opcode)
|
||||
{
|
||||
if (extOpTable[i] == DSPInterpreter::unknown)
|
||||
extOpTable[i] = opcodes_ext[j].interpFunc;
|
||||
if (extOpTable[i] == &cw)
|
||||
extOpTable[i] = &opcodes_ext[j];
|
||||
else
|
||||
ERROR_LOG(DSPLLE, "opcode ext table place %d already in use for %s", i, opcodes_ext[j].name);
|
||||
}
|
||||
@ -553,11 +545,7 @@ void InitInstructionTable()
|
||||
|
||||
// op table
|
||||
for (int i = 0; i < OPTABLE_SIZE; i++)
|
||||
{
|
||||
opTable[i] = DSPInterpreter::unknown;
|
||||
opTableUseExt[i] = false;
|
||||
opSize[i] = 0;
|
||||
}
|
||||
opTable[i] = &cw;
|
||||
|
||||
for (int i = 0; i < OPTABLE_SIZE; i++)
|
||||
{
|
||||
@ -566,16 +554,10 @@ void InitInstructionTable()
|
||||
u16 mask = opcodes[j].opcode_mask;
|
||||
if ((mask & i) == opcodes[j].opcode)
|
||||
{
|
||||
if (opTable[i] == DSPInterpreter::unknown)
|
||||
{
|
||||
opTable[i] = opcodes[j].interpFunc;
|
||||
opSize[i] = opcodes[j].size & 3;
|
||||
opTableUseExt[i] = opcodes[j].extended;
|
||||
}
|
||||
if (opTable[i] == &cw)
|
||||
opTable[i] = &opcodes[j];
|
||||
else
|
||||
{
|
||||
ERROR_LOG(DSPLLE, "opcode table place %d already in use for %s", i, opcodes[j].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,28 +68,6 @@ enum partype_t
|
||||
#define EXT_OPTABLE_SIZE 0xff + 1
|
||||
|
||||
typedef u16 UDSPInstruction;
|
||||
/*/union UDSPInstruction
|
||||
{
|
||||
u16 hex;
|
||||
|
||||
UDSPInstruction(u16 _hex) { hex = _hex; }
|
||||
UDSPInstruction() { hex = 0; }
|
||||
|
||||
struct
|
||||
{
|
||||
signed shift : 6;
|
||||
unsigned negating : 1;
|
||||
unsigned arithmetic : 1;
|
||||
unsigned areg : 1;
|
||||
unsigned op : 7;
|
||||
};
|
||||
struct
|
||||
{
|
||||
unsigned ushift : 6;
|
||||
};
|
||||
|
||||
// TODO: Figure out more instruction structures (add structs here)
|
||||
};*/
|
||||
|
||||
typedef void (*dspInstFunc)(const UDSPInstruction);
|
||||
|
||||
@ -125,14 +103,12 @@ extern const DSPOPCTemplate opcodes[];
|
||||
extern const int opcodes_size;
|
||||
extern const DSPOPCTemplate opcodes_ext[];
|
||||
extern const int opcodes_ext_size;
|
||||
extern u8 opSize[OPTABLE_SIZE];
|
||||
extern const DSPOPCTemplate cw;
|
||||
|
||||
#define WRITEBACKLOGSIZE 7
|
||||
|
||||
extern dspInstFunc opTable[];
|
||||
extern bool opTableUseExt[OPTABLE_SIZE];
|
||||
extern dspInstFunc extOpTable[EXT_OPTABLE_SIZE];
|
||||
extern const DSPOPCTemplate *opTable[OPTABLE_SIZE];
|
||||
extern const DSPOPCTemplate *extOpTable[EXT_OPTABLE_SIZE];
|
||||
extern u16 writeBackLog[WRITEBACKLOGSIZE];
|
||||
extern int writeBackLogIdx[WRITEBACKLOGSIZE];
|
||||
|
||||
@ -157,22 +133,22 @@ void applyWriteBackLog();
|
||||
void zeroWriteBackLog();
|
||||
void zeroWriteBackLogPreserveAcc(u8 acc);
|
||||
|
||||
const DSPOPCTemplate *GetOpTemplate(const UDSPInstruction &inst);
|
||||
|
||||
inline void ExecuteInstruction(const UDSPInstruction inst)
|
||||
{
|
||||
if (opTableUseExt[inst]) {
|
||||
const DSPOPCTemplate *tinst = GetOpTemplate(inst);
|
||||
|
||||
if (tinst->extended) {
|
||||
if ((inst >> 12) == 0x3)
|
||||
extOpTable[inst & 0x7F](inst);
|
||||
extOpTable[inst & 0x7F]->interpFunc(inst);
|
||||
else
|
||||
extOpTable[inst & 0xFF](inst);
|
||||
extOpTable[inst & 0xFF]->interpFunc(inst);
|
||||
}
|
||||
opTable[inst](inst);
|
||||
if (opTableUseExt[inst]) {
|
||||
tinst->interpFunc(inst);
|
||||
if (tinst->extended) {
|
||||
applyWriteBackLog();
|
||||
}
|
||||
}
|
||||
|
||||
// This one's pretty slow, try to use it only at init or seldomly.
|
||||
// returns NULL if no matching instruction.
|
||||
const DSPOPCTemplate *GetOpTemplate(const UDSPInstruction &inst);
|
||||
|
||||
#endif // _DSPTABLES_H
|
||||
|
@ -71,7 +71,7 @@ void ifcc(const UDSPInstruction opc)
|
||||
if (!CheckCondition(opc & 0xf))
|
||||
{
|
||||
// skip the next opcode - we have to lookup its size.
|
||||
g_dsp.pc += opSize[dsp_peek_code()];
|
||||
dsp_skip_inst();
|
||||
}
|
||||
}
|
||||
|
||||
@ -242,7 +242,7 @@ void bloop(const UDSPInstruction opc)
|
||||
else
|
||||
{
|
||||
g_dsp.pc = loop_pc;
|
||||
g_dsp.pc += opSize[dsp_peek_code()];
|
||||
dsp_skip_inst();
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,7 +269,7 @@ void bloopi(const UDSPInstruction opc)
|
||||
else
|
||||
{
|
||||
g_dsp.pc = loop_pc;
|
||||
g_dsp.pc += opSize[dsp_peek_code()];
|
||||
dsp_skip_inst();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user