Hoopl advice: How to extend the graph?

Dear devs, I haven’t worked with our Cmm representation before, so I have a beginner question: 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? It seems that one could use dataflowPassFwd for it, but * I could not find any use of it, and * I do not need to run an analysis along, I just want to rewrite the blocks, so I am not sure if this is the right thing. Any pointers? 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

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.
It seems that one could use dataflowPassFwd for it, but * I could not find any use of it, and * I do not need to run an analysis along, I just want to rewrite the blocks, so I am not sure if this is the right thing. You most likely don't want to use Hoopl's machinery for doing analyses and optimisation passes. From what I know Hoopl is very slow compared to hand-written graph traversals and transformations - Edward's CmmRewriteAssignments is a good example here [1].
Does that help? Janek [1] https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/Hoopl/Examples --- Politechnika Łódzka Lodz University of Technology Treść tej wiadomości zawiera informacje przeznaczone tylko dla adresata. Jeżeli nie jesteście Państwo jej adresatem, bądź otrzymaliście ją przez pomyłkę prosimy o powiadomienie o tym nadawcy oraz trwałe jej usunięcie. This email contains information intended solely for the use of the individual to whom it is addressed. If you are not the intended recipient or if you have received this message in error, please notify the sender and delete it from your system.

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

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). It generates new blocks from exisiting ones so I thought that qualifies. But if not then CmmProcPoints gives an example of generating new labels. (You probably noticed that already.)
Looking at CmmUtils, I guess I could just use ofBlockList entry . concatMap myPerBlockOperation . toBlockList Hard to say without actually seeing rest of the code. Use what works and once the patch is on Phab we can work on improving it :-)
Janek --- Politechnika Łódzka Lodz University of Technology Treść tej wiadomości zawiera informacje przeznaczone tylko dla adresata. Jeżeli nie jesteście Państwo jej adresatem, bądź otrzymaliście ją przez pomyłkę prosimy o powiadomienie o tym nadawcy oraz trwałe jej usunięcie. This email contains information intended solely for the use of the individual to whom it is addressed. If you are not the intended recipient or if you have received this message in error, please notify the sender and delete it from your system.

Hi, Am Freitag, den 06.03.2015, 07:46 +0100 schrieb Jan Stolarek:
Looking at CmmUtils, I guess I could just use ofBlockList entry . concatMap myPerBlockOperation . toBlockList Hard to say without actually seeing rest of the code. Use what works and once the patch is on Phab we can work on improving it :-)
will do – thanks! Greetings, 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
participants (2)
-
Jan Stolarek
-
Joachim Breitner