diff options
author | Artem Pyanykh <artem.pyanykh@gmail.com> | 2019-04-05 13:15:06 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-04-09 10:30:13 -0400 |
commit | bd2de4f06169e15506bb357cf7c2c8b1dad37d67 (patch) | |
tree | fc188fed10b7adf6d22468fa8db75f7ca36aaf61 /compiler/codeGen | |
parent | af4cea7f1411e5b99e2417d7c2d3d0e697093103 (diff) | |
download | haskell-bd2de4f06169e15506bb357cf7c2c8b1dad37d67.tar.gz |
codegen: use newtype for Alignment in BasicTypes
Diffstat (limited to 'compiler/codeGen')
-rw-r--r-- | compiler/codeGen/StgCmmPrim.hs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/compiler/codeGen/StgCmmPrim.hs b/compiler/codeGen/StgCmmPrim.hs index 1abef3a90a..63d8f7bc0e 100644 --- a/compiler/codeGen/StgCmmPrim.hs +++ b/compiler/codeGen/StgCmmPrim.hs @@ -2075,16 +2075,15 @@ doSetByteArrayOp :: CmmExpr -> CmmExpr -> CmmExpr -> CmmExpr -> FCode () doSetByteArrayOp ba off len c = do dflags <- getDynFlags - let maxAlign = wORD_SIZE dflags - align = minimum [maxAlign, possibleAlign] - p <- assignTempE $ cmmOffsetExpr dflags (cmmOffsetB dflags ba (arrWordsHdrSize dflags)) off + let byteArrayAlignment = wordAlignment dflags -- known since BA is allocated on heap + offsetAlignment = case off of + CmmLit (CmmInt intOff _) -> alignmentOf (fromInteger intOff) + _ -> mkAlignment 1 + align = min byteArrayAlignment offsetAlignment + p <- assignTempE $ cmmOffsetExpr dflags (cmmOffsetB dflags ba (arrWordsHdrSize dflags)) off emitMemsetCall p c len align - where - possibleAlign = case off of - CmmLit (CmmInt intOff _) -> fromIntegral $ byteAlignment (fromIntegral intOff) - _ -> 1 -- ---------------------------------------------------------------------------- -- Allocating arrays @@ -2355,7 +2354,7 @@ emitSetCards dst_start dst_cards_start n = do emitMemsetCall (cmmAddWord dflags dst_cards_start start_card) (mkIntExpr dflags 1) (cmmAddWord dflags (cmmSubWord dflags end_card start_card) (mkIntExpr dflags 1)) - 1 -- no alignment (1 byte) + (mkAlignment 1) -- no alignment (1 byte) -- Convert an element index to a card index cardCmm :: DynFlags -> CmmExpr -> CmmExpr @@ -2481,11 +2480,11 @@ emitMemmoveCall dst src n align = do -- | Emit a call to @memset@. The second argument must fit inside an -- unsigned char. -emitMemsetCall :: CmmExpr -> CmmExpr -> CmmExpr -> Int -> FCode () +emitMemsetCall :: CmmExpr -> CmmExpr -> CmmExpr -> Alignment -> FCode () emitMemsetCall dst c n align = do emitPrimCall [ {- no results -} ] - (MO_Memset align) + (MO_Memset (alignmentBytes align)) [ dst, c, n ] emitMemcmpCall :: LocalReg -> CmmExpr -> CmmExpr -> CmmExpr -> Int -> FCode () |