| 1 |
\section{MLRISC Based Compiler} |
| 2 |
A traditional compiler will typically consist of a |
| 3 |
\begin{color}{#dd0000}lex/yacc\end{color} based front end, an |
| 4 |
\begin{color}{#DD0000}optimization\end{color} |
| 5 |
phase that is repeatedly invoked |
| 6 |
over some intermediate representation, and finally a |
| 7 |
\begin{color}{#DD0000}back end\end{color} |
| 8 |
code generation phase. The intermediate |
| 9 |
representation is usually at a level of detail appropriate to the |
| 10 |
optimization being performed, and may be far removed from the |
| 11 |
native instructions of the target architecture. The back end |
| 12 |
proceeds by translating the intermediate representation into |
| 13 |
instructions and registers for an abstract machine that is much |
| 14 |
closer to the target architecture. Retargetting is then achieved |
| 15 |
by mapping the registers and instructions of the abstract machine |
| 16 |
to registers and instructions of the target architecture. |
| 17 |
|
| 18 |
\br{clear=left} |
| 19 |
|
| 20 |
\image{MLRISC based compiler}{pictures/png/compiler-2.png}{align=right} |
| 21 |
|
| 22 |
An MLRISC based compiler, on the other hand, translates the |
| 23 |
intermediate representation into MLRISC instructions and it is the |
| 24 |
MLRISC instructions that get mapped onto instructions of the target |
| 25 |
architecture. Another possibility is to translate the front end |
| 26 |
abstract machine instructions instead of the intermediate |
| 27 |
representation. Once MLRISC instructions have been generated, |
| 28 |
nearly all aspects of high quality code generation come for free. A |
| 29 |
long story would be cut short if MLRISC were just another abstract |
| 30 |
machine. |
| 31 |
|
| 32 |
\begin{color}{#580000} The key idea behind MLRISC is that there is no |
| 33 |
single MLRISC instruction set or intermediate program |
| 34 |
representation, \end{color} but the MLRISC intermediate representation |
| 35 |
is specialized to the needs of the front end source language being |
| 36 |
compiled. The specialization does not stop there, but the: |
| 37 |
\begin{itemize} |
| 38 |
\item \begin{color}{#005500}target instruction set\end{color}, |
| 39 |
\item \begin{color}{#005500}flowgraph\end{color}, and |
| 40 |
\item \begin{color}{#005500}entire optimization suite\end{color} |
| 41 |
\end{itemize} |
| 42 |
|
| 43 |
are specialized to the needs of the front end. The ability to |
| 44 |
consistently specialize each of these to create a back end for a |
| 45 |
specific language, summarizes the characteristics of MLRISC that |
| 46 |
distinguishes it from other retargetable backends. |
| 47 |
|
| 48 |
\begin{color}{#580000} It is important to emphasize that little |
| 49 |
optimizations performed on the MLRISC intermediate |
| 50 |
representation. \end{color} Most optimizations are done on a flowgraph of |
| 51 |
target machine instructions, to enable optimizations that take advantage |
| 52 |
of the characteristics of each architectural. |
| 53 |
The MLRISC intermediate representation is just used as a stepping |
| 54 |
stone to get to the flowgraph. |