[Git][ghc/ghc][master] MO_AcquireFence: Less restrictive barrier
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Wed Sep 4 11:21:09 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
fb0a4e5c by Sven Tennie at 2024-09-04T07:20:43-04:00
MO_AcquireFence: Less restrictive barrier
GCC and CLang translate the built-in `atomic_thread_fence(memory_order_acquire)`
to `dmb ishld`, which is a bit less restrictive than `dmb ish` (which
also implies stores.)
- - - - -
3 changed files:
- compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
- compiler/GHC/CmmToAsm/AArch64/Instr.hs
- compiler/GHC/CmmToAsm/AArch64/Ppr.hs
Changes:
=====================================
compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
=====================================
@@ -1990,9 +1990,13 @@ genCCall target dest_regs arg_regs = do
MO_SubIntC _w -> unsupported mop
-- Memory Ordering
- MO_AcquireFence -> return (unitOL DMBISH)
- MO_ReleaseFence -> return (unitOL DMBISH)
- MO_SeqCstFence -> return (unitOL DMBISH)
+ -- Set flags according to their C pendants (stdatomic.h):
+ -- atomic_thread_fence(memory_order_acquire); // -> dmb ishld
+ MO_AcquireFence -> return . unitOL $ DMBISH DmbLoad
+ -- atomic_thread_fence(memory_order_release); // -> dmb ish
+ MO_ReleaseFence -> return . unitOL $ DMBISH DmbLoadStore
+ -- atomic_thread_fence(memory_order_seq_cst); // -> dmb ish
+ MO_SeqCstFence -> return . unitOL $ DMBISH DmbLoadStore
MO_Touch -> return nilOL -- Keep variables live (when using interior pointers)
-- Prefetch
MO_Prefetch_Data _n -> return nilOL -- Prefetch hint.
=====================================
compiler/GHC/CmmToAsm/AArch64/Instr.hs
=====================================
@@ -134,7 +134,7 @@ regUsageOfInstr platform instr = case instr of
LDAR _ dst src -> usage (regOp src, regOp dst)
-- 8. Synchronization Instructions -------------------------------------------
- DMBISH -> usage ([], [])
+ DMBISH _ -> usage ([], [])
-- 9. Floating Point Instructions --------------------------------------------
FMOV dst src -> usage (regOp src, regOp dst)
@@ -281,7 +281,7 @@ patchRegsOfInstr instr env = case instr of
LDAR f o1 o2 -> LDAR f (patchOp o1) (patchOp o2)
-- 8. Synchronization Instructions -----------------------------------------
- DMBISH -> DMBISH
+ DMBISH c -> DMBISH c
-- 9. Floating Point Instructions ------------------------------------------
FMOV o1 o2 -> FMOV (patchOp o1) (patchOp o2)
@@ -649,7 +649,7 @@ data Instr
| BCOND Cond Target -- branch with condition. b.<cond>
-- 8. Synchronization Instructions -----------------------------------------
- | DMBISH
+ | DMBISH DMBISHFlags
-- 9. Floating Point Instructions
-- move to/from general purpose <-> floating, or floating to floating
| FMOV Operand Operand
@@ -672,6 +672,9 @@ data Instr
-- - fnmadd: d = - r1 * r2 - r3
| FMA FMASign Operand Operand Operand Operand
+data DMBISHFlags = DmbLoad | DmbLoadStore
+ deriving (Eq, Show)
+
instrCon :: Instr -> String
instrCon i =
case i of
=====================================
compiler/GHC/CmmToAsm/AArch64/Ppr.hs
=====================================
@@ -527,7 +527,8 @@ pprInstr platform instr = case instr of
LDAR _f o1 o2 -> op2 (text "\tldar") o1 o2
-- 8. Synchronization Instructions -------------------------------------------
- DMBISH -> line $ text "\tdmb ish"
+ DMBISH DmbLoadStore -> line $ text "\tdmb ish"
+ DMBISH DmbLoad -> line $ text "\tdmb ishld"
-- 9. Floating Point Instructions --------------------------------------------
FMOV o1 o2 -> op2 (text "\tfmov") o1 o2
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fb0a4e5cc545d8d995b6631138f40495917e795a
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fb0a4e5cc545d8d995b6631138f40495917e795a
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240904/cd74f32e/attachment-0001.html>
More information about the ghc-commits
mailing list