summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/nativeGen/X86/CodeGen.hs3
-rw-r--r--compiler/nativeGen/X86/Instr.hs3
-rw-r--r--compiler/nativeGen/X86/Ppr.hs2
3 files changed, 7 insertions, 1 deletions
diff --git a/compiler/nativeGen/X86/CodeGen.hs b/compiler/nativeGen/X86/CodeGen.hs
index 867dbfd2b6..a9ff8f2853 100644
--- a/compiler/nativeGen/X86/CodeGen.hs
+++ b/compiler/nativeGen/X86/CodeGen.hs
@@ -1838,7 +1838,8 @@ genCCall dflags _ (PrimTarget (MO_AtomicRead width)) [dst] [addr] = do
return (load_code (getRegisterReg platform use_sse2 (CmmLocal dst)))
genCCall _ _ (PrimTarget (MO_AtomicWrite width)) [] [addr, val] = do
- assignMem_IntCode (intSize width) addr val
+ code <- assignMem_IntCode (intSize width) addr val
+ return $ code `snocOL` MFENCE
genCCall dflags is32Bit (PrimTarget (MO_Cmpxchg width)) [dst] [addr, old, new] = do
-- On x86 we don't have enough registers to use cmpxchg with a
diff --git a/compiler/nativeGen/X86/Instr.hs b/compiler/nativeGen/X86/Instr.hs
index 82e52df1e5..172ce93f50 100644
--- a/compiler/nativeGen/X86/Instr.hs
+++ b/compiler/nativeGen/X86/Instr.hs
@@ -330,6 +330,7 @@ data Instr
| LOCK Instr -- lock prefix
| XADD Size Operand Operand -- src (r), dst (r/m)
| CMPXCHG Size Operand Operand -- src (r), dst (r/m), eax implicit
+ | MFENCE
data PrefetchVariant = NTA | Lvl0 | Lvl1 | Lvl2
@@ -437,6 +438,7 @@ x86_regUsageOfInstr platform instr
LOCK i -> x86_regUsageOfInstr platform i
XADD _ src dst -> usageMM src dst
CMPXCHG _ src dst -> usageRMM src dst (OpReg eax)
+ MFENCE -> noUsage
_other -> panic "regUsage: unrecognised instr"
where
@@ -606,6 +608,7 @@ x86_patchRegsOfInstr instr env
LOCK i -> LOCK (x86_patchRegsOfInstr i env)
XADD sz src dst -> patch2 (XADD sz) src dst
CMPXCHG sz src dst -> patch2 (CMPXCHG sz) src dst
+ MFENCE -> instr
_other -> panic "patchRegs: unrecognised instr"
diff --git a/compiler/nativeGen/X86/Ppr.hs b/compiler/nativeGen/X86/Ppr.hs
index 5ae1b540f2..15d29679b0 100644
--- a/compiler/nativeGen/X86/Ppr.hs
+++ b/compiler/nativeGen/X86/Ppr.hs
@@ -890,6 +890,8 @@ pprInstr GFREE
pprInstr (LOCK i) = ptext (sLit "\tlock") $$ pprInstr i
+pprInstr MFENCE = ptext (sLit "\tmfence")
+
pprInstr (XADD size src dst) = pprSizeOpOp (sLit "xadd") size src dst
pprInstr (CMPXCHG size src dst) = pprSizeOpOp (sLit "cmpxchg") size src dst