Graphical Visualization of Intermediate Code Graphs

Understanding the MLRISC intermediate code graphs just by poring over ascii dumps is an inefficient and unpleasant use of your time. A better approach is to use a visualization application which presents the intermediate code as an interactive graphical boxes-and-arrows display.

MLRISC supports two such tools, daVinci and vcg.

DaVinci 2.1 is available for download only as non-commercial-use binaries. (It appears to have been dead since about 1999.) The "daVinci V2.1 for Linux RedHat5" download was the one that worked for me.

VCG (Visualization of Compiler Graphs), by contrast, is fully open source software available in Debian Linux as a standard package. The Debian-less may download the source tarball directly from the VCG home page which also has various relevant papers and such.

The following instructions for using daVinci with SML/NJ are adapted from the Jan 16 1999 SML/NJ 110.13 release README:

    1. Loading the optimizer sources and set the hook using:

        CM.make'{force_relink=false, 
                 group="src/compiler/MLRISC-OPTIMIZER.cm"};

    2. At the top level execute:

       structure M = Compiler.Control.MLRISC;

      M.mlrisc :=true;(* enable optimizer *)
      M.Visual.viewer := "daVinci";(* set viewer *)
      M.view_IR := true;(* enable viewer *)
      M.mlrisc_phases :=(* set phases *)
        ["cluster->cfg", "view-dom", "cfg->cluster"];


    3. Compiling anything from here onwards, will go through the 
       optimizer. 
 
  Currently, the optimizer uses two different representations:
  the cluster and the IR.  The cluster is the old representation used
  in the register allocator and instruction selection.  The IR
  is the new representation.  Most new optimizations operate on
  the new IR.

  Several phases are possible in the mlrisc_phases list such as:

   a. view-cfg  -- view control flow graph
   b. view-dom  -- view dominator tree
   c. view-pdom -- view post dominator tree
   d. view-doms -- view dominator tree and post dominator tree
      together.
                   The post dominator is upside down.
   e. view-cdg  -- view control dependence graph
   f. view-loop -- show loop nesting tree
   g. guess     -- apply static branch prediction
                   (this need better machine descriptions)
   h. reshape   -- reorder the branch structure using frequencies 
                    gathered by static branch prediction

  All phases above transform IR into IR, so 
  they must be enclosed in phases "cluster->cfg", and "cfg->cluster",
  which translate clusters into IRs and vice versa.  In addition,
  there is a phase "copy-prop", which performs copy propagation on
  clusters.

Back to Cynbe's SML/NJ Internals Page


Cynbe ru Taren
Last modified: Mon Jan 31 17:25:41 CST 2005