mirror of
https://git.h3cjp.net/H3cJP/citra.git
synced 2024-11-29 23:42:48 +00:00
Merge pull request #3577 from ReinUsesLisp/lea
shader/lea: Fix LEA implementation
This commit is contained in:
commit
5b95a01463
|
@ -235,34 +235,30 @@ u32 ShaderIR::DecodeArithmeticInteger(NodeBlock& bb, u32 pc) {
|
||||||
case OpCode::Id::LEA_IMM:
|
case OpCode::Id::LEA_IMM:
|
||||||
case OpCode::Id::LEA_RZ:
|
case OpCode::Id::LEA_RZ:
|
||||||
case OpCode::Id::LEA_HI: {
|
case OpCode::Id::LEA_HI: {
|
||||||
const auto [op_a, op_b, op_c] = [&]() -> std::tuple<Node, Node, Node> {
|
auto [op_a, op_b, op_c] = [&]() -> std::tuple<Node, Node, Node> {
|
||||||
switch (opcode->get().GetId()) {
|
switch (opcode->get().GetId()) {
|
||||||
case OpCode::Id::LEA_R2: {
|
case OpCode::Id::LEA_R2: {
|
||||||
return {GetRegister(instr.gpr20), GetRegister(instr.gpr39),
|
return {GetRegister(instr.gpr20), GetRegister(instr.gpr39),
|
||||||
Immediate(static_cast<u32>(instr.lea.r2.entry_a))};
|
Immediate(static_cast<u32>(instr.lea.r2.entry_a))};
|
||||||
}
|
}
|
||||||
|
|
||||||
case OpCode::Id::LEA_R1: {
|
case OpCode::Id::LEA_R1: {
|
||||||
const bool neg = instr.lea.r1.neg != 0;
|
const bool neg = instr.lea.r1.neg != 0;
|
||||||
return {GetOperandAbsNegInteger(GetRegister(instr.gpr8), false, neg, true),
|
return {GetOperandAbsNegInteger(GetRegister(instr.gpr8), false, neg, true),
|
||||||
GetRegister(instr.gpr20),
|
GetRegister(instr.gpr20),
|
||||||
Immediate(static_cast<u32>(instr.lea.r1.entry_a))};
|
Immediate(static_cast<u32>(instr.lea.r1.entry_a))};
|
||||||
}
|
}
|
||||||
|
|
||||||
case OpCode::Id::LEA_IMM: {
|
case OpCode::Id::LEA_IMM: {
|
||||||
const bool neg = instr.lea.imm.neg != 0;
|
const bool neg = instr.lea.imm.neg != 0;
|
||||||
return {Immediate(static_cast<u32>(instr.lea.imm.entry_a)),
|
return {Immediate(static_cast<u32>(instr.lea.imm.entry_a)),
|
||||||
GetOperandAbsNegInteger(GetRegister(instr.gpr8), false, neg, true),
|
GetOperandAbsNegInteger(GetRegister(instr.gpr8), false, neg, true),
|
||||||
Immediate(static_cast<u32>(instr.lea.imm.entry_b))};
|
Immediate(static_cast<u32>(instr.lea.imm.entry_b))};
|
||||||
}
|
}
|
||||||
|
|
||||||
case OpCode::Id::LEA_RZ: {
|
case OpCode::Id::LEA_RZ: {
|
||||||
const bool neg = instr.lea.rz.neg != 0;
|
const bool neg = instr.lea.rz.neg != 0;
|
||||||
return {GetConstBuffer(instr.lea.rz.cb_index, instr.lea.rz.cb_offset),
|
return {GetConstBuffer(instr.lea.rz.cb_index, instr.lea.rz.cb_offset),
|
||||||
GetOperandAbsNegInteger(GetRegister(instr.gpr8), false, neg, true),
|
GetOperandAbsNegInteger(GetRegister(instr.gpr8), false, neg, true),
|
||||||
Immediate(static_cast<u32>(instr.lea.rz.entry_a))};
|
Immediate(static_cast<u32>(instr.lea.rz.entry_a))};
|
||||||
}
|
}
|
||||||
|
|
||||||
case OpCode::Id::LEA_HI:
|
case OpCode::Id::LEA_HI:
|
||||||
default:
|
default:
|
||||||
UNIMPLEMENTED_MSG("Unhandled LEA subinstruction: {}", opcode->get().GetName());
|
UNIMPLEMENTED_MSG("Unhandled LEA subinstruction: {}", opcode->get().GetName());
|
||||||
|
@ -275,12 +271,9 @@ u32 ShaderIR::DecodeArithmeticInteger(NodeBlock& bb, u32 pc) {
|
||||||
UNIMPLEMENTED_IF_MSG(instr.lea.pred48 != static_cast<u64>(Pred::UnusedIndex),
|
UNIMPLEMENTED_IF_MSG(instr.lea.pred48 != static_cast<u64>(Pred::UnusedIndex),
|
||||||
"Unhandled LEA Predicate");
|
"Unhandled LEA Predicate");
|
||||||
|
|
||||||
const Node shifted_c =
|
Node value = Operation(OperationCode::ILogicalShiftLeft, std::move(op_a), std::move(op_c));
|
||||||
Operation(OperationCode::ILogicalShiftLeft, NO_PRECISE, Immediate(1), op_c);
|
value = Operation(OperationCode::IAdd, std::move(op_b), std::move(value));
|
||||||
const Node mul_bc = Operation(OperationCode::IMul, NO_PRECISE, op_b, shifted_c);
|
SetRegister(bb, instr.gpr0, std::move(value));
|
||||||
const Node value = Operation(OperationCode::IAdd, NO_PRECISE, op_a, mul_bc);
|
|
||||||
|
|
||||||
SetRegister(bb, instr.gpr0, value);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue