[MLton] mlton code generation

Neophytos Michael nmichael@yahoo.com
Tue, 15 Mar 2005 13:02:53 -0800 (PST)

Thanks Matthew.  I'll give your suggestions a try.


--- Matthew Fluet <fluet@cs.cornell.edu> wrote:
> > Is there an easy way to instruct mlton to somehow show the code that it is
> > generating for a user function.  
> If you mean finding the exact sequence of C/assembly generated due to a 
> particular
>    fun f (...) = ...
> in the source program, then you might try using the profiling 
> infrastructure.  When a program is compiled with profiling, the front-end 
> embeds pseudo-operations denoting the entry and exit of each function, 
> which are preserved by the various optimizations and transformations, and 
> should delineate the code correspoinding to a particular source function 
> in the generated code.
> Unfortunately, translating back from the MLtonProfileNNN labels to source 
> code locations is something handled automatically by the mlprof tool, but 
> could be a bit cumbersome to do by hand.  It probably wouldn't be too hard 
> to augment either to compiler or mlprof to do this.  Then you could find 
> all the MLtonProfileNNN labels associated with the function of interest 
> and look for those labels.
> You might also have luck with the -keep ssa2 -keep machine flags in 
> conjunction with a -profile flag.  The SSA2 intermediate language 
> displays Enter/Leave pseudo-operations with the name of source 
> function/locations while the Machine intermediate language uses 
> MLtonProfileNNN labels.  These two intermediate languages are only one 
> lowering apart, so you might be able to find a non-profile label in the 
> SSA2 IL near the beginning of the function you in which you are 
> interested, and hope to find the same label in the Machine IL, now near 
> the corresponding MLtonProfileNNN label.  Now you can look for that 
> MLtonProfileNNN label in the generated C or assembly.

Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!