From df70442c46e7ee133b1fb79dc23ddd134e618085 Mon Sep 17 00:00:00 2001 From: merry Date: Sat, 19 Mar 2022 13:32:35 +0000 Subject: [PATCH] InstEmitMemoryEx: Barrier after write on ordered store (#3193) * InstEmitMemoryEx: Barrier after write on ordered store * increment ptc version * 32 --- ARMeilleure/Instructions/InstEmitMemoryEx.cs | 10 +++++----- ARMeilleure/Instructions/InstEmitMemoryEx32.cs | 15 ++++++++++----- ARMeilleure/Translation/PTC/Ptc.cs | 2 +- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/ARMeilleure/Instructions/InstEmitMemoryEx.cs b/ARMeilleure/Instructions/InstEmitMemoryEx.cs index 88b9d2f0c..af6adfb93 100644 --- a/ARMeilleure/Instructions/InstEmitMemoryEx.cs +++ b/ARMeilleure/Instructions/InstEmitMemoryEx.cs @@ -130,11 +130,6 @@ namespace ARMeilleure.Instructions bool ordered = (accType & AccessType.Ordered) != 0; bool exclusive = (accType & AccessType.Exclusive) != 0; - if (ordered) - { - EmitBarrier(context); - } - Operand address = context.Copy(GetIntOrSP(context, op.Rn)); Operand t = GetIntOrZR(context, op.Rt); @@ -163,6 +158,11 @@ namespace ARMeilleure.Instructions { EmitStoreExclusive(context, address, t, exclusive, op.Size, op.Rs, a32: false); } + + if (ordered) + { + EmitBarrier(context); + } } private static void EmitBarrier(ArmEmitterContext context) diff --git a/ARMeilleure/Instructions/InstEmitMemoryEx32.cs b/ARMeilleure/Instructions/InstEmitMemoryEx32.cs index 9a9787cfb..c2326cde7 100644 --- a/ARMeilleure/Instructions/InstEmitMemoryEx32.cs +++ b/ARMeilleure/Instructions/InstEmitMemoryEx32.cs @@ -146,13 +146,13 @@ namespace ARMeilleure.Instructions var exclusive = (accType & AccessType.Exclusive) != 0; var ordered = (accType & AccessType.Ordered) != 0; - if (ordered) - { - EmitBarrier(context); - } - if ((accType & AccessType.Load) != 0) { + if (ordered) + { + EmitBarrier(context); + } + if (size == DWordSizeLog2) { // Keep loads atomic - make the call to get the whole region and then decompose it into parts @@ -219,6 +219,11 @@ namespace ARMeilleure.Instructions Operand value = context.ZeroExtend32(OperandType.I64, GetIntA32(context, op.Rt)); EmitStoreExclusive(context, address, value, exclusive, size, op.Rd, a32: true); } + + if (ordered) + { + EmitBarrier(context); + } } } diff --git a/ARMeilleure/Translation/PTC/Ptc.cs b/ARMeilleure/Translation/PTC/Ptc.cs index 0431bea49..35bbc56e0 100644 --- a/ARMeilleure/Translation/PTC/Ptc.cs +++ b/ARMeilleure/Translation/PTC/Ptc.cs @@ -27,7 +27,7 @@ namespace ARMeilleure.Translation.PTC private const string OuterHeaderMagicString = "PTCohd\0\0"; private const string InnerHeaderMagicString = "PTCihd\0\0"; - private const uint InternalVersion = 3179; //! To be incremented manually for each change to the ARMeilleure project. + private const uint InternalVersion = 3193; //! To be incremented manually for each change to the ARMeilleure project. private const string ActualDir = "0"; private const string BackupDir = "1";