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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : monnier 411 (*
2 :     * Description of registers and other updatable cells.
3 : monnier 245 *
4 : monnier 411 * IMPORTANT NOTE:
5 :     * All physical registers in the machine architecture
6 :     * all given unique encodings. The encoding is not necessarily zero based.
7 :     * For example, 0 may NOT represent floating point register 0.
8 : monnier 245 *
9 : monnier 411 * This means that the client should not
10 :     * use hard coded integers to represent physical registers,
11 :     * but should instead use the function:
12 : monnier 245 *
13 : monnier 429 * Reg : cellkind -> int -> cell
14 : monnier 245 *
15 : monnier 411 * to compute the proper encoding.
16 :     *
17 :     * A call "Reg k n" returns the nth physical register of kind k.
18 :     * For integer and float point registers, the functions:
19 :     *
20 : monnier 429 * GPReg : int -> cell
21 :     * FPReg : int -> cell
22 : monnier 411 *
23 :     * can also be used as shortcuts.
24 :     *
25 :     * -- Allen.
26 :     *)
27 :     signature CELLS_BASIS =
28 :     sig
29 :     eqtype cellkind
30 : monnier 429 type cell = int
31 : george 545 type ty = int
32 : blume 733 type regmap = cell IntHashTable.hash_table
33 : monnier 411 exception Cells
34 : monnier 245
35 : monnier 411 val cellkinds : cellkind list (* list of all the cellkinds *)
36 : monnier 245
37 : monnier 411 val cellkindToString : cellkind -> string
38 : monnier 245
39 : monnier 411 (* first pseudo register *)
40 : monnier 429 val firstPseudo : cell
41 : monnier 245
42 : monnier 411 (* returns the encoding for the nth physical register of the given kind,
43 :     * raises Cells if there is none.
44 :     *)
45 : monnier 429 val Reg : cellkind -> int -> cell
46 :     val GPReg : int -> cell (* Reg GP *)
47 :     val FPReg : int -> cell (* Reg FP *)
48 : monnier 245
49 : monnier 411 (* given a cellkind returns its encoding range *)
50 :     val cellRange : cellkind -> {low:int, high:int}
51 : monnier 245
52 : monnier 411 (* generate a new name for a virtual register *)
53 : monnier 429 val newCell : cellkind -> 'a -> cell
54 : monnier 245
55 : monnier 411 (* lookup the number of virtual registers in a cellkind *)
56 :     val numCell : cellkind -> unit -> int
57 :    
58 :     (* the next virtual register name *)
59 : monnier 429 val maxCell : unit -> cell
60 : monnier 411
61 :     (* newCell GP *)
62 : monnier 429 val newReg : 'a -> cell
63 : monnier 411
64 :     (* newCell FP *)
65 : monnier 429 val newFreg : 'a -> cell
66 : monnier 411
67 :     (* Create a new register that has the same cellkind as the given one
68 :     * Note: the numCell kind is NOT updated!
69 :     *)
70 : monnier 429 val newVar : cell -> cell
71 : monnier 411
72 :     (* create a new regmap *)
73 :     val regmap : unit -> regmap
74 : monnier 429 val lookup : regmap -> cell -> cell
75 : monnier 411
76 :     (* reset all counters *)
77 :     val reset : unit -> unit
78 :    
79 :     (* auxiliary functions *)
80 : monnier 429 val printSet : (cell -> string) -> (cell list -> string)
81 : monnier 411 val printTuple : string list * string list -> string
82 : leunga 657
83 :     (*
84 :     * These annotations adds extract definitions and uses to an instruction
85 :     *)
86 :     exception DEF_USE of {cellkind:cellkind, defs:cell list, uses:cell list}
87 :     val DEFUSE : {cellkind:cellkind, defs:cell list, uses:cell list}
88 :     Annotations.property
89 : monnier 245 end
90 :    
91 :     (*
92 : monnier 411 * This is the abstract interface of cells
93 : monnier 245 *)
94 : monnier 411 signature CELLS =
95 :     sig
96 :     include CELLS_BASIS
97 :     val GP : cellkind (* general purpose *)
98 :     val FP : cellkind (* floating point *)
99 :     val CC : cellkind (* condition code *)
100 :     val MEM : cellkind (* memory cell *)
101 :     val CTRL : cellkind (* control dependence *)
102 : monnier 429 val toString : cellkind -> cell -> string
103 : george 545 val toStringWithType : cellkind -> cell * ty -> string
104 : monnier 429 val stackptrR : cell (* stack pointer register *)
105 :     val asmTmpR : cell (* assembly temporary *)
106 :     val fasmTmp : cell (* floating point temporary *)
107 :     val zeroReg : cellkind -> cell option (* register that contains 0 *)
108 : monnier 411
109 :     type cellset
110 :    
111 :     (* building a cellset *)
112 :     val empty : cellset
113 : monnier 429 val addCell : cellkind -> cell * cellset -> cellset
114 :     val rmvCell : cellkind -> cell * cellset -> cellset
115 :     val addReg : cell * cellset -> cellset
116 :     val rmvReg : cell * cellset -> cellset
117 :     val addFreg : cell * cellset -> cellset
118 :     val rmvFreg : cell * cellset -> cellset
119 :     val getCell : cellkind -> cellset -> cell list
120 :     val updateCell : cellkind -> cellset * cell list -> cellset
121 : monnier 411
122 :     (* pretty printing, the second one takes a regmap *)
123 :     val cellsetToString : cellset -> string
124 : monnier 429 val cellsetToString' : (cell -> cell) -> cellset -> string
125 : monnier 411
126 : monnier 429 (* convert cellset into a list of cells *)
127 :     val cellsetToCells : cellset -> cell list
128 : monnier 411 end

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