From c050994995268494d46a6cac1d4ffa931effa0f6 Mon Sep 17 00:00:00 2001 From: LDj3SNuD <35856442+LDj3SNuD@users.noreply.github.com> Date: Thu, 9 Jul 2020 02:45:24 +0200 Subject: [PATCH] Fix PPTC on Windows 7. (#1369) * Fix PPTC on Windows 7. * Address gdkchan comment. --- .../CodeGen/Optimizations/ConstantFolding.cs | 2 +- ARMeilleure/CodeGen/X86/Assembler.cs | 2 +- ARMeilleure/CodeGen/X86/X86Optimizer.cs | 4 ++-- .../IntermediateRepresentation/Operand.cs | 19 ++++++++++++------- .../OperandHelper.cs | 4 ++-- ARMeilleure/Translation/PTC/Ptc.cs | 2 +- 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/ARMeilleure/CodeGen/Optimizations/ConstantFolding.cs b/ARMeilleure/CodeGen/Optimizations/ConstantFolding.cs index eff53217ff..790fd53d00 100644 --- a/ARMeilleure/CodeGen/Optimizations/ConstantFolding.cs +++ b/ARMeilleure/CodeGen/Optimizations/ConstantFolding.cs @@ -218,7 +218,7 @@ namespace ARMeilleure.CodeGen.Optimizations { Operand srcOp = operation.GetSource(index); - if (srcOp.Kind != OperandKind.Constant || srcOp.DisableCF) + if (srcOp.Kind != OperandKind.Constant || srcOp.Relocatable) { return false; } diff --git a/ARMeilleure/CodeGen/X86/Assembler.cs b/ARMeilleure/CodeGen/X86/Assembler.cs index 99df3cb565..62ca05b275 100644 --- a/ARMeilleure/CodeGen/X86/Assembler.cs +++ b/ARMeilleure/CodeGen/X86/Assembler.cs @@ -914,7 +914,7 @@ namespace ARMeilleure.CodeGen.X86 WriteByte((byte)imm); } - else if (IsImm32(imm, type) && info.OpRMImm32 != BadOp) + else if (!source.Relocatable && IsImm32(imm, type) && info.OpRMImm32 != BadOp) { WriteOpCode(dest, null, null, type, info.Flags, info.OpRMImm32); diff --git a/ARMeilleure/CodeGen/X86/X86Optimizer.cs b/ARMeilleure/CodeGen/X86/X86Optimizer.cs index 30fd6c714f..643b515f61 100644 --- a/ARMeilleure/CodeGen/X86/X86Optimizer.cs +++ b/ARMeilleure/CodeGen/X86/X86Optimizer.cs @@ -31,7 +31,7 @@ namespace ARMeilleure.CodeGen.X86 Operand src1 = operation.GetSource(0); Operand src2 = operation.GetSource(1); - if (src1.Kind == OperandKind.Constant && CodeGenCommon.IsLongConst(src1)) + if (src1.Kind == OperandKind.Constant && (src1.Relocatable || CodeGenCommon.IsLongConst(src1))) { Operand temp = Local(src1.Type); @@ -42,7 +42,7 @@ namespace ARMeilleure.CodeGen.X86 operation.SetSource(0, temp); } - if (src2.Kind == OperandKind.Constant && CodeGenCommon.IsLongConst(src2)) + if (src2.Kind == OperandKind.Constant && (src2.Relocatable || CodeGenCommon.IsLongConst(src2))) { Operand temp = Local(src2.Type); diff --git a/ARMeilleure/IntermediateRepresentation/Operand.cs b/ARMeilleure/IntermediateRepresentation/Operand.cs index 6f6caea77e..b8650d5a9d 100644 --- a/ARMeilleure/IntermediateRepresentation/Operand.cs +++ b/ARMeilleure/IntermediateRepresentation/Operand.cs @@ -10,8 +10,8 @@ namespace ARMeilleure.IntermediateRepresentation public ulong Value { get; private set; } - public bool DisableCF { get; private set; } - public int? PtcIndex { get; private set; } + public bool Relocatable { get; private set; } + public int? PtcIndex { get; private set; } public List Assignments { get; } public List Uses { get; } @@ -28,15 +28,20 @@ namespace ARMeilleure.IntermediateRepresentation Type = type; } - public Operand With(OperandKind kind, OperandType type = OperandType.None, ulong value = 0, bool disableCF = false, int? index = null) + public Operand With( + OperandKind kind, + OperandType type = OperandType.None, + ulong value = 0, + bool relocatable = false, + int? index = null) { Kind = kind; Type = type; Value = value; - DisableCF = disableCF; - PtcIndex = index; + Relocatable = relocatable; + PtcIndex = index; Assignments.Clear(); Uses.Clear(); @@ -54,9 +59,9 @@ namespace ARMeilleure.IntermediateRepresentation return With(OperandKind.Constant, OperandType.I32, value); } - public Operand With(long value, bool disableCF = false, int? index = null) + public Operand With(long value, bool relocatable = false, int? index = null) { - return With(OperandKind.Constant, OperandType.I64, (ulong)value, disableCF, index); + return With(OperandKind.Constant, OperandType.I64, (ulong)value, relocatable, index); } public Operand With(ulong value) diff --git a/ARMeilleure/IntermediateRepresentation/OperandHelper.cs b/ARMeilleure/IntermediateRepresentation/OperandHelper.cs index 1004097718..c97023fce8 100644 --- a/ARMeilleure/IntermediateRepresentation/OperandHelper.cs +++ b/ARMeilleure/IntermediateRepresentation/OperandHelper.cs @@ -34,9 +34,9 @@ namespace ARMeilleure.IntermediateRepresentation return Operand().With(value); } - public static Operand Const(long value, bool disableCF = false, int? index = null) + public static Operand Const(long value, bool relocatable = false, int? index = null) { - return Operand().With(value, disableCF, index); + return Operand().With(value, relocatable, index); } public static Operand Const(ulong value) diff --git a/ARMeilleure/Translation/PTC/Ptc.cs b/ARMeilleure/Translation/PTC/Ptc.cs index 2b4059ec29..c715160392 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 = 2; //! To be incremented manually for each change to the ARMeilleure project. + private const int InternalVersion = 3; //! To be incremented manually for each change to the ARMeilleure project. private const string BaseDir = "Ryujinx";