diff options
author | Sebastian Graf <sebastian.graf@kit.edu> | 2021-01-10 18:49:13 +0100 |
---|---|---|
committer | Sebastian Graf <sebastian.graf@kit.edu> | 2021-01-11 09:44:04 +0100 |
commit | 3a115330a2f36e23c2e49fe59952345b9360009b (patch) | |
tree | e696987a098bed01f12456b6c6d1a36a788c30e9 /compiler/GHC/Core/Utils.hs | |
parent | 62b305376391dc11a4084a3ed4a4f027626b00b6 (diff) | |
download | haskell-wip/ww-refactoring.tar.gz |
WorkWrap: Explicit wantToUnbox* unboxing strategieswip/ww-refactoring
This is a refactoring that extracts a type synonym
```hs
type UnboxingStrategy s = Type -> s -> UnboxingDecision s
```
from `GHC.Core.WorkWrap.Utils`, and gives two such strategies
in the form of `wantToUnboxArg` and `wantToUnboxResult` there.
This is all in order to underline the common bits in `mkWWstr_one`
and `mkWWcpr`.
I've put `UnboxingStrategy` into its own module `GHC.Types.Unbox`,
because Nested CPR needs `GHC.Types.Cpr` to depend on it.
Diffstat (limited to 'compiler/GHC/Core/Utils.hs')
-rw-r--r-- | compiler/GHC/Core/Utils.hs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/compiler/GHC/Core/Utils.hs b/compiler/GHC/Core/Utils.hs index afebee0678..d419c2546e 100644 --- a/compiler/GHC/Core/Utils.hs +++ b/compiler/GHC/Core/Utils.hs @@ -47,7 +47,7 @@ module GHC.Core.Utils ( exprToType, exprToCoercion_maybe, applyTypeToArgs, applyTypeToArg, dataConRepInstPat, dataConRepFSInstPat, - isEmptyTy, + isEmptyTy, normSplitTyConApp_maybe, -- * Working with ticks stripTicksTop, stripTicksTopE, stripTicksTopT, @@ -87,6 +87,7 @@ import GHC.Core.DataCon import GHC.Builtin.PrimOps import GHC.Types.Id import GHC.Types.Id.Info +import GHC.Core.FamInstEnv import GHC.Core.Type as Type import GHC.Core.Predicate import GHC.Core.TyCo.Rep( TyCoBinder(..), TyBinder ) @@ -2563,6 +2564,17 @@ isEmptyTy ty | otherwise = False +-- | If `normSplitTyConApp_maybe _ ty = Just (tc, tys, co)` +-- then `ty |> co = tc tys`. It's 'splitArgType_maybe', but looks through +-- coercions via 'topNormaliseType_maybe'. Hence the \"norm\" prefix. +normSplitTyConApp_maybe :: FamInstEnvs -> Type -> Maybe (TyCon, [Type], Coercion) +normSplitTyConApp_maybe fam_envs ty + | let (co, ty1) = topNormaliseType_maybe fam_envs ty + `orElse` (mkRepReflCo ty, ty) + , Just (tc, tc_args) <- splitTyConApp_maybe ty1 + = Just (tc, tc_args, co) +normSplitTyConApp_maybe _ _ = Nothing + {- ***************************************************** * |