Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /MLRISC/releases/release-110.64/ir-archive/cfg-restructure.sml
ViewVC logotype

View of /MLRISC/releases/release-110.64/ir-archive/cfg-restructure.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2656 - (download) (annotate)
Thu May 31 22:17:39 2007 UTC (12 years, 1 month ago) by blume
File size: 1724 byte(s)
Release 110.64
(*
 * This module inserts preheaders and other stuff.
 * This is probably no longer used.
 *
 * -- Allen
 *)

functor ControlFlowGraphRestructure
    (structure Loop : LOOP_STRUCTURE) : CONTROL_FLOW_GRAPH_RESTRUCTURE =
struct
   structure Loop = Loop
   structure G    = Graph

   fun restructure (G.GRAPH cfg,G.GRAPH loop) 
          { add_preheader, 
            add_landing_pad
          } =
   let val add_node = #add_node cfg
       fun preheader f =
           fn {header,backedges} =>
              let val in_edges = #in_edges cfg header
                  fun g([],entries) = entries
                    | g((e as (i,j,_))::es,entries) = 
                       if List.exists (fn (i',j',_) => i=i' andalso j=j') 
                            backedges then g(es,entries)
                                      else g(es,e::entries)
              in  f{header =(header,#node_info cfg header),
                    entries=g(in_edges,[])
                   }
              end

       fun landing_pads f = fn {exits} => app (fn e => f {exit=e}) exits

       fun nop _ = ()
       val insert_preheader    = case add_preheader of
                                   SOME f => preheader f
                                 | NONE   => nop
       val insert_landing_pads = case add_landing_pad of
                                   SOME f => landing_pads f
                                 | NONE   => nop
       fun process_loop(i,Loop.LOOP{header,backedges=[],exits,...}) = ()
         | process_loop(i,Loop.LOOP{header,backedges,exits,...}) =
          (insert_preheader{header=header,backedges=backedges};
           insert_landing_pads{exits=exits}
          )
   in 
       #forall_nodes loop process_loop
   end

end


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