[commit: ghc] ghc-7.8: Introduce the Call data types (9622fca)
git at git.haskell.org
git at git.haskell.org
Mon Nov 3 13:41:46 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-7.8
Link : http://ghc.haskell.org/trac/ghc/changeset/9622fcaf4a2bbe650a588dec4ffff85105b2bdcb/ghc
>---------------------------------------------------------------
commit 9622fcaf4a2bbe650a588dec4ffff85105b2bdcb
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Mon Aug 25 12:24:55 2014 +0100
Introduce the Call data types
This is just a small refactoring that makes the code a bit clearer,
using a data type instead of a triple. We get better pretty-printing too.
(cherry picked from commit c0fe1d9e7a9f23d050319c77f3a38264f3aa22f8)
>---------------------------------------------------------------
9622fcaf4a2bbe650a588dec4ffff85105b2bdcb
compiler/specialise/SpecConstr.lhs | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/compiler/specialise/SpecConstr.lhs b/compiler/specialise/SpecConstr.lhs
index faedb94..609dcfd 100644
--- a/compiler/specialise/SpecConstr.lhs
+++ b/compiler/specialise/SpecConstr.lhs
@@ -33,6 +33,7 @@ import Rules
import Type hiding ( substTy )
import TyCon ( isRecursiveTyCon, tyConName )
import Id
+import PprCore ( pprParendExpr )
import MkCore ( mkImpossibleExpr )
import Var
import VarEnv
@@ -1017,15 +1018,27 @@ data ScUsage
} -- The domain is OutIds
type CallEnv = IdEnv [Call]
-type Call = (ValueEnv, [CoreArg])
+data Call = Call Id [CoreArg] ValueEnv
-- The arguments of the call, together with the
-- env giving the constructor bindings at the call site
+ -- We keep the function mainly for debug output
+
+instance Outputable Call where
+ ppr (Call fn args _) = ppr fn <+> fsep (map pprParendExpr args)
nullUsage :: ScUsage
nullUsage = SCU { scu_calls = emptyVarEnv, scu_occs = emptyVarEnv }
combineCalls :: CallEnv -> CallEnv -> CallEnv
combineCalls = plusVarEnv_C (++)
+ where
+-- plus cs ds | length res > 1
+-- = pprTrace "combineCalls" (vcat [ ptext (sLit "cs:") <+> ppr cs
+-- , ptext (sLit "ds:") <+> ppr ds])
+-- res
+-- | otherwise = res
+-- where
+-- res = cs ++ ds
combineUsage :: ScUsage -> ScUsage -> ScUsage
combineUsage u1 u2 = SCU { scu_calls = combineCalls (scu_calls u1) (scu_calls u2),
@@ -1283,7 +1296,7 @@ scApp env (other_fn, args)
mkVarUsage :: ScEnv -> Id -> [CoreExpr] -> ScUsage
mkVarUsage env fn args
= case lookupHowBound env fn of
- Just RecFun -> SCU { scu_calls = unitVarEnv fn [(sc_vals env, args)]
+ Just RecFun -> SCU { scu_calls = unitVarEnv fn [Call fn args (sc_vals env)]
, scu_occs = emptyVarEnv }
Just RecArg -> SCU { scu_calls = emptyVarEnv
, scu_occs = unitVarEnv fn arg_occ }
@@ -1709,7 +1722,7 @@ callToPats :: ScEnv -> [ArgOcc] -> Call -> UniqSM (Maybe (CallPat, ValueEnv))
-- Type variables come first, since they may scope
-- over the following term variables
-- The [CoreExpr] are the argument patterns for the rule
-callToPats env bndr_occs (con_env, args)
+callToPats env bndr_occs (Call _ args con_env)
| length args < length bndr_occs -- Check saturated
= return Nothing
| otherwise
More information about the ghc-commits
mailing list