2 LICE is a work in progress C99 compiler designed as a solution for
3 teaching myself and others about the internals of the C programming
4 language, how to write a compiler for it, and code generation.
6 Part of the philosophy behind LICE is to provide a public domain
7 implementation of a working conformant C99 compiler. As well as borrowing
8 extensions and ideas from existing compilers to ensure a wider range of
12 See the STANDARDS file for the status on which standards LICE supports.
15 If you don't find yourself needing any of the stuff which is marked as being
16 unsupported above then you may find that LICE will happily compile your
17 source into x86-64 assembly. The code generation is close from optimal.
18 LICE treats the entire system as a giant stack machine, since it's easier
19 to generate code that way. The problem is it's hardly efficent. All local
20 variables are assigned on the stack for operations. All operations operate
21 from the stack and write back the result to the stack location that is
22 the destination operand for that operation.
25 LICE should be farily straightforward to retarget for a specific architecture
26 or ABI. Start by making a copy of `arch_dummy.h`, naming it `arch_yourarch.h`
27 create an entry in `lice.h` for that header guarded by conditional include.
28 Supply that as a default option in the Makefile, remove `gen_amd64.c` from
29 the Makefile, add your own to it. Then write the code generator. Documentation
30 may be found in `gen.h`.
42 - Intermediate stage with optimizations (libfirm?)
44 - Code generation (directly to elf/coff, et. all)
46 - Support for x86, ARM, PPC
49 The following sources where used in the construction of LICE
51 - Aho, Alfred V., and Alfred V. Aho. Compilers: Principles, Techniques, & Tools. Boston: Pearson/Addison Wesley, 2007. Print.
52 http://www.amazon.ca/Compilers-Principles-Techniques-Alfred-Aho/dp/0201100886
54 - Degener, Jutta. "ANSI C Grammar, Lex Specification." ANSI C Grammar (Lex). N.p., 1995. Web.
55 http://www.lysator.liu.se/c/ANSI-C-grammar-l.html
57 - Matz, Michael, Jan Hubicka, Andreas Jaeger, and Mark Mitchell. "System V Application Binary Interface AMD64 Architecture Processor Supplement." N.p., 07 Oct. 2013. Print.
58 http://www.x86-64.org/documentation/abi.pdf
60 - Kahan, W., Prof. "IEEE Standard 754 for Binary Floating-Point Arithmetic." N.p., 1 Oct. 1997. Print.
61 http://www.eecs.berkeley.edu/~wkahan/ieee754status/IEEE754.PDF
63 - Crenshaw, Jack. "Let's Build a Compiler." I.E.C.C., 1995. Web.
64 http://compilers.iecc.com/crenshaw/
66 - "C99 Final Draft." ISO/IEC, 06 May 2006. Print.
67 http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf
69 - "C11 Final Draft." ISO/IEC, 12 April 2011. Print.
70 http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
72 - "Instruction Set Reference, A-Z." Intel 64 and IA-32 Architectures Software Developer's Manual. Vol. 2. [Calif.?]: Intel, 2013. N. pag. Print.
73 http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf
75 - Bendersky, Eli. "Complete C99 parser in pure Python." pycparser. N.p., N.d. Web.
76 https://github.com/eliben/pycparser
79 The following projects were seen as inspiration in the construciton of
83 http://www.t3x.org/subc/
86 http://bellard.org/tcc/
89 https://sites.google.com/site/lccretargetablecompiler/
92 http://llvm.org/docs/tutorial/index.html