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 744 - (view) (download) (as text)

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 744 spillLoc : G.spillLoc, (* logical spill location *)
49 : monnier 498 annotations : Annotations.annotations ref (* annotations *)
50 :     } -> I.instruction (* spill code *)
51 :    
52 :     (*
53 :     * Reload the value associated with reg from spillLoc.
54 :     * All uses of instr should be renamed to a new temporary newReg.
55 :     *)
56 : monnier 467 type reload =
57 :     {instr : I.instruction, (* instruction where spill is to occur *)
58 :     reg : C.cell, (* register to spill *)
59 : leunga 744 spillLoc : G.spillLoc, (* logical spill location *)
60 : monnier 498 annotations : Annotations.annotations ref (* annotations *)
61 : monnier 467 } ->
62 : monnier 498 {code : I.instruction list, (* instr + reload code *)
63 :     proh : C.cell list, (* prohibited from future spilling *)
64 :     newReg : C.cell option (* the reloaded value is here *)
65 : monnier 467 }
66 :    
67 :     (*
68 : monnier 498 * Rename all uses fromSrc to toSrc
69 :     *)
70 :     type renameSrc =
71 :     {instr : I.instruction, (* instruction where spill is to occur *)
72 :     fromSrc : C.cell, (* register to rename *)
73 : leunga 744 toSrc : C.cell (* register to rename to *)
74 : monnier 498 } ->
75 :     {code : I.instruction list, (* renamed instr *)
76 :     proh : C.cell list, (* prohibited from future spilling *)
77 :     newReg : C.cell option (* the renamed value is here *)
78 :     }
79 :    
80 :     (* Reload the register dst from spillLoc.
81 :     * The value is originally from register reg.
82 :     *)
83 :     type reloadDst =
84 :     {dst : C.cell, (* register to reload to *)
85 :     reg : C.cell, (* the register *)
86 : leunga 744 spillLoc : G.spillLoc, (* logical spill location *)
87 : monnier 498 annotations : Annotations.annotations ref (* annotations *)
88 :     } -> I.instruction list (* reload code *)
89 :    
90 :     (*
91 : monnier 467 * The following function rewrites an instruction and insert
92 :     * spill and reload code around it. The list of spill and reload
93 :     * registers may have duplicates.
94 :     *)
95 :     val spillRewrite :
96 : monnier 498 { graph : G.interferenceGraph,
97 :     spill : spill,
98 :     spillSrc : spillSrc,
99 :     spillCopyTmp : spillCopyTmp,
100 :     reload : reload,
101 :     reloadDst : reloadDst,
102 :     renameSrc : renameSrc,
103 :     copyInstr : copyInstr,
104 :     cellkind : C.cellkind,
105 : leunga 744 spillSet : C.cell list G.PPtHashTable.hash_table,
106 :     reloadSet : C.cell list G.PPtHashTable.hash_table,
107 :     killSet : C.cell list G.PPtHashTable.hash_table
108 : monnier 467 } ->
109 : leunga 744 { pt : G.programPoint, (* starting program pt *)
110 : monnier 498 annotations : Annotations.annotations ref, (* annotations *)
111 :     instrs : I.instruction list (* instructions to spill *)
112 : monnier 467 } ->
113 : monnier 498 I.instruction list (* instruction sequence after rewriting *)
114 :     (* Note, instructions are in reverse order *)
115 : monnier 467
116 :     end

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