Retrieving closure code during code generation
marlowsd at gmail.com
Tue Mar 3 08:27:06 EST 2009
William Jones wrote:
> I am currently working with GHC's code generator and am wondering if
> there is any way I can retrieve the Cmm for a function during the
> compilation of another? I have looked at the information passed using
> CgMonad and at the bindings in scope but these don't seem to be what I
> need. As an example, when generating code for the tail call "map f xs,"
> can I retrieve the Cmm expressions that make up "f"?
> Apologies if I am missing something glaringly obvious, thanks,
Not easily - if f is defined in the same module you'll have to save the Cmm
for it in the monad so that you can extract it later. But the Cmm for a
single function might consist of lots of separate code blocks.
Perhaps it's better to explain what you're trying to do - there might be a
better way to achieve it. Also note that the code generator is in
mid-rewrite; the new version of it starts with codeGen/StgCmm.hs.
More information about the Cvs-ghc