Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/cfg-ir/ssa-fn.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/cfg-ir/ssa-fn.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3502, Thu Dec 17 23:13:35 2015 UTC revision 3505, Fri Dec 18 02:47:03 2015 UTC
# Line 101  Line 101 
101        | EXIT of {                       (* includes die and stabilize *)        | EXIT of {                       (* includes die and stabilize *)
102              pred : node ref,              pred : node ref,
103              kind : ExitKind.kind,       (* kind of exit node *)              kind : ExitKind.kind,       (* kind of exit node *)
             live : var list,            (* live variables *)  
104              succ : node option ref      (* optional fake control-flow edge for when the EXIT is *)              succ : node option ref      (* optional fake control-flow edge for when the EXIT is *)
105                                          (* not the CFG exit node *)                                          (* not the CFG exit node *)
106            }            }
# Line 163  Line 162 
162    
163    (***** Program representation *****)    (***** Program representation *****)
164    
165        type input = global_var Inputs.input
166    
167      datatype program = Program of {      datatype program = Program of {
168          props : Properties.t list,          props : Properties.t list,
169          consts : global_var list,       (* large constant variables *)          consts : global_var list,       (* large constant variables *)
170          inputs : global_var list,       (* global input variables *)          inputs : input list,            (* global input variables *)
         globals : global_var list,      (* other global variables *)  
171          constInit : cfg,                (* code that initializes constants and inputs *)          constInit : cfg,                (* code that initializes constants and inputs *)
172            globals : global_var list,      (* other global variables *)
173          globalInit : cfg,               (* CFG to initialize other globals (if any) *)          globalInit : cfg,               (* CFG to initialize other globals (if any) *)
174          strand : strand,                (* the strand definition *)          strand : strand,                (* the strand definition *)
175          create : create,                (* initial strand creation *)          create : create,                (* initial strand creation *)
# Line 366  Line 367 
367                  | GASSIGN{rhs, ...} => [rhs]                  | GASSIGN{rhs, ...} => [rhs]
368                  | NEW{args, ...} => args                  | NEW{args, ...} => args
369                  | SAVE{rhs, ...} => [rhs]                  | SAVE{rhs, ...} => [rhs]
                 | EXIT{live, ...} => live  
370                  | _ => []                  | _ => []
371                (* end case *))                (* end case *))
372          fun defs (ND{kind, ...}) = (case kind          fun defs (ND{kind, ...}) = (case kind
# Line 413  Line 413 
413          fun mkSAVE (lhs, rhs) = new (SAVE{          fun mkSAVE (lhs, rhs) = new (SAVE{
414                  pred = ref dummy, lhs = lhs, rhs = rhs, succ = ref dummy                  pred = ref dummy, lhs = lhs, rhs = rhs, succ = ref dummy
415                })                })
416          fun mkEXIT (kind, xs) = new (EXIT{kind = kind, live = xs, pred = ref dummy, succ = ref NONE})          fun mkEXIT kind = new (EXIT{kind = kind, pred = ref dummy, succ = ref NONE})
417          fun mkFRAGMENT xs = mkEXIT (ExitKind.FRAGMENT, xs)          fun mkRETURN () = mkEXIT ExitKind.RETURN
418          fun mkRETURN () = mkEXIT (ExitKind.RETURN, [])          fun mkACTIVE () = mkEXIT ExitKind.ACTIVE
419          fun mkACTIVE () = mkEXIT (ExitKind.ACTIVE, [])          fun mkSTABILIZE () = mkEXIT ExitKind.STABILIZE
420          fun mkSTABILIZE () = mkEXIT (ExitKind.STABILIZE, [])          fun mkDIE () = mkEXIT ExitKind.DIE
421          fun mkDIE () = mkEXIT (ExitKind.DIE, [])          fun mkUNREACHABLE () = mkEXIT ExitKind.UNREACHABLE
         fun mkUNREACHABLE () = mkEXIT (ExitKind.UNREACHABLE, [])  
422          fun isNULL (ND{kind=NULL, ...}) = true          fun isNULL (ND{kind=NULL, ...}) = true
423            | isNULL _ = false            | isNULL _ = false
424        (* is a node reachable from the CFG entry; UNREACHABLE exit nodes and JOINs with no real        (* is a node reachable from the CFG entry; UNREACHABLE exit nodes and JOINs with no real
# Line 613  Line 612 
612          fun entry (CFG{entry = nd, ...}) = nd          fun entry (CFG{entry = nd, ...}) = nd
613          fun exit (CFG{exit = nd, ...}) = nd          fun exit (CFG{exit = nd, ...}) = nd
614    
       (* return the list of variables that are live at exit from a CFG *)  
         fun liveAtExit cfg = (case Node.kind(exit cfg)  
                of EXIT{live, ...} => live  
                 | _ => raise Fail "bogus exit node"  
               (* end case *))  
   
615        (* DFS sorting of the graph rooted at the entry to a statement; the resulting list will        (* DFS sorting of the graph rooted at the entry to a statement; the resulting list will
616         * be in preorder with parents before children.         * be in preorder with parents before children.
617         *)         *)
# Line 810  Line 803 
803                      end                      end
804                  | _ => concat(cfg, mkBlock stms)                  | _ => concat(cfg, mkBlock stms)
805                (* end case *))                (* end case *))
   
       (* update the exit of a CFG by modifying the live variable list *)  
         fun updateExit (CFG{entry, exit as ND{kind, ...}}, f) = let  
               val newExit = (case kind  
                      of EXIT{pred, kind, live, succ=ref NONE} => let  
                           val newNd = Node.mkEXIT(kind, f live)  
                           in  
                             Node.replaceInEdge {src = !pred, oldDst = exit, dst = newNd};  
                             newNd  
                           end  
                       | _ => raise Fail "bogus exit node for updateExit"  
                     (* end case *))  
               in  
                 CFG{entry=entry, exit=newExit}  
               end  
806        end        end
807    
808      structure RHS =      structure RHS =

Legend:
Removed from v.3502  
changed lines
  Added in v.3505

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