Commit f54faab0 authored by keithw's avatar keithw
Browse files

[project @ 1999-05-11 16:42:54 by keithw]

(this is number 6 of 9 commits to be applied together)

  It is useful to know the usage of a lambda outside the usage
  inference (specifically, in the simplifier); thus as a temporary
  hack to make this information available without undue modification
  to the rest of the compiler, the information is copied into the
  IdInfo field of the binder.

  The new information is LBVarInfo, which can be either NoLBVarInfo or
  IsOneShotLambda, corresponding to __m/no info and __o respectively.
  LBVarInfo is not intended to be printed in interface files; to
  enforce this ppLBVarInfo is defined to print nothing.
parent 1e23fb08
......@@ -49,7 +49,10 @@ module IdInfo (
CafInfo(..), cafInfo, setCafInfo, ppCafInfo,
-- Constructed Product Result Info
CprInfo(..), cprInfo, setCprInfo, ppCprInfo, noCprInfo
CprInfo(..), cprInfo, setCprInfo, ppCprInfo, noCprInfo,
-- Lambda-bound variable info
LBVarInfo(..), lbvarInfo, setLBVarInfo, noLBVarInfo,
) where
#include "HsVersions.h"
......@@ -61,6 +64,7 @@ import {-# SOURCE #-} CoreSyn ( CoreExpr )
import Var ( Id )
import SpecEnv ( SpecEnv, emptySpecEnv )
import Demand ( Demand, isLazy, wwLazy, pprDemands )
import Type ( UsageAnn )
import Outputable
import Maybe ( isJust )
......@@ -77,7 +81,8 @@ the properties attached to the other.
The @IdInfo@ gives information about the value, or definition, of the
@Id@. It does {\em not} contain information about the @Id@'s usage
(except for @DemandInfo@? ToDo).
(except for @DemandInfo@? ToDo). (@lbvarInfo@ is also a marginal
case. KSW 1999-04).
data IdInfo
......@@ -91,6 +96,7 @@ data IdInfo
updateInfo :: UpdateInfo, -- Which args should be updated
cafInfo :: CafInfo,
cprInfo :: CprInfo, -- Function always constructs a product result
lbvarInfo :: LBVarInfo, -- Info about a lambda-bound variable
inlinePragInfo :: !InlinePragInfo -- Inline pragmas
......@@ -108,6 +114,7 @@ setInlinePragInfo pr info = info { inlinePragInfo = pr }
setUnfoldingInfo uf info = info { unfoldingInfo = uf }
setCafInfo cf info = info { cafInfo = cf }
setCprInfo cp info = info { cprInfo = cp }
setLBVarInfo lb info = info { lbvarInfo = lb }
......@@ -122,6 +129,7 @@ noIdInfo = IdInfo {
updateInfo = NoUpdateInfo,
cafInfo = MayHaveCafRefs,
cprInfo = NoCPRInfo,
lbvarInfo = NoLBVarInfo,
inlinePragInfo = NoInlinePragInfo
......@@ -488,4 +496,43 @@ instance Show CprInfo where
%* *
\subsection[lbvar-IdInfo]{Lambda-bound var info about an @Id@}
%* *
If the @Id@ is a lambda-bound variable then it may have lambda-bound
var info. The usage analysis (UsageSP) detects whether the lambda
binding this var is a ``one-shot'' lambda; that is, whether it is
applied at most once.
This information may be useful in optimisation, as computations may
safely be floated inside such a lambda without risk of duplicating
data LBVarInfo
= NoLBVarInfo
| IsOneShotLambda -- the lambda that binds this Id is applied
-- at most once
-- HACK ALERT! placing this info here is a short-term hack,
-- but it minimises changes to the rest of the compiler.
-- Hack agreed by SLPJ/KSW 1999-04.
noLBVarInfo = NoLBVarInfo
-- not safe to print or parse LBVarInfo because it is not really a
-- property of the definition, but a property of the context.
ppLBVarInfo _ = empty
instance Outputable LBVarInfo where
ppr = ppLBVarInfo
instance Show LBVarInfo where
showsPrec p c = showsPrecSDoc p (ppr c)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment