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