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 /MLRISC/trunk/block-placement/jump-chain-elim-fn.sml
ViewVC logotype

Diff of /MLRISC/trunk/block-placement/jump-chain-elim-fn.sml

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

revision 1138, Wed Mar 13 03:03:50 2002 UTC revision 1139, Wed Mar 13 18:40:51 2002 UTC
# Line 15  Line 15 
15      structure InsnProps : INSN_PROPERTIES      structure InsnProps : INSN_PROPERTIES
16        where I = CFG.I        where I = CFG.I
17    
18      (* Control flag that when set true allows jumps to labels outside
19       * of the CFG to be chained.  Set this false when there are many
20       * short jumps to a long jump that exits the CFG.
21       *)
22        val chainEscapes : bool ref
23    
24      (* Control flag that when set true allows the direction (forward or
25       * backward) of conditional jumps to be changed.  Set this false
26       * when the direction of conditional branches is used to predict
27       * the branch.
28       *)
29        val reverseDirection : bool ref
30    
31    ) : sig    ) : sig
32    
33      structure CFG : CONTROL_FLOW_GRAPH      structure CFG : CONTROL_FLOW_GRAPH
# Line 41  Line 54 
54      fun run (cfg, blocks) = let      fun run (cfg, blocks) = let
55            val G.GRAPH{            val G.GRAPH{
56                    node_info, out_edges, set_out_edges, in_edges,                    node_info, out_edges, set_out_edges, in_edges,
57                    entries, forall_nodes, remove_node, ...                    entries, exits, forall_nodes, remove_node, ...
58                  } = cfg                  } = cfg
59              val chainEscapes = !chainEscapes
60              val reverseDirection = !reverseDirection
61            (* this flag is set to note that we need to filter out unreachable
62             * blocks after jump chaining.
63             *)
64            val needFilter = ref false            val needFilter = ref false
65            (* the exit block *)
66              val [exit] = exits()
67          (* map a block ID to a label *)          (* map a block ID to a label *)
68            fun labelOf blkId = (case node_info blkId            fun labelOf blkId = (case node_info blkId
69                   of CFG.BLOCK{labels=ref(lab::_), ...} => lab                   of CFG.BLOCK{labels=ref(lab::_), ...} => lab
# Line 67  Line 87 
87                   of CFG.BLOCK{insns as ref[i], kind=CFG.NORMAL, ...} => (                   of CFG.BLOCK{insns as ref[i], kind=CFG.NORMAL, ...} => (
88                      (* a normal block with one instruction *)                      (* a normal block with one instruction *)
89                        case out_edges blkId                        case out_edges blkId
90                         of [e as (_, dst, CFG.EDGE{k=CFG.JUMP, w, a})] => (                         of [e as (_, dst, CFG.EDGE{k=CFG.JUMP, w, a})] =>
91                                if ((dst <> exit) orelse chainEscapes)
92                                  then (
93                            (* the instruction must be a jump so transitively follow it                            (* the instruction must be a jump so transitively follow it
94                             * to get the target; but be careful to avoid infinite loops.                             * to get the target; but be careful to avoid infinite loops.
95                             *)                             *)
# Line 82  Line 104 
104                                      [(blkId, dst', CFG.EDGE{k=CFG.JUMP, w=w, a=a})]);                                      [(blkId, dst', CFG.EDGE{k=CFG.JUMP, w=w, a=a})]);
105                                    someLab)                                    someLab)
106                              (* end case *))                              (* end case *))
107                                  else NONE
108                          | _ => NONE                          | _ => NONE
109                        (* end case *))                        (* end case *))
110                    | _ => NONE                    | _ => NONE

Legend:
Removed from v.1138  
changed lines
  Added in v.1139

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