diff options
author | Artem Pyanykh <artem.pyanykh@gmail.com> | 2019-04-11 14:20:03 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-04-14 01:26:35 -0400 |
commit | edcef7b384ca5af6e67d58c39779d03f80768538 (patch) | |
tree | 0a873348e5fc80f17cabdc0f5b6dddf15b70d07d /compiler/cmm | |
parent | 6febc444c0abea6c033174aa0e813c950b9b2877 (diff) | |
download | haskell-edcef7b384ca5af6e67d58c39779d03f80768538.tar.gz |
codegen: unroll memcpy calls for small bytearrays
Diffstat (limited to 'compiler/cmm')
-rw-r--r-- | compiler/cmm/CmmExpr.hs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/cmm/CmmExpr.hs b/compiler/cmm/CmmExpr.hs index dd4e777436..901df5d908 100644 --- a/compiler/cmm/CmmExpr.hs +++ b/compiler/cmm/CmmExpr.hs @@ -5,7 +5,7 @@ {-# LANGUAGE UndecidableInstances #-} module CmmExpr - ( CmmExpr(..), cmmExprType, cmmExprWidth, maybeInvertCmmExpr + ( CmmExpr(..), cmmExprType, cmmExprWidth, cmmExprAlignment, maybeInvertCmmExpr , CmmReg(..), cmmRegType, cmmRegWidth , CmmLit(..), cmmLitType , LocalReg(..), localRegType @@ -43,6 +43,8 @@ import Unique import Data.Set (Set) import qualified Data.Set as Set +import BasicTypes (Alignment, mkAlignment, alignmentOf) + ----------------------------------------------------------------------------- -- CmmExpr -- An expression. Expressions have no side effects. @@ -239,6 +241,13 @@ cmmLabelType dflags lbl cmmExprWidth :: DynFlags -> CmmExpr -> Width cmmExprWidth dflags e = typeWidth (cmmExprType dflags e) +-- | Returns an alignment in bytes of a CmmExpr when it's a statically +-- known integer constant, otherwise returns an alignment of 1 byte. +-- The caller is responsible for using with a sensible CmmExpr +-- argument. +cmmExprAlignment :: CmmExpr -> Alignment +cmmExprAlignment (CmmLit (CmmInt intOff _)) = alignmentOf (fromInteger intOff) +cmmExprAlignment _ = mkAlignment 1 -------- --- Negation for conditional branches |