From 0195d0938d7582d8b4155482e4eef60406ba5ed8 Mon Sep 17 00:00:00 2001 From: Ficture Seven Date: Sat, 11 Jul 2020 05:00:41 +0400 Subject: [PATCH] Fold ZeroExtend8/16/32 imm32/64 (#1358) * Fold ZeroExtend8/16/32 imm32/64 * Increment PTC version --- .../CodeGen/Optimizations/ConstantFolding.cs | 33 +++++++++++++++++++ ARMeilleure/Translation/PTC/Ptc.cs | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/ARMeilleure/CodeGen/Optimizations/ConstantFolding.cs b/ARMeilleure/CodeGen/Optimizations/ConstantFolding.cs index 359af113c..19cc009c7 100644 --- a/ARMeilleure/CodeGen/Optimizations/ConstantFolding.cs +++ b/ARMeilleure/CodeGen/Optimizations/ConstantFolding.cs @@ -206,6 +206,39 @@ namespace ARMeilleure.CodeGen.Optimizations } break; + case Instruction.ZeroExtend16: + if (type == OperandType.I32) + { + EvaluateUnaryI32(operation, (x) => (ushort)x); + } + else if (type == OperandType.I64) + { + EvaluateUnaryI64(operation, (x) => (ushort)x); + } + break; + + case Instruction.ZeroExtend32: + if (type == OperandType.I32) + { + EvaluateUnaryI32(operation, (x) => x); + } + else if (type == OperandType.I64) + { + EvaluateUnaryI64(operation, (x) => (uint)x); + } + break; + + case Instruction.ZeroExtend8: + if (type == OperandType.I32) + { + EvaluateUnaryI32(operation, (x) => (byte)x); + } + else if (type == OperandType.I64) + { + EvaluateUnaryI64(operation, (x) => (byte)x); + } + break; + case Instruction.Subtract: if (type == OperandType.I32) { diff --git a/ARMeilleure/Translation/PTC/Ptc.cs b/ARMeilleure/Translation/PTC/Ptc.cs index 2742719dd..ced3d0d48 100644 --- a/ARMeilleure/Translation/PTC/Ptc.cs +++ b/ARMeilleure/Translation/PTC/Ptc.cs @@ -20,7 +20,7 @@ namespace ARMeilleure.Translation.PTC { private const string HeaderMagic = "PTChd"; - private const int InternalVersion = 4; //! To be incremented manually for each change to the ARMeilleure project. + private const int InternalVersion = 5; //! To be incremented manually for each change to the ARMeilleure project. private const string BaseDir = "Ryujinx";