
Hi Max,
2010/1/27 Max Bolingbroke
2010/1/27 José Pedro Magalhães
: Alright, ticket created: http://hackage.haskell.org/trac/ghc/ticket/3843
In any case, for now I am willing to hard-code a new core-to-core pass on the compiler. Any pointers for where I have to look at?
I recommend you look at compiler/simplCore/CSE.lhs. It is a simple example of a core-to-core pass.
However, in short you'll need to: 1) Create a function which implements your core to core pass, of a type such as [CoreBind] -> [CoreBind] *) If that function lives in a new module, edit ghc.cabal.in to tell the build system about the module 2) Add a constructor to the CoreToDo data type in compiler/simplCore/CoreMonad.lhs 3) Add a case for it to the coreDumpFlag and Outputable instance 4) Add that pass to the list returned by getCoreToDo in CoreMonad. The order of the list is the order the passes will be run in. *) If you want the pass to be under the control of a new flag, you'll need to add a new dynflag - add a constructor to the DOpt data type in compiler/main/DynFlags.lhs, and add something to build that constructor to one of the lists that get fed to the command line handling code in the same module. It should be fairly obvious how to do this. 5) Add a handler for the new constructor to compiler/simplCore/SimplCore.lhs, in the doCorePass function which calls into the core pass function you wrote
Hope that helps, Max
Yes, that helped quite a lot. One last thing: currently it takes me about 6 minutes to rebuild the compiler after I change the core pass. Are there any tricks of the build system I can use to speed this up? I'm already using a fast build without optimizations and docs... Thanks, Pedro

2010/1/28 José Pedro Magalhães
Yes, that helped quite a lot. One last thing: currently it takes me about 6 minutes to rebuild the compiler after I change the core pass. Are there any tricks of the build system I can use to speed this up? I'm already using a fast build without optimizations and docs...
Hmm. Some things that help with this for me are to: 1) Compile with -j12 (or lower, depending on your hardware spec) 2) Compile with "cd compiler && make stage=2" to only build the stage 2 compiler (if this isn't already happening). Make sure the stage 1 compiler is built with optimisations! (I use the stage2devel configuration, which already does this) This reduces compile times to a few minutes for me. Still tedious, but not too bad. Hope that helps, Max

Hi,
2010/1/28 Max Bolingbroke
2010/1/28 José Pedro Magalhães
: Yes, that helped quite a lot. One last thing: currently it takes me about 6 minutes to rebuild the compiler after I change the core pass. Are there any tricks of the build system I can use to speed this up? I'm already using a fast build without optimizations and docs...
Hmm. Some things that help with this for me are to: 1) Compile with -j12 (or lower, depending on your hardware spec) 2) Compile with "cd compiler && make stage=2" to only build the stage 2 compiler (if this isn't already happening). Make sure the stage 1 compiler is built with optimisations! (I use the stage2devel configuration, which already does this)
This reduces compile times to a few minutes for me. Still tedious, but not too bad.
Thanks. Doing this reduces compilation time to about 30s, but unfortunately my pass is not updated (even though it is compiled). I have to do 'make stage=2' at the root directory, not inside compiler. This brings compilation time to 1m10s (which is still better than what I was doing), but I really don't know what would need building outside the compiler directory... As an aside, is there any hope of using SYB in the core pass? As a generic programmer I quickly get tired of traversing the entire AST when I want just a few changes in specific places... Thanks, Pedro
Hope that helps, Max

On 29/01/10 09:32, José Pedro Magalhães wrote:
Hi,
2010/1/28 Max Bolingbroke
mailto:batterseapower@hotmail.com> 2010/1/28 José Pedro Magalhães
mailto:jpm@cs.uu.nl>: > Yes, that helped quite a lot. One last thing: currently it takes me about 6 > minutes to rebuild the compiler after I change the core pass. Are there any > tricks of the build system I can use to speed this up? I'm already using a > fast build without optimizations and docs... Hmm. Some things that help with this for me are to: 1) Compile with -j12 (or lower, depending on your hardware spec) 2) Compile with "cd compiler && make stage=2" to only build the stage 2 compiler (if this isn't already happening). Make sure the stage 1 compiler is built with optimisations! (I use the stage2devel configuration, which already does this)
This reduces compile times to a few minutes for me. Still tedious, but not too bad.
Thanks. Doing this reduces compilation time to about 30s, but unfortunately my pass is not updated (even though it is compiled). I have to do 'make stage=2' at the root directory, not inside compiler. This brings compilation time to 1m10s (which is still better than what I was doing), but I really don't know what would need building outside the compiler directory...
The correct way to update your stage 2 compiler without rebuilding extraneous dependencies is: $ cd ghc $ make 2 for more info, see http://hackage.haskell.org/trac/ghc/wiki/Building/Using#RebuildingtheGHCbina...
As an aside, is there any hope of using SYB in the core pass? As a generic programmer I quickly get tired of traversing the entire AST when I want just a few changes in specific places...
That's a discussion we ought to have at some point. Note however that Core is actually a very deep data type (Ids contain unfoldings, which contain more expressions, which contain Ids, which contain types, and so on), and is also cyclic. Simply traversing the whole thing would be a very bad idea. There is a ghc-syb package which has SYB instances for HsSyn I think. HsSyn is not as deep or cyclic as Core. Cheers, Simon
participants (3)
-
José Pedro Magalhães
-
Max Bolingbroke
-
Simon Marlow