diff options
Diffstat (limited to 'compiler/cmm/CmmMachOp.hs')
| -rw-r--r-- | compiler/cmm/CmmMachOp.hs | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/compiler/cmm/CmmMachOp.hs b/compiler/cmm/CmmMachOp.hs index e9215d5021..f3f9e74a0b 100644 --- a/compiler/cmm/CmmMachOp.hs +++ b/compiler/cmm/CmmMachOp.hs @@ -21,6 +21,7 @@ module CmmMachOp -- CallishMachOp , CallishMachOp(..), callishMachOpHints , pprCallishMachOp + , machOpMemcpyishAlign -- Atomic read-modify-write , AtomicMachOp(..) @@ -565,12 +566,12 @@ data CallishMachOp -- would the majority of use cases in ghc anyways - -- Note that these three MachOps all take 1 extra parameter than the - -- standard C lib versions. The extra (last) parameter contains - -- alignment of the pointers. Used for optimisation in backends. - | MO_Memcpy - | MO_Memset - | MO_Memmove + -- These three MachOps are parameterised by the known alignment + -- of the destination and source (for memcpy/memmove) pointers. + -- This information may be used for optimisation in backends. + | MO_Memcpy Int + | MO_Memset Int + | MO_Memmove Int | MO_PopCnt Width | MO_Clz Width @@ -600,8 +601,16 @@ pprCallishMachOp mo = text (show mo) callishMachOpHints :: CallishMachOp -> ([ForeignHint], [ForeignHint]) callishMachOpHints op = case op of - MO_Memcpy -> ([], [AddrHint,AddrHint,NoHint,NoHint]) - MO_Memset -> ([], [AddrHint,NoHint,NoHint,NoHint]) - MO_Memmove -> ([], [AddrHint,AddrHint,NoHint,NoHint]) - _ -> ([],[]) + MO_Memcpy _ -> ([], [AddrHint,AddrHint,NoHint]) + MO_Memset _ -> ([], [AddrHint,NoHint,NoHint]) + MO_Memmove _ -> ([], [AddrHint,AddrHint,NoHint]) + _ -> ([],[]) -- empty lists indicate NoHint + +-- | The alignment of a 'memcpy'-ish operation. +machOpMemcpyishAlign :: CallishMachOp -> Maybe Int +machOpMemcpyishAlign op = case op of + MO_Memcpy align -> Just align + MO_Memset align -> Just align + MO_Memmove align -> Just align + _ -> Nothing |
