summaryrefslogtreecommitdiff
path: root/thesis/reg-alloc.tex
diff options
context:
space:
mode:
Diffstat (limited to 'thesis/reg-alloc.tex')
-rw-r--r--thesis/reg-alloc.tex109
1 files changed, 56 insertions, 53 deletions
diff --git a/thesis/reg-alloc.tex b/thesis/reg-alloc.tex
index beb83c5..e90b36e 100644
--- a/thesis/reg-alloc.tex
+++ b/thesis/reg-alloc.tex
@@ -5,6 +5,7 @@
\small
\begin{subfigure}{.5\linewidth}
\begin{tikzpicture}
+ \ifcolours\else\selectcolormodel{gray}\fi
\begin{axis}
[ xbar
, xmin=0
@@ -41,6 +42,7 @@
\end{subfigure}%
\begin{subfigure}{.5\linewidth}
\begin{tikzpicture}
+ \ifcolours\else\selectcolormodel{gray}\fi
\begin{axis}
[ xbar
, xmin=0
@@ -153,7 +155,7 @@ In Clean programs, the ARM registers are used as follows~\parencite[\texttt{arms
\begin{table*}[b!]
\centering
- \newcommand{\highlight}[1]{\textcolor{red}{\textbf{#1}}}
+ \newcommand{\highlight}[1]{\textbf{\ifcolours\textcolor{red}{#1}\else\underline{#1}\fi}}
\begin{subfigure}{.5\linewidth}
\centering
\begin{tabular}{l >{\tt\footnotesize}c >{\tt\footnotesize}c}
@@ -200,60 +202,9 @@ For small programs it may not be negligible,
The counting method used here is rather simplistic:
basing a register allocation on these counts alone means assuming that every instruction has a 16-bit variant, which is not the case.
-A more accurate method would only count those instructions where using a high or low register actually makes a difference.
+A more accurate method would be to only count those instructions where using a high or low register actually makes a difference.
This is much more complicated, and for a rough estimate the simplistic method used here will already allow us to shrink down the code size.
-\begin{figure*}[b]
- \small
- \centering
- \begin{tikzpicture}
- \begin{axis}
- [ anchor=south east
- , height=.25\linewidth
- , width=.45\linewidth
- , xbar
- , xmin=0, xmax=6000000
- , xlabel={Bytes}
- , ytick=\empty
- , reverse stacked plots
- , ylabel={Clean compiler}
- , ymin=-1, ymax=1
- , axis lines*=left
- , nodes near coords, nodes near coords align=west
- , reverse legend
- , every axis plot/.append style={point meta=explicit symbolic}
- , legend style={at={($(1,-0.5)+(1.5em,0pt)$)},anchor=north,legend columns=-1}
- ]
- \addplot coordinates { (3785144,0) [80.7\%] };
- \addplot coordinates { (3827868,0) [81.6\%] };
- \addplot coordinates { (4385964,0) [93.5\%] };
- \addplot coordinates { (4692628,0) [100\%] };
- \legend{Thumb object-code (approximation), Thumb optimised, Thumb, ARM}
- \end{axis}
- \begin{axis}
- [ anchor=south west
- , height=.25\linewidth
- , width=.45\linewidth
- , xshift=3em
- , xbar
- , xmin=0, xmax=80000
- , xlabel={Bytes}
- , ytick=\empty
- , ymin=-1, ymax=1
- , ylabel={\texttt{frontend/scanner.icl}}
- , axis lines*=left
- , every axis plot/.append style={point meta=explicit symbolic}
- , nodes near coords, nodes near coords align=west
- ]
- \addplot coordinates { (57296,0) [82.0\%] };
- \addplot coordinates { (57864,0) [82.8\%] };
- \addplot coordinates { (64588,0) [92.4\%] };
- \addplot coordinates { (69896,0) [100\%] };
- \end{axis}
- \end{tikzpicture}
- \caption{Code size for different backends.\label{fig:reg-alloc:results}}
-\end{figure*}
-
\subsection{Optimisation}
\label{sec:reg-alloc:optimisation}
The register allocation used in the ARM backend is inefficient for Thumb-2 on several points (\cref{tab:reg-alloc:arm-and-thumb}).
@@ -329,6 +280,58 @@ To measure the code size improvement introduced by this optimisation,
With the new Thumb backend, with the optimised register allocation and leaving out any \ual{.align} directives to approximate object-code level efficiency.
\end{itemize}
+\begin{figure*}[b]
+ \small
+ \centering
+ \begin{tikzpicture}
+ \ifcolours\else\selectcolormodel{gray}\fi
+ \begin{axis}
+ [ anchor=south east
+ , height=.25\linewidth
+ , width=.45\linewidth
+ , xbar
+ , xmin=0, xmax=6000000
+ , xlabel={Bytes}
+ , ytick=\empty
+ , reverse stacked plots
+ , ylabel={Clean compiler}
+ , ymin=-1, ymax=1
+ , axis lines*=left
+ , nodes near coords, nodes near coords align=west
+ , reverse legend
+ , every axis plot/.append style={point meta=explicit symbolic}
+ , legend style={at={($(1,-0.5)+(1.5em,0pt)$)},anchor=north,legend columns=-1}
+ ]
+ \addplot coordinates { (3785144,0) [80.7\%] };
+ \addplot coordinates { (3827868,0) [81.6\%] };
+ \addplot coordinates { (4385964,0) [93.5\%] };
+ \addplot coordinates { (4692628,0) [100\%] };
+ \legend{Thumb object-code (approximation), Thumb optimised, Thumb, ARM}
+ \end{axis}
+ \begin{axis}
+ [ anchor=south west
+ , height=.25\linewidth
+ , width=.45\linewidth
+ , xshift=3em
+ , xbar
+ , xmin=0, xmax=80000
+ , xlabel={Bytes}
+ , ytick=\empty
+ , ymin=-1, ymax=1
+ , ylabel={\texttt{frontend/scanner.icl}}
+ , axis lines*=left
+ , every axis plot/.append style={point meta=explicit symbolic}
+ , nodes near coords, nodes near coords align=west
+ ]
+ \addplot coordinates { (57296,0) [82.0\%] };
+ \addplot coordinates { (57864,0) [82.8\%] };
+ \addplot coordinates { (64588,0) [92.4\%] };
+ \addplot coordinates { (69896,0) [100\%] };
+ \end{axis}
+ \end{tikzpicture}
+ \caption{Code size for different backends.\label{fig:reg-alloc:results}}
+\end{figure*}
+
The object code generator has not been finished yet at the moment these measurements were done,
so we can only estimate its efficiency.
A modification described in \cref{sec:storing-pc:solution} required us to add \ual{.align} to jump instructions, adding a \ual{nop} instruction in approximately half the instances.