summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/frontend/maxwell/translate/impl/integer_set_predicate.cpp
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-03-02 07:05:57 +0100
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:23 +0200
commitce9b116cfe4fcd96df889ed8997c93c6cd2a502c (patch)
tree31cdc1ac9a6c507b4952dc57fced81cdb5d3f7e4 /src/shader_recompiler/frontend/maxwell/translate/impl/integer_set_predicate.cpp
parentshader: Implement FLO (diff)
downloadyuzu-ce9b116cfe4fcd96df889ed8997c93c6cd2a502c.tar
yuzu-ce9b116cfe4fcd96df889ed8997c93c6cd2a502c.tar.gz
yuzu-ce9b116cfe4fcd96df889ed8997c93c6cd2a502c.tar.bz2
yuzu-ce9b116cfe4fcd96df889ed8997c93c6cd2a502c.tar.lz
yuzu-ce9b116cfe4fcd96df889ed8997c93c6cd2a502c.tar.xz
yuzu-ce9b116cfe4fcd96df889ed8997c93c6cd2a502c.tar.zst
yuzu-ce9b116cfe4fcd96df889ed8997c93c6cd2a502c.zip
Diffstat (limited to 'src/shader_recompiler/frontend/maxwell/translate/impl/integer_set_predicate.cpp')
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/integer_set_predicate.cpp64
1 files changed, 7 insertions, 57 deletions
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/integer_set_predicate.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/integer_set_predicate.cpp
index 1bc9ef363..7743701d0 100644
--- a/src/shader_recompiler/frontend/maxwell/translate/impl/integer_set_predicate.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/integer_set_predicate.cpp
@@ -4,62 +4,11 @@
#include "common/bit_field.h"
#include "common/common_types.h"
+#include "shader_recompiler/frontend/maxwell/translate/impl/common_funcs.h"
#include "shader_recompiler/frontend/maxwell/translate/impl/impl.h"
namespace Shader::Maxwell {
namespace {
-enum class CompareOp : u64 {
- F, // Always false
- LT, // Less than
- EQ, // Equal
- LE, // Less than or equal
- GT, // Greater than
- NE, // Not equal
- GE, // Greater than or equal
- T, // Always true
-};
-
-enum class Bop : u64 {
- AND,
- OR,
- XOR,
-};
-
-IR::U1 Compare(IR::IREmitter& ir, CompareOp op, const IR::U32& lhs, const IR::U32& rhs,
- bool is_signed) {
- switch (op) {
- case CompareOp::F:
- return ir.Imm1(false);
- case CompareOp::LT:
- return ir.ILessThan(lhs, rhs, is_signed);
- case CompareOp::EQ:
- return ir.IEqual(lhs, rhs);
- case CompareOp::LE:
- return ir.ILessThanEqual(lhs, rhs, is_signed);
- case CompareOp::GT:
- return ir.IGreaterThan(lhs, rhs, is_signed);
- case CompareOp::NE:
- return ir.INotEqual(lhs, rhs);
- case CompareOp::GE:
- return ir.IGreaterThanEqual(lhs, rhs, is_signed);
- case CompareOp::T:
- return ir.Imm1(true);
- }
- throw NotImplementedException("Invalid ISETP compare op {}", op);
-}
-
-IR::U1 Combine(IR::IREmitter& ir, Bop bop, const IR::U1& comparison, const IR::U1& bop_pred) {
- switch (bop) {
- case Bop::AND:
- return ir.LogicalAnd(comparison, bop_pred);
- case Bop::OR:
- return ir.LogicalOr(comparison, bop_pred);
- case Bop::XOR:
- return ir.LogicalXor(comparison, bop_pred);
- }
- throw NotImplementedException("Invalid ISETP bop {}", bop);
-}
-
void ISETP(TranslatorVisitor& v, u64 insn, const IR::U32& op_b) {
union {
u64 raw;
@@ -68,17 +17,18 @@ void ISETP(TranslatorVisitor& v, u64 insn, const IR::U32& op_b) {
BitField<8, 8, IR::Reg> src_reg_a;
BitField<39, 3, IR::Pred> bop_pred;
BitField<42, 1, u64> neg_bop_pred;
- BitField<45, 2, Bop> bop;
+ BitField<45, 2, BooleanOp> bop;
BitField<48, 1, u64> is_signed;
BitField<49, 3, CompareOp> compare_op;
} const isetp{insn};
- const Bop bop{isetp.bop};
+ const BooleanOp bop{isetp.bop};
+ const CompareOp compare_op{isetp.compare_op};
const IR::U32 op_a{v.X(isetp.src_reg_a)};
- const IR::U1 comparison{Compare(v.ir, isetp.compare_op, op_a, op_b, isetp.is_signed != 0)};
+ const IR::U1 comparison{IntegerCompare(v.ir, op_a, op_b, compare_op, isetp.is_signed != 0)};
const IR::U1 bop_pred{v.ir.GetPred(isetp.bop_pred, isetp.neg_bop_pred != 0)};
- const IR::U1 result_a{Combine(v.ir, bop, comparison, bop_pred)};
- const IR::U1 result_b{Combine(v.ir, bop, v.ir.LogicalNot(comparison), bop_pred)};
+ const IR::U1 result_a{PredicateCombine(v.ir, comparison, bop_pred, bop)};
+ const IR::U1 result_b{PredicateCombine(v.ir, v.ir.LogicalNot(comparison), bop_pred, bop)};
v.ir.SetPred(isetp.dest_pred_a, result_a);
v.ir.SetPred(isetp.dest_pred_b, result_b);
}