From 9dfbc2dadf268996963feeb8667eb2d0b0f30634 Mon Sep 17 00:00:00 2001 From: sof Date: Thu, 30 Apr 1998 18:47:13 +0000 Subject: [PATCH] [project @ 1998-04-30 18:47:08 by sof] Moved idSpecVars from Specialise to CoreUtils --- ghc/compiler/coreSyn/CoreUtils.lhs | 25 +++++++++++++++++++++++-- ghc/compiler/specialise/Specialise.lhs | 21 +-------------------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/ghc/compiler/coreSyn/CoreUtils.lhs b/ghc/compiler/coreSyn/CoreUtils.lhs index 838a61f..62d57cf 100644 --- a/ghc/compiler/coreSyn/CoreUtils.lhs +++ b/ghc/compiler/coreSyn/CoreUtils.lhs @@ -13,7 +13,8 @@ module CoreUtils ( maybeErrorApp, nonErrorRHSs, - squashableDictishCcExpr + squashableDictishCcExpr, + idSpecVars ) where #include "HsVersions.h" @@ -22,7 +23,7 @@ import CoreSyn import CostCentre ( isDictCC, CostCentre, noCostCentre ) import MkId ( mkSysLocal ) -import Id ( idType, isBottomingId, +import Id ( idType, isBottomingId, getIdSpecialisation, mkIdWithNewUniq, dataConRepType, addOneToIdEnv, growIdEnvList, lookupIdEnv, @@ -32,6 +33,7 @@ import Literal ( literalType, Literal(..) ) import Maybes ( catMaybes, maybeToBool ) import PprCore import PrimOp ( primOpType, PrimOp(..) ) +import SpecEnv ( specEnvValues ) import SrcLoc ( noSrcLoc ) import TyVar ( cloneTyVar, isEmptyTyVarEnv, addToTyVarEnv, TyVarEnv, @@ -411,3 +413,22 @@ squashableDictishCcExpr cc expr | notValArg a = squashable f squashable other = False \end{code} + + +Given an Id, idSpecVars returns all its specialisations. +We extract these from its SpecEnv. +This is used by the occurrence analyser and free-var finder; +we regard an Id's specialisations as free in the Id's definition. + +\begin{code} +idSpecVars :: Id -> [Id] +idSpecVars id + = map get_spec (specEnvValues (getIdSpecialisation id)) + where + -- get_spec is another cheapo function like dictRhsFVs + -- It knows what these specialisation temlates look like, + -- and just goes for the jugular + get_spec (App f _) = get_spec f + get_spec (Lam _ b) = get_spec b + get_spec (Var v) = v +\end{code} diff --git a/ghc/compiler/specialise/Specialise.lhs b/ghc/compiler/specialise/Specialise.lhs index 48ffd7f..a1c602d 100644 --- a/ghc/compiler/specialise/Specialise.lhs +++ b/ghc/compiler/specialise/Specialise.lhs @@ -4,10 +4,7 @@ \section[Specialise]{Stamping out overloading, and (optionally) polymorphism} \begin{code} -module Specialise ( - specProgram, - idSpecVars - ) where +module Specialise ( specProgram ) where #include "HsVersions.h" @@ -1105,22 +1102,6 @@ addIdSpecialisations id spec_stuff Succeeded spec_env' -> (spec_env', errs) Failed err -> (spec_env, err:errs) --- Given an Id, isSpecVars returns all its specialisations. --- We extract these from its SpecEnv. --- This is used by the occurrence analyser and free-var finder; --- we regard an Id's specialisations as free in the Id's definition. - -idSpecVars :: Id -> [Id] -idSpecVars id - = map get_spec (specEnvValues (getIdSpecialisation id)) - where - -- get_spec is another cheapo function like dictRhsFVs - -- It knows what these specialisation temlates look like, - -- and just goes for the jugular - get_spec (App f _) = get_spec f - get_spec (Lam _ b) = get_spec b - get_spec (Var v) = v - ---------------------------------------- type SpecM a = UniqSM a -- 1.7.10.4