mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-04-27 18:15:42 -04:00
CPU/Recompiler: Implement and/or/xor
This commit is contained in:
parent
a9cbc08890
commit
e2850b5a6c
@ -74,7 +74,7 @@ bool CodeGenerator::CompileInstruction(const CodeBlockInstruction& cbi)
|
|||||||
case InstructionOp::ori:
|
case InstructionOp::ori:
|
||||||
case InstructionOp::andi:
|
case InstructionOp::andi:
|
||||||
case InstructionOp::xori:
|
case InstructionOp::xori:
|
||||||
result = Compile_BitwiseImmediate(cbi);
|
result = Compile_Bitwise(cbi);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case InstructionOp::lb:
|
case InstructionOp::lb:
|
||||||
@ -114,6 +114,12 @@ bool CodeGenerator::CompileInstruction(const CodeBlockInstruction& cbi)
|
|||||||
{
|
{
|
||||||
switch (cbi.instruction.r.funct)
|
switch (cbi.instruction.r.funct)
|
||||||
{
|
{
|
||||||
|
case InstructionFunct::and_:
|
||||||
|
case InstructionFunct::or_:
|
||||||
|
case InstructionFunct::xor_:
|
||||||
|
result = Compile_Bitwise(cbi);
|
||||||
|
break;
|
||||||
|
|
||||||
case InstructionFunct::sll:
|
case InstructionFunct::sll:
|
||||||
case InstructionFunct::srl:
|
case InstructionFunct::srl:
|
||||||
case InstructionFunct::sra:
|
case InstructionFunct::sra:
|
||||||
@ -842,26 +848,65 @@ bool CodeGenerator::Compile_Fallback(const CodeBlockInstruction& cbi)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CodeGenerator::Compile_BitwiseImmediate(const CodeBlockInstruction& cbi)
|
bool CodeGenerator::Compile_Bitwise(const CodeBlockInstruction& cbi)
|
||||||
{
|
{
|
||||||
InstructionPrologue(cbi, 1);
|
InstructionPrologue(cbi, 1);
|
||||||
|
|
||||||
|
const InstructionOp op = cbi.instruction.op;
|
||||||
|
const InstructionFunct funct = cbi.instruction.r.funct;
|
||||||
|
Value lhs;
|
||||||
|
Value rhs;
|
||||||
|
Reg dest;
|
||||||
|
if (op != InstructionOp::funct)
|
||||||
|
{
|
||||||
// rt <- rs op zext(imm)
|
// rt <- rs op zext(imm)
|
||||||
Value rs = m_register_cache.ReadGuestRegister(cbi.instruction.i.rs);
|
lhs = m_register_cache.ReadGuestRegister(cbi.instruction.i.rs);
|
||||||
Value imm = Value::FromConstantU32(cbi.instruction.i.imm_zext32());
|
rhs = Value::FromConstantU32(cbi.instruction.i.imm_zext32());
|
||||||
|
dest = cbi.instruction.i.rt;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lhs = m_register_cache.ReadGuestRegister(cbi.instruction.r.rs);
|
||||||
|
rhs = m_register_cache.ReadGuestRegister(cbi.instruction.r.rt);
|
||||||
|
dest = cbi.instruction.r.rd;
|
||||||
|
}
|
||||||
|
|
||||||
Value result;
|
Value result;
|
||||||
switch (cbi.instruction.op)
|
switch (cbi.instruction.op)
|
||||||
{
|
{
|
||||||
case InstructionOp::ori:
|
case InstructionOp::ori:
|
||||||
result = OrValues(rs, imm);
|
result = OrValues(lhs, rhs);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case InstructionOp::andi:
|
case InstructionOp::andi:
|
||||||
result = AndValues(rs, imm);
|
result = AndValues(lhs, rhs);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case InstructionOp::xori:
|
case InstructionOp::xori:
|
||||||
result = XorValues(rs, imm);
|
result = XorValues(lhs, rhs);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case InstructionOp::funct:
|
||||||
|
{
|
||||||
|
switch (cbi.instruction.r.funct)
|
||||||
|
{
|
||||||
|
case InstructionFunct::or_:
|
||||||
|
result = OrValues(lhs, rhs);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case InstructionFunct::and_:
|
||||||
|
result = AndValues(lhs, rhs);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case InstructionFunct::xor_:
|
||||||
|
result = XorValues(lhs, rhs);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
UnreachableCode();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -869,7 +914,7 @@ bool CodeGenerator::Compile_BitwiseImmediate(const CodeBlockInstruction& cbi)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_register_cache.WriteGuestRegister(cbi.instruction.i.rt, std::move(result));
|
m_register_cache.WriteGuestRegister(dest, std::move(result));
|
||||||
|
|
||||||
InstructionEpilogue(cbi);
|
InstructionEpilogue(cbi);
|
||||||
return true;
|
return true;
|
||||||
@ -918,7 +963,6 @@ bool CodeGenerator::Compile_Shift(const CodeBlockInstruction& cbi)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_register_cache.WriteGuestRegister(cbi.instruction.r.rd, std::move(result));
|
m_register_cache.WriteGuestRegister(cbi.instruction.r.rd, std::move(result));
|
||||||
|
|
||||||
InstructionEpilogue(cbi);
|
InstructionEpilogue(cbi);
|
||||||
|
@ -173,7 +173,7 @@ private:
|
|||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
bool CompileInstruction(const CodeBlockInstruction& cbi);
|
bool CompileInstruction(const CodeBlockInstruction& cbi);
|
||||||
bool Compile_Fallback(const CodeBlockInstruction& cbi);
|
bool Compile_Fallback(const CodeBlockInstruction& cbi);
|
||||||
bool Compile_BitwiseImmediate(const CodeBlockInstruction& cbi);
|
bool Compile_Bitwise(const CodeBlockInstruction& cbi);
|
||||||
bool Compile_Shift(const CodeBlockInstruction& cbi);
|
bool Compile_Shift(const CodeBlockInstruction& cbi);
|
||||||
bool Compile_Load(const CodeBlockInstruction& cbi);
|
bool Compile_Load(const CodeBlockInstruction& cbi);
|
||||||
bool Compile_Store(const CodeBlockInstruction& cbi);
|
bool Compile_Store(const CodeBlockInstruction& cbi);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user