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