Description ------------- This is an experimental annotating C compiler that was built upon the CIL parser[1], Xavier Leroy's translation from C to Clight, and an existing back-end compiler for a register transfer language to a subset of the MIPS assembly language[2]. We rewrote the whole chain from Clight down to ASM, targetting the 8051 architecture. We extended interpreters for the intermediate languages to output a list of labels which denote key control points of the program that have been crossed during the interpretation. These labels are the places where the code can be instrumented to obtain a precise cost annotation. Thus, in that experiment, the annotation function is the composition of a labelling function followed by an instrumentation function. Labels are moreover indexed by iterations in loop, so that some loop transformations can be carried out without impacting the approach. Other implemented optimizations are constant propagation, copy propagation and partial redundancy elimination. The architecture of the compiler is described in full details in the documentation of this development, which can be found in this source tree at doc/html/index.html. [1] http://cil-parser.sourceforge.net/ [2] http://www.enseignement.polytechnique.fr/informatique/INF564/petit.tar.gz Licence --------- This piece of code must not be distributed. It is addressed to the CerCo partners only. Requirements -------------- - ocaml (>= 3.12) - menhir (>= 20090505) - CIL (included in the distribution) - GNU Make (>= 3.8) - gcc Compilation ------------- You can compile this compiler using the following command: % make (assuming that you are located at the root of the source tree) Installation -------------- To install the compiler in your favorite system hierarchy, use: % PREFIX=your-directory make install The executable "acc" will be installed in the subdirectory "bin/" of "your-directory". Usage ------- Usage: acc.native [options] file... -l Choose the target language between: Clight, Cminor, RTLabs, RTL, ERTL, LTL, LIN, ASM [default is ASM] -a Add cost annotations on the source code. -i Interpret the compiled code. -is Interpret all the compilation passes. -d Debugging mode. -o Prefix of the output files. -asm-pretty Output a pretty-printed assembly file. -lustre Input file is a Lustre file. -remove-lustre-externals Remove Lustre externals. -lustre-test Input file is a Lustre file, testing requested. -lustre-test-cases Set the number of test cases when testing a Lustre file. [default is 100] -lustre-test-cycles Set the number of cycles for each case when testing a Lustre file. [default is 100] -lustre-test-min-int Random int minimum value when testing a Lustre file. [default is -1000] -lustre-test-max-int Random int maximum value when testing a Lustre file. [default is 1000] -peel Apply loop peeling. [reindexing transformation, done in Clight] -cst-prop Apply constant propagation. [done in RTLabs] [done in RTL] -cpy-prop Apply copy propagation. [done in RTLabs] -pre Apply partial redundancy elimination. [done in RTLabs] -unroll-for Apply loop unrolling, specifying factor. [reindexing transformation, done in Clight] -unroll Apply loop unrolling. [reindexing transformation, done in Clight] -peeph Apply some basic peephole optimizations. [done in LIN] -O Apply some optimizations. -no-cost-tern Replace cost ternary expressions with equivalent branch statements. -no-reindex Prevent optimizations that reindex labels. -dev Playground for developers. -help Display this list of options --help Display this list of options Test-suite ------------ You can optionnally check that compilation went well by confronting the freshly built compiler to our test-suite. At the root of the source tree, use: % make check mcu8051ide ------------ The object code can be simulated using the mcu8051ide[3] emulator. The code makes use of an external memory and that the usage of such memory is not the default option in mcu8051ide. In order to enable this option, click on the 'Project' menu, and then on 'Edit project'. There is a box to enable 'External RAM (XDATA)' and a scrolling bar to specify its size (we suggest to use the maximum possible). Also, since the produced code might be too big for standard memory, it is recommended to enable 'External ROM/FLASH (XCODE)' to its maximum size. [3] http://mcu8051ide.sourceforge.net/