diff options
author | Luite Stegeman <stegeman@gmail.com> | 2020-12-10 16:32:19 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-03-20 07:49:15 -0400 |
commit | 26328a688183e3af49b5ac315b27afc2691bbc46 (patch) | |
tree | 007b8105d2cabf52142cb8f5d7b790e888e42197 /compiler/GHC/Core | |
parent | dd11f2d5e87ba83ca16510e3e1ac6c41c1df1647 (diff) | |
download | haskell-26328a688183e3af49b5ac315b27afc2691bbc46.tar.gz |
remove superfluous 'id' type parameter from GenTickish
The 'id' type is now determined by the pass, using the XTickishId
type family.
Diffstat (limited to 'compiler/GHC/Core')
-rw-r--r-- | compiler/GHC/Core/FVs.hs | 3 | ||||
-rw-r--r-- | compiler/GHC/Core/Map/Expr.hs | 6 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/CallerCC.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/FloatOut.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/OccurAnal.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/Pipeline.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/Simplify.hs | 3 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/Simplify/Utils.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/Specialise.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Core/Ppr.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Core/Seq.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Core/SimpleOpt.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Core/Stats.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Core/Subst.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Core/Tidy.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Core/Utils.hs | 24 |
16 files changed, 34 insertions, 30 deletions
diff --git a/compiler/GHC/Core/FVs.hs b/compiler/GHC/Core/FVs.hs index da661f1439..8baa5f26f8 100644 --- a/compiler/GHC/Core/FVs.hs +++ b/compiler/GHC/Core/FVs.hs @@ -6,6 +6,7 @@ Taken quite directly from the Peyton Jones/Lester paper. -} {-# LANGUAGE CPP #-} +{-# LANGUAGE TypeFamilies #-} -- | A module concerned with finding the free variables of an expression. module GHC.Core.FVs ( @@ -289,7 +290,7 @@ rhs_fvs (bndr, rhs) = expr_fvs rhs `unionFV` exprs_fvs :: [CoreExpr] -> FV exprs_fvs exprs = mapUnionFV expr_fvs exprs -tickish_fvs :: Tickish Id -> FV +tickish_fvs :: Tickish -> FV tickish_fvs (Breakpoint _ _ ids) = FV.mkFVs ids tickish_fvs _ = emptyFV diff --git a/compiler/GHC/Core/Map/Expr.hs b/compiler/GHC/Core/Map/Expr.hs index 03c0876138..b4a687f2c2 100644 --- a/compiler/GHC/Core/Map/Expr.hs +++ b/compiler/GHC/Core/Map/Expr.hs @@ -324,11 +324,11 @@ xtE (D env (Case e b ty as)) f m in xtList (xtA env1) as f } -- TODO: this seems a bit dodgy, see 'eqTickish' -type TickishMap a = Map.Map (Tickish Id) a -lkTickish :: Tickish Id -> TickishMap a -> Maybe a +type TickishMap a = Map.Map Tickish a +lkTickish :: Tickish -> TickishMap a -> Maybe a lkTickish = lookupTM -xtTickish :: Tickish Id -> XT a -> TickishMap a -> TickishMap a +xtTickish :: Tickish -> XT a -> TickishMap a -> TickishMap a xtTickish = alterTM ------------------------ diff --git a/compiler/GHC/Core/Opt/CallerCC.hs b/compiler/GHC/Core/Opt/CallerCC.hs index 0807675d57..5a88482b42 100644 --- a/compiler/GHC/Core/Opt/CallerCC.hs +++ b/compiler/GHC/Core/Opt/CallerCC.hs @@ -82,7 +82,7 @@ doExpr env e@(Var v) top:_ -> nameSrcSpan $ varName top _ -> noSrcSpan cc = NormalCC (ExprCC ccIdx) ccName (thisModule env) span - tick :: Tickish Id + tick :: Tickish tick = ProfNote cc True True pure $ Tick tick e | otherwise = pure e diff --git a/compiler/GHC/Core/Opt/FloatOut.hs b/compiler/GHC/Core/Opt/FloatOut.hs index 26a7c261bf..b8b434292f 100644 --- a/compiler/GHC/Core/Opt/FloatOut.hs +++ b/compiler/GHC/Core/Opt/FloatOut.hs @@ -738,7 +738,7 @@ atJoinCeiling (fs, floats, expr') where (floats', ceils) = partitionAtJoinCeiling floats -wrapTick :: Tickish Id -> FloatBinds -> FloatBinds +wrapTick :: Tickish -> FloatBinds -> FloatBinds wrapTick t (FB tops ceils defns) = FB (mapBag wrap_bind tops) (wrap_defns ceils) (M.map (M.map wrap_defns) defns) diff --git a/compiler/GHC/Core/Opt/OccurAnal.hs b/compiler/GHC/Core/Opt/OccurAnal.hs index 74fe628a49..96c63f11a7 100644 --- a/compiler/GHC/Core/Opt/OccurAnal.hs +++ b/compiler/GHC/Core/Opt/OccurAnal.hs @@ -2055,7 +2055,7 @@ Constructors are rather like lambdas in this way. -} occAnalApp :: OccEnv - -> (Expr CoreBndr, [Arg CoreBndr], [Tickish Id]) + -> (Expr CoreBndr, [Arg CoreBndr], [Tickish]) -> (UsageDetails, Expr CoreBndr) -- Naked variables (not applied) end up here too occAnalApp env (Var fun, args, ticks) diff --git a/compiler/GHC/Core/Opt/Pipeline.hs b/compiler/GHC/Core/Opt/Pipeline.hs index c85b39754e..a9b5eabc30 100644 --- a/compiler/GHC/Core/Opt/Pipeline.hs +++ b/compiler/GHC/Core/Opt/Pipeline.hs @@ -981,7 +981,7 @@ ticks. More often than not, other references will be unfoldings of x_exported, and therefore carry the tick anyway. -} -type IndEnv = IdEnv (Id, [Tickish Var]) -- Maps local_id -> exported_id, ticks +type IndEnv = IdEnv (Id, [Tickish]) -- Maps local_id -> exported_id, ticks shortOutIndirections :: CoreProgram -> CoreProgram shortOutIndirections binds diff --git a/compiler/GHC/Core/Opt/Simplify.hs b/compiler/GHC/Core/Opt/Simplify.hs index f137534ec0..d3522f5478 100644 --- a/compiler/GHC/Core/Opt/Simplify.hs +++ b/compiler/GHC/Core/Opt/Simplify.hs @@ -5,6 +5,7 @@ -} {-# LANGUAGE CPP #-} +{-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates -Wno-incomplete-uni-patterns #-} module GHC.Core.Opt.Simplify ( simplTopBinds, simplExpr, simplRules ) where @@ -1160,7 +1161,7 @@ simplCoercion env co -- long as this is a non-scoping tick, to let case and application -- optimisations apply. -simplTick :: SimplEnv -> Tickish Id -> InExpr -> SimplCont +simplTick :: SimplEnv -> Tickish -> InExpr -> SimplCont -> SimplM (SimplFloats, OutExpr) simplTick env tickish expr cont -- A scoped tick turns into a continuation, so that we can spot diff --git a/compiler/GHC/Core/Opt/Simplify/Utils.hs b/compiler/GHC/Core/Opt/Simplify/Utils.hs index 2e27466c55..a8b16f8ba3 100644 --- a/compiler/GHC/Core/Opt/Simplify/Utils.hs +++ b/compiler/GHC/Core/Opt/Simplify/Utils.hs @@ -166,7 +166,7 @@ data SimplCont , sc_cont :: SimplCont } | TickIt -- (TickIt t K)[e] = K[ tick t e ] - (Tickish Id) -- Tick tickish <hole> + Tickish -- Tick tickish <hole> SimplCont type StaticEnv = SimplEnv -- Just the static part is relevant diff --git a/compiler/GHC/Core/Opt/Specialise.hs b/compiler/GHC/Core/Opt/Specialise.hs index 63e52ce258..ee08e31eb5 100644 --- a/compiler/GHC/Core/Opt/Specialise.hs +++ b/compiler/GHC/Core/Opt/Specialise.hs @@ -1125,7 +1125,7 @@ specLam env bndrs body ; return (mkLams bndrs (wrapDictBindsE dumped_dbs body'), free_uds) } -------------- -specTickish :: SpecEnv -> Tickish Id -> Tickish Id +specTickish :: SpecEnv -> Tickish -> Tickish specTickish env (Breakpoint ext ix ids) = Breakpoint ext ix [ id' | id <- ids, Var id' <- [specVar env id]] -- drop vars from the list if they have a non-variable substitution. diff --git a/compiler/GHC/Core/Ppr.hs b/compiler/GHC/Core/Ppr.hs index 820f1f1785..06c35c1d28 100644 --- a/compiler/GHC/Core/Ppr.hs +++ b/compiler/GHC/Core/Ppr.hs @@ -1,6 +1,8 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -fno-warn-orphans #-} @@ -648,7 +650,7 @@ pprRule (Rule { ru_name = name, ru_act = act, ru_fn = fn, ----------------------------------------------------- -} -instance Outputable id => Outputable (GenTickish pass id) where +instance Outputable (XTickishId pass) => Outputable (GenTickish pass) where ppr (HpcTick modl ix) = hcat [text "hpc<", ppr modl, comma, diff --git a/compiler/GHC/Core/Seq.hs b/compiler/GHC/Core/Seq.hs index 4dafc9c2e8..ce145b1c9c 100644 --- a/compiler/GHC/Core/Seq.hs +++ b/compiler/GHC/Core/Seq.hs @@ -21,7 +21,7 @@ import GHC.Types.Var.Set( seqDVarSet ) import GHC.Types.Var( varType, tyVarKind ) import GHC.Core.Type( seqType, isTyVar ) import GHC.Core.Coercion( seqCo ) -import GHC.Types.Id( Id, idInfo ) +import GHC.Types.Id( idInfo ) -- | Evaluate all the fields of the 'IdInfo' that are generally demanded by the -- compiler @@ -71,7 +71,7 @@ seqExprs :: [CoreExpr] -> () seqExprs [] = () seqExprs (e:es) = seqExpr e `seq` seqExprs es -seqTickish :: Tickish Id -> () +seqTickish :: Tickish -> () seqTickish ProfNote{ profNoteCC = cc } = cc `seq` () seqTickish HpcTick{} = () seqTickish Breakpoint{ breakpointFVs = ids } = seqBndrs ids diff --git a/compiler/GHC/Core/SimpleOpt.hs b/compiler/GHC/Core/SimpleOpt.hs index 81bbc9247e..07b77a5d12 100644 --- a/compiler/GHC/Core/SimpleOpt.hs +++ b/compiler/GHC/Core/SimpleOpt.hs @@ -1322,7 +1322,7 @@ Currently, it is used in GHC.Core.Rules.match, and is required to make -} exprIsLambda_maybe :: InScopeEnv -> CoreExpr - -> Maybe (Var, CoreExpr,[Tickish Id]) + -> Maybe (Var, CoreExpr,[Tickish]) -- See Note [exprIsLambda_maybe] -- The simple case: It is a lambda already diff --git a/compiler/GHC/Core/Stats.hs b/compiler/GHC/Core/Stats.hs index 46d5af5106..a25fd7b108 100644 --- a/compiler/GHC/Core/Stats.hs +++ b/compiler/GHC/Core/Stats.hs @@ -116,7 +116,7 @@ exprSize (Tick n e) = tickSize n + exprSize e exprSize (Type _) = 1 exprSize (Coercion _) = 1 -tickSize :: Tickish Id -> Int +tickSize :: Tickish -> Int tickSize (ProfNote _ _ _) = 1 tickSize _ = 1 diff --git a/compiler/GHC/Core/Subst.hs b/compiler/GHC/Core/Subst.hs index 7110208d79..bcf5790b99 100644 --- a/compiler/GHC/Core/Subst.hs +++ b/compiler/GHC/Core/Subst.hs @@ -717,7 +717,7 @@ substDVarSet subst fvs | otherwise = tyCoFVsOfType (lookupTCvSubst subst fv) (const True) emptyVarSet $! acc ------------------ -substTickish :: Subst -> Tickish Id -> Tickish Id +substTickish :: Subst -> Tickish -> Tickish substTickish subst (Breakpoint ext n ids) = Breakpoint ext n (map do_one ids) where diff --git a/compiler/GHC/Core/Tidy.hs b/compiler/GHC/Core/Tidy.hs index 3e71d2c5b2..2c4b0b9203 100644 --- a/compiler/GHC/Core/Tidy.hs +++ b/compiler/GHC/Core/Tidy.hs @@ -88,7 +88,7 @@ tidyAlt env (Alt con vs rhs) (Alt con vs (tidyExpr env' rhs)) ------------ Tickish -------------- -tidyTickish :: TidyEnv -> Tickish Id -> Tickish Id +tidyTickish :: TidyEnv -> Tickish -> Tickish tidyTickish env (Breakpoint ext ix ids) = Breakpoint ext ix (map (tidyVarOcc env) ids) tidyTickish _ other_tickish = other_tickish diff --git a/compiler/GHC/Core/Utils.hs b/compiler/GHC/Core/Utils.hs index f2772edd8b..35a32d4c5d 100644 --- a/compiler/GHC/Core/Utils.hs +++ b/compiler/GHC/Core/Utils.hs @@ -339,7 +339,7 @@ mkCast expr co -- | Wraps the given expression in the source annotation, dropping the -- annotation if possible. -mkTick :: Tickish Id -> CoreExpr -> CoreExpr +mkTick :: Tickish -> CoreExpr -> CoreExpr mkTick t orig_expr = mkTick' id id orig_expr where -- Some ticks (cost-centres) can be split in two, with the @@ -424,7 +424,7 @@ mkTick t orig_expr = mkTick' id id orig_expr -- Catch-all: Annotate where we stand _any -> top $ Tick t $ rest expr -mkTicks :: [Tickish Id] -> CoreExpr -> CoreExpr +mkTicks :: [Tickish] -> CoreExpr -> CoreExpr mkTicks ticks expr = foldr mkTick expr ticks isSaturatedConApp :: CoreExpr -> Bool @@ -435,13 +435,13 @@ isSaturatedConApp e = go e [] go (Cast f _) as = go f as go _ _ = False -mkTickNoHNF :: Tickish Id -> CoreExpr -> CoreExpr +mkTickNoHNF :: Tickish -> CoreExpr -> CoreExpr mkTickNoHNF t e | exprIsHNF e = tickHNFArgs t e | otherwise = mkTick t e -- push a tick into the arguments of a HNF (call or constructor app) -tickHNFArgs :: Tickish Id -> CoreExpr -> CoreExpr +tickHNFArgs :: Tickish -> CoreExpr -> CoreExpr tickHNFArgs t e = push t e where push t (App f (Type u)) = App (push t f) (Type u) @@ -449,28 +449,28 @@ tickHNFArgs t e = push t e push _t e = e -- | Strip ticks satisfying a predicate from top of an expression -stripTicksTop :: (Tickish Id -> Bool) -> Expr b -> ([Tickish Id], Expr b) +stripTicksTop :: (Tickish -> Bool) -> Expr b -> ([Tickish], Expr b) stripTicksTop p = go [] where go ts (Tick t e) | p t = go (t:ts) e go ts other = (reverse ts, other) -- | Strip ticks satisfying a predicate from top of an expression, -- returning the remaining expression -stripTicksTopE :: (Tickish Id -> Bool) -> Expr b -> Expr b +stripTicksTopE :: (Tickish -> Bool) -> Expr b -> Expr b stripTicksTopE p = go where go (Tick t e) | p t = go e go other = other -- | Strip ticks satisfying a predicate from top of an expression, -- returning the ticks -stripTicksTopT :: (Tickish Id -> Bool) -> Expr b -> [Tickish Id] +stripTicksTopT :: (Tickish -> Bool) -> Expr b -> [Tickish] stripTicksTopT p = go [] where go ts (Tick t e) | p t = go (t:ts) e go ts _ = ts -- | Completely strip ticks satisfying a predicate from an -- expression. Note this is O(n) in the size of the expression! -stripTicksE :: (Tickish Id -> Bool) -> Expr b -> Expr b +stripTicksE :: (Tickish -> Bool) -> Expr b -> Expr b stripTicksE p expr = go expr where go (App e a) = App (go e) (go a) go (Lam b e) = Lam b (go e) @@ -486,7 +486,7 @@ stripTicksE p expr = go expr go_b (b, e) = (b, go e) go_a (Alt c bs e) = Alt c bs (go e) -stripTicksT :: (Tickish Id -> Bool) -> Expr b -> [Tickish Id] +stripTicksT :: (Tickish -> Bool) -> Expr b -> [Tickish] stripTicksT p expr = fromOL $ go expr where go (App e a) = go e `appOL` go a go (Lam _ e) = go e @@ -2103,7 +2103,7 @@ cheapEqExpr :: Expr b -> Expr b -> Bool cheapEqExpr = cheapEqExpr' (const False) -- | Cheap expression equality test, can ignore ticks by type. -cheapEqExpr' :: (Tickish Id -> Bool) -> Expr b -> Expr b -> Bool +cheapEqExpr' :: (Tickish -> Bool) -> Expr b -> Expr b -> Bool {-# INLINE cheapEqExpr' #-} cheapEqExpr' ignoreTick e1 e2 = go e1 e2 @@ -2167,7 +2167,7 @@ eqExpr in_scope e1 e2 go_alt env (Alt c1 bs1 e1) (Alt c2 bs2 e2) = c1 == c2 && go (rnBndrs2 env bs1 bs2) e1 e2 -eqTickish :: RnEnv2 -> Tickish Id -> Tickish Id -> Bool +eqTickish :: RnEnv2 -> Tickish -> Tickish -> Bool eqTickish env (Breakpoint _ lid lids) (Breakpoint _ rid rids) = lid == rid && map (rnOccL env) lids == map (rnOccR env) rids eqTickish _ l r = l == r @@ -2483,7 +2483,7 @@ tryEtaReduce bndrs body -> Type -- Type of the function to which the argument is applied -> Maybe (Coercion -- Of type (arg_t -> t1 ~ bndr_t -> t2) -- (and similarly for tyvars, coercion args) - , [Tickish Var]) + , [Tickish]) -- See Note [Eta reduction with casted arguments] ok_arg bndr (Type ty) co _ | Just tv <- getTyVar_maybe ty |