diff --git a/FEXCore/Source/Interface/Core/JIT/Arm64/ALUOps.cpp b/FEXCore/Source/Interface/Core/JIT/Arm64/ALUOps.cpp index 63c16e257..0055812e8 100644 --- a/FEXCore/Source/Interface/Core/JIT/Arm64/ALUOps.cpp +++ b/FEXCore/Source/Interface/Core/JIT/Arm64/ALUOps.cpp @@ -311,6 +311,20 @@ DEF_OP(RmifNZCV) { rmif(GetReg(Op->Src.ID()).X(), Op->Rotate, Op->Mask); } +DEF_OP(SetSmallNZV) { + auto Op = IROp->C(); + LOGMAN_THROW_A_FMT(CTX->HostFeatures.SupportsFlagM, "Unsupported flagm op"); + + const uint8_t OpSize = IROp->Size; + LOGMAN_THROW_AA_FMT(OpSize == 1 || OpSize == 2, "Unsupported {} size: {}", __func__, OpSize); + + if (OpSize == 1) { + setf8(GetReg(Op->Src.ID()).W()); + } else { + setf16(GetReg(Op->Src.ID()).W()); + } +} + DEF_OP(AXFlag) { LOGMAN_THROW_A_FMT(CTX->HostFeatures.SupportsFlagM2, "Unsupported flagm2 op"); axflag(); diff --git a/FEXCore/Source/Interface/IR/IR.json b/FEXCore/Source/Interface/IR/IR.json index f22537db4..9e29955d1 100644 --- a/FEXCore/Source/Interface/IR/IR.json +++ b/FEXCore/Source/Interface/IR/IR.json @@ -992,6 +992,14 @@ "HasSideEffects": true, "DestSize": "Size" }, + "SetSmallNZV OpSize:#Size, GPR:$Src": { + "Desc": ["Set NZV with a SETF instruction. Preserves CF."], + "HasSideEffects": true, + "DestSize": "Size", + "EmitValidation": [ + "Size == FEXCore::IR::OpSize::i8Bit || Size == FEXCore::IR::OpSize::i16Bit" + ] + }, "CarryInvert": { "Desc": ["Invert carry flag in NZCV"], "HasSideEffects": true diff --git a/FEXCore/Source/Interface/IR/Passes/RedundantFlagCalculationElimination.cpp b/FEXCore/Source/Interface/IR/Passes/RedundantFlagCalculationElimination.cpp index bb8c12723..4a0fde231 100644 --- a/FEXCore/Source/Interface/IR/Passes/RedundantFlagCalculationElimination.cpp +++ b/FEXCore/Source/Interface/IR/Passes/RedundantFlagCalculationElimination.cpp @@ -183,6 +183,12 @@ DeadFlagCalculationEliminination::Classify(IROp_Header *IROp) .CanEliminate = true, }; + case OP_SETSMALLNZV: + return { + .Write = FLAG_N | FLAG_Z | FLAG_V, + .CanEliminate = true, + }; + case OP_LOADNZCV: return {.Read = FLAG_NZCV};