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/instructions/cells-basis.sig
ViewVC logotype

Annotation of /MLRISC/trunk/instructions/cells-basis.sig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 775 - (view) (download) (as text)
Original Path: sml/trunk/src/MLRISC/instructions/cells-basis.sig

1 : leunga 744 (*
2 :     * This updated signature describes the abstractions on ``cells'', which
3 :     * denote storage cells in the machine architecture.
4 :     *
5 :     * Allen Leung (12/2/00)
6 :     *)
7 :     signature CELLS_BASIS =
8 :     sig
9 :     type cellkindInfo
10 :     type cellkindDesc
11 :    
12 :     (* Cellkind denotes the types of storage cells.
13 :     * This definition is further augumented by architecture specific
14 :     * cells descriptions. Type cellkind is an equality type.
15 :     *)
16 :     datatype cellkind =
17 :     GP (* general purpose register *)
18 :     | FP (* floating point register *)
19 :     | CC (* condition code register *)
20 :    
21 :     | MEM (* memory *)
22 :     | CTRL (* control dependence *)
23 :    
24 :     | MISC_KIND of cellkindInfo ref (* client defined *)
25 :    
26 :     type sz = int (* width in bits *)
27 :     type cell_id = int (* unique cell identifier *)
28 :     type register_id = int (* register id *)
29 :     type register_num = int (* register number *)
30 :     (* Note: register_id and register_num should probably be made into
31 :     * different datatypes with different tags, but FLINT currently boxes
32 :     * such objects.
33 :     *)
34 :    
35 :     (*
36 :     * A cell is a stateful object reprensenting a storage cell in a
37 :     * processor. Cells are partitioned into their kinds, such as
38 :     * GP (general purpose, i.e., integer, registers), * FP
39 :     * (floating point registers) etc. Each cell has an unique cell_id
40 :     * that determines its identity. Its attributes include
41 :     *
42 :     * 1. its color, and
43 :     * 2. other client defined properties,
44 :     * which is represented as a property list of annotations.
45 :     *
46 :     * Note that cell_id and color are two distinct concepts; for example,
47 :     * two different cells may have the same color.
48 :     *
49 :     * Type cell is not an equality type. We provide the function
50 :     * sameCell for testing for object identity, and the function
51 :     * sameColor for testing for color identity. For most things,
52 :     * sameColor is the right function to use.
53 :     *)
54 :     datatype cell =
55 :     CELL of {id : cell_id,
56 :     col : cellColor ref,
57 :     desc : cellkindDesc,
58 :     an : Annotations.annotations ref
59 :     }
60 :     and cellColor =
61 :     MACHINE of register_id
62 :     | PSEUDO
63 :     | ALIASED of cell
64 :     | SPILLED
65 :    
66 :     (*
67 :     * Basic functions on cellkinds
68 :     *)
69 :     val cellkindToString : cellkind -> string (* name *)
70 :     val cellkindToNickname : cellkind -> string (* abbreviation *)
71 :     val newCellKind : {name:string,nickname:string} -> cellkind
72 :    
73 :     (*
74 :     * Basic functions on cells.
75 :     * All functions marked with +++ implicitly chases aliases.
76 :     *
77 :     * Function register_id returns the current color of a node.
78 :     * The color of a pseudo register is the same as its cell_id.
79 :     * A spilled node is given a color of ~1, so all spilled nodes have
80 :     * the same color.
81 :     *
82 :     * NOTE: distinction between registerId and registerNum:
83 :     * Function register_id returns register_id.
84 :     * Physical registers in distinct
85 :     * cell classes are given disjoint register_ids. So for example,
86 :     * the register id for r0 and f0 in the Alpha are different.
87 :     *
88 :     * The function, registerNum, on the other hand, returns a
89 :     * register number of a cell that starts from 0 for physical registers.
90 :     * So registerNum r0 = registerNum f0 = 0. It behaves the same
91 :     * as registerId in other cases.
92 :     *
93 :     * The function physicalRegisterNum is the same as registerNum,
94 :     * except that it is an error to call it on a pseudo or spilled cell.
95 :     * As a rule, use registerId whenever possible. Function registerNum
96 :     * is used only if you have to deal with machine encoding.
97 :     *)
98 :     val cellId : cell -> cell_id (* return cell id *)
99 :     val cellkind : cell -> cellkind (* return cellkind *)
100 : leunga 775 val isConst : cell -> bool
101 : leunga 744 val annotations : cell -> Annotations.annotations ref
102 :     val sameCell : cell * cell -> bool (* object identity *)
103 :     val sameKind : cell * cell -> bool (* same cellkind? *)
104 :     val chase : cell -> cell (* chase aliases +++ *)
105 :     val sameAliasedCell : cell * cell -> bool (* chase aliases +++ *)
106 :     val hashCell : cell -> word
107 :     val registerId : cell -> register_id (* +++ *)
108 :     val registerNum : cell -> register_num (* +++ *)
109 :     val physicalRegisterNum : cell -> int (* +++ *)
110 :     val sameColor : cell * cell -> bool (* color identity +++ *)
111 : leunga 775 val compareColor : cell * cell -> order (* +++ *)
112 : leunga 744 val toString : cell -> string (* pretty print a cell +++ *)
113 :     val toStringWithSize : cell * sz -> string (* +++ *)
114 :    
115 :     (* Set the color of the 'from' cell to be the same as
116 : leunga 775 * the 'to' cell. The 'from' cell MUST be a pseudo register,
117 :     * and cannot be of kind CONST.
118 : leunga 744 *)
119 :     val setAlias : {from: cell, to: cell} -> unit (* +++ *)
120 :    
121 :     (*
122 :     * The following abstraction represents a set of cells
123 :     * indexed by colors. When two or more cells with the same color
124 :     * exists, we arbitrarily choose a representative.
125 :     * WARNING: while using sorted_cells it is important not to
126 :     * update the colors in the elements, or you'll get wrong results.
127 :     *)
128 :     structure SortedCells :
129 :     sig
130 :     type sorted_cells
131 :     val empty : sorted_cells
132 :     val enter : cell * sorted_cells -> sorted_cells
133 :     val rmv : cell * sorted_cells -> sorted_cells
134 :     val eq : sorted_cells * sorted_cells -> bool
135 :     val notEq : sorted_cells * sorted_cells -> bool
136 :     val uniq : cell list -> sorted_cells
137 :     val difference : sorted_cells * sorted_cells -> sorted_cells
138 :     val intersect : sorted_cells * sorted_cells -> sorted_cells
139 :     val union : sorted_cells * sorted_cells -> sorted_cells
140 :     val return : sorted_cells -> cell list
141 :     val isEmpty : sorted_cells -> bool
142 :     val emptyIntersection : sorted_cells * sorted_cells -> bool
143 :     val nonEmptyIntersection : sorted_cells * sorted_cells -> bool
144 :     end
145 :    
146 :     (*
147 :     * Hash table indexed by cell id.
148 :     * IMPORTANT: this table is not indexed by color!
149 :     *)
150 :     structure HashTable : MONO_HASH_TABLE where type Key.hash_key = cell
151 :    
152 : leunga 775 (*
153 :     * Hash table indexed by cell color.
154 :     * IMPORTANT: this table is indexed by color!
155 :     * ALSO: DO NOT change the colors of the cells while using this table!
156 :     *)
157 :     structure ColorTable : MONO_HASH_TABLE where type Key.hash_key = cell
158 :    
159 : leunga 744 (*
160 :     * These annotations adds extra definitions and uses to an instruction
161 :     *)
162 :     exception DEF_USE of {cellkind:cellkind, defs:cell list, uses:cell list}
163 :     val DEFUSE : {cellkind:cellkind, defs:cell list, uses:cell list}
164 :     Annotations.property
165 :    
166 :     (* Internal use for alias analysis; don't use! *)
167 :     val mem : register_id -> cell
168 : leunga 775
169 :     (* Internal use only! *)
170 :     val show : cellkindDesc -> register_id -> string
171 :     val showWithSize : cellkindDesc -> register_id * sz -> string
172 : leunga 744 end
173 :    

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