]> pd.if.org Git - lice/blob - README.md
autocommit for files dated 2014-11-17 20:15:26
[lice] / README.md
1 ### Epilogue
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.
5
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
9 support.
10
11 ### Status
12 See the STANDARDS file for the status on which standards LICE supports.
13
14 ### Prologue
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.
23
24 ### Porting
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`.
31
32
33 ### Future Endeavors
34 -   Full C90 support
35
36 -   Full C99 support
37
38 -   Full C11 support
39
40 -   Preprocessor
41
42 -   Intermediate stage with optimizations (libfirm?)
43
44 -   Code generation (directly to elf/coff, et. all)
45
46 -   Support for x86, ARM, PPC
47
48 ### Sources
49 The following sources where used in the construction of LICE
50
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
53
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
56
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
59
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
62
63 -   Crenshaw, Jack. "Let's Build a Compiler." I.E.C.C., 1995. Web.
64     http://compilers.iecc.com/crenshaw/
65
66 -   "C99 Final Draft." ISO/IEC, 06 May 2006. Print.
67     http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf
68
69 -   "C11 Final Draft." ISO/IEC, 12 April 2011. Print.
70     http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
71
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
74
75 -   Bendersky, Eli. "Complete C99 parser in pure Python." pycparser. N.p., N.d. Web.
76     https://github.com/eliben/pycparser
77
78 ### Inspiration
79 The following projects were seen as inspiration in the construciton of
80 LICE.
81
82 -   SubC
83     http://www.t3x.org/subc/
84
85 -   TCC
86     http://bellard.org/tcc/
87
88 -   lcc
89     https://sites.google.com/site/lccretargetablecompiler/
90
91 -   Kaleidoscope
92     http://llvm.org/docs/tutorial/index.html