Home My Page Projects Code Snippets Project Openings 3D graphics for Standard ML
Summary Activity SCM

SCM Repository

[sml3d] View of /trunk/sml3d/src/particles/compiler/optimizer.sml
ViewVC logotype

View of /trunk/sml3d/src/particles/compiler/optimizer.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 874 - (download) (annotate)
Thu May 6 18:08:36 2010 UTC (9 years, 4 months ago) by pavelk
File size: 1264 byte(s)
Added a new property to blocks: reference count. This new property is used in an optimization where we remove unused blocks from the program, and inline blocks that only have one reference count to reduce the amount of branching that we need to do.
structure Optimize : sig
  val optimizeIR : PSysIR.program -> PSysIR.program
 end = struct

  val gProgramChanged = ref false
 
  fun printErr s = TextIO.output(TextIO.stdErr, s ^ "\n")

  structure IR = PSysIR

  val optimizations = [
  
    (* We want to run this optimization first since this is the only
     * optimization that will actually affect the control flow of the
     * program (from block to block). Hence, it will not only change any
     * of the other optimizations that happen within blocks, but also will
     * produce the same results regardless of when we run it. In order to
     * maximize the results of the rest of the optimizations, it's best to
     * do it first.
     *)
    BlockEliminator.optimize,
    
    RemoveUnused.optimize,
    
    ConstantFolder.optimize,
    
    Specialized.optimize,
    
    RemoveUnused.optimize,
    
    ConstantFolder.optimize,
    
    Specialized.optimize,

    RemoveUnused.optimize,
    
    RemoveUseless.optimize,
  
    RemoveUnused.optimize
  ] 

  
  fun optimizeIR(inPgm) = 
   let
    fun applyOptimizations(pgm, []) = pgm
      | applyOptimizations(pgm, opt :: opts) = applyOptimizations(opt pgm, opts)
   in
    applyOptimizations(inPgm, optimizations)
   end
 
 end (* structure *)

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0