[Git][ghc/ghc][wip/T22115] nativeGen/AArch64: Emit Atomic{Read, Write} inline

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Sun Jan 29 14:10:14 UTC 2023



Ben Gamari pushed to branch wip/T22115 at Glasgow Haskell Compiler / GHC


Commits:
a01de041 by Ben Gamari at 2023-01-29T09:10:09-05:00
nativeGen/AArch64: Emit Atomic{Read,Write} inline

Previously the AtomicRead and AtomicWrite operations were emitted as
out-of-line calls. However, these tend to be very important for
performance, especially the RELAXED case (which only exists for
ThreadSanitizer checking).

Fixes #22115.

- - - - -


1 changed file:

- compiler/GHC/CmmToAsm/AArch64/CodeGen.hs


Changes:

=====================================
compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
=====================================
@@ -1532,9 +1532,24 @@ genCCall target dest_regs arg_regs bid = do
         MO_BRev w           -> mkCCall (bRevLabel w)
 
         -- -- Atomic read-modify-write.
+        MO_AtomicRead w ord
+          | [p_reg] <- arg_regs
+          , [dst_reg] <- dst_regs -> do
+              (p_addr, _format_p, code_p) <- getFloatReg p_reg
+              let dst = getRegisterReg platform (CmmLocal dest_reg)
+                  instr = case ord of
+                      OrderRelaxed -> LDR
+                      _            -> LDAR
+              return $ code_p `appOL` instr dst src
+        MO_AtomicWrite w ord
+          | [p_reg, val_reg] <- arg_regs -> do
+              (p_addr, _format_p, code_p) <- getFloatReg p_reg
+              (val_addr, _format_val, code_val) <- getFloatReg val_reg
+              let instr = case ord of
+                      OrderRelaxed -> STR
+                      _            -> STLR
+              return $ val_code `appOL` code_p `appOL` instr val p
         MO_AtomicRMW w amop -> mkCCall (atomicRMWLabel w amop)
-        MO_AtomicRead w _   -> mkCCall (atomicReadLabel w)
-        MO_AtomicWrite w _  -> mkCCall (atomicWriteLabel w)
         MO_Cmpxchg w        -> mkCCall (cmpxchgLabel w)
         -- -- Should be an AtomicRMW variant eventually.
         -- -- Sequential consistent.



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a01de041753b289fb985f72f28c7a95a04050d92

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a01de041753b289fb985f72f28c7a95a04050d92
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/20230129/317b8b3d/attachment-0001.html>


More information about the ghc-commits mailing list