diff options
-rw-r--r-- | log.md | 2 | ||||
-rw-r--r-- | thesis/intro.tex | 5 | ||||
-rw-r--r-- | thesis/preamble.tex | 2 | ||||
-rw-r--r-- | thesis/status.tex | 85 | ||||
-rw-r--r-- | thesis/thesis.tex | 3 |
5 files changed, 94 insertions, 3 deletions
@@ -618,3 +618,5 @@ need to look at register optimisations. - C calls - Capitalisation in the reference list +- More optimisations: branch optimisation +- More optimisations: tail recursion diff --git a/thesis/intro.tex b/thesis/intro.tex index 12a1484..f92b21d 100644 --- a/thesis/intro.tex +++ b/thesis/intro.tex @@ -52,7 +52,7 @@ ARM instructions have 4-bit register fields to address them. Some 16-bit Thumb instructions have 3-bit register fields that can only address the lowest eight registers. For these instructions there exist 32-bit variants that can address all sixteen registers. -\begin{figure*}[t] +\begin{figure*}[b] \centering \begin{subfigure}[b]{.2\linewidth} \centering @@ -312,6 +312,9 @@ There was a minor problem with negative offsets to the \ual{ldr} instruction, that cannot be as large in Thumb as they can in ARM. \Cref{sec:load-offsets} deals with this. +Moving to Thumb introduces a number of interesting optimisation vectors. +One of them, register allocation, is discussed in \cref{sec:reg-alloc}. + We benchmark the Thumb backend for Clean and discuss the results in \cref{sec:results}. \subsection{Terminology} diff --git a/thesis/preamble.tex b/thesis/preamble.tex index 9f07f6b..8d7dfed 100644 --- a/thesis/preamble.tex +++ b/thesis/preamble.tex @@ -66,6 +66,8 @@ \let\oldtexttt\texttt \def\texttt#1{\oldtexttt{\footnotesize #1}} +\let\oldurl\url +\renewcommand{\url}[1]{{\small\oldurl{#1}}} \newcommand*{\blankpage}{% \vspace*{\fill} diff --git a/thesis/status.tex b/thesis/status.tex new file mode 100644 index 0000000..29eff12 --- /dev/null +++ b/thesis/status.tex @@ -0,0 +1,85 @@ +\section{Current status} +\label{sec:status} + +\begin{multicols}{2} + +In this section, we briefly discuss the current status of the Thumb backend for Clean. + +\subsection{Run-time system} +\label{sec:status:rts} +The latest version of the RTS can be found at \url{https://git.camilstaps.nl/clean-run-time-system.git/}. +The Thumb backend is located in the \texttt{thumb2*} files and can be built with \texttt{Makefile.linux\_thumb2}. + +Register aliases have been used to ease changing the register allocation. +The current allocation is set in \texttt{thumb2regs.s}. + +The Clean RTS has three garbage collectors: + a copying, + a compacting + and a marking collector. +At this point only the first works. +The expectation is that the others can be fixed rather easily and that only a few bits need to be flipped. +We don't expect any problems other than the ones encountered in the copying collector (which has been discussed in \cref{sec:code-addresses}). + +\subsection{Code generator} +\label{sec:status:cg} +The latest version of the code generator can be found at \url{https://git.camilstaps.nl/clean-code-generator.git/}. +The Thumb-specific part is in the \texttt{cgthumb2*} files and + throughout other files in a few \texttt{\#ifdef} blocks. +It can be built with \texttt{Makefile.linux\_thumb2}. + +There are two code generators: + one that generates readable assembly code (\texttt{thumb2was.c}) + and one that generates object code (\texttt{thumb2as.c}). +At the moment of writing, only the first has been adapted to work for Thumb --- + the second is the same as the ARM code generator. + +\subsection{Building programs} +\label{sec:status:building} +To build a file \texttt{mymodule.icl} for a Thumb target, the following workflow can be used: + +\begin{minted}{bash} + # Build _system, needed only once + cg _system -s _system.s + as -o _system.o _system.s -march=armv7-a + + # Build cgopts, needed only once + as -o cgopts.o cgopts.s -march=armv7-a + + # Build actual program + clm -ABC mymodule + cg Clean\ System\ Files/mymodule -s mymodule.s + as -o mymodule.o mymodule.s -march=armv7-a + cc -o mymodule \ + /path/to/rts/_startup.o \ + /path/to/_system.o \ + cgopts.o \ + mymodule.o \ + -lc -lm \ + -march=armv7-a +\end{minted} + +The \texttt{\_system.abc} that is needed can be taken from any Clean distribution \parencite{clean}. + +In \texttt{cgopts.s}, some variables are set that are normally added by the Clean make tool \texttt{clm}. +The file may look like this: + +\begin{minted}{ual} + .data + .global ab_stack_size + .global flags + .global heap_size + .global heap_size_multiple + .global initial_heap_size + + heap_size: .word 0x00200000 + ab_stack_size: .word 0x00080000 + flags: .word 0x00000008 + heap_size_multiple: .word 0x00001400 + initial_heap_size: .word 0x00019000 +\end{minted} + +Another option to build Clean programs using the Thumb backend is to get the Clean make tool \texttt{clm} from \url{https://svn.cs.ru.nl/repos/clean-tools/trunk/clm/} and build it so that \texttt{NO\_ASSEMBLE} is \emph{not} defined + (which will cause it to execute the readable code generator instead of the object code generator). + +\end{multicols} diff --git a/thesis/thesis.tex b/thesis/thesis.tex index 9e320c2..7ebb7ad 100644 --- a/thesis/thesis.tex +++ b/thesis/thesis.tex @@ -62,13 +62,12 @@ It produces on average 20\% smaller code than the ARM code generator, which is o \appendix \input{terms} \input{system} +\input{status} \ifdraft\else \cleardoublepage \fi -\let\oldurl\url -\renewcommand{\url}[1]{{\small\oldurl{#1}}} % See http://tex.stackexchange.com/a/40750/23992 \DeclareRobustCommand{\VAN}[1]{van #1} \phantomsection\addcontentsline{toc}{section}{\bibname} |