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 /MLRISC/trunk/ra/ra-spill.sig
ViewVC logotype

Annotation of /MLRISC/trunk/ra/ra-spill.sig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1033 - (view) (download) (as text)
Original Path: sml/trunk/src/MLRISC/ra/ra-spill.sig

1 : monnier 467 (*
2 :     * This module manages the spill/reload process.
3 :     *
4 :     * -- Allen
5 :     *)
6 :     signature RA_SPILL =
7 :     sig
8 :    
9 :     structure I : INSTRUCTIONS
10 : monnier 498 structure G : RA_GRAPH = RAGraph
11 : leunga 744 structure C : CELLS
12 : monnier 467 sharing I.C = C
13 :    
14 : george 889 structure CB : CELLS_BASIS = CellsBasis
15 : monnier 467 type copyInstr =
16 : george 889 (CB.cell list * CB.cell list) * I.instruction -> I.instruction list
17 : monnier 467
18 : monnier 498 (*
19 :     * Spill the value associated with reg into spillLoc.
20 :     * All definitions of instr should be renamed to a new temporary newReg.
21 :     *)
22 : monnier 467 type spill =
23 :     {instr : I.instruction, (* instruction where spill is to occur *)
24 : george 889 reg : CB.cell, (* register to spill *)
25 : leunga 744 spillLoc : G.spillLoc, (* logical spill location *)
26 : monnier 467 kill : bool, (* can we kill the current node? *)
27 : monnier 498 annotations : Annotations.annotations ref (* annotations *)
28 : monnier 467 } ->
29 : monnier 498 {code : I.instruction list, (* instruction + spill code *)
30 : george 889 proh : CB.cell list, (* prohibited from future spilling *)
31 :     newReg : CB.cell option (* the spilled value is available here *)
32 : monnier 467 }
33 :    
34 : monnier 498 (* Spill the register src into spillLoc.
35 :     * The value is originally from register reg.
36 :     *)
37 :     type spillSrc =
38 : george 889 {src : CB.cell, (* register to spill from *)
39 :     reg : CB.cell, (* the register *)
40 : leunga 744 spillLoc : G.spillLoc, (* logical spill location *)
41 : monnier 498 annotations : Annotations.annotations ref (* annotations *)
42 :     } -> I.instruction list (* spill code *)
43 :    
44 :     (*
45 :     * Spill the temporary associated with a copy into spillLoc
46 :     *)
47 :     type spillCopyTmp =
48 :     {copy : I.instruction, (* copy to spill *)
49 : george 889 reg : CB.cell, (* the register *)
50 : leunga 744 spillLoc : G.spillLoc, (* logical spill location *)
51 : monnier 498 annotations : Annotations.annotations ref (* annotations *)
52 :     } -> I.instruction (* spill code *)
53 :    
54 :     (*
55 :     * Reload the value associated with reg from spillLoc.
56 :     * All uses of instr should be renamed to a new temporary newReg.
57 :     *)
58 : monnier 467 type reload =
59 :     {instr : I.instruction, (* instruction where spill is to occur *)
60 : george 889 reg : CB.cell, (* register to spill *)
61 : leunga 744 spillLoc : G.spillLoc, (* logical spill location *)
62 : monnier 498 annotations : Annotations.annotations ref (* annotations *)
63 : monnier 467 } ->
64 : monnier 498 {code : I.instruction list, (* instr + reload code *)
65 : george 889 proh : CB.cell list, (* prohibited from future spilling *)
66 :     newReg : CB.cell option (* the reloaded value is here *)
67 : monnier 467 }
68 :    
69 :     (*
70 : monnier 498 * Rename all uses fromSrc to toSrc
71 :     *)
72 :     type renameSrc =
73 : george 1033 {instr : I.instruction, (* instruction where spill is to occur *)
74 : george 889 fromSrc : CB.cell, (* register to rename *)
75 :     toSrc : CB.cell (* register to rename to *)
76 : monnier 498 } ->
77 : george 1033 {code : I.instruction list, (* renamed instr *)
78 : george 889 proh : CB.cell list, (* prohibited from future spilling *)
79 :     newReg : CB.cell option (* the renamed value is here *)
80 : monnier 498 }
81 :    
82 :     (* Reload the register dst from spillLoc.
83 :     * The value is originally from register reg.
84 :     *)
85 :     type reloadDst =
86 : george 889 {dst : CB.cell, (* register to reload to *)
87 :     reg : CB.cell, (* the register *)
88 : george 1033 spillLoc : G.spillLoc, (* logical spill location *)
89 : monnier 498 annotations : Annotations.annotations ref (* annotations *)
90 : george 1033 } -> I.instruction list (* reload code *)
91 : monnier 498
92 :     (*
93 : monnier 467 * The following function rewrites an instruction and insert
94 :     * spill and reload code around it. The list of spill and reload
95 :     * registers may have duplicates.
96 :     *)
97 :     val spillRewrite :
98 : monnier 498 { graph : G.interferenceGraph,
99 :     spill : spill,
100 :     spillSrc : spillSrc,
101 :     spillCopyTmp : spillCopyTmp,
102 :     reload : reload,
103 :     reloadDst : reloadDst,
104 :     renameSrc : renameSrc,
105 :     copyInstr : copyInstr,
106 : george 889 cellkind : CB.cellkind,
107 :     spillSet : CB.cell list G.PPtHashTable.hash_table,
108 :     reloadSet : CB.cell list G.PPtHashTable.hash_table,
109 :     killSet : CB.cell list G.PPtHashTable.hash_table
110 : monnier 467 } ->
111 : leunga 744 { pt : G.programPoint, (* starting program pt *)
112 : monnier 498 annotations : Annotations.annotations ref, (* annotations *)
113 :     instrs : I.instruction list (* instructions to spill *)
114 : monnier 467 } ->
115 : monnier 498 I.instruction list (* instruction sequence after rewriting *)
116 :     (* Note, instructions are in reverse order *)
117 : monnier 467
118 :     end

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