| 1 |
\section{Cells} |
| 2 |
|
| 3 |
MLRISC uses |
| 4 |
the \mlrischref{instructions/cells.sig}{CELLS} |
| 5 |
interface to define all readable/writable resources |
| 6 |
in a machine architecture, or \emph{cells} |
| 7 |
The types defined herein are: |
| 8 |
\begin{itemize} |
| 9 |
\item \sml{cellkind} -- different classes of cells are assigned |
| 10 |
difference cellkinds. The following cellkinds should be present |
| 11 |
\begin{itemize} |
| 12 |
\item \sml{GP} -- general purpose registers. |
| 13 |
\item \sml{FP} -- floating point registers. |
| 14 |
\item \sml{CC} -- condition code registers. |
| 15 |
\end{itemize} |
| 16 |
In addition, the cellkinds \sml{MEM} and \sml{CTRL} |
| 17 |
should also be defined. These are used for representing |
| 18 |
memory based data dependence and control dependence. |
| 19 |
\begin{itemize} |
| 20 |
\item \sml{MEM} -- memory |
| 21 |
\item \sml{CTRL} -- control dependence |
| 22 |
\end{itemize} |
| 23 |
\item \sml{regmap} -- \href{regmap.html}{register map} |
| 24 |
\item \sml{cellset} -- a cellset represent a set of cells. This |
| 25 |
type can be used to denote live-in/live-out information. Cellsets are |
| 26 |
implemented as immutable abstract types. |
| 27 |
\end{itemize} |
| 28 |
|
| 29 |
These core definitions are defined in the following signature |
| 30 |
\begin{SML} |
| 31 |
signature \mlrischref{instructions/cells.sig}{CELLS\_BASIS} = |
| 32 |
sig |
| 33 |
eqtype cellkind |
| 34 |
type cell = int |
| 35 |
type regmap = cell Intmap.intmap |
| 36 |
exception Cells |
| 37 |
|
| 38 |
val cellkinds : cellkind list |
| 39 |
val cellkindToString : cellkind -> string |
| 40 |
val firstPseudo : cell |
| 41 |
val Reg : cellkind -> int -> cell |
| 42 |
val GPReg : int -> cell |
| 43 |
val FPReg : int -> cell |
| 44 |
val cellRange : cellkind -> {low:int, high:int} |
| 45 |
val newCell : cellkind -> 'a -> cell |
| 46 |
val cellKind : cell -> cellkind |
| 47 |
val updateCellKind : cell * cellkind -> unit |
| 48 |
val numCell : cellkind -> unit -> int |
| 49 |
val maxCell : unit -> cell |
| 50 |
val newReg : 'a -> cell |
| 51 |
val newFreg : 'a -> cell |
| 52 |
val newVar : cell -> cell |
| 53 |
val regmap : unit -> regmap |
| 54 |
val lookup : regmap -> cell -> cell |
| 55 |
val reset : unit -> unit |
| 56 |
end |
| 57 |
\end{SML} |
| 58 |
|
| 59 |
\begin{itemize} |
| 60 |
\item\sml{cellkinds} -- this is a list of all the cellkinds defined in the |
| 61 |
architecture |
| 62 |
\item\sml{cellkindToString} -- this function maps a cellkind into its name |
| 63 |
\item\sml{firstPseudo} -- MLRISC numbered physical resources |
| 64 |
in the architecture from 0 to firstPseudo-1. |
| 65 |
This is the first usable virtual register number. |
| 66 |
\item\sml{Reg} -- This function maps the $i$th physical |
| 67 |
resource of a particular cellkind to its internal encoding used by MLRISC. |
| 68 |
Note that all resources in MLRISC are named uniquely. |
| 69 |
\item\sml{GPReg} -- abbreviation for \sml{Reg GP} |
| 70 |
\item\sml{FPReg} -- abbreviation for \sml{Reg FP} |
| 71 |
\item \sml{cellRange} -- this returns a range \sml{{low, high}} |
| 72 |
when given a cellkind, with denotes the range of physical resources |
| 73 |
\item \sml{newCell} -- This function returns a new virtual register |
| 74 |
of a particular cellkind. |
| 75 |
\item \sml{newReg} -- abbreviation as \sml{newCell GP} |
| 76 |
\item \sml{newFreg} -- abbreviation as \sml{newCell FP} |
| 77 |
\item \sml{cellKind} -- When given a cell number, this returns its |
| 78 |
cellkind. Note that this feature is not enabled by default. |
| 79 |
\item \sml{updateCellKind} -- updates the cellkind of a cell. |
| 80 |
\item \sml{numCell} -- returns the number of virtual cells allocated for one cellkind. |
| 81 |
\item \sml{maxCell} -- returns the next virtual cell id. |
| 82 |
\item \sml{newVar} -- given a cell id, return a new cell id of |
| 83 |
the same cellkind. |
| 84 |
\item \sml{regmap} -- This function returns a new empty regmap |
| 85 |
\item \sml{lookup} -- This converts a regmap into a lookup function. |
| 86 |
\item \sml{reset} -- This function resets all counters associated |
| 87 |
with all virtual cells. |
| 88 |
\end{itemize} |
| 89 |
|
| 90 |
\begin{SML} |
| 91 |
signature CELLS = sig |
| 92 |
include CELLS_BASIS |
| 93 |
val GP : cellkind |
| 94 |
val FP : cellkind |
| 95 |
val CC : cellkind |
| 96 |
val MEM : cellkind |
| 97 |
val CTRL : cellkind |
| 98 |
val toString : cellkind -> cell -> string |
| 99 |
val stackptrR : cell |
| 100 |
val asmTmpR : cell |
| 101 |
val fasmTmp : cell |
| 102 |
val zeroReg : cellkind -> cell option |
| 103 |
|
| 104 |
type cellset |
| 105 |
|
| 106 |
val empty : cellset |
| 107 |
val addCell : cellkind -> cell * cellset -> cellset |
| 108 |
val rmvCell : cellkind -> cell * cellset -> cellset |
| 109 |
val addReg : cell * cellset -> cellset |
| 110 |
val rmvReg : cell * cellset -> cellset |
| 111 |
val addFreg : cell * cellset -> cellset |
| 112 |
val rmvFreg : cell * cellset -> cellset |
| 113 |
val getCell : cellkind -> cellset -> cell list |
| 114 |
val updateCell : cellkind -> cellset * cell list -> cellset |
| 115 |
|
| 116 |
val cellsetToString : cellset -> string |
| 117 |
val cellsetToString' : (cell -> cell) -> cellset -> string |
| 118 |
|
| 119 |
val cellsetToCells : cellset -> cell list |
| 120 |
end |
| 121 |
\end{SML} |
| 122 |
|
| 123 |
\begin{itemize} |
| 124 |
\item \sml{toString} -- convert a cell id of a certain cellkind into |
| 125 |
its assembly name. |
| 126 |
\item \sml{stackptrR} -- the cell id of the stack pointer register. |
| 127 |
\item \sml{asmTmpR} -- the cell id of the assembly temporary |
| 128 |
\item \sml{fasmTmp} -- the cell id of the floating point temporary |
| 129 |
\item \sml{zeroReg} -- given the cellkind, returns the cell id of the |
| 130 |
source that always hold the value of zero, if there is any. |
| 131 |
\item \sml{empty} -- an empty cellset |
| 132 |
\item \sml{addCell} -- inserts a cell into a cellset |
| 133 |
\item \sml{rmvCell} -- remove a cell from a cellset |
| 134 |
\item \sml{addReg} -- abbreviation for \sml{addCell GP} |
| 135 |
\item \sml{rmvReg} -- abbreviation for \sml{rmvCell GP} |
| 136 |
\item \sml{addFreg} -- abbreviation for \sml{addCell FP} |
| 137 |
\item \sml{rmvFreg} -- abbreviation for \sml{rmvCell FP} |
| 138 |
\item \sml{getCell} -- lookup all cells of a particular cellkind from |
| 139 |
the cellset |
| 140 |
\item \sml{updateCell} -- replace all cells of a particular cellkind |
| 141 |
from the cellset. |
| 142 |
\item \sml{cellsetToString} -- pretty print a cellset |
| 143 |
\item \sml{cellsetToString'} -- pretty print a cellset, but first |
| 144 |
apply a regmap function. |
| 145 |
\item \sml{cellsetToCells} -- convert a cellset into list form. |
| 146 |
\end{itemize} |