diff options
author | simonpj <unknown> | 2003-02-20 18:33:55 +0000 |
---|---|---|
committer | simonpj <unknown> | 2003-02-20 18:33:55 +0000 |
commit | 56b5a8b862d4eaeeaa941dd53e3d1009bdeadc0d (patch) | |
tree | 6bad69fec74d502a12abb8dcb912593a8356d484 /ghc/compiler/hsSyn | |
parent | 8589a69045e96e56f2f4e8cced1bdfc486355623 (diff) | |
download | haskell-56b5a8b862d4eaeeaa941dd53e3d1009bdeadc0d.tar.gz |
[project @ 2003-02-20 18:33:50 by simonpj]
-------------------------------------
Add Core Notes and the {-# CORE #-} pragma
-------------------------------------
This is an idea of Hal Daume's. The key point is that Notes in Core
are augmented thus:
data Note
= SCC CostCentre
| ...
| CoreNote String -- NEW
These notes can be injected via a Haskell-source pragma:
f x = ({-# CORE "foo" #-} show) ({-# CORE "bar" #-} x)
This wraps a (Note (CoreNote "foo")) around the 'show' variable,
and a similar note around the argument to 'show'.
These notes are basically ignored by GHC, but are emitted into
External Core, where they may convey useful information.
Exactly how code involving these notes is munged by the simplifier
isn't very well defined. We'll see how it pans out. Meanwhile
the impact on the rest of the compiler is minimal.
Diffstat (limited to 'ghc/compiler/hsSyn')
-rw-r--r-- | ghc/compiler/hsSyn/HsCore.lhs | 4 | ||||
-rw-r--r-- | ghc/compiler/hsSyn/HsExpr.lhs | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/ghc/compiler/hsSyn/HsCore.lhs b/ghc/compiler/hsSyn/HsCore.lhs index e73c4a4f32..86f657b856 100644 --- a/ghc/compiler/hsSyn/HsCore.lhs +++ b/ghc/compiler/hsSyn/HsCore.lhs @@ -76,6 +76,7 @@ data UfNote name = UfSCC CostCentre | UfCoerce (HsType name) | UfInlineCall | UfInlineMe + | UfCoreNote String type UfAlt name = (UfConAlt name, [name], UfExpr name) @@ -124,6 +125,7 @@ toUfNote (SCC cc) = UfSCC cc toUfNote (Coerce t1 _) = UfCoerce (toHsType t1) toUfNote InlineCall = UfInlineCall toUfNote InlineMe = UfInlineMe +toUfNote (CoreNote s) = UfCoreNote s --------------------- toUfBind (NonRec b r) = UfNonRec (toUfBndr b) (toUfExpr r) @@ -252,6 +254,7 @@ instance Outputable name => Outputable (UfNote name) where ppr (UfCoerce ty) = ptext SLIT("__coerce") <+> pprParendHsType ty ppr UfInlineCall = ptext SLIT("__inline_call") ppr UfInlineMe = ptext SLIT("__inline_me") + ppr (UfCoreNote s)= ptext SLIT("__core_note") <+> pprHsString (mkFastString s) instance Outputable name => Outputable (UfConAlt name) where ppr UfDefault = text "__DEFAULT" @@ -353,6 +356,7 @@ eq_ufExpr env (UfNote n1 r1) (UfNote n2 r2) eq_ufNote (UfCoerce t1) (UfCoerce t2) = eq_hsType env t1 t2 eq_ufNote UfInlineCall UfInlineCall = True eq_ufNote UfInlineMe UfInlineMe = True + eq_ufNote (UfCoreNote s1) (UfCoreNote s2) = s1==s2 eq_ufNote _ _ = False eq_ufExpr env _ _ = False diff --git a/ghc/compiler/hsSyn/HsExpr.lhs b/ghc/compiler/hsSyn/HsExpr.lhs index 0cdd2b208d..70888b93ff 100644 --- a/ghc/compiler/hsSyn/HsExpr.lhs +++ b/ghc/compiler/hsSyn/HsExpr.lhs @@ -157,6 +157,9 @@ data HsExpr id | HsSCC FastString -- "set cost centre" (_scc_) annotation (HsExpr id) -- expr whose cost is to be measured + + | HsCoreAnn FastString -- hdaume: core annotation + (HsExpr id) -- MetaHaskell Extensions | HsBracket (HsBracket id) SrcLoc |