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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 498 - (view) (download) (as text)
Original Path: sml/branches/SMLNJ/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 :     structure C : CELLS
11 : monnier 498 structure G : RA_GRAPH = RAGraph
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 :     spillLoc : int, (* logical spill location *)
25 :     kill : bool, (* can we kill the current node? *)
26 :     regmap : C.cell -> C.cell, (* current register map *)
27 : monnier 498 annotations : Annotations.annotations ref (* annotations *)
28 : monnier 467 } ->
29 : monnier 498 {code : I.instruction list, (* instruction + spill code *)
30 : monnier 467 proh : C.cell list, (* prohibited from future spilling *)
31 : monnier 498 newReg : C.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 :     {src : C.cell, (* register to spill from *)
39 :     reg : C.cell, (* the register *)
40 :     spillLoc : int, (* logical spill location *)
41 :     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 :     spillLoc : int, (* logical spill location *)
50 :     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 :     spillLoc : int, (* logical spill location *)
61 :     regmap : C.cell -> C.cell, (* current register map *)
62 : monnier 498 annotations : Annotations.annotations ref (* annotations *)
63 : monnier 467 } ->
64 : monnier 498 {code : I.instruction list, (* instr + reload code *)
65 :     proh : C.cell list, (* prohibited from future spilling *)
66 :     newReg : C.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 :     {instr : I.instruction, (* instruction where spill is to occur *)
74 :     fromSrc : C.cell, (* register to rename *)
75 :     toSrc : C.cell, (* register to rename to *)
76 :     regmap : C.cell -> C.cell (* current register map *)
77 :     } ->
78 :     {code : I.instruction list, (* renamed instr *)
79 :     proh : C.cell list, (* prohibited from future spilling *)
80 :     newReg : C.cell option (* the renamed value is here *)
81 :     }
82 :    
83 :     (* Reload the register dst from spillLoc.
84 :     * The value is originally from register reg.
85 :     *)
86 :     type reloadDst =
87 :     {dst : C.cell, (* register to reload to *)
88 :     reg : C.cell, (* the register *)
89 :     spillLoc : int, (* logical spill location *)
90 :     annotations : Annotations.annotations ref (* annotations *)
91 :     } -> I.instruction list (* reload code *)
92 :    
93 :     (*
94 : monnier 467 * The following function rewrites an instruction and insert
95 :     * spill and reload code around it. The list of spill and reload
96 :     * registers may have duplicates.
97 :     *)
98 :     val spillRewrite :
99 : monnier 498 { graph : G.interferenceGraph,
100 :     spill : spill,
101 :     spillSrc : spillSrc,
102 :     spillCopyTmp : spillCopyTmp,
103 :     reload : reload,
104 :     reloadDst : reloadDst,
105 :     renameSrc : renameSrc,
106 :     copyInstr : copyInstr,
107 :     cellkind : C.cellkind,
108 :     spillSet : C.cell list Intmap.intmap,
109 :     reloadSet : C.cell list Intmap.intmap,
110 :     killSet : C.cell list Intmap.intmap
111 : monnier 467 } ->
112 : monnier 498 { pt : int, (* starting program pt *)
113 :     annotations : Annotations.annotations ref, (* annotations *)
114 :     instrs : I.instruction list (* instructions to spill *)
115 : monnier 467 } ->
116 : monnier 498 I.instruction list (* instruction sequence after rewriting *)
117 :     (* Note, instructions are in reverse order *)
118 : monnier 467
119 :     end

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