Debian Codegraph @

lib/mlrisc-lib/MLRISC/ra/ra-core.sig

raw
1 (* ra-core.sig
2 *
3 * COPYRIGHT (c) 2002 Bell Labs, Lucent Technologies.
4 *
5 * Note: This is the core of the new register allocator, i.e. the portion
6 * that manipulates only the interference graph and not the flowgraph.
7 *
8 * -- Allen
9 *)
10
11 signature RA_CORE =
12 sig
13
14 structure G : RA_GRAPH (* = RAGraph *)
15 where type C.CellSet.cellset = RAGraph.C.CellSet.cellset
16 and type 'a C.ColorTable.hash_table = 'a RAGraph.C.ColorTable.hash_table
17 and type 'a C.HashTable.hash_table = 'a RAGraph.C.HashTable.hash_table
18 and type C.SortedCells.sorted_cells = RAGraph.C.SortedCells.sorted_cells
19 and type C.cell = RAGraph.C.cell
20 and type C.cellColor = RAGraph.C.cellColor
21 and type C.cellkind = RAGraph.C.cellkind
22 and type C.cellkindDesc = RAGraph.C.cellkindDesc
23 and type C.cellkindInfo = RAGraph.C.cellkindInfo
24 and type 'a PPtHashTable.hash_table = 'a RAGraph.PPtHashTable.hash_table
25 and type 'a SpillLocHashTable.hash_table = 'a RAGraph.SpillLocHashTable.hash_table
26 and type interferenceGraph = RAGraph.interferenceGraph
27 and type move = RAGraph.move
28 and type moveKind = RAGraph.moveKind
29 and type moveStatus = RAGraph.moveStatus
30 and type node = RAGraph.node
31 and type nodeStatus = RAGraph.nodeStatus
32 and type spillLoc = RAGraph.spillLoc
33 and type trailInfo = RAGraph.trailInfo
34 structure BM : RA_BITMATRIX
35 structure MV : RA_PRIORITY_QUEUE where type elem = G.move
36 structure FZ : RA_PRIORITY_QUEUE where type elem = G.node
37
38 type move_queue
39 type freeze_queue
40
41 val NO_OPTIMIZATION : G.mode
42 val BIASED_SELECTION : G.mode
43 val DEAD_COPY_ELIM : G.mode
44 val COMPUTE_SPAN : G.mode
45 val SAVE_COPY_TEMPS : G.mode
46 val HAS_PARALLEL_COPIES : G.mode
47
48 (*
49 * Basic functions
50 *)
51
52 (* dump the interference graph to a stream *)
53 val dumpGraph : G.interferenceGraph -> TextIO.outstream -> unit
54 val show : G.interferenceGraph -> G.node -> string
55
56 (* add an edge to the interference graph *)
57 val addEdge : G.interferenceGraph -> G.node * G.node -> unit
58
59 (*
60 * Function to create new nodes
61 *)
62 val newNodes : G.interferenceGraph ->
63 {cost:real,pt:G.programPoint,defs:G.C.cell list,uses:G.C.cell list} ->
64 G.node list (* defs *)
65
66 (*
67 * Update the colors of cell to reflect the current interference graph
68 *)
69 val updateCellColors : G.interferenceGraph -> unit
70 val updateCellAliases : G.interferenceGraph -> unit
71
72 val markDeadCopiesAsSpilled : G.interferenceGraph -> unit
73
74 (*
75 * Return the spill location id of the interference graph
76 *)
77 val spillLoc : G.interferenceGraph -> int -> int
78 val spillLocToString : G.interferenceGraph -> int -> string
79
80 (*
81 * Create an initial set of worklists from a new interference graph
82 * and a list of moves
83 *)
84 val initWorkLists : G.interferenceGraph ->
85 { moves : G.move list
86 } ->
87 { simplifyWkl : G.node list,
88 moveWkl : move_queue,
89 freezeWkl : freeze_queue,
90 spillWkl : G.node list (* high degreee nodes *)
91 }
92
93 (*
94 * Clear the interference graph but keep the nodes table intact
95 *)
96 val clearGraph : G.interferenceGraph -> unit
97
98 (*
99 * Remove all adjacency lists from the nodes table.
100 *)
101 val clearNodes : G.interferenceGraph -> unit
102
103 (*
104 * Simplify, Coalease and Freeze until the work list is done
105 *)
106 val iteratedCoalescing :
107 G.interferenceGraph ->
108 { simplifyWkl : G.node list,
109 moveWkl : move_queue,
110 freezeWkl : freeze_queue,
111 stack : G.node list
112 } ->
113 { stack : G.node list
114 }
115
116 (*
117 * potentially spill a node.
118 *)
119 val potentialSpillNode :
120 G.interferenceGraph ->
121 { node : G.node,
122 cost : real,
123 stack : G.node list
124 } ->
125 { moveWkl : move_queue,
126 freezeWkl : freeze_queue,
127 stack : G.node list
128 }
129
130 (*
131 * Color nodes on the stack, using Briggs' optimistic spilling.
132 * Return a list of actual spills
133 *)
134 val select :
135 G.interferenceGraph ->
136 { stack : G.node list
137 } ->
138 { spills : G.node list (* actual spills *)
139 }
140
141 (*
142 * Incorporate memory <-> register moves
143 *)
144 val initMemMoves : G.interferenceGraph -> unit
145
146 (*
147 * Compute spill savings due to memory <-> register moves
148 *)
149 val moveSavings : G.interferenceGraph -> (int -> real)
150
151 end