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

SCM Repository

[smlnj] Diff of /sml/trunk/src/MLRISC/IR/mlrisc-cfg-util.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/IR/mlrisc-cfg-util.sml

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

revision 605, Fri Apr 7 14:06:42 2000 UTC revision 606, Sun Apr 9 23:10:59 2000 UTC
# Line 118  Line 118 
118         val _  = case !d2 of [] => () | _ => raise Can'tMerge         val _  = case !d2 of [] => () | _ => raise Can'tMerge
119         val CFG.BLOCK{data=d1,insns=i1,annotations=a1,...} =         val CFG.BLOCK{data=d1,insns=i1,annotations=a1,...} =
120                #node_info cfg i                #node_info cfg i
121            (* If both blocks have annotations then don't merge them *)            (* If both blocks have annotations then don't merge them.
122         val _ = case (!a1, !a2) of             * But instead, just try to removed the jump instruction instead.
123                   (_::_, _::_) => raise Can'tMerge             *)
124                 | _ => ()         val canMerge = case (!a1, !a2) of
125                     (_::_, _::_) => false
126                   | _ => true
127         val insns1 = case !i1 of         val insns1 = case !i1 of
128                        [] => []                        [] => []
129                      | insns as jmp::rest =>                      | insns as jmp::rest =>
130                          if InsnProps.instrKind jmp = InsnProps.IK_JUMP                          if InsnProps.instrKind jmp = InsnProps.IK_JUMP
131                          then rest else insns                          then rest else insns
132     in  i1 := !i2 @ insns1;     in  if canMerge then
133            (i1 := !i2 @ insns1;
134         a1 := !a1 @ !a2;         a1 := !a1 @ !a2;
135         #set_out_edges cfg (i,map (fn (_,j',e) => (i,j',e)) (#out_edges cfg j));           #set_out_edges cfg
136               (i,map (fn (_,j',e) => (i,j',e)) (#out_edges cfg j));
137         #remove_node cfg j;         #remove_node cfg j;
138         updateJumpLabel CFG i;           updateJumpLabel CFG i
139            )
140           else (* Just eliminate the jump instruction at the end *)
141             (i1 := insns1;
142              #set_out_edges cfg
143                (i,map (fn (i,j,CFG.EDGE{w,a,...}) =>
144                      (i,j,CFG.EDGE{k=CFG.FALLSTHRU,w=w,a=a}))
145                         (#out_edges cfg i))
146             );
147         true         true
148     end handle Can'tMerge => false     end handle Can'tMerge => false
149    
# Line 215  Line 227 
227      *      *
228      *=====================================================================*)      *=====================================================================*)
229     fun splitAllCriticalEdges (CFG as G.GRAPH cfg) =     fun splitAllCriticalEdges (CFG as G.GRAPH cfg) =
230         (#forall_edges cfg (fn e => if isCriticalEdge CFG e then     let val changed = ref false
231            (splitEdge CFG {edge=e,kind=CFG.NORMAL,jump=false}; ())     in  #forall_edges cfg
232             (fn e => if isCriticalEdge CFG e then
233               (splitEdge CFG {edge=e,kind=CFG.NORMAL,jump=false}; changed := true)
234                                    else ());                                    else ());
235          CFG.changed CFG         if !changed then CFG.changed CFG else ()
236         )     end
237    
238     (*=====================================================================     (*=====================================================================
239      *      *

Legend:
Removed from v.605  
changed lines
  Added in v.606

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