Capitalize Montium.
[matthijs/projects/internship.git] / Report / Main / Context / MontiumC.tex
1 \section{MontiumC}
2 \label{MontiumC}
3 Since having just a piece of hardware is not enough, we also need some way to
4 program the Montium. To this end, the MontiumC language was created. The
5 MontiumC language is a language very similar to C. It allows very fine grained
6 control over the Montium through a set of functions that can be called (where
7 the function called determines the operation mapped on the Montium).
8
9 MontiumC is, on one hand, a strict subset of C. Every MontiumC program is
10 therefore a valid C program as well. This is one of the strong points of
11 MontiumC: By using a normal C compiler, a MontiumC program can be functionally
12 simulated on normal hardware.
13
14 On the other hand, MontiumC defines a number of special functions which are
15 mapped onto the Montium ALU when compiling with the Montium-specific
16 backend. When compiling with a normal C compiler, these functions are
17 implemented by a library implemented in C.
18
19 Figure \ref{CompilingMontiumC} show the flow for compiling a MontiumC program
20 into a Montium binary file, which can be loaded directly onto a Montium. The
21 process is roughly divided into two parts (each of which corresponds to a
22 different program in the compiler suite): The frontend and the backend.
23
24 The frontend takes in a MontiumC program and turns it into a lower level
25 description of the program (LLVM Intermediate Representation, see the next
26 section). The frontend is responsible for mapping higher level
27 C constructs onto simpler instructions, for canonicalizing and simplifying the
28 code. These canonicalizations and simplifications ensure that the backend can be
29 kept simpler and does not have to deal with all the complexities of the original
30 program. 
31
32 The frontend is again divided into two pieces, the first of which
33 transforms C code into an intermediate representation (also see section
34 \ref{LLVM}). The second part transforms this intermediate representation, output
35 again a (reduced form of) this representation.
36
37 The backend, in turn, takes in this reduced description of the program and
38 transforms this into a valid Montium binary. To do this, it must find an ALU
39 configuration to execute a given set of operations, trace values to allocate
40 them to registers, generate instructions for the adress generation units, etc.
41
42 \begin{figure}
43 \epsfig{file=Img/Compiling.ps, width=\textwidth}
44 \caption{MontiumC compilation flow}
45 \label{CompilingMontiumC}
46 \end{figure}