
Hi, Am Donnerstag, den 05.03.2015, 23:05 +0100 schrieb Jan Stolarek:
What function I should reach for when I want to look at each block (or each Last node) in an CmmGraph, possibly modifying it and possibly adding auxillary nodes on the way?
Take a look at Compiler.Hoopl.Block in hoopl library - it has some useful functions for working on blocks. blockSplitTail might be what you're looking for if you want to look at the last block. If you want to look at each block in a graph you most likely need postorderDfs from CmmUtils. I suggest studying one of existing Cmm passes to see how to traverse a Cmm graph and operate on it. CmmContFlowOpt seems to be a good candidate - good comments, fairly short, uses many functions that you should learn if you want to work with Cmm.
I had a look around, of course. CmmContFlowOpt is not quite a good example, as it does not generate new blocks (quite obvious from the fact that there is no UniqSM around to generate the new labels). Looking at CmmUtils, I guess I could just use ofBlockList entry . concatMap myPerBlockOperation . toBlockList I was expecting something a bit higher level, but maybe it’s that simple :-) Thanks! Joachim -- Joachim “nomeata” Breitner mail@joachim-breitner.de • http://www.joachim-breitner.de/ Jabber: nomeata@joachim-breitner.de • GPG-Key: 0xF0FBF51F Debian Developer: nomeata@debian.org