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

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