diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2012-09-18 17:40:23 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2012-09-18 17:40:23 +0100 |
commit | 8e7d41525dd6360eb828b14b2c1c764ed5023916 (patch) | |
tree | 9c9482d8c27173064199232fa01a4f27af84114d /compiler/coreSyn | |
parent | 94291904305fb4885cbbd3b8011d1b8fa4e308b2 (diff) | |
parent | 16cc37ff034213250c764cd941908398e4150100 (diff) | |
download | haskell-8e7d41525dd6360eb828b14b2c1c764ed5023916.tar.gz |
Merge remote-tracking branch 'origin/master' into tc-untouchables
Diffstat (limited to 'compiler/coreSyn')
-rw-r--r-- | compiler/coreSyn/CorePrep.lhs | 12 | ||||
-rw-r--r-- | compiler/coreSyn/CoreSyn.lhs | 19 | ||||
-rw-r--r-- | compiler/coreSyn/CoreUtils.lhs | 7 | ||||
-rw-r--r-- | compiler/coreSyn/MkCore.lhs | 17 |
4 files changed, 29 insertions, 26 deletions
diff --git a/compiler/coreSyn/CorePrep.lhs b/compiler/coreSyn/CorePrep.lhs index 0bd199ff18..fda2bccf9a 100644 --- a/compiler/coreSyn/CorePrep.lhs +++ b/compiler/coreSyn/CorePrep.lhs @@ -471,7 +471,7 @@ cpeRhsE :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeRhs) cpeRhsE _env expr@(Type {}) = return (emptyFloats, expr) cpeRhsE _env expr@(Coercion {}) = return (emptyFloats, expr) cpeRhsE env (Lit (LitInteger i _)) - = cpeRhsE env (cvtLitInteger (getMkIntegerId env) i) + = cpeRhsE env (cvtLitInteger (cpe_dynFlags env) (getMkIntegerId env) i) cpeRhsE _env expr@(Lit {}) = return (emptyFloats, expr) cpeRhsE env expr@(Var {}) = cpeApp env expr @@ -521,16 +521,16 @@ cpeRhsE env (Case scrut bndr ty alts) ; rhs' <- cpeBodyNF env2 rhs ; return (con, bs', rhs') } -cvtLitInteger :: Id -> Integer -> CoreExpr +cvtLitInteger :: DynFlags -> Id -> Integer -> CoreExpr -- Here we convert a literal Integer to the low-level -- represenation. Exactly how we do this depends on the -- library that implements Integer. If it's GMP we -- use the S# data constructor for small literals. -- See Note [Integer literals] in Literal -cvtLitInteger mk_integer i +cvtLitInteger dflags mk_integer i | cIntegerLibraryType == IntegerGMP - , inIntRange i -- Special case for small integers in GMP - = mkConApp integerGmpSDataCon [Lit (mkMachInt i)] + , inIntRange dflags i -- Special case for small integers in GMP + = mkConApp integerGmpSDataCon [Lit (mkMachInt dflags i)] | otherwise = mkApps (Var mk_integer) [isNonNegative, ints] @@ -540,7 +540,7 @@ cvtLitInteger mk_integer i f 0 = [] f x = let low = x .&. mask high = x `shiftR` bits - in mkConApp intDataCon [Lit (mkMachInt low)] : f high + in mkConApp intDataCon [Lit (mkMachInt dflags low)] : f high bits = 31 mask = 2 ^ bits - 1 diff --git a/compiler/coreSyn/CoreSyn.lhs b/compiler/coreSyn/CoreSyn.lhs index f972fc706d..2fb5aafd61 100644 --- a/compiler/coreSyn/CoreSyn.lhs +++ b/compiler/coreSyn/CoreSyn.lhs @@ -101,6 +101,7 @@ import DataCon import Module import TyCon import BasicTypes +import DynFlags import FastString import Outputable import Util @@ -561,7 +562,7 @@ data CoreRule ru_fn :: Name, -- ^ As above ru_nargs :: Int, -- ^ Number of arguments that 'ru_try' consumes, -- if it fires, including type arguments - ru_try :: Id -> IdUnfoldingFun -> [CoreExpr] -> Maybe CoreExpr + ru_try :: DynFlags -> Id -> IdUnfoldingFun -> [CoreExpr] -> Maybe CoreExpr -- ^ This function does the rewrite. It given too many -- arguments, it simply discards them; the returned 'CoreExpr' -- is just the rewrite of 'ru_fn' applied to the first 'ru_nargs' args @@ -1117,23 +1118,23 @@ mkConApp con args = mkApps (Var (dataConWorkId con)) args -- | Create a machine integer literal expression of type @Int#@ from an @Integer@. -- If you want an expression of type @Int@ use 'MkCore.mkIntExpr' -mkIntLit :: Integer -> Expr b +mkIntLit :: DynFlags -> Integer -> Expr b -- | Create a machine integer literal expression of type @Int#@ from an @Int@. -- If you want an expression of type @Int@ use 'MkCore.mkIntExpr' -mkIntLitInt :: Int -> Expr b +mkIntLitInt :: DynFlags -> Int -> Expr b -mkIntLit n = Lit (mkMachInt n) -mkIntLitInt n = Lit (mkMachInt (toInteger n)) +mkIntLit dflags n = Lit (mkMachInt dflags n) +mkIntLitInt dflags n = Lit (mkMachInt dflags (toInteger n)) -- | Create a machine word literal expression of type @Word#@ from an @Integer@. -- If you want an expression of type @Word@ use 'MkCore.mkWordExpr' -mkWordLit :: Integer -> Expr b +mkWordLit :: DynFlags -> Integer -> Expr b -- | Create a machine word literal expression of type @Word#@ from a @Word@. -- If you want an expression of type @Word@ use 'MkCore.mkWordExpr' -mkWordLitWord :: Word -> Expr b +mkWordLitWord :: DynFlags -> Word -> Expr b -mkWordLit w = Lit (mkMachWord w) -mkWordLitWord w = Lit (mkMachWord (toInteger w)) +mkWordLit dflags w = Lit (mkMachWord dflags w) +mkWordLitWord dflags w = Lit (mkMachWord dflags (toInteger w)) mkWord64LitWord64 :: Word64 -> Expr b mkWord64LitWord64 w = Lit (mkMachWord64 (toInteger w)) diff --git a/compiler/coreSyn/CoreUtils.lhs b/compiler/coreSyn/CoreUtils.lhs index f15c648694..cad80128b9 100644 --- a/compiler/coreSyn/CoreUtils.lhs +++ b/compiler/coreSyn/CoreUtils.lhs @@ -64,6 +64,7 @@ import TyCon import Unique import Outputable import TysPrim +import DynFlags import FastString import Maybes import Platform @@ -602,8 +603,8 @@ Note [exprIsDupable] \begin{code} -exprIsDupable :: CoreExpr -> Bool -exprIsDupable e +exprIsDupable :: DynFlags -> CoreExpr -> Bool +exprIsDupable dflags e = isJust (go dupAppSize e) where go :: Int -> CoreExpr -> Maybe Int @@ -613,7 +614,7 @@ exprIsDupable e go n (Tick _ e) = go n e go n (Cast e _) = go n e go n (App f a) | Just n' <- go n a = go n' f - go n (Lit lit) | litIsDupable lit = decrement n + go n (Lit lit) | litIsDupable dflags lit = decrement n go _ _ = Nothing decrement :: Int -> Maybe Int diff --git a/compiler/coreSyn/MkCore.lhs b/compiler/coreSyn/MkCore.lhs index 0857cd556e..e903ab2084 100644 --- a/compiler/coreSyn/MkCore.lhs +++ b/compiler/coreSyn/MkCore.lhs @@ -84,6 +84,7 @@ import BasicTypes import Util import Pair import Constants +import DynFlags import Data.Char ( ord ) import Data.List @@ -233,20 +234,20 @@ mkCoreLams = mkLams \begin{code} -- | Create a 'CoreExpr' which will evaluate to the given @Int@ -mkIntExpr :: Integer -> CoreExpr -- Result = I# i :: Int -mkIntExpr i = mkConApp intDataCon [mkIntLit i] +mkIntExpr :: DynFlags -> Integer -> CoreExpr -- Result = I# i :: Int +mkIntExpr dflags i = mkConApp intDataCon [mkIntLit dflags i] -- | Create a 'CoreExpr' which will evaluate to the given @Int@ -mkIntExprInt :: Int -> CoreExpr -- Result = I# i :: Int -mkIntExprInt i = mkConApp intDataCon [mkIntLitInt i] +mkIntExprInt :: DynFlags -> Int -> CoreExpr -- Result = I# i :: Int +mkIntExprInt dflags i = mkConApp intDataCon [mkIntLitInt dflags i] -- | Create a 'CoreExpr' which will evaluate to the a @Word@ with the given value -mkWordExpr :: Integer -> CoreExpr -mkWordExpr w = mkConApp wordDataCon [mkWordLit w] +mkWordExpr :: DynFlags -> Integer -> CoreExpr +mkWordExpr dflags w = mkConApp wordDataCon [mkWordLit dflags w] -- | Create a 'CoreExpr' which will evaluate to the given @Word@ -mkWordExprWord :: Word -> CoreExpr -mkWordExprWord w = mkConApp wordDataCon [mkWordLitWord w] +mkWordExprWord :: DynFlags -> Word -> CoreExpr +mkWordExprWord dflags w = mkConApp wordDataCon [mkWordLitWord dflags w] -- | Create a 'CoreExpr' which will evaluate to the given @Integer@ mkIntegerExpr :: MonadThings m => Integer -> m CoreExpr -- Result :: Integer |