Skip to content

Commit

Permalink
Add support for RSP vector control register names (ctc2/cfc2)
Browse files Browse the repository at this point in the history
  • Loading branch information
sp1187 committed May 23, 2018
1 parent 5996abc commit 0450d1a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions Archs/MIPS/CMipsInstruction.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ enum class MipsRegisterType
VfpuMatrix, VfpuMatrix,
RspCop0, RspCop0,
RspVector, RspVector,
RspVectorControl,
RspBroadcastElement, RspBroadcastElement,
RspScalarElement, RspScalarElement,
RspOffsetElement RspOffsetElement
Expand Down
4 changes: 2 additions & 2 deletions Archs/MIPS/MipsOpcodes.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -557,9 +557,9 @@ const tMipsOpcode MipsOpcodes[] = {
// hi |-------|-------|-------|-------|-------|-------|-------|-------| // hi |-------|-------|-------|-------|-------|-------|-------|-------|


{ "mfc2", "t,RsRo", MIPS_COP2(0x00), MA_RSP, 0 }, { "mfc2", "t,RsRo", MIPS_COP2(0x00), MA_RSP, 0 },
{ "cfc2", "t,d", MIPS_COP2(0x02), MA_RSP, 0 }, { "cfc2", "t,Rc", MIPS_COP2(0x02), MA_RSP, 0 },
{ "mtc2", "t,RsRo", MIPS_COP2(0x04), MA_RSP, 0 }, { "mtc2", "t,RsRo", MIPS_COP2(0x04), MA_RSP, 0 },
{ "ctc2", "t,d", MIPS_COP2(0x06), MA_RSP, 0 }, { "ctc2", "t,Rc", MIPS_COP2(0x06), MA_RSP, 0 },
// VVVVVV VVVVV ttttt -------- C DDDDDDD // VVVVVV VVVVV ttttt -------- C DDDDDDD
{ "mfv", "t,vd", MIPS_COP2(0x03), MA_PSP, MO_VFPU|MO_VFPU_SINGLE }, { "mfv", "t,vd", MIPS_COP2(0x03), MA_PSP, MO_VFPU|MO_VFPU_SINGLE },
{ "mfvc", "t,vc", MIPS_COP2(0x03) | 0x80, MA_PSP, MO_VFPU }, { "mfvc", "t,vc", MIPS_COP2(0x03) | 0x80, MA_PSP, MO_VFPU },
Expand Down
17 changes: 17 additions & 0 deletions Archs/MIPS/MipsParser.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ const MipsRegisterDescriptor mipsRspCop0Registers[] = {
{ L"dpc_tmem", 15 }, { L"dpc_tmem", 15 },
}; };


const MipsRegisterDescriptor mipsRspVectorControlRegisters[] = {
{ L"vco", 0 }, { L"vcc", 1 }, { L"vce", 2 },
};

const MipsRegisterDescriptor mipsRspVectorRegisters[] = { const MipsRegisterDescriptor mipsRspVectorRegisters[] = {
{ L"v0", 0 }, { L"v1", 1 }, { L"v2", 2 }, { L"v3", 3 }, { L"v0", 0 }, { L"v1", 1 }, { L"v2", 2 }, { L"v3", 3 },
{ L"v4", 4 }, { L"v5", 5 }, { L"v6", 6 }, { L"v7", 7 }, { L"v4", 4 }, { L"v5", 5 }, { L"v6", 6 }, { L"v7", 7 },
Expand Down Expand Up @@ -279,6 +283,16 @@ bool MipsParser::parseRspCop0Register(Parser& parser, MipsRegisterValue& dest)
return parseRegisterTable(parser,dest,mipsRspCop0Registers,ARRAY_SIZE(mipsRspCop0Registers)); return parseRegisterTable(parser,dest,mipsRspCop0Registers,ARRAY_SIZE(mipsRspCop0Registers));
} }


bool MipsParser::parseRspVectorControlRegister(Parser& parser, MipsRegisterValue& dest)
{
dest.type = MipsRegisterType::RspVectorControl;

if (parseRegisterNumber(parser, dest, 32))
return true;

return parseRegisterTable(parser,dest,mipsRspVectorControlRegisters,ARRAY_SIZE(mipsRspVectorControlRegisters));
}

bool MipsParser::parseRspVectorRegister(Parser& parser, MipsRegisterValue& dest) bool MipsParser::parseRspVectorRegister(Parser& parser, MipsRegisterValue& dest)
{ {
dest.type = MipsRegisterType::RspVector; dest.type = MipsRegisterType::RspVector;
Expand Down Expand Up @@ -1277,6 +1291,9 @@ bool MipsParser::parseParameters(Parser& parser, const tMipsOpcode& opcode)
case 'z': // cop0 register case 'z': // cop0 register
CHECK(parseRspCop0Register(parser,registers.grd)); CHECK(parseRspCop0Register(parser,registers.grd));
break; break;
case 'c': // vector control register
CHECK(parseRspVectorControlRegister(parser,registers.grd));
break;
case 't': // vector register case 't': // vector register
CHECK(parseRspVectorRegister(parser,registers.rspvrt)); CHECK(parseRspVectorRegister(parser,registers.rspvrt));
break; break;
Expand Down
1 change: 1 addition & 0 deletions Archs/MIPS/MipsParser.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class MipsParser
bool parseCop0Register(Parser& parser, MipsRegisterValue& dest); bool parseCop0Register(Parser& parser, MipsRegisterValue& dest);
bool parsePs2Cop2Register(Parser& parser, MipsRegisterValue& dest); bool parsePs2Cop2Register(Parser& parser, MipsRegisterValue& dest);
bool parseRspCop0Register(Parser& parser, MipsRegisterValue& dest); bool parseRspCop0Register(Parser& parser, MipsRegisterValue& dest);
bool parseRspVectorControlRegister(Parser& parser, MipsRegisterValue& dest);
bool parseRspVectorRegister(Parser& parser, MipsRegisterValue& dest); bool parseRspVectorRegister(Parser& parser, MipsRegisterValue& dest);
bool parseRspBroadcastElement(Parser& parser, MipsRegisterValue& dest); bool parseRspBroadcastElement(Parser& parser, MipsRegisterValue& dest);
bool parseRspScalarElement(Parser& parser, MipsRegisterValue& dest); bool parseRspScalarElement(Parser& parser, MipsRegisterValue& dest);
Expand Down

0 comments on commit 0450d1a

Please sign in to comment.