| 1 |
\section{Annotations} |
| 2 |
|
| 3 |
\subsection{Overview} |
| 4 |
A compiler front-end has to be propagate information to |
| 5 |
the back-end. An optimization phase may have to leave behind information |
| 6 |
at various places of the IR so that other phases can reuse such information. |
| 7 |
MLRISC uses the \newdef{annotations} |
| 8 |
mechanism for these functions. |
| 9 |
Individual instructions, basic blocks, and flow graph edges, |
| 10 |
can be attached one or more annotations. |
| 11 |
|
| 12 |
The basic MLRISC system understands many annotations. Some examples are: |
| 13 |
\begin{description} |
| 14 |
\item[COMMENT] |
| 15 |
these can be used to attach comments. If attached to |
| 16 |
an instruction, the assemblers will output |
| 17 |
them as part of their assembly output. |
| 18 |
\item[BRANCH\_PROB] |
| 19 |
these can be attached to a branch instruction to indicate |
| 20 |
the probability in which is it taken. |
| 21 |
\item[EXECUTION\_FREQ] |
| 22 |
these can be attached to a basic block to indicate |
| 23 |
its expected execution frequency |
| 24 |
\end{description} |
| 25 |
|
| 26 |
\subsection{Details} |
| 27 |
The primitive annotations datatype is defined |
| 28 |
to have this \mlrischref{library/annotations.sig}{signature}. |
| 29 |
In addition, MLRISC predefined a few primitive annotations that are |
| 30 |
recognized by the core system. This signature is |
| 31 |
\mlrischref{instructions/mlriscAnnotations.sig}{MLRISC\_ANNOTATIONS}. |
| 32 |
More detailed documentation can be found in this |
| 33 |
\href{http://cm.bell-labs.com/cm/cs/what/smlnj/compiler-notes/annotations.ps}{paper}. |