summaryrefslogtreecommitdiff
path: root/thesis/storing-pc.tex
diff options
context:
space:
mode:
Diffstat (limited to 'thesis/storing-pc.tex')
-rw-r--r--thesis/storing-pc.tex27
1 files changed, 14 insertions, 13 deletions
diff --git a/thesis/storing-pc.tex b/thesis/storing-pc.tex
index e08fb4d..81a688b 100644
--- a/thesis/storing-pc.tex
+++ b/thesis/storing-pc.tex
@@ -128,20 +128,8 @@ The offset, 9, is calculated as the number of bytes to the instruction after the
For \ual{b} and \ual{bl} instructions, this means an offset of 9, since these instructions are 32-bit.
The \ual{bx} and \ual{blx} instructions are 16-bit, and require an offset of 7.
-\subsection{Other solutions}
-\label{sec:storing-pc:other-solutions}
-Another solution than the one we present makes use of the link register.
-Some branch instructions, like \ual{bl}, store the address of the next instruction in the link register.
-We could therefore imagine a setup where the callee gets the return address from that register rather than from the stack.
-This is the approach taken by GCC.
-The code of a typical C subroutine starts with \ual{push {...,lr}} and ends with \ual{pop {...,pc}}.
-
-When generating code for a functional language, it is not straightforward to do this, due to tail recursion.
-It is an easier solution to have the caller responsible for storing the return address,
- which is why this approach is taken in Clean's ARM code generator~\parencite{armcg}
- and why we continue along these lines for the Thumb backend.
-
\subsection{Comparison}
+\label{sec:storing-pc:comparison}
Assuming the worst case, that all instructions in the jump block are wide, we need four more bytes in Thumb than in ARM.
As a benchmark, the Clean compiler has 41,006 jumps of this kind in 1,253,978 instructions, a rough 3.27\%.
The four extra bytes in Thumb mean a size increase of $41006\cdot4\approx160$KiB on the 5.3MiB file, an increase of 3.00\%.
@@ -157,4 +145,17 @@ A general comparison of running time under ARM and Thumb is made in \cref{sec:re
% pi@rasppi:~/clean/exe$ objdump -d cocl | grep -E '^\s+[0123456789abcdef]{5,8}:\s+[0123456789abcdef]{8}' | wc -l
% 1253978
+\subsection{Other solutions}
+\label{sec:storing-pc:other-solutions}
+Another solution than the one we present makes use of the link register.
+Some branch instructions, like \ual{bl}, store the address of the next instruction in the link register.
+We could therefore imagine a setup where the callee gets the return address from that register rather than from the stack.
+This is the approach taken by GCC.
+The code of a typical C subroutine starts with \ual{push {...,lr}} and ends with \ual{pop {...,pc}}.
+
+When generating code for a functional language, it is not straightforward to do this, due to tail recursion.
+It is an easier solution to have the caller responsible for storing the return address,
+ which is why this approach is taken in Clean's ARM code generator~\parencite{armcg}
+ and why we continue along these lines for the Thumb backend.
+
\end{multicols}