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

SCM Repository

[smlnj] Annotation of /sml/trunk/src/MLRISC/SSA/mlrisc-ssa.sig
ViewVC logotype

Annotation of /sml/trunk/src/MLRISC/SSA/mlrisc-ssa.sig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 228 - (view) (download) (as text)

1 : monnier 221 (*
2 :     * SSA graph.
3 :     * The node id's in this graph are indexed by ssa variables.
4 :     * If a node has multiple definitions r1,...,rn, then each of the ri
5 :     * refers to the same ssa op.
6 :     *)
7 :     signature SSA =
8 :     sig
9 :    
10 :     structure I : INSTRUCTIONS
11 :     structure C : CELLS
12 :     structure CFG : CONTROL_FLOW_GRAPH
13 :     structure Dom : DOMINATOR_TREE
14 :     structure SP : SSA_PROPERTIES
15 :     sharing CFG.I = SP.I = I
16 :     sharing I.C = SP.C = C
17 :    
18 :     type value = int (* value id *)
19 :     type pos = int (* position within a block *)
20 :     type block = Graph.node_id (* block id *)
21 :     type exp = SSAExp.exp (* SSA expression *)
22 :     type const = SP.const
23 :     type dom = (CFG.block,CFG.edge_info,CFG.info) Dom.dominator_tree
24 :    
25 :     (*
26 :     * An SSA op can be either a phi node, a normal instruction,
27 :     * a source node or a sink node.
28 :     * For source/sink instructions, also keep around the original register
29 :     * names.
30 :     *)
31 :     datatype ssa_op =
32 :     PHI of {preds:block list,t':C.register,t:value,s:value list,b:block}
33 :     | OP of {e:exp,i:I.instruction,s:value list,t:value list,b:block,p:pos}
34 :     | SOURCE of {t:value list, t':C.register list, b:block}
35 :     | SINK of {s:value list, s':C.register list, b:block}
36 :    
37 :     type info
38 :     type ssa = (ssa_op,value,info) Graph.graph
39 :    
40 :     val newSSA : CFG.cfg * (CFG.cfg -> dom) -> ssa
41 :     (* create an empty SSA graph *)
42 :     val newVar : ssa -> C.cellclass -> value (* generate new variable *)
43 :     val newRenamedVar : int Array.array option ->
44 :     ssa -> value -> value (* generate renamed variable *)
45 :     val immed : ssa -> int -> value (* create a new immed value *)
46 :     val label : ssa -> Label.label -> value (* create a new label operand*)
47 :     val operand : ssa -> I.operand -> value (* create a new operand *)
48 :    
49 :     val dom : ssa -> dom (* extracts the dominator *)
50 :     val cfg : ssa -> CFG.cfg (* extracts the CFG *)
51 :     val maxVar : ssa -> int (* maximum number of ssa names *)
52 :     val operands : ssa -> int (* number of operands *)
53 :     val const : ssa -> value -> const (* lookup const values *)
54 :     val defSite : ssa -> value -> Graph.node_id (* lookup definition site *)
55 :     val cellClass : ssa -> value -> C.cellclass (* lookup cell class *)
56 :     val updateCellClass : ssa -> value * C.cellclass -> unit
57 :    
58 :     (* linearize the SSA *)
59 :     val nodes : ssa -> { source : ssa_op Graph.node list,
60 :     phis : ssa_op Graph.node list,
61 :     ops : ssa_op Graph.node list,
62 :     sink : ssa_op Graph.node list
63 :     } Array.array
64 :     (*
65 :     * Replace all use of one value with another. Return true iff
66 :     * this operation is successful.
67 :     * Note: The definition of "from" must dominate all uses of "to", as
68 :     * required by the SSA form.
69 :     *)
70 :     val replaceAllUses : ssa -> {from:value, to:value} -> bool
71 :    
72 :     (*
73 :     * Replace the value of 'from' by a copy of value of 'to'
74 :     *)
75 :     val replaceByCopy : ssa -> {from:value, to:value} -> bool
76 :    
77 :     (*
78 :     * Replace the definition of value by const. Return true iff
79 :     * this operation is successful.
80 :     *)
81 :     val foldConstant : ssa -> {value:value, const:value} -> bool
82 :    
83 :     (*
84 :     * Move an instruction from one block to another
85 :     *)
86 :     val move : ssa -> {i:ssa_op Graph.node, block:block} -> unit
87 :    
88 :     (*
89 :     * Set the target of a conditional branch as true or false.
90 :     * This removes the branch and eliminates all unreachable code.
91 :     *)
92 :     val setBranch : ssa -> {jmp:ssa_op Graph.node, cond:bool} -> unit
93 :    
94 :     (*
95 :     * Signal that an SSA has been changed
96 :     *)
97 :     val changed : ssa -> unit
98 :    
99 :     (*
100 :     * Graph viewing and pretty printing
101 :     *)
102 :     val show_op : ssa -> ssa_op -> string
103 :     val show_val : ssa -> value -> string
104 :     val viewAsSSA : ssa -> GraphLayout.layout
105 :     val viewAsCFG : ssa -> GraphLayout.layout
106 :    
107 :     end
108 :    
109 :     (*
110 : monnier 227 * $Log$
111 : monnier 221 *)

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