blob: 29eff12b401cf531edfda4ea6ce348b399a490f2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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}
|