RE: ghc feature request: core notes

2003-02-12 Thread Simon Peyton-Jones
Hal, 

OK.  If you want to change CoreSyn.Note to have an extra constructor,
thus:

data Note = 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. 

[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:[EMAIL PROTECTED]]
| 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
| 
| 
| Hal Daume III [EMAIL PROTECTED] 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. [...]
| 
| Simon Peyton-Jones [EMAIL PROTECTED] 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? [...]
| 
| 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 :-)
| 
| 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.)
| 
| 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:
| 
| #ifdef TRACK_NOTES
| #define NOTE(x,y) (_scc_ NOTE  x  (y))
| #else
| #define NOTE(x,y) {- nothing -}
| #endif
| 
| --
| Alastair Reid
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: ghc feature request: core notes

2003-02-12 Thread Simon Marlow

 [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.]

Not in source code, surely?  It certainly doesn't look like 'inline' is
a keyword.  In external Core, you can write '%note InlineCall' to get
this effect though.

Cheers,
Simon

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: ghc feature request: core notes

2003-02-12 Thread Simon Peyton-Jones
Yes in source code (albeit I have not tested this recently).  'inline'
is [was] a magic Id whose unfolding is the relevant core goop.  Like I
say, the last time I visted this was years ago!

S

| -Original Message-
| From: Simon Marlow [mailto:[EMAIL PROTECTED]]
| Sent: 12 February 2003 16:56
| To: Simon Peyton-Jones; Alastair Reid
| Cc: Hal Daume III; GHC Users Mailing List
| Subject: RE: ghc feature request: core notes
| 
| 
|  [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.]
| 
| Not in source code, surely?  It certainly doesn't look like 'inline'
is
| a keyword.  In external Core, you can write '%note InlineCall' to get
| this effect though.
| 
| Cheers,
|   Simon
| 
| ___
| Glasgow-haskell-users mailing list
| [EMAIL PROTECTED]
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Re: ghc feature request: core notes

2003-02-06 Thread Alastair Reid

Hal Daume III [EMAIL PROTECTED] 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. [...]

Simon Peyton-Jones [EMAIL PROTECTED] 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? [...]

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 :-)

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.)

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:

#ifdef TRACK_NOTES
#define NOTE(x,y) (_scc_ NOTE  x  (y))
#else
#define NOTE(x,y) {- nothing -}
#endif

--
Alastair Reid
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: ghc feature request: core notes

2003-02-04 Thread Simon Peyton-Jones
I have to say that I'm not very keen.  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?

So just now I'm a bit sceptical.  Core is a data type that I'm trying
hard to keep simple.  

Simon

| -Original Message-
| From: Hal Daume III [mailto:[EMAIL PROTECTED]]
| Sent: 03 February 2003 23:24
| To: GHC Users Mailing List
| Subject: ghc feature request: core notes
| 
| 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.  For instance, in my Haskell program I would have something
| like:
| 
|   f x y =
| case {-# CORE my first note #-} g x of
|   ...
| 
| then, the core would come out with, instead of:
| 
|   case g x of ...
| 
| we would have
| 
|   case {note my first note} g x of ...
| 
| The reason I would find this useful is somewhat obscure, but the basic
| idea is that I need to be able to both preprocess code and then change
| core based on how it was preprocessed.  I'd like to send annotations
like
| these out of the preprocessor so they can then be picked up later by
my
| core transformer.
| 
| If this sounds like a good enough idea to go in, but no one has time
to
| implement it, I could do it myself (probably), but I thought I'd ask
the
| experts first (or if there's anything like this in there currently)...
| 
|  - Hal
| 
| --
| Hal Daume III
| 
|  Computer science is no more about computers| [EMAIL PROTECTED]
|   than astronomy is about telescopes. -Dijkstra | www.isi.edu/~hdaume
| 
| ___
| Glasgow-haskell-users mailing list
| [EMAIL PROTECTED]
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: ghc feature request: core notes

2003-02-04 Thread Hal Daume III
Simon,

I wasn't suggesting extending the Core datatype.  Part of the Core Exp
datatype is these notes.  From ExternalCore.hs:

 data Exp 
   ...
   | Note String Exp
   ...

My suggestion is simply to allow pragmas to fill in these Note
values.  I've actually implemented it in my copy of GHC and it's a very
very small addition.  It requires essentially modifying slightly the
parser and lexer to accept '{-# CORE' as a pragma and then to pass this
value down through all the passes (typechecking, renaming, etc.).  I think
it's about 20 additional lines of code in all.

It doesn't seem that these get thrown away anywhere in the AbsSyn - Core
piping process.  I'm not sure the extend to which this de-simplifies
Core.  Currently these Notes are only used to store SCC information for
profiling and INLINE information.

 - Hal

--
Hal Daume III

 Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes. -Dijkstra | www.isi.edu/~hdaume

On Tue, 4 Feb 2003, Simon Peyton-Jones wrote:

 I have to say that I'm not very keen.  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?
 
 So just now I'm a bit sceptical.  Core is a data type that I'm trying
 hard to keep simple.  
 
 Simon
 
 | -Original Message-
 | From: Hal Daume III [mailto:[EMAIL PROTECTED]]
 | Sent: 03 February 2003 23:24
 | To: GHC Users Mailing List
 | Subject: ghc feature request: core notes
 | 
 | 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.  For instance, in my Haskell program I would have something
 | like:
 | 
 |   f x y =
 | case {-# CORE my first note #-} g x of
 |   ...
 | 
 | then, the core would come out with, instead of:
 | 
 |   case g x of ...
 | 
 | we would have
 | 
 |   case {note my first note} g x of ...
 | 
 | The reason I would find this useful is somewhat obscure, but the basic
 | idea is that I need to be able to both preprocess code and then change
 | core based on how it was preprocessed.  I'd like to send annotations
 like
 | these out of the preprocessor so they can then be picked up later by
 my
 | core transformer.
 | 
 | If this sounds like a good enough idea to go in, but no one has time
 to
 | implement it, I could do it myself (probably), but I thought I'd ask
 the
 | experts first (or if there's anything like this in there currently)...
 | 
 |  - Hal
 | 
 | --
 | Hal Daume III
 | 
 |  Computer science is no more about computers| [EMAIL PROTECTED]
 |   than astronomy is about telescopes. -Dijkstra | www.isi.edu/~hdaume
 | 
 | ___
 | Glasgow-haskell-users mailing list
 | [EMAIL PROTECTED]
 | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
 

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



ghc feature request: core notes

2003-02-03 Thread Hal Daume III
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.  For instance, in my Haskell program I would have something
like:

  f x y = 
case {-# CORE my first note #-} g x of
  ...

then, the core would come out with, instead of:

  case g x of ...

we would have

  case {note my first note} g x of ...

The reason I would find this useful is somewhat obscure, but the basic
idea is that I need to be able to both preprocess code and then change
core based on how it was preprocessed.  I'd like to send annotations like
these out of the preprocessor so they can then be picked up later by my
core transformer.

If this sounds like a good enough idea to go in, but no one has time to
implement it, I could do it myself (probably), but I thought I'd ask the
experts first (or if there's anything like this in there currently)...

 - Hal  

--
Hal Daume III

 Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes. -Dijkstra | www.isi.edu/~hdaume

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users