From 996fa013d01cb7bada333967ed1a72d359e3179d Mon Sep 17 00:00:00 2001 From: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:26:03 +0300 Subject: [PATCH] Implement float comparison instruction. --- PowerRecomp/main.cpp | 1 + PowerUtils/ppc_context.h | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/PowerRecomp/main.cpp b/PowerRecomp/main.cpp index 05856e1..369d477 100644 --- a/PowerRecomp/main.cpp +++ b/PowerRecomp/main.cpp @@ -341,6 +341,7 @@ int main() break; case PPC_INST_FCMPU: + std::println(f, "\tctx.cr{}.compare(ctx.f{}.f64, ctx.f{}.f64);", insn.operands[0], insn.operands[1], insn.operands[2]); break; case PPC_INST_FCTID: diff --git a/PowerUtils/ppc_context.h b/PowerUtils/ppc_context.h index 4c5b029..d4b4a34 100644 --- a/PowerUtils/ppc_context.h +++ b/PowerUtils/ppc_context.h @@ -1,6 +1,7 @@ #pragma once #include #include +#include #ifdef __clang__ #include @@ -53,7 +54,11 @@ struct PPCCRRegister uint8_t lt; uint8_t gt; uint8_t eq; - uint8_t so; + union + { + uint8_t so; + uint8_t un; + }; template void compare(T left, T right, const PPCXERRegister& xer) @@ -63,6 +68,14 @@ struct PPCCRRegister eq = left == right; so = xer.so; } + + void compare(double left, double right) + { + lt = left < right; + gt = left > right; + eq = left == right; + un = isnan(left) || isnan(right); + } }; typedef float float128[4];