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
void XEmitter::ABI_CallFunction(void *func) {
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
//CALL(func);
//MOV(64, R(RAX), Imm64((u64)func));
//CALLptr(R(RAX));
CALL(func);
}
void XEmitter::ABI_CallFunctionC16(void *func, u16 param1) {
MOV(32, R(ABI_PARAM1), Imm32((u32)param1));
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
//CALL(func);
//MOV(64, R(RAX), Imm64((u64)func));
//CALLptr(R(RAX));
CALL(func);
}
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);
}
inline void dsp_skip_inst()
{
g_dsp.pc += opTable[dsp_peek_code()]->size;
}
#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},
{"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);
}
}
}
}

View File

@ -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

View File

@ -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();
}
}

View File

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