mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
Merge pull request #2878 from FernandoS27/icmp
shader_ir: Implement ICMP
This commit is contained in:
commit
9286976948
2 changed files with 42 additions and 0 deletions
|
@ -949,6 +949,11 @@ union Instruction {
|
||||||
BitField<49, 3, PredCondition> cond;
|
BitField<49, 3, PredCondition> cond;
|
||||||
} isetp;
|
} isetp;
|
||||||
|
|
||||||
|
union {
|
||||||
|
BitField<48, 1, u64> is_signed;
|
||||||
|
BitField<49, 3, PredCondition> cond;
|
||||||
|
} icmp;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
BitField<0, 3, u64> pred0;
|
BitField<0, 3, u64> pred0;
|
||||||
BitField<3, 3, u64> pred3;
|
BitField<3, 3, u64> pred3;
|
||||||
|
@ -1645,6 +1650,10 @@ public:
|
||||||
SEL_C,
|
SEL_C,
|
||||||
SEL_R,
|
SEL_R,
|
||||||
SEL_IMM,
|
SEL_IMM,
|
||||||
|
ICMP_RC,
|
||||||
|
ICMP_R,
|
||||||
|
ICMP_CR,
|
||||||
|
ICMP_IMM,
|
||||||
MUFU, // Multi-Function Operator
|
MUFU, // Multi-Function Operator
|
||||||
RRO_C, // Range Reduction Operator
|
RRO_C, // Range Reduction Operator
|
||||||
RRO_R,
|
RRO_R,
|
||||||
|
@ -1910,6 +1919,10 @@ private:
|
||||||
INST("0100110010100---", Id::SEL_C, Type::ArithmeticInteger, "SEL_C"),
|
INST("0100110010100---", Id::SEL_C, Type::ArithmeticInteger, "SEL_C"),
|
||||||
INST("0101110010100---", Id::SEL_R, Type::ArithmeticInteger, "SEL_R"),
|
INST("0101110010100---", Id::SEL_R, Type::ArithmeticInteger, "SEL_R"),
|
||||||
INST("0011100-10100---", Id::SEL_IMM, Type::ArithmeticInteger, "SEL_IMM"),
|
INST("0011100-10100---", Id::SEL_IMM, Type::ArithmeticInteger, "SEL_IMM"),
|
||||||
|
INST("010100110100----", Id::ICMP_RC, Type::ArithmeticInteger, "ICMP_RC"),
|
||||||
|
INST("010110110100----", Id::ICMP_R, Type::ArithmeticInteger, "ICMP_R"),
|
||||||
|
INST("010010110100----", Id::ICMP_CR, Type::ArithmeticInteger, "ICMP_CR"),
|
||||||
|
INST("0011011-0100----", Id::ICMP_IMM, Type::ArithmeticInteger, "ICMP_IMM"),
|
||||||
INST("0101101111011---", Id::LEA_R2, Type::ArithmeticInteger, "LEA_R2"),
|
INST("0101101111011---", Id::LEA_R2, Type::ArithmeticInteger, "LEA_R2"),
|
||||||
INST("0101101111010---", Id::LEA_R1, Type::ArithmeticInteger, "LEA_R1"),
|
INST("0101101111010---", Id::LEA_R1, Type::ArithmeticInteger, "LEA_R1"),
|
||||||
INST("001101101101----", Id::LEA_IMM, Type::ArithmeticInteger, "LEA_IMM"),
|
INST("001101101101----", Id::LEA_IMM, Type::ArithmeticInteger, "LEA_IMM"),
|
||||||
|
|
|
@ -138,6 +138,35 @@ u32 ShaderIR::DecodeArithmeticInteger(NodeBlock& bb, u32 pc) {
|
||||||
SetRegister(bb, instr.gpr0, value);
|
SetRegister(bb, instr.gpr0, value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case OpCode::Id::ICMP_CR:
|
||||||
|
case OpCode::Id::ICMP_R:
|
||||||
|
case OpCode::Id::ICMP_RC:
|
||||||
|
case OpCode::Id::ICMP_IMM: {
|
||||||
|
const Node zero = Immediate(0);
|
||||||
|
|
||||||
|
const auto [op_b, test] = [&]() -> std::pair<Node, Node> {
|
||||||
|
switch (opcode->get().GetId()) {
|
||||||
|
case OpCode::Id::ICMP_CR:
|
||||||
|
return {GetConstBuffer(instr.cbuf34.index, instr.cbuf34.offset),
|
||||||
|
GetRegister(instr.gpr39)};
|
||||||
|
case OpCode::Id::ICMP_R:
|
||||||
|
return {GetRegister(instr.gpr20), GetRegister(instr.gpr39)};
|
||||||
|
case OpCode::Id::ICMP_RC:
|
||||||
|
return {GetRegister(instr.gpr39),
|
||||||
|
GetConstBuffer(instr.cbuf34.index, instr.cbuf34.offset)};
|
||||||
|
case OpCode::Id::ICMP_IMM:
|
||||||
|
return {Immediate(instr.alu.GetSignedImm20_20()), GetRegister(instr.gpr39)};
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
return {zero, zero};
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
const Node op_a = GetRegister(instr.gpr8);
|
||||||
|
const Node comparison =
|
||||||
|
GetPredicateComparisonInteger(instr.icmp.cond, instr.icmp.is_signed != 0, test, zero);
|
||||||
|
SetRegister(bb, instr.gpr0, Operation(OperationCode::Select, comparison, op_a, op_b));
|
||||||
|
break;
|
||||||
|
}
|
||||||
case OpCode::Id::LOP_C:
|
case OpCode::Id::LOP_C:
|
||||||
case OpCode::Id::LOP_R:
|
case OpCode::Id::LOP_R:
|
||||||
case OpCode::Id::LOP_IMM: {
|
case OpCode::Id::LOP_IMM: {
|
||||||
|
|
Loading…
Reference in a new issue