ghc feature request: core notes
Simon Peyton-Jones
simonpj@microsoft.com
Wed, 12 Feb 2003 15:40:23 -0000
Hal,=20
OK. If you want to change CoreSyn.Note to have an extra constructor,
thus:
data Note =3D SCC CostCentre
| Coerce Type Type
| InlineMe
| InlineCall
| NoteString String -- NEW
and check that the rest of the compiler does something sensible with
NoteString, I do not object. There are only 12 lines of the compiler
than mention InlineCall, for example, so I expect NoteString would be
similarly low-impact.=20
[Incidentally, InlineCall is an undocumented feature. You can write
inline f x
to mean the same as (f x), except that this particular call to f will be
inlined.]
Simon
| -----Original Message-----
| From: Alastair Reid [mailto:alastair@reid-consulting-uk.ltd.uk]
| Sent: 06 February 2003 11:28
| To: Simon Peyton-Jones
| Cc: Hal Daume III; GHC Users Mailing List
| Subject: Re: ghc feature request: core notes
|=20
|=20
| "Hal Daume III" <hdaume@ISI.EDU> writes:
| > I'm not sure how "generally useful" this would be, but I would
| > find it useful to be able to attach notes to core expressions from
| > the Haskell code. The idea being something along the lines of a
| > code annotation like a pragma. [...]
|=20
| Simon Peyton-Jones <simonpj@microsoft.com> writes:
| > [...] There is an annotation facility in Core, but it's easy for the
notes
| > to be discarded. So if they are conveying important info, it might
| > easily get lost... and if not, what's it doing there in the first
| > place. What do you expect to happen to these annotations? [...]
|=20
| It seems like _scc_ is (almost) exactly what you need here. When used
| for profiling, you mark subexpressions you want profiled and ghc takes
| care to preserve and propagate them in a semantically meaningful way.
| Any _scc_ annotations that ghc chooses to drop can be reported as
| bugs :-)
|=20
| I say "almost" because what the semantics used when profiling may not
| be the right ones for your purposes. (I'm being vague because I don't
| know your purposes.)
|=20
| Naturally, you'd want to be able to use these notes independently of
| profiling - which can probably be done with a little preprocessor
| hackery. Assuming that the 1st argument to 'NOTE' is a literal string
| in the following:
|=20
| #ifdef TRACK_NOTES
| #define NOTE(x,y) (_scc_ "<NOTE " x ">" (y))
| #else
| #define NOTE(x,y) {- nothing -}
| #endif
|=20
| --
| Alastair Reid