diff options
author | Ian Lynagh <ian@well-typed.com> | 2012-08-29 00:10:44 +0100 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2012-08-29 00:10:44 +0100 |
commit | 41448969dad90e479e4eac3721fc5d5dd4968885 (patch) | |
tree | 2a0f5932617ef767802c15caed2df1d05eeb2f33 /compiler/coreSyn | |
parent | baa7c0fd8cd9e4fc3b2a50085061c9e95bbb5f5d (diff) | |
download | haskell-41448969dad90e479e4eac3721fc5d5dd4968885.tar.gz |
Remove CPP from coreSyn/CoreUtils.lhs
Diffstat (limited to 'compiler/coreSyn')
-rw-r--r-- | compiler/coreSyn/CorePrep.lhs | 11 | ||||
-rw-r--r-- | compiler/coreSyn/CoreUtils.lhs | 10 |
2 files changed, 12 insertions, 9 deletions
diff --git a/compiler/coreSyn/CorePrep.lhs b/compiler/coreSyn/CorePrep.lhs index 5a996c8c6f..0bd199ff18 100644 --- a/compiler/coreSyn/CorePrep.lhs +++ b/compiler/coreSyn/CorePrep.lhs @@ -46,6 +46,7 @@ import DynFlags import Util import Pair import Outputable +import Platform import FastString import Config import Data.Bits @@ -401,6 +402,8 @@ cpePair top_lvl is_rec is_strict_or_unlifted env bndr rhs ; return (floats3, bndr', rhs') } where + platform = targetPlatform (cpe_dynFlags env) + arity = idArity bndr -- We must match this arity --------------------- @@ -422,7 +425,7 @@ cpePair top_lvl is_rec is_strict_or_unlifted env bndr rhs = return (floats, rhs) -- So the top-level binding is marked NoCafRefs - | Just (floats', rhs') <- canFloatFromNoCaf floats rhs + | Just (floats', rhs') <- canFloatFromNoCaf platform floats rhs = return (floats', rhs') | otherwise @@ -1069,9 +1072,9 @@ dropDeadCodeAlts alts = (alts', unionVarSets fvss) where !(e', fvs) = dropDeadCode e ------------------------------------------- -canFloatFromNoCaf :: Floats -> CpeRhs -> Maybe (Floats, CpeRhs) +canFloatFromNoCaf :: Platform -> Floats -> CpeRhs -> Maybe (Floats, CpeRhs) -- Note [CafInfo and floating] -canFloatFromNoCaf (Floats ok_to_spec fs) rhs +canFloatFromNoCaf platform (Floats ok_to_spec fs) rhs | OkToSpec <- ok_to_spec -- Worth trying , Just (subst, fs') <- go (emptySubst, nilOL) (fromOL fs) = Just (Floats OkToSpec fs', subst_expr subst rhs) @@ -1114,7 +1117,7 @@ canFloatFromNoCaf (Floats ok_to_spec fs) rhs -- We can only float to top level from a NoCaf thing if -- the new binding is static. However it can't mention -- any non-static things or it would *already* be Caffy - rhs_ok = rhsIsStatic (\_ -> False) + rhs_ok = rhsIsStatic platform (\_ -> False) wantFloatNested :: RecFlag -> Bool -> Floats -> CpeRhs -> Bool wantFloatNested is_rec strict_or_unlifted floats rhs diff --git a/compiler/coreSyn/CoreUtils.lhs b/compiler/coreSyn/CoreUtils.lhs index 12a3fb3491..f15c648694 100644 --- a/compiler/coreSyn/CoreUtils.lhs +++ b/compiler/coreSyn/CoreUtils.lhs @@ -66,6 +66,7 @@ import Outputable import TysPrim import FastString import Maybes +import Platform import Util import Pair import Data.Word @@ -1733,7 +1734,7 @@ and 'execute' it rather than allocating it statically. -- | This function is called only on *top-level* right-hand sides. -- Returns @True@ if the RHS can be allocated statically in the output, -- with no thunks involved at all. -rhsIsStatic :: (Name -> Bool) -> CoreExpr -> Bool +rhsIsStatic :: Platform -> (Name -> Bool) -> CoreExpr -> Bool -- It's called (i) in TidyPgm.hasCafRefs to decide if the rhs is, or -- refers to, CAFs; (ii) in CoreToStg to decide whether to put an -- update flag on it and (iii) in DsExpr to decide how to expand @@ -1788,7 +1789,7 @@ rhsIsStatic :: (Name -> Bool) -> CoreExpr -> Bool -- -- c) don't look through unfolding of f in (f x). -rhsIsStatic _is_dynamic_name rhs = is_static False rhs +rhsIsStatic platform is_dynamic_name rhs = is_static False rhs where is_static :: Bool -- True <=> in a constructor argument; must be atomic -> CoreExpr -> Bool @@ -1813,9 +1814,8 @@ rhsIsStatic _is_dynamic_name rhs = is_static False rhs is_static in_arg other_expr = go other_expr 0 where go (Var f) n_val_args -#if mingw32_TARGET_OS - | not (_is_dynamic_name (idName f)) -#endif + | (platformOS platform /= OSMinGW32) || + not (is_dynamic_name (idName f)) = saturated_data_con f n_val_args || (in_arg && n_val_args == 0) -- A naked un-applied variable is *not* deemed a static RHS |