added local bound generation
[tinycc.git] / README
blob4043652dd437c18b89790633317159c3bd685efa
1 Tiny C Compiler - C Scripting Everywhere - The Smallest ANSI C compiler
2 -----------------------------------------------------------------------
4 Features:
5 --------
7 - SMALL! You can compile and execute C code everywhere, for example on
8   rescue disks.
10 - FAST! tcc generates optimized x86 code. No byte code
11   overhead. Compiles, assemble and link about 7 times faster than 'gcc
12   -O0'.
14 - UNLIMITED! Any C dynamic library can be used directly. TCC is
15   heading torward full ISOC99 compliance. TCC can of course compile
16   itself.
18 - Compile and execute C source directly. No linking or assembly
19   necessary. Full C preprocessor included. 
21 - C script supported : just add '#!/usr/local/bin/tcc' at the first
22   line of your C source, and execute it directly from the command
23   line.
25 Documentation:
26 -------------
28 1) Installation
30 ***TCC currently only works on Linux x86***.
32 Type 'make install' to compile and install tcc in /usr/local/bin and
33 /usr/local/lib/tcc.
35 2) Introduction
37 We assume here that you know ANSI C. Look at the example ex1.c to know
38 what the programs look like.
40 The main limitation of tcc is that you cannot use floats. 
42 The include file <tcclib.h> can be used if you want a small basic libc
43 include support (especially useful for floppy disks). Of course, you
44 can also use standard headers, although they are slower to compile.
46 You can begin your C script with '#!/usr/local/bin/tcc' on the first
47 line and set its execute bits (chmod a+x your_script). Then, you can
48 launch the C code as a shell or perl script :-) The command line
49 arguments are put in 'argc' and 'argv' of the main functions, as in
50 ANSI C.
52 3) Invokation
54 '-Idir' : specify an additionnal include path. The
55 default ones are: /usr/include, /usr/lib/tcc, /usr/local/lib/tcc.
57 '-Dsym' : define preprocessor symbol 'sym' to 1.
59 '-lxxx' : dynamically link your program with library
60 libxxx.so. Standard library paths are checked, including those
61 specificed with LD_LIBRARY_PATH.
63 '-i file' : compile C source 'file' before main C source. With this
64 command, multiple C files can be compiled and linked together.
66 4) Examples
68 ex1.c: simplest example (hello world). Can also be launched directly
69 as a script: './ex1.c'.
71 ex2.c: more complicated example: find a number with the four
72 operations given a list of numbers (benchmark).
74 ex3.c: compute fibonacci numbers (benchmark).
76 ex4.c: more complicated: X11 program. Very complicated test in fact
77 because standard headers are being used !
79 ex5.c: 'hello world' with standard glibc headers.
81 tcc.c: TCC can of course compile itself. Used to check the code
82 generator.
84 prog.c: auto test for TCC which tests many subtle possible bugs. Used
85 when doing 'make test'.
87 5) Full Documentation
89 Please read tcc-doc.html to have all the features of TCC.
91 Technical Description:
92 ---------------------
94 This is not my first C compiler (see my 'fbcc' compiler) but it
95 contains the first C preprocessor I wrote. The project started as a
96 joke to make the smallest C compiler. Then I expanded it torward
97 ISOC99 compliance. This C compiler is particular because each feature
98 was added while trying to be as simple and compact as possible. For
99 example, no intermediate structure is used to store code or
100 expressions.
102 The TCC code generator directly generates linked binary code. It is
103 rather unusual these days (see gcc for example which generates text
104 assembly), but it allows to be very fast and surprisingly not so
105 complicated.
107 The TCC code generator is register based. It means that it could even
108 generate good code for RISC processors. On x86, three temporary
109 registers are used. When more registers are needed, one register is
110 flushed in a new local variable.
112 Constant propagation is done for all operations. Multiplications and
113 divisions are optimized to shifts when appropriate. Comparison
114 operators are optimized by maintaining a special cache for the
115 processor flags. &&, || and ! are optimized by maintaining a special
116 'jmp target' value. No other jmp optimization is currently performed
117 because it would require to store the code in a more abstract fashion.
119 The types and values descriptions are stored in a single 'int'
120 variable (see VT_xxx constants). It was choosen in the first stages of
121 development when tcc was much simpler. Now, it may not be the best
122 solution.
124 License:
125 -------
127 TCC is distributed under the GNU General Public License (see COPYING
128 file). 
130 I accept only patches where you give your copyright explicitely to me
131 to simplify licensing issues.
133 Fabrice Bellard - Nov 17, 2001.