summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-05-19 06:29:07 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:32 +0200
commit3777592ada560e2943a066f7d2d62fd468dbf62c (patch)
treec5205b150d4d2f566f3e1854cd763f12ec599d67 /src
parentglasm: Implement BFE.CC (diff)
downloadyuzu-3777592ada560e2943a066f7d2d62fd468dbf62c.tar
yuzu-3777592ada560e2943a066f7d2d62fd468dbf62c.tar.gz
yuzu-3777592ada560e2943a066f7d2d62fd468dbf62c.tar.bz2
yuzu-3777592ada560e2943a066f7d2d62fd468dbf62c.tar.lz
yuzu-3777592ada560e2943a066f7d2d62fd468dbf62c.tar.xz
yuzu-3777592ada560e2943a066f7d2d62fd468dbf62c.tar.zst
yuzu-3777592ada560e2943a066f7d2d62fd468dbf62c.zip
Diffstat (limited to '')
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp
index ba69c7a1b..ff353df8d 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp
@@ -9,7 +9,32 @@
namespace Shader::Backend::GLASM {
void EmitIAdd32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
- ctx.Add("ADD.S {}.x,{},{};", inst, a, b);
+ const bool cc{inst.HasAssociatedPseudoOperation()};
+ const std::string_view cc_mod{cc ? ".CC" : ""};
+ if (cc) {
+ ctx.reg_alloc.InvalidateConditionCodes();
+ }
+ const auto ret{ctx.reg_alloc.Define(inst)};
+ ctx.Add("ADD.S{} {}.x,{},{};", cc_mod, ret, a, b);
+ if (!cc) {
+ return;
+ }
+ static constexpr std::array<std::string_view, 4> masks{"EQ", "SF", "CF", "OF"};
+ const std::array flags{
+ inst.GetAssociatedPseudoOperation(IR::Opcode::GetZeroFromOp),
+ inst.GetAssociatedPseudoOperation(IR::Opcode::GetSignFromOp),
+ inst.GetAssociatedPseudoOperation(IR::Opcode::GetCarryFromOp),
+ inst.GetAssociatedPseudoOperation(IR::Opcode::GetOverflowFromOp),
+ };
+ for (size_t i = 0; i < flags.size(); ++i) {
+ if (flags[i]) {
+ const auto flag_ret{ctx.reg_alloc.Define(*flags[i])};
+ ctx.Add("MOV.S {},0;"
+ "MOV.S {}({}.x),-1;",
+ flag_ret, flag_ret, masks[i]);
+ flags[i]->Invalidate();
+ }
+ }
}
void EmitIAdd64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register a,