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:
XTra.KrazzY 2010-03-29 01:18:05 +00:00
parent 49d568488c
commit a8865d21b3
6 changed files with 54 additions and 79 deletions

View file

@ -190,17 +190,17 @@ void XEmitter::ABI_RestoreStack(unsigned int frameSize) {
// Common functions // Common functions
void XEmitter::ABI_CallFunction(void *func) { void XEmitter::ABI_CallFunction(void *func) {
// Far call // Far call
MOV(64, R(RAX), Imm64((u64)func)); //MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX)); //CALLptr(R(RAX));
//CALL(func); CALL(func);
} }
void XEmitter::ABI_CallFunctionC16(void *func, u16 param1) { void XEmitter::ABI_CallFunctionC16(void *func, u16 param1) {
MOV(32, R(ABI_PARAM1), Imm32((u32)param1)); MOV(32, R(ABI_PARAM1), Imm32((u32)param1));
// Far call // Far call
MOV(64, R(RAX), Imm64((u64)func)); //MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX)); //CALLptr(R(RAX));
//CALL(func); CALL(func);
} }
void XEmitter::ABI_CallFunctionC(void *func, u32 param1) { void XEmitter::ABI_CallFunctionC(void *func, u32 param1) {

View file

@ -46,4 +46,9 @@ inline u16 dsp_peek_code()
return dsp_imem_read(g_dsp.pc); return dsp_imem_read(g_dsp.pc);
} }
inline void dsp_skip_inst()
{
g_dsp.pc += opTable[dsp_peek_code()]->size;
}
#endif #endif

View file

@ -39,7 +39,7 @@ const DSPOPCTemplate opcodes[] =
{"SUBARN", 0x000c, 0xfffc, DSPInterpreter::subarn, nop, 1, 1, {{P_REG, 1, 0, 0, 0x0003}}, false, false}, {"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}, {"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}, {"RETGE", 0x02d0, 0xffff, DSPInterpreter::ret, nop, 1, 0, {}, false, true},
{"RETL", 0x02d1, 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",}, {0x23, "AX1", "Extra Accu 1",},
}; };
u8 opSize[OPTABLE_SIZE]; const DSPOPCTemplate *opTable[OPTABLE_SIZE];
dspInstFunc opTable[OPTABLE_SIZE]; const DSPOPCTemplate *extOpTable[EXT_OPTABLE_SIZE];
dspInstFunc extOpTable[EXT_OPTABLE_SIZE];
bool opTableUseExt[OPTABLE_SIZE];
u16 writeBackLog[WRITEBACKLOGSIZE]; u16 writeBackLog[WRITEBACKLOGSIZE];
int writeBackLogIdx[WRITEBACKLOGSIZE]; int writeBackLogIdx[WRITEBACKLOGSIZE];
@ -518,13 +516,7 @@ const char *pdregnamelong(int val)
const DSPOPCTemplate *GetOpTemplate(const UDSPInstruction &inst) const DSPOPCTemplate *GetOpTemplate(const UDSPInstruction &inst)
{ {
for (int i = 0; i < opcodes_size; i++) return opTable[inst];
{
u16 mask = opcodes[i].opcode_mask;
if ((mask & inst) == opcodes[i].opcode)
return &opcodes[i];
}
return NULL;
} }
@ -534,7 +526,7 @@ void InitInstructionTable()
{ {
// ext op table // ext op table
for (int i = 0; i < EXT_OPTABLE_SIZE; i++) 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++) for (int i = 0; i < EXT_OPTABLE_SIZE; i++)
{ {
@ -543,8 +535,8 @@ void InitInstructionTable()
u16 mask = opcodes_ext[j].opcode_mask; u16 mask = opcodes_ext[j].opcode_mask;
if ((mask & i) == opcodes_ext[j].opcode) if ((mask & i) == opcodes_ext[j].opcode)
{ {
if (extOpTable[i] == DSPInterpreter::unknown) if (extOpTable[i] == &cw)
extOpTable[i] = opcodes_ext[j].interpFunc; extOpTable[i] = &opcodes_ext[j];
else else
ERROR_LOG(DSPLLE, "opcode ext table place %d already in use for %s", i, opcodes_ext[j].name); 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 // op table
for (int i = 0; i < OPTABLE_SIZE; i++) for (int i = 0; i < OPTABLE_SIZE; i++)
{ opTable[i] = &cw;
opTable[i] = DSPInterpreter::unknown;
opTableUseExt[i] = false;
opSize[i] = 0;
}
for (int i = 0; i < OPTABLE_SIZE; i++) for (int i = 0; i < OPTABLE_SIZE; i++)
{ {
@ -566,19 +554,13 @@ void InitInstructionTable()
u16 mask = opcodes[j].opcode_mask; u16 mask = opcodes[j].opcode_mask;
if ((mask & i) == opcodes[j].opcode) if ((mask & i) == opcodes[j].opcode)
{ {
if (opTable[i] == DSPInterpreter::unknown) if (opTable[i] == &cw)
{ opTable[i] = &opcodes[j];
opTable[i] = opcodes[j].interpFunc;
opSize[i] = opcodes[j].size & 3;
opTableUseExt[i] = opcodes[j].extended;
}
else else
{
ERROR_LOG(DSPLLE, "opcode table place %d already in use for %s", i, opcodes[j].name); ERROR_LOG(DSPLLE, "opcode table place %d already in use for %s", i, opcodes[j].name);
} }
} }
} }
}
for (int i=0; i < WRITEBACKLOGSIZE; i++) for (int i=0; i < WRITEBACKLOGSIZE; i++)
writeBackLogIdx[i] = -1; writeBackLogIdx[i] = -1;

View file

@ -68,28 +68,6 @@ enum partype_t
#define EXT_OPTABLE_SIZE 0xff + 1 #define EXT_OPTABLE_SIZE 0xff + 1
typedef u16 UDSPInstruction; 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); typedef void (*dspInstFunc)(const UDSPInstruction);
@ -125,14 +103,12 @@ extern const DSPOPCTemplate opcodes[];
extern const int opcodes_size; extern const int opcodes_size;
extern const DSPOPCTemplate opcodes_ext[]; extern const DSPOPCTemplate opcodes_ext[];
extern const int opcodes_ext_size; extern const int opcodes_ext_size;
extern u8 opSize[OPTABLE_SIZE];
extern const DSPOPCTemplate cw; extern const DSPOPCTemplate cw;
#define WRITEBACKLOGSIZE 7 #define WRITEBACKLOGSIZE 7
extern dspInstFunc opTable[]; extern const DSPOPCTemplate *opTable[OPTABLE_SIZE];
extern bool opTableUseExt[OPTABLE_SIZE]; extern const DSPOPCTemplate *extOpTable[EXT_OPTABLE_SIZE];
extern dspInstFunc extOpTable[EXT_OPTABLE_SIZE];
extern u16 writeBackLog[WRITEBACKLOGSIZE]; extern u16 writeBackLog[WRITEBACKLOGSIZE];
extern int writeBackLogIdx[WRITEBACKLOGSIZE]; extern int writeBackLogIdx[WRITEBACKLOGSIZE];
@ -157,22 +133,22 @@ void applyWriteBackLog();
void zeroWriteBackLog(); void zeroWriteBackLog();
void zeroWriteBackLogPreserveAcc(u8 acc); void zeroWriteBackLogPreserveAcc(u8 acc);
const DSPOPCTemplate *GetOpTemplate(const UDSPInstruction &inst);
inline void ExecuteInstruction(const UDSPInstruction inst) inline void ExecuteInstruction(const UDSPInstruction inst)
{ {
if (opTableUseExt[inst]) { const DSPOPCTemplate *tinst = GetOpTemplate(inst);
if (tinst->extended) {
if ((inst >> 12) == 0x3) if ((inst >> 12) == 0x3)
extOpTable[inst & 0x7F](inst); extOpTable[inst & 0x7F]->interpFunc(inst);
else else
extOpTable[inst & 0xFF](inst); extOpTable[inst & 0xFF]->interpFunc(inst);
} }
opTable[inst](inst); tinst->interpFunc(inst);
if (opTableUseExt[inst]) { if (tinst->extended) {
applyWriteBackLog(); 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 #endif // _DSPTABLES_H

View file

@ -71,7 +71,7 @@ void ifcc(const UDSPInstruction opc)
if (!CheckCondition(opc & 0xf)) if (!CheckCondition(opc & 0xf))
{ {
// skip the next opcode - we have to lookup its size. // 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 else
{ {
g_dsp.pc = loop_pc; 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 else
{ {
g_dsp.pc = loop_pc; g_dsp.pc = loop_pc;
g_dsp.pc += opSize[dsp_peek_code()]; dsp_skip_inst();
} }
} }

View file

@ -76,8 +76,10 @@
GenerateDebugInformation="true" GenerateDebugInformation="true"
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb" ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
SubSystem="2" SubSystem="2"
BaseAddress="0x00b00000"
RandomizedBaseAddress="1" RandomizedBaseAddress="1"
DataExecutionPrevention="0" FixedBaseAddress="1"
DataExecutionPrevention="2"
ImportLibrary="$(PlatformName)\$(ConfigurationName)\$(TargetName).lib" ImportLibrary="$(PlatformName)\$(ConfigurationName)\$(TargetName).lib"
TargetMachine="1" TargetMachine="1"
/> />
@ -164,8 +166,10 @@
AssemblyDebug="1" AssemblyDebug="1"
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb" ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
SubSystem="2" SubSystem="2"
BaseAddress="0x00b00000"
RandomizedBaseAddress="1" RandomizedBaseAddress="1"
DataExecutionPrevention="0" FixedBaseAddress="1"
DataExecutionPrevention="2"
ImportLibrary="$(PlatformName)\$(ConfigurationName)\$(TargetName).lib" ImportLibrary="$(PlatformName)\$(ConfigurationName)\$(TargetName).lib"
TargetMachine="17" TargetMachine="17"
/> />
@ -254,8 +258,10 @@
SubSystem="2" SubSystem="2"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"
BaseAddress="0x00b00000"
RandomizedBaseAddress="1" RandomizedBaseAddress="1"
DataExecutionPrevention="0" FixedBaseAddress="1"
DataExecutionPrevention="2"
ImportLibrary="$(PlatformName)\$(ConfigurationName)\$(TargetName).lib" ImportLibrary="$(PlatformName)\$(ConfigurationName)\$(TargetName).lib"
TargetMachine="1" TargetMachine="1"
/> />
@ -310,7 +316,7 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="2" Optimization="2"
InlineFunctionExpansion="2" InlineFunctionExpansion="0"
EnableIntrinsicFunctions="true" EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1" FavorSizeOrSpeed="1"
OmitFramePointers="true" OmitFramePointers="true"
@ -345,8 +351,10 @@
SubSystem="2" SubSystem="2"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"
BaseAddress="0x00b00000"
RandomizedBaseAddress="1" RandomizedBaseAddress="1"
DataExecutionPrevention="0" FixedBaseAddress="1"
DataExecutionPrevention="2"
ImportLibrary="$(PlatformName)\$(ConfigurationName)\$(TargetName).lib" ImportLibrary="$(PlatformName)\$(ConfigurationName)\$(TargetName).lib"
TargetMachine="17" TargetMachine="17"
/> />
@ -435,8 +443,10 @@
SubSystem="2" SubSystem="2"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"
BaseAddress="0x00b00000"
RandomizedBaseAddress="1" RandomizedBaseAddress="1"
DataExecutionPrevention="0" FixedBaseAddress="1"
DataExecutionPrevention="2"
ImportLibrary="$(PlatformName)\$(ConfigurationName)\$(TargetName).lib" ImportLibrary="$(PlatformName)\$(ConfigurationName)\$(TargetName).lib"
TargetMachine="1" TargetMachine="1"
/> />
@ -526,8 +536,10 @@
SubSystem="2" SubSystem="2"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"
BaseAddress="0x00b00000"
RandomizedBaseAddress="1" RandomizedBaseAddress="1"
DataExecutionPrevention="0" FixedBaseAddress="1"
DataExecutionPrevention="2"
ImportLibrary="$(PlatformName)\$(ConfigurationName)\$(TargetName).lib" ImportLibrary="$(PlatformName)\$(ConfigurationName)\$(TargetName).lib"
TargetMachine="17" TargetMachine="17"
/> />